:root {
  --bg: #05070e;
  --text: #eef2f8;
  --text-muted: rgba(203, 213, 225, 0.72);
  --text-dim: rgba(148, 163, 184, 0.48);
  --hairline: rgba(255, 255, 255, 0.11);
  --gold: #f6c959;
  --gold-glow: rgba(246, 201, 89, 0.45);
  --hp: #34d399;
  --cyan: #38bdf8;
  --warn: #fb923c;
  --danger: #f87171;
  --font-display: "Chakra Petch", "Noto Sans SC", sans-serif;
  --font-serif: "Noto Serif SC", "Cinzel", serif;
  --font-sans: "Noto Sans SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.stage-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.canvas-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 右侧纯景深暗暮渐变：零边框、零矩形感 */
.right-scrim {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 470px;
  pointer-events: none;
  z-index: 6;
  background: linear-gradient(
    270deg,
    rgba(6, 9, 17, 0.92) 0%,
    rgba(6, 9, 17, 0.78) 62%,
    rgba(6, 9, 17, 0) 100%
  );
}

.floating-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 12;
}

.float-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
  animation: floatUp 1.25s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  white-space: nowrap;
}

.float-pop.gold { color: var(--gold); }
.float-pop.rock { color: var(--danger); }
.float-pop.descent { color: #cbd5e1; font-size: 14px; }

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -10%) scale(0.9); }
  20% { opacity: 1; transform: translate(-50%, -65%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -175%) scale(1); }
}

.tile-tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: rgba(8, 12, 22, 0.86);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  transition: box-shadow 0.4s ease;
}

.vignette-overlay.warning { box-shadow: inset 0 0 90px rgba(248, 113, 113, 0.42); }
.vignette-overlay.dead { box-shadow: inset 0 0 140px rgba(220, 38, 38, 0.68); }

/* ==================== 顶部无框极简导航 ==================== */
.floating-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 25;
  background: linear-gradient(180deg, rgba(5, 7, 14, 0.72) 0%, transparent 100%);
}

.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-diamond {
  width: 8px;
  height: 8px;
  transform: rotate(45deg) translateY(-1px);
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f8fafc;
}

.brand-sub {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-sep {
  width: 1px;
  height: 14px;
  background: var(--hairline);
}

.text-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.text-tab {
  position: relative;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.18s ease;
  white-space: nowrap;
}

.text-tab:hover { color: #ffffff; }

.text-tab.active {
  color: var(--gold);
  font-weight: 600;
}

.text-tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.16s ease;
  white-space: nowrap;
}

.nav-link:hover:not(:disabled) { color: #ffffff; }
.nav-link:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-link.accent { color: var(--gold); font-weight: 600; }
.nav-link.active { color: var(--gold); text-decoration: underline; text-underline-offset: 6px; }
.nav-link.full { width: 100%; text-align: center; padding: 4px 0; }

/* 唯一圆润实心主按钮样式（绝不用生硬直角矩形） */
.pill-btn {
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.pill-btn.primary {
  background: linear-gradient(135deg, #f8d26a, #e2a22a);
  color: #0b0f19;
  box-shadow: 0 6px 24px rgba(245, 196, 81, 0.28);
}

.pill-btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(245, 196, 81, 0.4);
}

.pill-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.pill-btn.xl { padding: 13px 34px; font-size: 14px; letter-spacing: 0.04em; }
.pill-btn.full { width: 100%; }

/* 轻量毛玻璃参数浮层 */
.params-wrap { position: relative; }

.glass-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 240px;
  padding: 18px;
  border-radius: 16px;
  background: rgba(11, 16, 28, 0.88);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
}

.pop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #f8fafc;
}

.pop-head code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
}

.pop-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.pop-field input {
  width: 88px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 4px;
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  text-align: right;
}

/* ==================== 开局无框电影级引导 ==================== */
.hero-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(5, 7, 14, 0.42), rgba(5, 7, 14, 0.82));
  backdrop-filter: blur(2px);
}

.hero-inner {
  text-align: center;
  max-width: 580px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hero-kicker {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--gold);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ffffff;
  text-shadow: 0 8px 36px rgba(0, 0, 0, 0.65);
}

.hero-rules {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}

.hero-rules b { color: var(--gold); font-family: var(--font-display); }

.hero-cta {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.hero-ghost-link {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.16s ease;
}

.hero-ghost-link:hover { color: var(--gold); }

/* ==================== 右侧无框现代排版区（零嵌套矩形！） ==================== */
.editorial-rail {
  position: absolute;
  top: 68px;
  right: 28px;
  bottom: 24px;
  width: 396px;
  z-index: 16;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 11px;
  pointer-events: auto;
  overflow-y: auto;
  scrollbar-width: none;
}

.editorial-rail::-webkit-scrollbar { display: none; }

.rail-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.hairline-sep {
  height: 1px;
  background: linear-gradient(90deg, var(--hairline) 0%, rgba(255, 255, 255, 0.02) 100%);
}

/* 1. 大号数字战况 */
.telemetry-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.big-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.big-stat.right { align-items: flex-end; }

.stat-kicker {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}

.stat-num {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-num.hp { color: var(--hp); }
.stat-num.hp.warn { color: var(--warn); }
.stat-num.hp.dead { color: var(--danger); }
.stat-num.gold { color: var(--gold); }

.hairline-hp {
  position: relative;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

.hairline-hp-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--hp);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.55);
  transition: width 0.3s ease, background 0.3s ease;
}

.hairline-hp-fill.warn { background: var(--warn); box-shadow: 0 0 10px rgba(251, 146, 60, 0.6); }
.hairline-hp-fill.dead { background: var(--danger); box-shadow: 0 0 12px rgba(248, 113, 113, 0.7); }

.hp-dot {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 9px;
}

.hp-dot.warn { background: var(--warn); }
.hp-dot.death { background: var(--danger); }

.alert-line {
  font-size: 12px;
  font-weight: 600;
  color: #fca5a5;
  letter-spacing: 0.04em;
  animation: pulseWarn 1.2s ease-in-out infinite;
}

@keyframes pulseWarn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* 2. 当前路口“算法预见未来”抉择洞察 */
.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.block-kicker {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.block-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--gold);
}

.head-right-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.verify-link {
  border: none;
  background: transparent;
  color: var(--cyan);
  font-family: var(--font-sans);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.verify-link:hover:not(:disabled) { color: #ffffff; }
.verify-link.verified { color: var(--hp); text-decoration: none; cursor: default; }

.insight-headline {
  font-size: 14.5px;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.45;
}

.fate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fate-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--hairline);
  transition: all 0.2s ease;
}

.fate-item.chosen {
  border-left-color: var(--gold);
  color: #ffffff;
}

.fate-item.dead {
  border-left-color: var(--danger);
  color: rgba(248, 113, 113, 0.88);
}

.fate-item.alt {
  border-left-color: rgba(56, 189, 248, 0.45);
  color: var(--text-muted);
}

.fate-dir {
  font-size: 12.5px;
  font-weight: 600;
}

.fate-outcome {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.fate-item.chosen .fate-outcome { color: var(--gold); font-weight: 700; }

.ptr-chain {
  margin-top: 2px;
  padding-left: 12px;
  border-left: 2px solid rgba(52, 211, 153, 0.55);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-muted);
  word-break: break-all;
}

.ptr-chain b {
  color: var(--hp);
  font-weight: 700;
}

/* 可视化 N×N 二维 DP 数组全息矩阵（无外框，通透现代） */
.dp-matrix-host {
  width: 100%;
  margin: 2px 0 4px;
}

.dp-matrix-svg {
  width: 100%;
  max-width: 364px;
  height: auto;
  display: block;
}

.dp-cell-group {
  cursor: pointer;
}

.dp-cell-group:hover .dp-cell-rect {
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 1.4;
}

/* Python 标准输出行（终局显性输出黄金数与血条） */
.py-stdout {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--hp);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--hp);
  letter-spacing: 0.02em;
}

.py-stdout.dead {
  border-left-color: var(--danger);
  color: var(--danger);
}

/* 舞台顶部居中无框终局输出字幕 */
.final-output-banner {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.82);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.final-tag {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--hp);
}

.final-output-banner.dead .final-tag { color: var(--danger); }

.final-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.03em;
}

.final-text b.g { color: var(--gold); }
.final-text b.h { color: var(--hp); }
.final-output-banner.dead .final-text b.h { color: var(--danger); }

/* 3. 无框 Python 源码流 */
.code-block {
  flex: 1;
  min-height: 0;
  justify-content: flex-start;
}

.code-stream {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11.8px;
  line-height: 1.5;
}

.cs-sep {
  height: 1px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.08);
}

.cs-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 2px 0 2px 10px;
  border-left: 2px solid transparent;
  color: #cbd5e1;
  transition: all 0.18s ease;
}

.code-stream.has-active .cs-line:not(.active) {
  opacity: 0.42;
}

.cs-line.active {
  border-left-color: var(--gold);
  color: #ffffff;
  text-shadow: 0 0 18px rgba(246, 201, 89, 0.28);
}

.cs-line.active.tone-win { border-left-color: var(--hp); }
.cs-line.active.tone-warn { border-left-color: var(--warn); }
.cs-line.active.tone-danger { border-left-color: var(--danger); }

.cs-no {
  font-size: 10px;
  color: var(--text-dim);
  user-select: none;
  flex-shrink: 0;
}

.cs-src {
  flex: 1;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}

.cs-line.tone-win .cs-val { color: var(--hp); }
.cs-line.tone-warn .cs-val { color: var(--warn); }
.cs-line.tone-danger .cs-val { color: var(--danger); }

.tok-kw { color: #c084fc; }
.tok-fn { color: #38bdf8; }
.tok-str { color: #86efac; }
.tok-num { color: #fbbf24; }
.tok-cst { color: #f472b6; }
.tok-cmt { color: #64748b; font-style: italic; }

/* ==================== 底部居中悬浮极简控条 ==================== */
.floating-dock {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.dock-phases {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phase-link {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 4px;
  cursor: pointer;
  transition: color 0.16s ease;
  white-space: nowrap;
}

.phase-link:hover { color: #ffffff; }

.phase-link.active {
  color: var(--gold);
  font-weight: 600;
  text-shadow: 0 0 12px var(--gold-glow);
}

.phase-dot {
  color: var(--text-dim);
  font-size: 12px;
  user-select: none;
}

.dock-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(9, 13, 24, 0.78);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.dock-icon, .dock-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.dock-icon:hover:not(:disabled), .dock-btn:hover:not(:disabled) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.dock-btn.active { color: var(--gold); }
.dock-icon:disabled, .dock-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.dock-step {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 6px;
}

.dock-slider {
  width: 260px;
  height: 3px;
  accent-color: var(--gold);
  cursor: pointer;
  opacity: 0.75;
}

.dock-slider:hover { opacity: 1; }

/* 改图模式提示 */
.floating-notice {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(246, 201, 89, 0.16);
  backdrop-filter: blur(12px);
  color: #fef3c7;
  font-size: 12.5px;
}

.notice-btn {
  border: none;
  background: var(--gold);
  color: #0b0f19;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}

/* 改图浮层 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 7, 14, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.glass-modal {
  width: 290px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(13, 19, 34, 0.94);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.center-tabs { justify-content: space-around; }

.val-slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.val-slider-row b { color: var(--gold); font-family: var(--font-mono); }
.val-slider-row input { width: 100%; accent-color: var(--gold); }
