/* ==========================================================================
   FX戦士くるみちゃん 模拟器 — 布局与组件层
   ========================================================================== */

/* ============================ 角色素材 ============================ */
/* 情绪插画长宽比不同；舞台用固定画布承载，切换时不改变卡片高度。 */
.kurumi-art {
  display: block; width: 100%; height: auto;
  border-radius: 14px;
}
.stage-art .kurumi-art { border-radius: 0; }
@media (prefers-reduced-motion: reduce) {
  .kurumi-art, .stage-art, .stage-mood, .stage-bubble, .meter i {
    transition: none !important;
  }
}

/* 官方表情／半身像有透明通道，直接裁圆即可 */
.avatar-img {
  flex: 0 0 auto; width: 46px; height: 46px;
  border: var(--line-thin) solid var(--ink); border-radius: 50%;
  object-fit: cover; object-position: 50% 18%;
  background: var(--pink-mist);
}
.log .avatar-img { width: 28px; height: 28px; }

/* 空素材位（未放入图片时） */
.stage-art .art-slot, .hero-art .art-slot { aspect-ratio: 3 / 4; }
.art-slot {
  display: grid; place-items: center;
  width: 100%;
  border: var(--line) dashed var(--pink);
  border-radius: 20px;
  background:
    repeating-linear-gradient(45deg,
      transparent 0 12px, rgba(255,120,166,.06) 12px 24px),
    linear-gradient(170deg, #fff 0%, var(--pink-mist) 100%);
}
.art-slot-inner { display: grid; justify-items: center; gap: 6px; padding: 14px; text-align: center; }
.art-slot-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border: var(--line-thin) solid var(--pink); border-radius: 50%;
  background: #fff; color: var(--pink-deep);
  font-size: 22px; line-height: 1;
}
.art-slot b { font-family: var(--font-display); font-size: 15px; color: var(--pink-deep); font-weight: 400; }
.art-slot small { font-size: 11px; color: var(--plum-soft); max-width: 22ch; line-height: 1.5; }

/* 配角首字母徽章（无脸图时的兜底） */
.avatar-badge {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border: var(--line-thin) solid var(--ink); border-radius: 50%;
  background: var(--badge, var(--pink));
  color: #fff; font-family: var(--font-display); font-size: 18px;
  box-shadow: 2px 2px 0 var(--plum);
}

/* 情绪用配色表达 */
.stage-mood { border-color: var(--mood, var(--ink)); }
.stage-mood::before {
  content: ""; display: inline-block;
  width: 9px; height: 9px; margin-right: 6px;
  border: 2px solid var(--ink); border-radius: 50%;
  background: var(--mood, var(--cyan));
  vertical-align: middle;
}

/* 首页：官方关键视觉做背景 */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background-image: url("../img/visual1.jpg");
  background-size: cover;
  background-position: 78% 26%;
  opacity: .17;
  -webkit-mask-image: linear-gradient(100deg, transparent 26%, #000 78%);
  mask-image: linear-gradient(100deg, transparent 26%, #000 78%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

/* 官方 logo：原图 419×173，「くるみちゃん」粉色大字刻意上顶与「FX戦士」重叠。
   顶栏高度有限，这里只框取粉色主字一带（用 object-fit 裁切，避免顶字被切断）。 */
.brand-logo {
  display: block;
  width: 128px; height: 42px;
  object-fit: cover;
  object-position: 50% 88%;
}
@media (max-width: 560px) {
  .brand-logo { width: 106px; height: 36px; }
}

/* ============================ 选模式 ============================ */
/* 开启一局的两步：首页 ->（点开始）-> 选模式 */
.mode-head { margin-bottom: 16px; }
.mode-sub { margin: 6px 0 0; font-size: 14px; color: var(--plum); }
.mode-actions { display: flex; justify-content: center; margin-top: 18px; }
.mode-actions .btn { min-width: 260px; min-height: 50px; font-size: 17px; }
.mode-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px; margin-bottom: 16px;
}
.mode-card {
  display: grid; gap: 7px; align-content: start;
  padding: 20px 18px; text-align: left;
  border: var(--line) solid var(--ink); border-radius: 22px;
  background: var(--paper); box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s, background .15s;
}
.mode-card:hover { background: var(--pink-mist); transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }
.mode-card:active { transform: translate(3px, 3px); box-shadow: var(--shadow-sm); }
.mode-card.is-picked { background: var(--pink-mist); border-color: var(--pink-deep); }
.mode-icon { font-size: 34px; line-height: 1; }
.mode-card h3 { font-size: 20px; color: var(--pink-deep); }
.mode-tagline {
  justify-self: start; padding: 2px 11px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--cream); font-size: 10px; font-weight: 700;
}
.mode-card ul { margin: 4px 0 0; padding-left: 17px; font-size: 13px; }
.mode-card li { margin-bottom: 3px; }
.mode-cta {
  margin-top: 6px; font-family: var(--font-display); font-size: 14px; color: var(--cyan-deep);
}
.mode-note {
  padding: 13px 16px; border: var(--line-thin) dashed var(--cyan);
  border-radius: var(--radius); background: var(--cyan-mist); font-size: 13px;
}

/* 选完模式后展开的故事介绍 */
#view-home .reveal { margin-top: 22px; }
#view-home .reveal.hidden { display: none !important; }
#view-home .reveal:not(.hidden) { animation: reveal-in .32s ease-out; }
@keyframes reveal-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #view-home .reveal:not(.hidden) { animation: none; }
}

/* ============================ 开局设置 ============================ */
.setup-panel { padding: 22px; max-width: 780px; margin: 0 auto; }
.back-link {
  margin-bottom: 10px; padding: 0; border: 0; background: none;
  color: var(--cyan-deep); font-size: 13px; font-weight: 700; text-decoration: underline;
}
.setup-sub { margin: 4px 0 16px; font-size: 13px; color: var(--plum-soft); }
.setup-line { font-size: 14px; margin-bottom: 14px; }
.setup-hint { margin-top: 10px; font-size: 12px; color: var(--plum-soft); }
.setup-actions { margin-top: 18px; }
.setup-actions .btn { width: 100%; min-height: 50px; font-size: 17px; }
.setup-error { margin: 10px 0 0; color: var(--down-deep); font-size: 13px; font-weight: 700; }
.setup-actions-inline { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }

.scenario-list { display: grid; gap: 12px; }
.scenario-card {
  display: grid; gap: 4px; padding: 15px 17px; text-align: left;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow-sm);
}
.scenario-card:hover { background: var(--pink-mist); }
.scenario-card.is-picked { background: var(--pink-mist); border-color: var(--pink-deep); border-width: var(--line); }
.scenario-date { font-family: var(--font-num); font-size: 12px; color: var(--plum-soft); }
.scenario-card b { font-size: 17px; }
.scenario-tag {
  justify-self: start; padding: 1px 10px; margin: 2px 0 4px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--yellow-pop); font-size: 10px; font-weight: 700;
}
.scenario-card p { margin: 0; font-size: 13px; color: var(--plum); }
.scenario-stat {
  margin-top: 5px; font-family: var(--font-num); font-size: 12px; font-weight: 700;
  color: var(--down-deep);
}

.history-events-label { margin: 16px 0 8px; font-weight: 800; }
.history-event-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.history-event-card {
  display: grid; align-content: start; gap: 8px; min-width: 0; padding: 14px 15px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow-sm); color: var(--ink); text-align: left;
  cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.history-event-card:hover { background: var(--pink-mist); transform: translateY(-1px); }
.history-event-card:focus-visible { outline: 3px solid var(--cyan-deep); outline-offset: 2px; }
.history-event-card.is-picked {
  border-color: var(--pink-deep); border-width: var(--line);
  background: var(--pink-mist); box-shadow: var(--shadow-sm);
}
.history-event-name { font-size: 16px; }
.history-event-summary { min-height: 2.8em; color: var(--plum); font-size: 12px; line-height: 1.5; }
.history-event-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: 12px; }
.history-event-meta span { color: var(--plum-soft); }
.history-event-meta b { font-family: var(--font-num); }
.history-event-pair {
  justify-self: start; padding: 2px 9px; border: var(--line-thin) solid var(--ink);
  border-radius: var(--radius-pill); background: var(--yellow-pop); font-size: 11px; font-weight: 700;
}

@media (max-width: 560px) {
  .history-event-grid { grid-template-columns: minmax(0, 1fr); }
  .history-event-summary { min-height: 0; }
}

/* ============================ 剧情横幅 ============================ */
.story-banner {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 13px 17px; margin-bottom: 16px;
  background: linear-gradient(100deg, var(--pink-mist), var(--cream));
}
.story-banner.hidden { display: none; }
.story-tag {
  flex: 0 0 auto; padding: 3px 12px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--pink); color: #fff; font-size: 11px; font-weight: 700;
}
.story-copy b { display: block; font-size: 15px; }
.story-copy p { margin: 2px 0 0; font-size: 13px; color: var(--plum); }

/* ============================ 顶栏 ============================ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(12px, 3vw, 26px);
  border-bottom: var(--line) solid var(--ink);
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border: var(--line) solid var(--ink); border-radius: 12px;
  background: var(--pink); color: #fff;
  font-family: var(--font-display); font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-family: var(--font-display); font-size: 18px; font-weight: 400; }
.brand-text em { font-style: normal; color: var(--pink-deep); }
.brand-text small { font-size: 10px; color: var(--plum-soft); letter-spacing: .06em; }

.nav { display: flex; gap: 6px; margin-left: auto; }
.nav-btn {
  padding: 7px 16px;
  border: var(--line-thin) solid transparent; border-radius: var(--radius-pill);
  background: none; font-weight: 700; font-size: 14px;
}
.nav-btn:hover { background: var(--pink-mist); }
.nav-btn[aria-current="page"] {
  border-color: var(--ink); background: var(--pink); color: #fff;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ============================ 视图 ============================ */
main { padding: clamp(14px, 2.5vw, 26px); max-width: 1420px; margin: 0 auto; }
.view { display: block; }
.view.hidden { display: none; }

/* ============================ 首页 Hero ============================ */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(16px, 3vw, 34px); align-items: center;
  padding: clamp(18px, 3vw, 34px);
  margin-bottom: 22px;
  border: var(--line) solid var(--ink); border-radius: 26px;
  background:
    radial-gradient(circle at 12% 18%, var(--pink-soft) 0 22%, transparent 22.5%),
    radial-gradient(circle at 88% 82%, var(--cyan-soft) 0 18%, transparent 18.5%),
    var(--paper);
  box-shadow: var(--shadow-lg);
}
.hero h1 {
  margin: 14px 0 16px;
  font-size: clamp(24px, 3.4vw, 42px);
  color: var(--pink-deep);
}
.hero-lead { font-size: 15px; max-width: 46ch; }
.hero-lead b { color: var(--pink-deep); }
.hero-lead--warn {
  padding: 11px 15px;
  border-left: 6px solid var(--cyan);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--cyan-mist);
  font-weight: 700;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 14px; }
.hero-carry { display: flex; flex-wrap: wrap; gap: 7px; }

.hero-art { position: relative; display: grid; place-items: center; }
.art-frame {
  width: min(100%, 340px);
  border: var(--line) solid var(--ink); border-radius: 24px;
  background: linear-gradient(170deg, #fff 0%, var(--pink-mist) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.art-frame svg { display: block; width: 100%; height: auto; }
.art-bubble { position: absolute; left: 0; bottom: 6%; max-width: 74%; font-weight: 700; font-size: 13px; }

/* ============================ 本局记录说明 ============================ */
.rules-brief { padding: 18px; margin-bottom: 22px; }

/* ============================ 练什么 ============================ */
.brief-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.brief {
  padding: 14px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius);
  background: var(--paper-warm);
}
.brief-icon { display: block; font-size: 22px; margin-bottom: 4px; }
.brief h3 { font-size: 16px; margin-bottom: 5px; color: var(--pink-deep); }
.brief p { font-size: 13px; margin: 0; color: var(--plum); }
.brief-note {
  margin: 14px 0 0; padding: 10px 14px;
  border: var(--line-thin) dashed var(--pink); border-radius: var(--radius-sm);
  background: var(--pink-mist); font-size: 13px;
}

/* ============================ HUD ============================ */
.hud {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 10px; padding: 12px 16px; margin-bottom: 16px;
}
.hud-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hud-label { font-size: 11px; color: var(--plum-soft); font-weight: 700; }
.hud-value {
  font-family: var(--font-num); font-size: 19px; font-weight: 700;
  color: var(--pink-deep); white-space: nowrap;
}
.hud-value--sm { font-size: 15px; color: var(--ink); }
.hud-item--day { align-items: flex-end; text-align: right; }
.hud-date { font-family: var(--font-num); font-size: 12px; color: var(--plum-soft); }
.is-up { color: var(--up-deep) !important; }
.is-down { color: var(--down-deep) !important; }

/* ============================ 三栏 ============================ */
.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, .78fr) minmax(0, .95fr);
  gap: 16px; align-items: start; min-width: 0;
}
.play-grid > * { min-width: 0; }
.market, .kurumi-stage, .order { padding: 16px; min-width: 0; }

/* ---------- 行情 ---------- */
.market-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.quote { display: flex; align-items: baseline; gap: 8px; }
.quote b { font-family: var(--font-num); font-size: 26px; }
.quote-change { font-family: var(--font-num); font-size: 13px; font-weight: 700; }

.chart-wrap {
  position: relative;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fffdf8, var(--cream));
  padding: 8px; margin-bottom: 12px; min-width: 0; max-width: 100%;
}
.chart-host { width: 100%; height: 300px; min-width: 0; max-width: 100%; }
.chart-host:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

/* 图表下方一行：缩放控件 + 涨跌图例 + 操作提示。
   控件放在图表**外面**——放里面会盖住价格轴和当前价标签。 */
.chart-toolbar-inline {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 8px; min-width: 0; max-width: 100%;
}
.chart-toolbar-inline > * { min-width: 0; max-width: 100%; }
.chart-view-controls {
  display: flex; gap: 4px; flex: 0 0 auto;
  padding: 3px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: 2px 2px 0 var(--plum);
}
.chart-view-controls .tool-tab { min-height: 26px; padding: 1px 10px; font-size: 12px; }
.chart-view-controls .tool-tab:disabled { opacity: .42; }
.chart-legend { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.chart-hint { font-size: 11px; color: var(--plum-soft); margin-left: auto; }

.market-actions { display: flex; gap: 8px; }
.market-actions .btn--block { flex: 1; }

/* K 线周期与刷新间隔 */
.chart-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  margin-top: 13px; padding-top: 12px;
  border-top: var(--line-thin) dashed var(--pink-soft); min-width: 0; max-width: 100%;
}
.tool-group { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; flex-wrap: wrap; }
.tool-label { font-size: 11px; font-weight: 700; color: var(--plum-soft); white-space: nowrap; }
.tool-tabs { display: flex; gap: 5px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.tool-tab {
  min-height: 34px; padding: 4px 14px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: #fff; font-size: 13px; font-weight: 700;
}
.tool-tab:hover { background: var(--cream); }
.tool-tab.is-on { background: var(--pink); color: #fff; }
.tool-tab--sm { min-height: 32px; padding: 3px 11px; font-size: 12px; }
.tool-tab--sm.is-on { background: var(--cyan); }
.toolbar-note { margin: 9px 0 0; font-size: 11px; color: var(--plum-soft); }
.market-meta { margin-top: 9px; font-size: 11px; color: var(--plum-soft); }
.chart-source-details { flex: 0 0 100%; font-size: 11px; color: var(--plum-soft); }
.chart-source-details summary { width: fit-content; cursor: pointer; font-weight: 700; }
.chart-source-details p { margin: 5px 0 0; max-width: 80ch; line-height: 1.55; }

/* ---------- 久留美舞台 ---------- */
.kurumi-stage {
  --stage-accent: #17bcc8;
  --stage-wash: #effcfd;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border-color: var(--stage-accent);
  background: linear-gradient(180deg, var(--stage-wash), #fff 48%);
  transition: border-color .2s, background-color .2s;
}
.kurumi-stage[data-mood="determined"] { --stage-accent: #ff78a6; --stage-wash: #fff1f7; }
.kurumi-stage[data-mood="calm"] { --stage-accent: #17bcc8; --stage-wash: #effcfd; }
.kurumi-stage[data-mood="uneasy"] { --stage-accent: #d4aa00; --stage-wash: #fffbea; }
.kurumi-stage[data-mood="panic"] { --stage-accent: #ef4a72; --stage-wash: #fff0f2; }
.kurumi-stage[data-mood="despair"] { --stage-accent: #7a5568; --stage-wash: #f2edf1; }
.stage-mood {
  align-self: stretch; margin-bottom: 8px; padding: 5px 12px;
  border: var(--line-thin) solid var(--stage-accent); border-radius: var(--radius-pill);
  background: #fff; color: var(--stage-accent); font-size: 12px; font-weight: 700;
  transition: color .2s, border-color .2s;
}
.stage-mood::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px;
  border: 2px solid currentColor; border-radius: 50%; background: var(--stage-accent);
  vertical-align: middle;
}
.stage-art {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; place-items: center;
  width: 100%; max-width: 268px; height: 258px; margin: 0;
  border: 2px solid var(--stage-accent); border-radius: 20px;
  background: radial-gradient(circle at 50% 38%, #fff 0 42%, var(--stage-wash) 100%);
  box-shadow: 0 3px 0 rgba(23,188,200,.24);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.stage-art::before {
  position: absolute; z-index: 2; top: 8px; right: 10px;
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--stage-accent); border-radius: 50%;
  background: #fff; color: var(--stage-accent); font-size: 20px; font-weight: 900;
  line-height: 1; opacity: .94;
}
.kurumi-stage[data-mood="determined"] .stage-art::before { content: "✦"; }
.kurumi-stage[data-mood="calm"] .stage-art::before { content: "○"; }
.kurumi-stage[data-mood="uneasy"] .stage-art::before { content: "？"; }
.kurumi-stage[data-mood="panic"] .stage-art::before { content: "！！"; font-size: 14px; }
.kurumi-stage[data-mood="despair"] .stage-art::before { content: "…"; }
.kurumi-stage[data-mood="determined"] .stage-art {
  background: repeating-conic-gradient(from 8deg at 50% 44%, rgba(255,120,166,.12) 0 8deg, transparent 8deg 24deg), #fff8fb;
  box-shadow: 0 3px 0 rgba(255,120,166,.28);
}
.kurumi-stage[data-mood="calm"] .stage-art {
  background: radial-gradient(ellipse at 50% 45%, #fff 0 44%, #dff8fa 100%);
}
.kurumi-stage[data-mood="uneasy"] .stage-art {
  background: repeating-linear-gradient(135deg, rgba(212,170,0,.10) 0 5px, transparent 5px 14px), #fffdf4;
}
.kurumi-stage[data-mood="panic"] .stage-art {
  border-width: 3px;
  background: repeating-linear-gradient(135deg, rgba(239,74,114,.10) 0 6px, transparent 6px 14px), #fff2f4;
  box-shadow: 0 3px 0 rgba(239,74,114,.4), 0 0 0 2px rgba(239,74,114,.12);
}
.kurumi-stage[data-mood="despair"] .stage-art {
  border-color: #7a5568;
  background: radial-gradient(ellipse at 50% 40%, #f7f3f6 0 35%, #e5dce3 100%);
  box-shadow: inset 0 0 24px rgba(64,43,57,.12), 0 3px 0 rgba(122,85,104,.35);
}
.stage-art img, .stage-art svg {
  position: relative; z-index: 1;
  display: block; width: auto; max-width: 100%; height: 100%;
  object-fit: contain; object-position: center center;
}
.stage-bubble {
  margin: 8px 0 12px; border-color: var(--stage-accent);
  font-size: 13px; font-weight: 700; max-width: 96%;
  transition: border-color .2s;
}
.stage-bubble::after, .stage-bubble::before { left: 50%; margin-left: -8px; }
.stage-meter { align-self: stretch; display: grid; gap: 7px; width: 100%; min-width: 0; }
.meter-row { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; }
.meter-label { flex: 0 0 4.2em; text-align: left; }
.meter-value { flex: 0 0 4.8em; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter {
  position: relative; flex: 1; min-width: 20px; height: 12px; overflow: hidden;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: #fff;
}
.meter i { position: relative; z-index: 1; display: block; height: 100%; background: var(--stage-accent); transition: width .25s; }
.meter--risk { background: #fff; }
.meter--risk i { background: #f0c000; }
.kurumi-stage[data-mood="panic"] .meter--risk i { background: #ef4a72; }
.kurumi-stage[data-mood="despair"] .meter--risk i { background: #7a5568; }
.meter-threshold { position: absolute; z-index: 2; top: -1px; bottom: -1px; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(34,27,32,.5); pointer-events: none; }
.meter-threshold--warn { left: 60%; }
.meter-threshold--cut { left: 80%; }
.risk-thresholds { display: flex; justify-content: space-between; margin: -4px 4.9em 0 4.5em; color: var(--plum-soft); font-size: 9px; line-height: 1.2; }
.stage-feedback { display: grid; gap: 3px; text-align: left; }
.stage-risk-label {
  justify-self: start; padding: 2px 8px; border: 1px solid var(--stage-accent);
  border-radius: var(--radius-pill); background: var(--stage-wash);
  color: var(--stage-accent); font-size: 10px; font-weight: 800;
}
.stage-reason, .account-pressure { margin: 0; color: var(--ink); font-size: 10px; line-height: 1.4; }
.account-pressure { color: var(--plum-soft); }
#stageRiskAction { width: 100%; margin-top: 2px; }
#stageRiskAction[hidden] { display: none !important; }

/* ---------- 下单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 5px; font-size: 12px; font-weight: 700;
}
.field-label em { font-style: normal; color: var(--plum-soft); font-weight: 400; }
.field-label output { font-family: var(--font-num); font-size: 16px; color: var(--pink-deep); }
.field-row { display: flex; gap: 6px; }
.field input[type="number"] {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-sm);
  background: #fff; font-family: var(--font-num); font-size: 16px;
}
.field input[type="range"] { width: 100%; accent-color: var(--pink); min-height: 32px; }
.range-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--plum-soft); }
.range-scale i { font-style: normal; }

.estimates {
  display: grid; gap: 5px; margin-bottom: 14px; padding: 11px 13px;
  border: var(--line-thin) dashed var(--cyan); border-radius: var(--radius-sm);
  background: var(--cyan-mist);
}
.estimates > div { display: flex; justify-content: space-between; font-size: 12px; }
.estimates b { font-family: var(--font-num); }

.order-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.btn--up { background: var(--up); color: #fff; }
.btn--up:hover:not(:disabled) { background: var(--up-deep); }
.btn--down { background: var(--down); color: #fff; }
.btn--down:hover:not(:disabled) { background: var(--down-deep); }

.order-lock {
  margin: 11px 0 0; padding: 8px 12px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-sm);
  background: var(--yellow-pop); font-size: 12px; font-weight: 700;
}
.rule { margin: 16px 0; border: 0; border-top: var(--line-thin) dashed var(--pink-soft); }
.loan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.loan-head h3 { font-size: 15px; }
.loan-note { font-size: 11px; color: var(--plum-soft); margin-bottom: 9px; }
.loan-actions { display: flex; gap: 7px; }

/* ============================ 持仓 ============================ */
.positions, .logbook { padding: 16px; margin-top: 16px; }
.count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px;
  padding: 0 7px; border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--pink); color: #fff; font-family: var(--font-num); font-size: 12px;
}
.pos-list { display: grid; gap: 9px; }
.pos {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
  padding: 11px 13px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-sm);
  background: #fff;
}
.pos--up { background: var(--cyan-mist); }
.pos--down { background: var(--pink-mist); }
.pos-side {
  padding: 3px 10px; border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; color: #fff;
}
.pos-side--long { background: var(--up); }
.pos-side--short { background: var(--down); }
.pos-main { min-width: 0; }
.pos-main b { display: block; font-size: 14px; }
.pos-main small { font-size: 11px; color: var(--plum-soft); }
.pos-pnl { font-family: var(--font-num); font-size: 15px; font-weight: 700; text-align: right; }
.pos-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 13px; }
.pos-foot-note { font-size: 11px; color: var(--plum-soft); }
.empty { padding: 16px; text-align: center; color: var(--plum-soft); font-size: 13px; }
.empty.hidden { display: none; }

/* ============================ 日志 ============================ */
.log-list { display: grid; gap: 8px; max-height: 340px; overflow-y: auto; }
.log {
  display: flex; gap: 10px; padding: 10px 12px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-sm);
  background: #fff; font-size: 13px;
}
.log--warn { background: var(--pink-mist); border-color: var(--pink-deep); }
.log--good { background: var(--cyan-mist); }
.log--info { background: var(--cream); }
.log-icon { flex: 0 0 auto; font-size: 16px; }
.log-body b { display: block; font-size: 13px; }
.log-body p { margin: 1px 0 0; font-size: 12px; color: var(--plum); }
.log-day { margin-left: auto; font-family: var(--font-num); font-size: 11px; color: var(--plum-soft); white-space: nowrap; }

/* ============================ 复盘 ============================ */
.review-head { padding: 18px; margin-bottom: 16px; }
.verdict { padding: 15px; border: var(--line-thin) solid var(--ink); border-radius: var(--radius); background: var(--cream); }
.verdict-tag {
  display: inline-block; margin-bottom: 8px; padding: 4px 16px;
  border: var(--line) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--pink); color: #fff; font-family: var(--font-display); font-size: 17px;
  box-shadow: var(--shadow-sm);
}
.verdict p { margin: 0; font-size: 14px; }

.review-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 11px; margin-bottom: 16px;
}
.stat {
  padding: 13px; border: var(--line-thin) solid var(--ink); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow-sm);
}
.stat span { display: block; font-size: 11px; color: var(--plum-soft); font-weight: 700; }
.stat b { font-family: var(--font-num); font-size: 21px; color: var(--pink-deep); }
.stat small { display: block; font-size: 10px; color: var(--plum-soft); }

.review .panel, #view-review > .panel { padding: 16px; margin-bottom: 16px; }
.trap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 11px; }
.trap {
  padding: 13px; border: var(--line-thin) solid var(--ink); border-radius: var(--radius);
  background: #fff;
}
.trap--hit { background: var(--pink-mist); border-color: var(--pink-deep); }
.trap b { display: block; font-size: 14px; margin-bottom: 3px; }
.trap-num { font-family: var(--font-num); font-size: 24px; color: var(--pink-deep); }
.trap small { font-size: 11px; color: var(--plum-soft); }

.table-wrap { overflow-x: auto; }
.trades { width: 100%; border-collapse: collapse; font-size: 12px; }
.trades th, .trades td { padding: 7px 9px; border-bottom: 1px solid var(--pink-soft); text-align: right; white-space: nowrap; }
.trades th { background: var(--cream); font-size: 11px; }
.trades th:first-child, .trades td:first-child { text-align: left; }
.trades td.num { font-family: var(--font-num); }
.review-actions { display: flex; flex-wrap: wrap; gap: 9px; }

/* ============================ 页脚 ============================ */
.footer {
  padding: 20px clamp(14px, 3vw, 26px) 34px;
  border-top: var(--line-thin) solid var(--pink-soft);
  font-size: 11px; color: var(--plum-soft); text-align: center;
}
.footer p { max-width: 80ch; margin: 0 auto 6px; }
.footer-warn { font-weight: 700; color: var(--down-deep); }

/* ============================ 弹窗 / 提示 ============================ */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 18px;
  background: rgba(43, 27, 38, .55);
}
.modal.hidden { display: none; }
.dialog { width: min(560px, 100%); max-height: 86vh; overflow-y: auto; padding: 22px; }
.dialog h2 { font-size: 20px; margin-bottom: 10px; color: var(--pink-deep); }
.dialog-body { font-size: 14px; }
.dialog-body ul { margin: 8px 0; padding-left: 20px; }
.dialog-body li { margin-bottom: 5px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.dialog-actions .btn { flex: 1; min-width: 130px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 70;
  transform: translate(-50%, 20px);
  padding: 11px 20px;
  border: var(--line) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(90vw, 520px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast--warn { background: var(--down-deep); }
.toast--good { background: var(--up-deep); }

/* ============================ 响应式 ============================ */
@media (max-width: 1080px) {
  .play-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .kurumi-stage { grid-column: 1 / -1; flex-direction: row; text-align: left; gap: 16px; }
  .kurumi-stage .stage-art { max-width: 150px; height: 220px; flex: 0 0 150px; }
  .kurumi-stage .stage-mood { align-self: flex-start; }
  .stage-meter { align-self: center; flex: 1; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
  .hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hud-item--day { grid-column: 1 / -1; align-items: flex-start; text-align: left; }
}

@media (max-width: 700px) {
  main, .view, .play-grid, .play-grid > *, .watch, .watch-row,
  .market, .chart-wrap, .chart-host, .chart-toolbar, .tool-group, .tool-tabs {
    min-width: 0;
    max-width: 100%;
  }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .nav-btn {
    flex: 1; min-width: 0; min-height: 44px;
    padding-inline: 4px; white-space: nowrap;
  }
  .play-grid { grid-template-columns: minmax(0, 1fr); }
  .tool-group { flex: 1 1 100%; }
  .chart-toolbar .tool-tab, .chart-view-controls .tool-tab { min-height: 44px; }
  .kurumi-stage { flex-direction: column; text-align: center; }
  .kurumi-stage .stage-art { max-width: 190px; height: 230px; flex: none; }
  .kurumi-stage .stage-mood { align-self: stretch; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-value { font-size: 16px; }
  .hud-value--sm { font-size: 13px; }
  .chart-host { height: 240px; }
  .pos { grid-template-columns: auto 1fr; row-gap: 8px; }
  .pos-pnl { grid-column: 2; text-align: left; }
  .art-bubble { position: static; max-width: 100%; margin-top: 10px; }
  .hero-actions .btn { flex: 1; }
  .order-sides { grid-template-columns: 1fr; }
  .dialog-actions .btn { min-width: 100%; }
}

/* ---------- 章节目标条（只在剧情模式出现） ---------- */
.goal-bar { padding: 10px 12px; margin-bottom: 12px; }
.goal-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.goal-chapter {
  font-size: 11px; font-weight: 700; padding: 2px 9px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--pink); color: #fff; flex: 0 0 auto;
}
.goal-text { font-size: 15px; }
.goal-figures { margin-left: auto; font-size: 12px; color: var(--plum); }
.goal-track {
  height: 12px; margin-top: 8px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: #fff; overflow: hidden;
}
.goal-fill {
  display: block; height: 100%; width: 0;
  background: var(--cyan); transition: width .25s ease;
}
.goal-bar.is-reached .goal-fill { background: var(--cyan); }
.goal-bar.is-reached .goal-chapter { background: var(--cyan); }
.goal-bar.is-failed .goal-fill { background: var(--pink); }
.goal-bar.is-failed .goal-chapter { background: var(--pink); }
.goal-detail { margin: 6px 0 0; font-size: 11px; color: var(--plum-soft); }
.scenario-goal {
  display: inline-block; margin-top: 2px; font-size: 12px; font-weight: 700;
  color: var(--pink-deep, #c62b52);
}

/* ---------- 横向行情列表（MARKET WATCH） ---------- */
.watch { padding: 12px 14px 14px; margin-bottom: 14px; min-width: 0; max-width: 100%; }
.watch-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.watch-kicker {
  font-size: 10px; letter-spacing: .16em; font-weight: 700;
  color: var(--plum-soft); text-transform: uppercase;
}
.watch-title { margin: 0; font-size: 17px; letter-spacing: .04em; }
.watch-pulse {
  margin-left: auto; font-size: 15px; line-height: 1;
  color: var(--cyan); opacity: .35;
}
/* 每次推进行情时闪一下，表示数据刷新了 */
.watch-pulse.is-tick { animation: watchTick .55s ease-out; }
@keyframes watchTick {
  0% { opacity: 1; transform: rotate(0deg) scale(1.25); }
  100% { opacity: .35; transform: rotate(90deg) scale(1); }
}

/* 横向排列：窄屏可以横向滚动，不换行挤压 */
.watch-row {
  display: flex; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  width: 100%; min-width: 0; max-width: 100%;
}
.watch-card {
  flex: 1 0 132px; min-width: 132px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 11px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-sm);
  background: #fff; text-align: left; scroll-snap-align: start;
  transition: background .12s ease, transform .12s ease;
}
.watch-card:hover:not(.is-on) { background: var(--cream); transform: translateY(-1px); }
.watch-card.is-on {
  background: var(--cyan); color: #fff;
  box-shadow: 2px 2px 0 var(--plum);
}
.watch-code { font-family: var(--font-num); font-size: 14px; font-weight: 700; letter-spacing: .2px; }
.watch-name { font-size: 10px; opacity: .62; }
.watch-price { font-family: var(--font-num); font-size: 15px; font-weight: 700; margin-top: 3px; }
.watch-change { font-family: var(--font-num); font-size: 11px; font-weight: 700; min-height: 14px; }
.watch-card .is-up { color: #0e8d97; }
.watch-card .is-down { color: #c62b52; }
/* 选中卡片是青绿底，涨跌色要换成白色系才看得清 */
.watch-card.is-on .is-up, .watch-card.is-on .is-down { color: #fff; }
.watch-card.is-on .watch-name { opacity: .85; }

.market-pair-badge {
  font-family: var(--font-num); font-size: 12px; font-weight: 700;
  padding: 2px 9px;
  border: var(--line-thin) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--cream);
}

@media (max-width: 720px) {
  .watch-card { flex: 0 0 116px; min-width: 116px; }
}

/* 剧情模式下的品种提示（说明品种不锁死） */
.pair-note { margin: 6px 0 0; font-size: 11px; color: var(--plum-soft); }

/* ---------- 杠杆滑杆：六个等距节点，分段步长由 noUiSlider 管理 ---------- */
.lev-value-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.lev-current {
  color: var(--plum); font: 800 20px/1 var(--font-num, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
}
.lev-ruler {
  height: 46px; margin: 4px 7px 0; padding: 17px 0 0;
  touch-action: pan-y;
}
.lev-slider.noUi-target {
  height: 12px; border: 1px solid var(--ink); border-radius: 999px;
  background: var(--cream); box-shadow: none;
}
.lev-slider .noUi-base,
.lev-slider .noUi-connects { border-radius: inherit; }
.lev-slider .noUi-connect { background: var(--pink); }
.lev-slider .noUi-handle {
  top: -15px; right: -19px; width: 38px; height: 38px;
  border: 2px solid var(--ink); border-radius: 50%;
  background: var(--pink); box-shadow: 0 2px 0 var(--ink);
  cursor: grab;
}
.lev-slider .noUi-handle:active { cursor: grabbing; }
.lev-slider .noUi-handle::before { display: none; }
/* 保持粉色圆钮的视觉尺寸，把透明触控区域扩至至少 44×44px。 */
.lev-slider .noUi-touch-area {
  position: absolute; inset: -4px; width: auto; height: auto;
}
.lev-slider .noUi-handle:focus-visible {
  outline: 3px solid var(--cyan); outline-offset: 3px;
}
.lev-ticks {
  position: relative; height: 18px; margin: 0 7px 4px;
  font: 700 10px/1 var(--font-num, ui-monospace, monospace);
  color: var(--plum-soft); font-variant-numeric: tabular-nums;
}
.lev-ticks span {
  position: absolute; transform: translateX(-50%); white-space: nowrap;
}
.lev-ticks span:first-child { transform: none; }
.lev-ticks span:last-child { transform: translateX(-100%); }
.lev-quick { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.lev-quick .tool-tab { min-width: 0; padding-inline: 3px; font-size: 12px; }
.lev-quick .tool-tab.is-on { background: var(--pink-mist); color: var(--plum); }
@media (max-width: 720px) {
  .lev-ruler { min-height: 50px; }
  .lev-slider .noUi-handle { width: 40px; height: 40px; right: -20px; }
  .lev-quick { gap: 4px; }
  .lev-quick .tool-tab { min-height: 44px; }
  .lev-ticks { font-size: 9px; }
}

/* 杠杆风险提示 */
.lev-warn { margin: 6px 0 0; font-size: 11px; color: var(--plum-soft); }
.lev-warn--watch { color: #b8860b; }
.lev-warn--high { color: #c62b52; }
.lev-warn--extreme { color: #c62b52; font-weight: 700; }
