/* ---- Runtime overlay overrides for live three.js HUD ---- */
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--f-cn);
}
button { font: inherit; color: inherit; }

/* canvas */
#viewport { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: var(--bg-0); }

/* deep space backdrop nebula + scanlines on top of canvas */
.shell {
  position: fixed; inset: 0; pointer-events: none;
  isolation: isolate;
}
.shell::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 18% 22%, rgba(125,249,255,.06) 0%, transparent 45%),
    radial-gradient(ellipse at 78% 80%, rgba(255,184,107,.05) 0%, transparent 50%);
  z-index: 1;
}
.shell::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(125,249,255,.025) 0 1px, transparent 1px 4px);
  z-index: 2;
}

/* universal corner brackets */
.ab-frame { position: absolute; inset: 14px; pointer-events: none; z-index: 6; }
.ab-frame::before, .ab-frame::after,
.ab-frame > i::before, .ab-frame > i::after {
  content: ''; position: absolute; width: 28px; height: 28px;
  border: 1px solid var(--hud); opacity: .55;
}
.ab-frame::before { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.ab-frame::after  { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.ab-frame > i::before { bottom: 0; left: 0; position: absolute; border-right: 0; border-top: 0; }
.ab-frame > i::after  { bottom: 0; right: 0; position: absolute; border-left: 0; border-top: 0; }
.ab-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); pointer-events: none; z-index: 5; }

/* ---- Top status bar (centered with brand mark) ---- */
.ab-statusbar {
  position: absolute;
  top: 14px; left: 14px; right: 14px;
  height: 32px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  border: 1px solid var(--hud-line);
  background: linear-gradient(180deg, rgba(125,249,255,.06), rgba(125,249,255,.02));
  z-index: 12;
  pointer-events: auto;
}
.brandmark { width: 22px; height: 22px; flex: 0 0 auto; }
.brandmark circle, .brandmark ellipse, .brandmark line { vector-effect: non-scaling-stroke; }
.glowline-h { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--hud) 50%, transparent); box-shadow: 0 0 12px var(--hud-glow); }

/* ---- Minimal HUD (bottom-only, fly-layer) ---- */
.hud-min {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 48px 36px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: 24px;
  pointer-events: none;
  z-index: 10;
}
.hud-min > section { pointer-events: auto; }

.hud-progress { display: flex; flex-direction: column; gap: 8px; }
.hud-progress-line { display: flex; gap: 8px; align-items: baseline; }
.hud-progress-line .bignum { font-size: 36px; color: var(--ink); line-height: 1; }
.hud-progress-total { font-family: var(--f-mono); font-size: 14px; color: var(--ink-mute); }
.hud-bar {
  position: relative;
  width: 220px; height: 2px;
  background: rgba(125,249,255,.10);
}
.hud-bar > #progressBar {
  display: block; height: 100%; width: 0;
  background: var(--hud);
  box-shadow: 0 0 8px var(--hud-glow);
  transition: width .25s ease;
}
.hud-bar-ticks { position: absolute; inset: -2px 0 0 0; pointer-events: none; }
.hud-bar-ticks span {
  position: absolute; top: 0;
  width: 1px; height: 6px;
  background: var(--bg-0);
}
.hud-progress-stage {
  font-family: var(--f-cn);
  font-size: 11px; letter-spacing: 0.22em;
  color: var(--ink-dim);
  margin-top: 4px;
  max-width: 320px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.hud-action { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.hud-action-meta {
  display: flex; gap: 10px; align-items: baseline;
  font-family: var(--f-mono);
  font-size: 11px; color: var(--ink); letter-spacing: 0.22em;
}
.hud-action-meta .dim { color: var(--ink-mute); }
.hud-action-cap {
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.3em;
  color: var(--hud-dim);
}
.hud-action-row { display: flex; gap: 10px; }
.hud-action-row .btn { min-height: 38px; padding: 0 18px; }
.btn:disabled { cursor: default; opacity: .48; box-shadow: none; }

.hud-side { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; text-align: right; }
.hud-side-keys { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.hud-side-keys .data { font-size: 10px; }
.hud-side-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hud-side-row .btn { min-height: 32px; padding: 0 14px; font-size: 10px; }

/* legacy heavy panels kept around for state-machine CSS but never shown */
.mission, .codex, .controls { display: none !important; }

/* mission legacy block (kept commented-out base for reference) */
.mission-legacy {
  position: absolute; left: 24px; top: 64px;
  width: min(420px, calc(100vw - 48px));
  padding: 18px 20px 16px;
  pointer-events: auto;
  z-index: 10;
}
.kicker {
  margin: 0 0 10px;
  font-family: var(--f-mono);
  font-size: 10px; letter-spacing: 0.32em;
  color: var(--copper); text-transform: uppercase;
}
h1 {
  margin: 0;
  font-family: var(--f-cn);
  font-weight: 900;
  font-size: 26px; line-height: 1.05;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(125,249,255,.32);
}
.summary { margin: 12px 0 0; color: var(--ink-dim); font-size: 12px; line-height: 1.6; letter-spacing: 0.06em; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat {
  position: relative;
  min-height: 62px;
  border-left: 1px solid var(--hud-line);
  padding: 4px 0 4px 10px;
  background: transparent;
}
.stat span {
  display: block;
  font-family: var(--f-mono);
  color: var(--hud-dim); font-size: 9px;
  letter-spacing: 0.28em; text-transform: uppercase;
}
.stat strong {
  display: block; margin-top: 6px;
  font-family: var(--f-data);
  font-weight: 400;
  font-size: 18px; line-height: 1.1;
  color: var(--ink);
}
.meter {
  height: 3px; margin-top: 16px;
  background: rgba(125,249,255,.08);
  border: 0;
  position: relative; overflow: hidden;
}
.meter > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--hud), var(--copper));
  box-shadow: 0 0 10px var(--hud-glow);
  transition: width .25s ease;
}
.meter-cap {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
}
.meter-cap .label { font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.32em; color: var(--hud-dim); text-transform: uppercase; }

/* codex (top-right) */
.codex {
  position: absolute; right: 24px; top: 64px;
  width: min(380px, calc(100vw - 48px));
  max-height: calc(100vh - 220px);
  display: grid; grid-template-rows: auto auto auto 1fr;
  pointer-events: auto;
  z-index: 10;
  overflow: hidden;
}
.codex header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--hud-line);
}
.codex h2 {
  margin: 0;
  font-family: var(--f-cn);
  font-weight: 700;
  font-size: 16px; letter-spacing: 0.4em;
  color: var(--ink);
}
#assetBadge { color: var(--hud); font-size: 10px; letter-spacing: 0.22em; }
.fact {
  padding: 14px 18px;
  color: var(--ink-dim); font-size: 12px; line-height: 1.7;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--hud-line);
}
.scan-frame {
  margin: 0; padding: 12px 18px 14px;
  border-bottom: 1px solid var(--hud-line);
  display: grid; gap: 8px;
}
.scan-frame.hidden { display: none; }
.scan-frame img {
  display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--hud-line);
}
.scan-frame figcaption {
  font-family: var(--f-mono);
  color: var(--copper);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
}
.entries {
  overflow: auto; padding: 12px 14px;
  display: grid; gap: 8px;
}
.entries::-webkit-scrollbar { width: 4px; }
.entries::-webkit-scrollbar-thumb { background: var(--hud-line); }
.entry {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--hud-line);
  background: rgba(125,249,255,.03);
  padding: 10px 12px;
  color: var(--ink-dim);
  font-family: var(--f-cn);
  font-size: 12px; line-height: 1.5;
  letter-spacing: 0.04em;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.entry.current { border-color: var(--copper); color: var(--ink); background: rgba(255,184,107,.08); }
.entry.done { border-color: var(--good); color: var(--good); }

/* controls (bottom) */
.controls {
  position: absolute; left: 24px; right: 24px; bottom: 24px;
  padding: 14px 16px;
  display: grid; gap: 12px;
  pointer-events: auto;
  z-index: 10;
}
.timeline, .route {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 2px 2px 6px;
}
.timeline::-webkit-scrollbar, .route::-webkit-scrollbar { height: 4px; }
.timeline::-webkit-scrollbar-thumb, .route::-webkit-scrollbar-thumb { background: var(--hud-line); }

.stage, .destination {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 16px;
  display: inline-flex; align-items: center;
  border: 1px solid var(--hud-line);
  background: linear-gradient(180deg, rgba(125,249,255,.05), rgba(125,249,255,.01));
  color: var(--ink-dim);
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.2em;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.stage:hover, .destination:hover { color: var(--hud); border-color: var(--hud); }
.stage.active, .destination.active {
  color: var(--copper);
  border-color: var(--copper);
  background: linear-gradient(180deg, rgba(255,184,107,.16), rgba(255,184,107,.04));
  box-shadow: 0 0 20px rgba(255,184,107,.18), inset 0 0 18px rgba(255,184,107,.08);
}
.stage.done, .destination.done { color: var(--good); border-color: rgba(158,240,200,.55); }
.stage.active.done, .destination.active.done { color: var(--copper); }

.actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.control-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 18px;
  background: linear-gradient(180deg, rgba(125,249,255,.10), rgba(125,249,255,.02));
  border: 1px solid var(--hud);
  color: var(--hud);
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.control-btn:hover { box-shadow: 0 0 16px var(--hud-glow); }
.control-btn.primary {
  background: linear-gradient(180deg, rgba(255,184,107,.20), rgba(255,184,107,.06));
  border-color: var(--copper);
  color: var(--copper);
  box-shadow: 0 0 20px rgba(255,184,107,.20), inset 0 0 20px rgba(255,184,107,.10);
}
.control-btn:disabled { opacity: .48; cursor: default; box-shadow: none; }

/* toast */
.toast {
  position: absolute; left: 50%; top: 64px;
  transform: translateX(-50%) translateY(-14px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  padding: 10px 18px;
  border: 1px solid var(--copper);
  background: linear-gradient(180deg, rgba(255,184,107,.12), rgba(8,12,22,.92));
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.22em;
  box-shadow: 0 0 24px rgba(255,184,107,.25);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  z-index: 14;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* loading panel — decorations via pseudo so JS textContent updates don't wipe them */
.loading {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: min(520px, calc(100vw - 48px));
  max-width: min(620px, calc(100vw - 48px));
  padding: 32px 36px;
  text-align: center;
  font-family: var(--f-cn);
  font-size: 14px; line-height: 1.7;
  letter-spacing: 0.32em;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(10,20,40,.86), rgba(6,12,26,.94));
  border: 1px solid var(--copper);
  box-shadow: 0 0 40px rgba(255,184,107,.25), inset 0 0 30px rgba(125,249,255,.06);
  z-index: 13;
  pointer-events: auto;
}
.loading::before {
  content: 'LOADING SEQUENCE · 装载航段';
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  padding: 0 12px;
  background: var(--bg-0);
  font-family: var(--f-mono);
  font-size: 10px; letter-spacing: 0.4em;
  color: var(--copper);
}
.loading::after {
  content: '';
  position: absolute; bottom: -1px; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--copper), transparent);
  box-shadow: 0 0 8px var(--copper-glow);
}
.loading.hidden { display: none; }

/* ---- Override voyager-ui.css .panel for runtime use ---- */
.panel {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(10,20,40,.78), rgba(6,12,26,.88));
  border: 1px solid var(--hud-line);
  backdrop-filter: blur(14px);
  position: relative;
}
.panel::before {
  content: ''; position: absolute; inset: 0;
  border: 1px solid rgba(125,249,255,.06);
  margin: 4px; pointer-events: none;
}
/* corner notches via .notch */
.notch::before, .notch::after,
.notch > .nb::before, .notch > .nb::after {
  content: ''; position: absolute; width: 10px; height: 10px;
  border: 1px solid var(--hud);
}
.notch::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.notch::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.notch > .nb::before { bottom: -1px; left: -1px; position: absolute; border-right: 0; border-top: 0; }
.notch > .nb::after  { bottom: -1px; right: -1px; position: absolute; border-left: 0; border-top: 0; }

/* re-assert absolute positioning over .panel { position: relative } */
.shell .mission, .shell .codex, .shell .controls { position: absolute; }

/* status bar segments */
.ab-statusbar .seg {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono);
  font-size: 10px; color: var(--hud);
  letter-spacing: 0.18em; text-transform: uppercase;
}
.ab-statusbar .seg.dim { color: var(--ink-dim); }
.ab-statusbar .seg.alt { color: var(--copper); }
.ab-statusbar .dot { width: 6px; height: 6px; background: var(--hud); box-shadow: 0 0 8px var(--hud-glow); }
.ab-statusbar .seg.alt .dot { background: var(--copper); box-shadow: 0 0 8px var(--copper-glow); }
.ab-statusbar .spacer { flex: 1; }

/* ============================================================
   SCREEN · STATE MACHINE
   data-screen on body controls overlays + HUD visibility
   ============================================================ */
.screen {
  position: fixed; inset: 0;
  pointer-events: auto;
  z-index: 30;
  display: none;
  isolation: isolate;
}
body[data-screen="title"]         .screen-title         { display: block; }
body[data-screen="scanning"]      .screen-scanning      { display: block; }
body[data-screen="codex-detail"]  .screen-codex-detail  { display: block; }
body[data-screen="map"]           .screen-map           { display: block; }
body[data-screen="complete"]      .screen-complete      { display: block; }

/* hide HUD on title-only / overlay where it does not belong */
body[data-screen="title"] .ab-statusbar,
body[data-screen="title"] .hud-min,
body[data-screen="title"] .toast { display: none; }

body[data-screen="scanning"] .hud-min { opacity: .25; pointer-events: none; }

body[data-screen="codex-detail"] .hud-min { display: none; }
body[data-screen="map"] .hud-min { display: none; }
body[data-screen="complete"] .hud-min,
body[data-screen="complete"] .ab-statusbar { display: none; }

/* universal vignette + frame for overlays */
.screen .ab-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); pointer-events: none; z-index: 1; }

/* ============================================================
   SCREEN · TITLE
   ============================================================ */
.screen-title { background: var(--bg-0); }
.screen-title::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 18% 22%, rgba(125,249,255,.08) 0%, transparent 45%),
    radial-gradient(ellipse at 78% 80%, rgba(255,184,107,.06) 0%, transparent 50%);
}
.title-orbit {
  position: absolute; left: -260px; top: -100px;
  width: 900px; height: 900px;
  opacity: 0.55;
  pointer-events: none;
  z-index: 2;
}
.title-mark { position: absolute; left: 48px; top: 48px; z-index: 10; display: flex; gap: 14px; align-items: center; }
.title-mark > svg { width: 42px; height: 42px; }
.title-mark-en { font-family: var(--f-mono); font-size: 11px; color: var(--hud); letter-spacing: 0.4em; }
.title-mark-cn { font-family: var(--f-cn); font-size: 11px; letter-spacing: 0.35em; color: var(--ink-dim); margin-top: 4px; }

.title-meta {
  position: absolute; right: 48px; top: 48px; z-index: 10;
  text-align: right;
  font-family: var(--f-mono);
  font-size: 10px; color: var(--ink-dim); letter-spacing: 0.22em;
  display: flex; flex-direction: column; gap: 6px;
}

.title-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 10; text-align: center; max-width: min(780px, calc(100vw - 96px));
}
.title-kicker {
  font-family: var(--f-mono);
  font-size: 13px; letter-spacing: 0.55em; color: var(--copper);
  margin-bottom: 24px;
}
.title-name {
  font-family: var(--f-cn); font-weight: 900;
  font-size: clamp(48px, 9vw, 96px); line-height: 1;
  color: var(--ink);
  letter-spacing: 0.5em;
  margin: 0 -0.5em 0 0;
  text-shadow: 0 0 32px rgba(125,249,255,.5);
}
.title-en {
  font-family: var(--f-mono);
  font-size: 24px; letter-spacing: 0.7em;
  color: var(--hud);
  margin-top: 18px;
  text-shadow: 0 0 16px var(--hud-glow);
}
.title-rule {
  height: 1px; width: 380px; margin: 36px auto;
  background: linear-gradient(90deg, transparent, var(--hud), transparent);
  box-shadow: 0 0 8px var(--hud-glow);
}
.title-sub {
  font-family: var(--f-cn);
  font-size: 12px; letter-spacing: 1em; color: var(--ink-dim);
  margin-bottom: 42px;
}
.title-actions { display: flex; gap: 14px; justify-content: center; }
.title-actions .btn { min-height: 44px; padding: 0 24px; }

.title-foot-l { position: absolute; left: 48px; bottom: 48px; z-index: 10; display: flex; flex-direction: column; gap: 6px; }
.title-foot-r { position: absolute; right: 48px; bottom: 48px; z-index: 10; text-align: right; display: flex; flex-direction: column; gap: 6px; }
.title-foot-label { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.32em; color: var(--hud-dim); text-transform: uppercase; }
.title-foot-line { font-family: var(--f-cn); font-size: 13px; letter-spacing: 0.4em; color: var(--ink-dim); }
.title-foot-key { font-family: var(--f-mono); font-size: 12px; color: var(--hud); letter-spacing: 0.3em; }

/* ============================================================
   SCREEN · SCANNING (overlay)
   ============================================================ */
.scan-dim { position: absolute; inset: 0; background: rgba(3,6,15,.72); z-index: 1; backdrop-filter: blur(2px); }
.scan-rings {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 90vmin); height: min(640px, 90vmin);
  z-index: 2;
  pointer-events: none;
}
.scan-rings svg { width: 100%; height: 100%; display: block; }
.scan-sweep {
  transform-origin: 320px 320px;
  animation: scan-spin 1.2s linear infinite;
}
@keyframes scan-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.scan-head {
  position: absolute; left: 50%; top: 60px; transform: translateX(-50%);
  text-align: center;
  z-index: 4;
}
.scan-head-en { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.6em; color: var(--copper); }
.scan-head-cn {
  margin: 14px 0 0;
  font-family: var(--f-cn); font-weight: 700;
  font-size: 38px; letter-spacing: 0.3em;
  color: var(--ink);
  text-shadow: 0 0 20px rgba(255,184,107,.5);
}

.scan-foot {
  position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%);
  width: min(560px, calc(100vw - 48px));
  z-index: 4;
}
.scan-foot-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.scan-bar {
  position: relative; height: 4px;
  background: rgba(255,184,107,.1);
  border: 1px solid rgba(255,184,107,.3);
}
.scan-bar > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, transparent, var(--copper));
  box-shadow: 0 0 12px var(--copper-glow);
  transition: width 0.08s linear;
}
.scan-chips {
  display: flex; gap: 12px; margin-top: 18px; justify-content: center; flex-wrap: wrap;
}

/* ============================================================
   SCREEN · CODEX DETAIL (overlay)
   ============================================================ */
.cd-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(125,249,255,.06), transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(255,184,107,.05), transparent 50%),
    rgba(3,6,15,.92);
  z-index: 1;
  backdrop-filter: blur(8px);
}
.cd-breadcrumb {
  position: absolute; left: 48px; top: 56px; z-index: 5;
  display: flex; gap: 12px; align-items: center;
}

.cd-image-wrap {
  position: absolute; left: 6%; top: 110px;
  width: min(46%, 560px);
  aspect-ratio: 1 / 1;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
}
.cd-image-wrap img {
  width: 78%; height: 78%; object-fit: contain;
  border-radius: 50%;
  box-shadow: 0 0 80px rgba(255,184,107,.18), inset 0 0 60px rgba(0,0,0,.6);
  background: rgba(3,6,15,.6);
}
.cd-image-wrap img[src=""], .cd-image-wrap img:not([src]) {
  background: radial-gradient(circle, rgba(125,249,255,.12), rgba(3,6,15,.8));
}
.cd-rings { position: absolute; inset: 0; pointer-events: none; opacity: 0.7; }

.cd-info {
  position: absolute; right: 48px; top: 110px;
  width: min(48%, 540px);
  z-index: 5;
  display: flex; flex-direction: column; gap: 10px;
}
.cd-chips { display: flex; gap: 12px; align-items: center; }
.cd-name {
  margin: 14px 0 0;
  font-family: var(--f-cn); font-weight: 900;
  font-size: clamp(48px, 6vw, 80px); line-height: 1;
  letter-spacing: 0.3em;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(125,249,255,.4);
}
.cd-en { font-family: var(--f-mono); font-size: 18px; letter-spacing: 0.55em; color: var(--hud); margin-top: 8px; }
.cd-region { font-family: var(--f-cn); font-size: 13px; letter-spacing: 0.5em; color: var(--copper); margin-top: 6px; }
.cd-fact {
  margin: 0;
  font-family: var(--f-cn);
  font-size: 14px; line-height: 1.9;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
}
.cd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
.cd-cell {
  border-left: 1px solid var(--hud-line);
  padding: 4px 0 4px 12px;
}
.cd-cell-label { font-family: var(--f-cn); font-size: 11px; letter-spacing: 0.4em; color: var(--ink-dim); }
.cd-cell-value {
  display: flex; gap: 8px; align-items: baseline; margin-top: 6px;
}
.cd-cell-value strong { font-family: var(--f-data); font-weight: 400; font-size: 22px; color: var(--ink); }
.cd-cell-value span { font-family: var(--f-mono); font-size: 10px; color: var(--ink-mute); }

.cd-foot {
  position: absolute; left: 48px; right: 48px; bottom: 36px;
  z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px;
}
.cd-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.cd-actions .btn { min-height: 38px; padding: 0 18px; }

/* ============================================================
   SCREEN · STAGE MAP (overlay)
   ============================================================ */
.map-head { position: absolute; left: 48px; top: 64px; z-index: 5; }
.map-head-en { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.5em; color: var(--copper); }
.map-head-cn { margin: 8px 0 10px; font-family: var(--f-cn); font-weight: 900; font-size: 40px; letter-spacing: 0.4em; color: var(--ink); }
.map-meta { position: absolute; right: 48px; top: 80px; z-index: 5; text-align: right; }

.map-track-wrap {
  position: absolute; left: 0; right: 0; top: 230px;
  height: 200px;
  z-index: 5;
  overflow: hidden;
}
.map-track {
  display: flex; align-items: center; gap: 60px;
  padding: 60px 48px;
  overflow-x: auto;
  height: 100%;
  position: relative;
}
.map-track::before {
  content: ''; position: absolute;
  left: 48px; right: 48px; top: 50%;
  height: 1px;
  background: linear-gradient(90deg, var(--good) 0%, var(--copper) 40%, var(--ink-mute) 40%, var(--ink-mute) 100%);
  opacity: 0.55;
  transform: translateY(-1px);
  pointer-events: none;
}
.map-node {
  flex: 0 0 auto;
  width: 110px;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  background: transparent; border: 0; padding: 0;
  color: inherit;
  font: inherit;
  position: relative;
}
.map-node-year {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.18em;
  color: var(--ink-dim);
  margin-bottom: 10px;
}
.map-hex {
  width: 60px; height: 60px;
  position: relative;
}
.map-hex svg { width: 100%; height: 100%; display: block; }
.map-node-label {
  margin-top: 14px;
  text-align: center;
  font-family: var(--f-cn); font-size: 11px; font-weight: 700;
  color: var(--ink-dim); letter-spacing: 0.3em;
}
.map-node-en {
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.22em;
  color: var(--ink-mute);
  margin-top: 3px;
}
.map-node.done .map-node-year { color: var(--good); }
.map-node.done .map-node-label { color: var(--good); }
.map-node.current .map-node-year { color: var(--copper); }
.map-node.current .map-node-label { color: var(--ink); }

.map-card {
  position: absolute; left: 120px; right: 120px; top: 470px;
  z-index: 5;
  padding: 24px 32px;
  border: 1px solid var(--copper);
  background: linear-gradient(180deg, rgba(255,184,107,.08), rgba(255,184,107,.02));
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 24px;
  align-items: center;
}
.map-card-thumb {
  width: 120px; height: 120px;
  border: 1px solid var(--copper);
  background: rgba(255,184,107,.04);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-cn); font-size: 22px; font-weight: 900; color: var(--copper);
  letter-spacing: 0.2em;
}
.map-card-body { display: flex; flex-direction: column; gap: 8px; }
.map-card-row { display: flex; gap: 12px; align-items: center; }
.map-card-title { margin: 0; font-family: var(--f-cn); font-weight: 900; font-size: 28px; letter-spacing: 0.3em; color: var(--ink); }
.map-card-summary { font-family: var(--f-cn); font-size: 13px; line-height: 1.8; letter-spacing: 0.12em; color: var(--ink-dim); max-width: 600px; }
.map-card-targets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.map-card-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: 140px; }
.map-card-actions .btn { width: 100%; }

.map-foot {
  position: absolute; left: 48px; right: 48px; bottom: 36px;
  z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}

/* ============================================================
   SCREEN · COMPLETE (overlay)
   ============================================================ */
.comp-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,184,107,.22) 0%, transparent 50%);
  z-index: 2;
  pointer-events: none;
}
.comp-head {
  position: absolute; left: 50%; top: 80px; transform: translateX(-50%);
  z-index: 5;
  text-align: center;
  max-width: calc(100vw - 96px);
}
.comp-medal { width: 140px; height: 140px; display: block; margin: 0 auto; }
.comp-en { font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.7em; color: var(--copper); margin-top: 16px; }
.comp-cn {
  margin: 14px 0 0;
  font-family: var(--f-cn); font-weight: 900;
  font-size: clamp(36px, 5vw, 56px);
  letter-spacing: 0.4em;
  color: var(--ink);
  text-shadow: 0 0 32px rgba(255,184,107,.5);
}
.comp-sub { font-family: var(--f-cn); font-size: 13px; letter-spacing: 0.5em; color: var(--hud); margin-top: 12px; }

.comp-stats {
  position: absolute; left: 80px; right: 80px; top: 440px;
  z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
.comp-stat {
  padding: 16px 18px;
  border: 1px solid var(--hud-line);
  background: rgba(125,249,255,.04);
  display: flex; flex-direction: column; gap: 6px;
}
.comp-stat.warn { border-color: var(--copper); background: rgba(255,184,107,.06); }
.comp-stat-num { font-family: var(--f-data); font-weight: 400; font-size: 36px; color: var(--hud); line-height: 1; }
.comp-stat.warn .comp-stat-num { color: var(--copper); text-shadow: 0 0 12px var(--copper-glow); }
.comp-stat-cn { font-family: var(--f-cn); font-size: 11px; letter-spacing: 0.4em; font-weight: 700; color: var(--ink-dim); }
.comp-stat-en { font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.22em; color: var(--ink-mute); }

.comp-strip {
  position: absolute; left: 48px; right: 48px; top: 580px;
  z-index: 5;
}
.comp-strip-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
.comp-grid {
  display: grid; grid-template-columns: repeat(13, 1fr); gap: 8px;
}
.comp-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--hud-line);
  background: rgba(125,249,255,.04);
  position: relative;
  overflow: hidden;
}
.comp-cell.done { border-color: var(--good); background: rgba(158,240,200,.06); }
.comp-cell.future { border-color: var(--copper); background: rgba(255,184,107,.06); }
.comp-cell img { width: 100%; height: 100%; object-fit: cover; filter: contrast(1.1); }
.comp-cell-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 6px;
  background: linear-gradient(0deg, rgba(0,0,0,.85), transparent);
  font-family: var(--f-cn); font-size: 9px; letter-spacing: 0.18em; font-weight: 700;
  text-align: center;
  color: var(--ink-dim);
}
.comp-cell.done .comp-cell-name { color: var(--good); }
.comp-cell-mark {
  position: absolute; top: 4px; right: 4px;
  font-family: var(--f-mono); font-size: 8px;
  color: var(--good);
}

.comp-foot {
  position: absolute; left: 48px; right: 48px; bottom: 32px;
  z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}

@media (max-width: 980px) {
  .ab-frame { inset: 8px; }
  .ab-statusbar { left: 8px; right: 8px; top: 8px; gap: 8px; padding: 0 10px; }
  .ab-statusbar .seg { font-size: 9px; letter-spacing: 0.14em; }
  .ab-statusbar .seg.dim { max-width: 42vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .hud-min { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); gap: 12px; }
  .hud-side-keys { display: none; }
  .title-mark { left: 24px; top: 28px; }
  .title-meta { right: 24px; top: 28px; }
  .title-center { max-width: calc(100vw - 40px); }
  .title-name { letter-spacing: .3em; margin-right: -.3em; }
  .title-en { font-size: 18px; letter-spacing: .5em; }
  .title-sub { letter-spacing: .5em; }
  .title-foot-l { left: 24px; bottom: 28px; }
  .title-foot-r { right: 24px; bottom: 28px; }

  .screen-codex-detail,
  .screen-map,
  .screen-complete { overflow: auto; background: var(--bg-0); }
  .cd-breadcrumb { position: relative; left: auto; top: auto; margin: 64px 24px 0; }
  .cd-image-wrap { position: relative; left: auto; top: auto; width: min(78vw, 420px); margin: 24px auto 0; }
  .cd-info { position: relative; right: auto; top: auto; width: auto; margin: 8px 24px 0; }
  .cd-name { font-size: clamp(36px, 10vw, 64px); }
  .cd-foot { position: relative; left: auto; right: auto; bottom: auto; margin: 28px 24px 32px; }

  .map-head { position: relative; left: auto; top: auto; margin: 64px 24px 0; }
  .map-meta { position: relative; right: auto; top: auto; margin: 16px 24px 0; text-align: left; }
  .map-track-wrap { position: relative; top: auto; height: 180px; margin-top: 12px; }
  .map-track { padding: 46px 24px; gap: 36px; }
  .map-track::before { left: 24px; right: 24px; }
  .map-card { position: relative; left: auto; right: auto; top: auto; margin: 12px 24px 0; grid-template-columns: 88px 1fr; padding: 20px; }
  .map-card-thumb { width: 88px; height: 88px; }
  .map-card-actions { grid-column: 1 / -1; flex-direction: row; }
  .map-foot { position: relative; left: auto; right: auto; bottom: auto; margin: 24px 24px 32px; }

  .comp-head { position: relative; left: auto; top: auto; transform: none; max-width: none; padding: 48px 24px 0; }
  .comp-medal { width: 96px; height: 96px; }
  .comp-stats { position: relative; left: auto; right: auto; top: auto; margin: 28px 24px 0; grid-template-columns: repeat(3, 1fr); }
  .comp-strip { position: relative; left: auto; right: auto; top: auto; margin: 28px 24px 0; }
  .comp-grid { grid-template-columns: repeat(7, 1fr); }
  .comp-foot { position: relative; left: auto; right: auto; bottom: auto; margin: 28px 24px 32px; }
  .mission { left: 12px; top: 56px; width: calc(100vw - 24px); padding: 14px 16px 12px; }
  .codex { right: 12px; left: 12px; top: auto; bottom: 220px; width: auto; max-height: 32vh; }
  .controls { left: 12px; right: 12px; bottom: 12px; padding: 12px; }
  .actions { display: grid; grid-template-columns: 1fr; }
  .button-row { justify-content: space-between; }
  .control-btn { flex: 1 1 auto; }
}
@media (max-width: 640px) {
  .ab-statusbar .seg.dim,
  .ab-statusbar .seg.alt { display: none; }
  .hud-min { grid-template-columns: 1fr auto; align-items: end; }
  .hud-progress { min-width: 0; }
  .hud-bar { width: 100%; }
  .hud-action { align-items: flex-end; }
  .hud-action-meta { font-size: 9px; }
  .hud-action-row .btn { min-height: 42px; padding: 0 12px; }
  .hud-side { grid-column: 1 / -1; align-items: stretch; }
  .hud-side-row { flex-wrap: nowrap; justify-content: stretch; gap: 6px; }
  .hud-side-row .btn { flex: 1; min-width: 0; min-height: 38px; padding: 0 7px; font-size: 9px; letter-spacing: .08em; }

  .title-orbit { left: -370px; top: -120px; }
  .title-mark { left: 18px; top: 22px; }
  .title-mark > svg { width: 34px; height: 34px; }
  .title-meta,
  .title-foot-l,
  .title-foot-r { display: none; }
  .title-kicker { font-size: 10px; letter-spacing: .35em; margin-bottom: 18px; }
  .title-name { font-size: clamp(38px, 13vw, 58px); letter-spacing: .16em; margin-right: -.16em; }
  .title-en { font-size: 13px; letter-spacing: .35em; }
  .title-rule { width: min(280px, 80vw); margin: 24px auto; }
  .title-sub { margin-bottom: 28px; font-size: 10px; line-height: 1.8; letter-spacing: .28em; }
  .title-actions { flex-direction: column; align-items: stretch; }
  .title-actions .btn { justify-content: center; min-height: 46px; }

  .scan-head { top: max(42px, env(safe-area-inset-top)); width: calc(100vw - 32px); }
  .scan-head-en { font-size: 9px; letter-spacing: .32em; }
  .scan-head-cn { font-size: 27px; letter-spacing: .18em; }
  .scan-rings { width: 92vmin; height: 92vmin; }
  .scan-foot { bottom: max(54px, calc(32px + env(safe-area-inset-bottom))); }

  .cd-breadcrumb { margin: 48px 16px 0; flex-wrap: wrap; }
  .cd-image-wrap { width: min(88vw, 340px); margin-top: 14px; }
  .cd-info { margin: 4px 16px 0; }
  .cd-name { font-size: 38px; letter-spacing: .18em; }
  .cd-en { font-size: 13px; letter-spacing: .3em; }
  .cd-fact { font-size: 13px; line-height: 1.7; }
  .cd-grid { gap: 10px; }
  .cd-cell-value strong { font-size: 17px; }
  .cd-foot { margin: 22px 16px max(24px, env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; }
  .cd-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .cd-actions .btn:last-child { grid-column: 1 / -1; justify-content: center; }

  .map-head { margin: 48px 16px 0; }
  .map-head-cn { font-size: 30px; letter-spacing: .24em; }
  .map-meta { margin: 14px 16px 0; }
  .map-meta .chip { white-space: normal; line-height: 1.5; }
  .map-track { padding: 40px 16px 48px; gap: 16px; scroll-snap-type: x proximity; }
  .map-track::before { left: 16px; right: 16px; }
  .map-node { width: 84px; scroll-snap-align: center; }
  .map-hex { width: 52px; height: 52px; }
  .map-node-label { letter-spacing: .14em; }
  .map-node-en { letter-spacing: .1em; }
  .map-card { margin: 10px 16px 0; grid-template-columns: 1fr; padding: 16px; }
  .map-card-thumb { display: none; }
  .map-card-title { font-size: 23px; }
  .map-card-row { flex-wrap: wrap; }
  .map-card-actions { grid-column: auto; }
  .map-foot { margin: 20px 16px 24px; }

  .comp-head { padding: 38px 16px 0; }
  .comp-medal { width: 72px; height: 72px; }
  .comp-en { font-size: 9px; letter-spacing: .36em; }
  .comp-cn { font-size: 30px; letter-spacing: .2em; }
  .comp-sub { font-size: 11px; letter-spacing: .18em; }
  .comp-stats { margin: 20px 16px 0; grid-template-columns: 1fr 1fr; gap: 8px; }
  .comp-stat { padding: 12px; }
  .comp-stat-num { font-size: 25px; }
  .comp-strip { margin: 22px 16px 0; }
  .comp-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .comp-foot { margin: 22px 16px max(24px, env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; letter-spacing: 0.12em; }
  .summary { font-size: 11px; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .codex { bottom: 320px; max-height: 220px; }
  .codex header { padding: 10px 12px; }
  .codex h2 { font-size: 14px; letter-spacing: 0.32em; }
  .fact { padding: 10px 12px; font-size: 11px; }
  .scan-frame { padding: 10px 12px; }
  .scan-frame img { aspect-ratio: auto; height: 78px; }
  .entries { display: none; }
  .toast { width: calc(100vw - 32px); text-align: center; }
  .loading { padding: 22px 18px; font-size: 12px; letter-spacing: 0.22em; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .title-mark { display: none; }
  .title-kicker { margin-bottom: 10px; }
  .title-rule { margin: 14px auto; }
  .title-sub { margin-bottom: 14px; }
  .cd-image-wrap { display: none; }
  .cd-info { margin-top: 24px; }
  .scan-head { top: 30px; }
  .scan-foot { bottom: 28px; }
  .comp-head { padding-top: 24px; }
  .comp-medal { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
