/* ============================================================
   一笔画 · 蓝图纸纸
   — 深靛 + 暖琥珀：冷峻的科学笔记本，热情的节点高亮
   - 与 sokoban（仓库夜班）/ bee-loop（临床蓝白）刻意拉开
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* body 用 min-height（而非 height:100%）：让 body 高度随内容增长，保证 sticky 顶栏全程有效 */
html { height: 100%; }
body { min-height: 100%; }
body {
  background:
    linear-gradient(180deg, #0b1220 0%, #0f172a 60%, #1e293b 100%),
    var(--bg-page, #fafbfc);
  background-attachment: fixed;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }

:root {
  --ink:        #e2e8f0;
  --ink-soft:   #94a3b8;
  --ink-mute:   #64748b;
  --ink-faint:  #475569;
  --ink-line:   #334155;
  --paper:      #0f172a;
  --paper-2:    #1e293b;
  --paper-hi:   #273345;

  --line:       #475569;     /* 未走的边 */
  --line-on:    #38bdf8;     /* 已走的边：冰蓝 */
  --line-hint:  #fde68a;     /* 提示叠加边：暖琥珀 */

  --node:       #94a3b8;     /* 普通节点：钢灰 */
  --node-on:    #38bdf8;     /* 当前节点：冰蓝 */
  --node-odd:   #fde68a;     /* 奇点节点：暖琥珀 */
  --node-hint:  #fbbf24;     /* 提示节点：焦糖 */

  --accent:     #38bdf8;
  --accent-hi:  #7dd3fc;
  --accent-soft:rgba(56, 189, 248, 0.18);
  --warm:       #f59e0b;
  --warm-soft:  rgba(245, 158, 11, 0.18);
  --success:    #10b981;
  --danger:     #ef4444;
  --warning:    #f59e0b;

  --star:       #fde047;

  --shadow:     0 1px 0 rgba(0, 0, 0, 0.4), 0 6px 18px rgba(15, 23, 42, 0.6);
  --shadow-hi:  0 8px 30px rgba(56, 189, 248, 0.18), 0 1px 0 rgba(255, 255, 255, 0.04);
}

.back-link { padding: 18px 40px 0; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-mute); display: inline-block; }
.back-link:hover { color: var(--accent); }

main { flex: 1; padding: 8px 40px 80px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ============================================================
   HERO
   ============================================================ */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; align-items: center; padding: 36px 0 28px; border-bottom: 1px dashed rgba(148, 163, 184, 0.18); }
.hero-meta .eyebrow { font-size: 10px; letter-spacing: 0.5em; color: var(--accent); text-transform: uppercase; }
.hero-meta h1 { font-size: 56px; font-weight: 200; letter-spacing: 0.04em; line-height: 1; margin: 12px 0 6px; background: linear-gradient(180deg, #f8fafc, #94a3b8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-meta .h1-en { display: block; font-size: 11px; letter-spacing: 0.32em; color: var(--ink-mute); text-transform: uppercase; }
.hero-meta .sub { margin-top: 18px; font-size: 14px; color: var(--ink-soft); line-height: 1.7; max-width: 540px; }
.hero-deco { position: relative; aspect-ratio: 1 / 1; background: linear-gradient(135deg, rgba(56,189,248,0.06), rgba(245,158,11,0.04)); border: 1px solid rgba(148, 163, 184, 0.15); border-radius: 18px; padding: 18px; overflow: hidden; }
.deco-svg { width: 100%; height: 100%; display: block; }
.deco-graph line { stroke: rgba(56, 189, 248, 0.4); stroke-width: 1.6; stroke-linecap: round; }
.deco-graph circle { transition: filter 0.3s ease; }
.deco-graph circle:hover { filter: drop-shadow(0 0 6px var(--accent)); }

/* ============================================================
   MODE 选择
   ============================================================ */
.mode-bar { display: flex; flex-direction: column; gap: 16px; padding: 24px 0; align-items: center; }
.mode-pills { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mode-pill {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--ink-soft);
  padding: 10px 22px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  border-radius: 999px;
  transition: all 0.22s ease;
}
.mode-pill:hover { color: var(--ink); border-color: var(--accent); }
.mode-pill.active { background: var(--accent); color: #0b1220; border-color: var(--accent); }
.mode-pill .m-ico { font-size: 14px; }
.mode-pill .m-name { font-size: 12px; font-weight: 600; }
.mode-pill .m-desc { font-size: 10px; opacity: 0.65; }

.diff-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.diff-pill {
  background: transparent; border: 1px solid rgba(148, 163, 184, 0.16); color: var(--ink-mute);
  padding: 8px 18px; font-family: inherit; font-size: 11px; letter-spacing: 0.16em;
  cursor: pointer; border-radius: 999px; transition: all 0.2s ease;
}
.diff-pill:hover { color: var(--ink); border-color: var(--ink-mute); }
.diff-pill.active { color: var(--warm); border-color: var(--warm); background: rgba(245, 158, 11, 0.08); }

/* ============================================================
   工作台（棋盘 + 工具栏）
   ============================================================ */
.stage-area { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; }
.stage-card {
  background: linear-gradient(180deg, rgba(15,23,42,0.6), rgba(30,41,59,0.6));
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  padding: 18px 20px 16px;
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
  box-shadow: var(--shadow);
}
.stage-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid rgba(148, 163, 184, 0.08); }
.stage-head .l { display: flex; align-items: center; gap: 12px; }
.stage-pill { font-size: 10px; letter-spacing: 0.24em; color: var(--accent); text-transform: uppercase; padding: 4px 12px; border: 1px solid var(--accent-soft); border-radius: 999px; background: var(--accent-soft); }
.stage-mode { font-size: 10px; letter-spacing: 0.2em; color: var(--ink-mute); text-transform: uppercase; }
.stage-head .info { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.06em; }
.stage-head .info b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; margin: 0 2px; }

.board-wrap { position: relative; padding: 8px; background: rgba(15, 23, 42, 0.6); border-radius: 10px; min-height: 460px; display: flex; align-items: center; justify-content: center; }
.board { width: 100%; display: flex; align-items: center; justify-content: center; }
.board-svg { max-width: 100%; height: auto; }
.board-svg .edge { stroke: var(--line); stroke-width: 2.2; stroke-linecap: round; transition: stroke 0.18s ease, stroke-width 0.18s ease; }
.board-svg .edge.on { stroke: var(--line-on); stroke-width: 3.4; filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.55)); }
.board-svg .edge.hint { stroke: var(--line-hint); stroke-width: 2.4; opacity: 0.85; }

.board-svg .node { fill: var(--node); stroke: var(--paper-2); stroke-width: 2; transition: fill 0.2s ease, transform 0.2s ease; cursor: pointer; }
.board-svg .node.odd { fill: var(--node-odd); stroke: #b45309; }
.board-svg .node.current { fill: var(--node-on); stroke: #fff; stroke-width: 2.4; filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.9)); animation: pulse 1.4s ease-in-out infinite; }
.board-svg .node.hint-node { fill: var(--node-hint); stroke: #92400e; filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.7)); }
.board-svg .node:hover { fill: var(--accent-hi); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.status-overlay {
  position: absolute; left: 28px; bottom: 22px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 2px;
  pointer-events: none;
  max-width: 240px;
}
.status-overlay .so-msg { color: var(--accent-hi); font-weight: 600; text-transform: uppercase; font-size: 10px; }
.status-overlay .so-sub { color: var(--ink-mute); }

/* HUD strip (mobile / narrow) */
.hud-strip { display: none; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px 0; }
.hs-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border: 1px solid rgba(148, 163, 184, 0.12); border-radius: 6px; font-size: 11px; color: var(--ink-soft); }
.hs-item b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.hs-item .hs-l { font-size: 9px; letter-spacing: 0.2em; color: var(--ink-mute); text-transform: uppercase; }
.hs-item.idle b { color: var(--ink-mute); }
.hs-item.playing b { color: var(--accent-hi); }
.hs-item.won b { color: var(--success); }
.hs-item.dead b { color: var(--danger); }

/* ============================================================
   工作台右侧
   ============================================================ */
.workbench {
  background: linear-gradient(180deg, rgba(15,23,42,0.55), rgba(30,41,59,0.55));
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.wb-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 6px; border-bottom: 1px solid rgba(148, 163, 184, 0.08); }
.wb-head .l { font-size: 10px; letter-spacing: 0.32em; color: var(--ink-mute); text-transform: uppercase; }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 10px 12px; border: 1px solid rgba(148, 163, 184, 0.12); border-radius: 8px; background: rgba(15, 23, 42, 0.4); }
.stat .l { font-size: 9px; letter-spacing: 0.24em; color: var(--ink-mute); text-transform: uppercase; }
.stat .v { font-size: 18px; font-weight: 300; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat.status { grid-column: 1 / -1; }
.stat.status .v { font-size: 13px; font-weight: 600; }
.stat.status.idle .v { color: var(--ink-mute); }
.stat.status.playing .v { color: var(--accent-hi); }
.stat.status.won .v { color: var(--success); }
.stat.status.dead .v { color: var(--danger); }

.hint-line { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: rgba(245, 158, 11, 0.05); border: 1px solid rgba(245, 158, 11, 0.2); border-radius: 8px; }
.hint-line .ico { font-size: 16px; }
.hint-line .txt { font-size: 11px; line-height: 1.6; color: var(--ink-soft); }

.actions { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.btn-row:has(.btn:only-child) { grid-template-columns: 1fr; }
.actions .btn-row:nth-child(2) { grid-template-columns: 1fr 1fr; }
.btn {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--ink);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-hi); }
.btn.primary { background: var(--accent); color: #0b1220; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.ghost { background: transparent; border-color: rgba(148, 163, 184, 0.18); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.keys { font-size: 10px; color: var(--ink-mute); line-height: 1.8; }
.keys kbd { display: inline-block; padding: 1px 6px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 9px; color: var(--ink-soft); border: 1px solid rgba(148, 163, 184, 0.2); border-radius: 4px; background: rgba(15, 23, 42, 0.6); margin: 0 2px; }

/* ============================================================
   章节进度
   ============================================================ */
.chapter-bar { margin-top: 32px; padding: 18px 20px; background: linear-gradient(180deg, rgba(15,23,42,0.45), rgba(30,41,59,0.45)); border: 1px solid rgba(148, 163, 184, 0.1); border-radius: 14px; }
.chapter-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.chapter-head .l { font-size: 10px; letter-spacing: 0.32em; color: var(--ink-mute); text-transform: uppercase; }
.chapter-head .progress { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.06em; }
.chapter-head .progress b { color: var(--warm); font-weight: 600; }
.stars-sum { color: var(--star); margin-left: 10px; }

.chapter-track { position: relative; height: 48px; background: rgba(15, 23, 42, 0.4); border: 1px solid rgba(148, 163, 184, 0.08); border-radius: 8px; overflow: hidden; padding: 0 12px; display: flex; align-items: center; gap: 0; }
.chapter-seg-fill { position: absolute; left: 0; top: 0; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-soft), transparent); pointer-events: none; transition: width 0.4s ease; }
.chapter-nodes { display: flex; width: 100%; justify-content: space-between; position: relative; z-index: 1; }
.chapter-node { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 4px; }
.chapter-node .chapter-pin { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 11px; font-weight: 700; background: rgba(15, 23, 42, 0.7); color: var(--ink-mute); border: 1px solid rgba(148, 163, 184, 0.2); transition: all 0.2s ease; }
.chapter-node.cleared .chapter-pin { background: var(--warm); color: #0b1220; border-color: var(--warm); }
.chapter-node.current .chapter-pin { background: var(--accent); color: #0b1220; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.18); }
.chapter-node.locked { cursor: not-allowed; opacity: 0.5; }
.chapter-node .chapter-tip { font-size: 9px; color: var(--ink-mute); max-width: 60px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-node:hover:not(.locked) .chapter-pin { transform: scale(1.08); }

/* ============================================================
   互导 banner（用于 bee-loop & euler-draw 互链）
   ============================================================ */
.cross-link-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  margin: 12px 0 28px;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), rgba(56, 189, 248, 0.06));
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: all 0.2s ease;
}
.cross-link-banner:hover { border-color: var(--warm); color: var(--ink); }
.cross-link-banner.light { background: rgba(255, 255, 255, 0.92); border-color: var(--warm); color: #1f2937; margin: 14px auto 0; max-width: 380px; }
.cross-link-banner.light:hover { background: #fff; }
.cross-link-banner .cl-ico { font-size: 18px; color: var(--warm); }
.cross-link-banner .cl-strong { color: var(--warm); font-weight: 700; border-bottom: 1px solid var(--warm); padding-bottom: 1px; }
.cross-link-banner .cl-text { flex: 1; line-height: 1.5; }
.cross-link-banner .cl-arrow { font-size: 14px; color: var(--warm); }

/* ============================================================
   弹窗
   ============================================================ */
.modal-mask { position: fixed; inset: 0; background: rgba(8, 12, 22, 0.78); backdrop-filter: blur(6px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-mask.show { display: flex; }
.modal {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 32px 36px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  color: var(--ink);
}
.modal h2 { font-size: 22px; font-weight: 500; letter-spacing: 0.06em; color: var(--ink); margin-bottom: 4px; }
.modal .sub { font-size: 10px; color: var(--ink-mute); letter-spacing: 0.3em; text-transform: uppercase; margin-bottom: 20px; }
.modal .result { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-bottom: 16px; padding: 16px 0; border-top: 1px solid rgba(148, 163, 184, 0.1); border-bottom: 1px solid rgba(148, 163, 184, 0.1); }
.modal .result .r { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.modal .result .r .l { font-size: 9px; letter-spacing: 0.24em; color: var(--ink-mute); text-transform: uppercase; }
.modal .result .r .v { font-size: 18px; font-weight: 300; color: var(--ink); font-variant-numeric: tabular-nums; }

.win-stars { font-size: 28px; letter-spacing: 0.4em; color: var(--star); margin-bottom: 14px; }
.win-stars::before, .win-stars::after { content: ''; }
.win .reward { font-size: 13px; color: var(--warm); margin-bottom: 18px; padding: 8px 16px; background: var(--warm-soft); border: 1px dashed var(--warm); border-radius: 8px; }
.win .actions { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }

.modal.tutor { text-align: left; }
.tutor .tutor-step { font-size: 10px; letter-spacing: 0.32em; color: var(--accent); text-transform: uppercase; margin-bottom: 8px; }
.tutor .tutor-title { font-size: 18px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.tutor .tutor-text { font-size: 13px; line-height: 1.7; color: var(--ink-soft); margin-bottom: 20px; }
.tutor .tutor-board { height: 120px; background: rgba(56, 189, 248, 0.04); border: 1px dashed rgba(56, 189, 248, 0.2); border-radius: 8px; margin-bottom: 20px; display: flex; align-items: center; justify-content: center; }
.tutor .actions { display: flex; gap: 8px; justify-content: flex-end; }

.dead .dead-ico { font-size: 40px; color: var(--warning); margin-bottom: 8px; }

/* ============================================================
   Toast
   ============================================================ */
.toast { position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(15, 23, 42, 0.95); color: var(--ink); border: 1px solid var(--accent); padding: 10px 22px; font-size: 12px; letter-spacing: 0.08em; border-radius: 999px; opacity: 0; transition: all 0.22s ease; pointer-events: none; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
.toast.warn { border-color: var(--warning); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .stage-area { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-meta h1 { font-size: 42px; }
  .hero-deco { max-width: 280px; }
  .hud-strip { display: grid; }
  .stat-row { display: none; }
}
@media (max-width: 720px) {
  main { padding: 0 16px 60px; }
  .back-link { padding: 16px 16px 0; }
  .hero-meta h1 { font-size: 36px; }
  .modal { padding: 28px 24px 20px; }
  .btn-row { grid-template-columns: 1fr; }
  .actions .btn-row:nth-child(2) { grid-template-columns: 1fr 1fr; }
}