:root {
  color-scheme: dark;
  --void: #09080e;
  --ivory: #f7eee3;
  --secondary: #bdb3b2;
  --muted: #a097a4;
  --line: rgb(231 215 229 / 20%);
  --gold: #efc393;
  --accent: var(--gold);
  --accent-rgb: 239 195 147;
  --gutter: clamp(25px, 5vw, 94px);
  --mono: "Plex Mono", "SFMono-Regular", Consolas, monospace;
  --serif: "Observatory Serif", "Songti SC", SimSun, serif;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ivory);
  background: var(--void);
}

:root[data-era="1"] { --accent: #bfb6ff; --accent-rgb: 191 182 255; }
:root[data-era="2"] { --accent: #b5e2dc; --accent-rgb: 181 226 220; }

*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overscroll-behavior: none; }
p, h1 { margin: 0; }
button { font: inherit; color: inherit; }
button:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.viewport, .poster, #cosmos, .veil { position: fixed; inset: 0; width: 100%; height: 100%; }
.viewport { overflow: hidden; }
.poster {
  --cx: 69%;
  --cy: 43%;
  background:
    radial-gradient(ellipse at 65% 70%, rgb(var(--accent-rgb) / 15%), transparent 43%),
    radial-gradient(ellipse at 67% 46%, #251a3e 4%, transparent 62%),
    radial-gradient(circle at 72% 35%, #171427, var(--void) 67%);
  transition: opacity 800ms ease;
}

.poster span {
  position: absolute;
  top: var(--cy);
  left: var(--cx);
  width: min(40vh, 40vw);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: #05040a;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 23px rgb(var(--accent-rgb) / 50%), 0 0 110px rgb(var(--accent-rgb) / 22%);
}

.poster span::after {
  content: "";
  position: absolute;
  top: 56%;
  left: 50%;
  width: 250%;
  height: 40%;
  transform: translate(-50%, -50%) rotate(-14deg);
  border-radius: 50%;
  border-bottom: 7px double var(--accent);
  box-shadow: 0 12px 16px -14px var(--accent);
}

#cosmos {
  display: block;
  opacity: 0;
  cursor: grab;
  touch-action: none;
  transition: opacity 750ms ease;
}

#cosmos:active { cursor: grabbing; }
#cosmos:focus-visible { outline-offset: -5px; }
body[data-engine="ready"] #cosmos { opacity: 1; }
body[data-engine="ready"] .poster { opacity: 0; }
body[data-engine="unavailable"] #cosmos { visibility: hidden; }
.veil {
  pointer-events: none;
  transition: opacity 320ms ease;
  background:
    linear-gradient(90deg, rgb(8 7 13 / 91%) 0%, rgb(8 7 13 / 74%) 16%, rgb(8 7 13 / 35%) 32%, transparent 55%),
    linear-gradient(180deg, rgb(8 7 13 / 79%), transparent 18%, transparent 74%, rgb(8 7 13 / 86%));
}

.instrument {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100svh;
  min-height: 510px;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
  pointer-events: none;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  padding-block: max(19px, env(safe-area-inset-top)) 16px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { flex: none; }
.brand-title { font: 500 15px var(--serif); letter-spacing: .23em; }
.brand-en { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.signal {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--secondary);
  font-size: 10px;
  letter-spacing: .16em;
  white-space: nowrap;
}
.signal-lamp {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.signal-slash { color: var(--muted); }
.tools, .view-tools { display: flex; gap: 8px; align-items: center; }

body[data-immersive] .veil { opacity: 0; }
body[data-immersive] .top-bar { border-color: transparent; }
body[data-immersive] :is(.observation, .bottom-bar, .brand, .signal, .sound) { visibility: hidden; }

.tool, .jump, .chapter {
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tool {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: rgb(11 9 17 / 48%);
  color: var(--secondary);
  transition: border-color 180ms, background 180ms, color 180ms;
}

.tool:hover, .tool[aria-pressed="true"] {
  border-color: rgb(var(--accent-rgb) / 55%);
  background: rgb(var(--accent-rgb) / 10%);
  color: var(--accent);
}
.tool.icon-button { width: 40px; padding: 0; }
.sound { font-size: 12px; }
.sound .mono { font-size: 9px; color: var(--muted); }
.sound[aria-pressed="true"] .mono { color: var(--accent); }
.observation { position: relative; min-height: 0; }
.field-corner {
  position: absolute;
  top: 19px;
  left: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
  letter-spacing: .13em;
}
.corner-mark {
  display: block;
  width: 9px;
  height: 9px;
  border-top: 1px solid var(--secondary);
  border-left: 1px solid var(--secondary);
}

.intro {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: min(44vw, 535px);
}

.kicker {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .16em;
  white-space: nowrap;
  transition: color 500ms;
}
.lozenge { width: 5px; height: 5px; background: currentColor; transform: rotate(45deg); flex: none; }
.kicker-rule { width: 24px; height: 1px; background: currentColor; opacity: .5; }

h1 {
  margin-top: clamp(13px, 2.4vh, 26px);
  font: 500 clamp(65px, min(7.9vw, 13.25vh), 138px) / .99 var(--serif);
  letter-spacing: -.074em;
  text-indent: -.062em;
  white-space: nowrap;
  text-shadow: 0 0 36px rgb(9 7 13 / 62%);
}

h1 span {
  display: block;
  color: var(--accent);
  transition: color 650ms;
}

.work-en {
  margin-top: clamp(17px, 2.8vh, 29px);
  color: var(--ivory);
  font-size: clamp(10px, 1.03vw, 15px);
  letter-spacing: .43em;
}

.narrative {
  margin-top: clamp(17px, 3.4vh, 34px);
  color: var(--secondary);
  font-size: clamp(13px, 1.05vw, 16px);
  line-height: 1.95;
  letter-spacing: .08em;
  text-shadow: 0 1px 10px #08070d;
}

.jump {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 35px;
  min-width: 151px;
  min-height: 44px;
  margin-top: clamp(16px, 2.8vh, 28px);
  padding: 0 13px 0 16px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #161017;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .12em;
  transition: background 300ms, box-shadow 220ms;
}
.jump:hover { box-shadow: 0 0 28px rgb(var(--accent-rgb) / 30%); }
.jump .icon { transition: transform 220ms; }
.jump:hover .icon { transform: translateX(3px); }

.telemetry {
  position: absolute;
  top: clamp(19px, 5.7vh, 56px);
  right: 0;
  padding: 7px 10px 7px 16px;
  border-right: 1px solid rgb(var(--accent-rgb) / 48%);
  text-align: right;
  background: linear-gradient(90deg, transparent, rgb(9 8 14 / 56%));
}
.telemetry-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .21em;
}
.telemetry-time { margin-top: 7px; font-size: 13px; letter-spacing: .08em; }
.telemetry-angle { margin-top: 4px; color: var(--secondary); font-size: 9px; letter-spacing: .06em; }
.view-tools { position: absolute; bottom: 18px; right: 0; }

.engine-note {
  position: absolute;
  right: 0;
  bottom: 67px;
  max-width: min(90vw, 300px);
  color: var(--secondary);
  background: rgb(9 8 14 / 90%);
  border: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.6;
}

.echo-indicator {
  position: absolute;
  right: 0;
  bottom: 74px;
  opacity: 0;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .19em;
  text-shadow: 0 1px 7px #070609;
}
.echo-indicator span { margin-left: 5px; }
.echo-indicator[data-echo="active"] { animation: echo-caption 1650ms both; }
@keyframes echo-caption {
  0%, 100% { opacity: 0; }
  13%, 68% { opacity: 1; }
}

.bottom-bar {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: clamp(13px, 2.5vw, 41px);
  border-top: 1px solid var(--line);
  padding-block: 15px max(20px, env(safe-area-inset-bottom));
}
.chapter-caption { display: grid; gap: 6px; color: var(--secondary); font-size: 11px; letter-spacing: .15em; }
.chapter-caption .mono { color: var(--muted); font-size: 9px; }
.chapters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-width: 585px;
}

.chapter {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(8px, 1.2vw, 19px);
  min-height: 54px;
  min-width: 0;
  padding: 8px clamp(9px, 1.15vw, 19px);
  background: rgb(15 12 22 / 61%);
  border: 1px solid var(--line);
  text-align: left;
  transition: background 280ms, border-color 280ms, color 280ms;
}
.chapter::after {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 18px;
  height: 1px;
  background: transparent;
}
.chapter:hover { background: rgb(var(--accent-rgb) / 11%); border-color: rgb(var(--accent-rgb) / 46%); }
.chapter[aria-current] {
  background: linear-gradient(110deg, rgb(var(--accent-rgb) / 16%), rgb(15 12 22 / 76%));
  border-color: rgb(var(--accent-rgb) / 59%);
  color: var(--accent);
}
.chapter[aria-current]::after { background: var(--accent); }
.chapter-number { color: var(--muted); font-size: 11px; }
.chapter[aria-current] .chapter-number { color: var(--accent); }
.chapter-name { font: 500 17px / 1.1 var(--serif); letter-spacing: .08em; white-space: nowrap; }
.chapter-name small { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; letter-spacing: .11em; }
.chapter[aria-current] .chapter-name small { color: var(--accent); opacity: .82; }

.instructions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-size: 11px;
  white-space: nowrap;
  letter-spacing: .055em;
}
.instructions span { color: var(--accent); padding-inline: 2px; }
.instructions .icon { width: 16px; height: 16px; color: var(--accent); }
.touch-instructions { display: none; }

@media (hover: none), (pointer: coarse) {
  .desktop-instructions { display: none; }
  .touch-instructions { display: block; }
}

@media (max-width: 1050px) {
  .bottom-bar { gap: 12px; }
  .chapter-caption { display: none; }
  .bottom-bar { grid-template-columns: minmax(0, 1fr) max-content; }
}

@media (max-width: 760px) and (orientation: portrait) {
  :root { --gutter: clamp(16px, 5.4vw, 33px); }
  .instrument { min-height: 540px; }
  .poster { --cx: 57%; --cy: 31%; }
  .poster span { width: min(48vw, 36vh); }
  .veil {
    background:
      linear-gradient(180deg, rgb(8 7 13 / 78%), transparent 24%, transparent 36%, rgb(8 7 13 / 77%) 61%, #08070ddd 97%),
      linear-gradient(90deg, rgb(8 7 13 / 38%), transparent 55%);
  }
  .top-bar { padding-block: max(10px, env(safe-area-inset-top)) 10px; }
  .brand { gap: 7px; }
  .brand img { width: 32px; height: 32px; }
  .brand-title { font-size: 13px; }
  .brand-en { font-size: 7px; letter-spacing: .09em; }
  .signal { display: none; }
  .tool { min-height: 38px; }
  .tool.icon-button { width: 38px; }
  .tools { gap: 5px; }
  .sound { gap: 5px; padding-inline: 7px; }
  .sound .mono { display: none; }
  .field-corner { top: 13px; font-size: 8px; }
  .telemetry { top: 11px; padding: 4px 7px 5px 11px; }
  .telemetry-time { margin-top: 4px; font-size: 10px; }
  .telemetry-angle { font-size: 8px; }
  .intro {
    top: auto;
    bottom: 16px;
    width: 100%;
    transform: none;
  }
  .kicker { gap: 7px; font-size: 9px; }
  h1 {
    margin-top: 12px;
    font-size: clamp(41px, 12vw, 83px);
    line-height: 1.04;
  }
  h1 span { display: inline; }
  .work-en { margin-top: 11px; font-size: 10px; letter-spacing: .31em; }
  .narrative { margin-top: 13px; font-size: 12px; line-height: 1.65; }
  .jump { margin-top: 12px; min-height: 38px; min-width: 122px; gap: 15px; font-size: 12px; }
  .view-tools { bottom: 16px; gap: 5px; }
  .echo-indicator { bottom: 65px; }
  .bottom-bar { display: grid; grid-template-columns: 1fr; gap: 8px; padding-block: 8px max(9px, env(safe-area-inset-bottom)); }
  .chapters { max-width: none; gap: 5px; }
  .chapter { padding-inline: 8px; gap: 7px; min-height: 46px; }
  .chapter-name { font-size: 15px; }
  .chapter-name small { margin-top: 4px; font-size: 7px; letter-spacing: .05em; }
  .chapter-number { font-size: 9px; }
  .instructions { justify-content: center; font-size: 10px; }
  .instructions .icon { width: 13px; height: 13px; }
}

@media (max-height: 660px) and (min-width: 761px), (max-height: 660px) and (orientation: landscape) {
  .instrument { min-height: 350px; }
  .top-bar { padding-block: 9px; }
  .bottom-bar { padding-block: 7px; }
  .chapter { min-height: 45px; padding-block: 5px; }
  .field-corner { display: none; }
  h1 { font-size: clamp(43px, min(7.9vw, 12.3vh), 82px); }
  .work-en, .narrative, .jump { margin-top: 12px; }
  .narrative { line-height: 1.6; }
  .jump { min-height: 36px; }
}

@media (max-height: 460px) and (orientation: landscape) {
  h1 span { display: inline; }
  .telemetry { top: 12px; }
  .instructions { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
  .echo-indicator[data-echo="active"] { animation-timing-function: steps(1, end); animation-name: quiet-caption; }
  @keyframes quiet-caption { 0% { opacity: 1; } 100% { opacity: 0; } }
}
