:root {
  --bg: #071018;
  --panel: rgba(11, 18, 28, 0.62);
  --panel-strong: rgba(9, 14, 23, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef7f5;
  --muted: rgba(238, 247, 245, 0.68);
  --soft: rgba(238, 247, 245, 0.48);
  --u: #73e2ff;
  --v: #ffb06f;
  --seal: #f6edc8;
  --green: #b3ffd7;
  --rose: #ff8fb8;
  --shadow: rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 8%, #1d2a3b 0%, #0b121c 46%, #05080e 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 10px 15px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
button:hover, button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.11);
  outline: none;
}
button:active { transform: translateY(0); }

.ambient, .level-frame, .world-bridge-canvas, .unified-world-canvas, .loading-veil, .story-overlay {
  position: fixed;
  inset: 0;
}
.ambient { pointer-events: none; z-index: 0; }
.unified-world-canvas {
  z-index: 1;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  background: #071018;
  transition: opacity 420ms ease, filter 420ms ease;
}
body.single-scene-mode .unified-world-canvas {
  opacity: 1;
  pointer-events: auto;
}
body.single-scene-mode.overlay-open .unified-world-canvas {
  /* 与下方两条 filter 规则保持相同的 function 列表（saturate+contrast+brightness），
     否则 CSS 会对 mismatched function lists 退化为 discrete 切换，造成可见突变。 */
  filter: saturate(0.82) contrast(0.99) brightness(0.72);
}
body.single-scene-mode .level-frame,
body.single-scene-mode .world-bridge-canvas {
  display: none !important;
}
.world-bridge-canvas {
  z-index: 4;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  background: transparent;
  transition: opacity 80ms linear;
}
.world-bridge-canvas.active {
  opacity: 1;
}
.level-frame {
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  filter: saturate(0.94) contrast(1.04);
  transition: opacity 800ms ease, filter 800ms ease;
  background: #05080e;
}
.level-frame.ready { opacity: 1; }

.aura {
  position: absolute;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.6;
  mix-blend-mode: screen;
}
.aura-one {
  width: 52vw; height: 52vw; left: -16vw; top: -18vw;
  background: radial-gradient(circle, rgba(115, 226, 255, 0.26), rgba(115, 226, 255, 0));
  animation: driftOne 15s ease-in-out infinite alternate;
}
.aura-two {
  width: 58vw; height: 58vw; right: -20vw; bottom: -22vw;
  background: radial-gradient(circle, rgba(255, 176, 111, 0.20), rgba(255, 143, 184, 0));
  animation: driftTwo 18s ease-in-out infinite alternate;
}
.waterline {
  position: absolute;
  left: 8vw; right: 8vw; top: 50%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(179, 255, 215, 0.38), rgba(246, 237, 200, 0.34), transparent);
  box-shadow: 0 0 40px rgba(179, 255, 215, 0.22);
  opacity: 0.45;
}
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image:
    radial-gradient(circle at 12% 20%, rgba(255,255,255,0.06), transparent 16%),
    radial-gradient(circle at 72% 70%, rgba(255,255,255,0.05), transparent 18%),
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: auto, auto, 42px 42px, 42px 42px;
}
@keyframes driftOne { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(6vw,5vh,0) scale(1.1); } }
@keyframes driftTwo { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(-5vw,-4vh,0) scale(1.08); } }

.topbar {
  position: fixed;
  z-index: 6;
  top: 16px;
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(12, 19, 30, 0.68), rgba(12, 19, 30, 0.38));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 14px 44px var(--shadow);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(238, 247, 245, 0.58);
}
.brand-title {
  margin-top: 2px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.22em;
}
.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}
.chapter-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: rgba(238,247,245,0.68);
  cursor: pointer;
  white-space: nowrap;
}
.chapter-node .num {
  width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.chapter-node.active {
  color: var(--text);
  border-color: rgba(246,237,200,0.42);
  background: rgba(246,237,200,0.08);
  box-shadow: 0 0 28px rgba(246,237,200,0.12);
}
.chapter-node.complete .num {
  background: rgba(179,255,215,0.18);
  color: var(--green);
}
.shell-actions { display: flex; gap: 8px; align-items: center; }
.shell-actions button { padding: 9px 12px; font-size: 13px; }

.coop-ribbon {
  position: fixed;
  z-index: 5;
  left: 18px;
  bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100vw - 36px);
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 999px;
  background: rgba(8, 13, 20, 0.42);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  color: rgba(238,247,245,0.72);
  font-size: 13px;
  pointer-events: none;
}

.unified-hud {
  position: fixed;
  z-index: 5;
  right: 18px;
  bottom: 18px;
  width: min(380px, calc(100vw - 36px));
  padding: 16px 17px 15px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(8, 13, 20, 0.68), rgba(8, 13, 20, 0.42));
  backdrop-filter: blur(16px) saturate(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
  box-shadow: 0 18px 54px rgba(0,0,0,0.42);
  color: rgba(238,247,245,0.78);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 240ms ease, transform 240ms ease, border-color 240ms ease;
}
body.single-scene-mode.level-running .unified-hud {
  opacity: 1;
  transform: translateY(0);
}
body.single-scene-mode.overlay-open .unified-hud {
  opacity: 0;
  transform: translateY(10px);
}
body.single-world-transitioning .unified-hud {
  opacity: 0.86;
}
.unified-hud.ready {
  border-color: rgba(246,237,200,0.34);
  box-shadow: 0 18px 54px rgba(0,0,0,0.42), 0 0 36px rgba(246,237,200,0.10);
}
.unified-hud-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.unified-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(238,247,245,0.66);
  font-size: 11px;
}
.unified-hud.ready .unified-status {
  color: var(--seal);
  border-color: rgba(246,237,200,0.32);
  background: rgba(246,237,200,0.10);
}
.unified-hud h2 {
  margin: 7px 0 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0.08em;
}
.unified-hud code {
  flex: 0 1 auto;
  max-width: 46%;
  margin-top: 2px;
  padding: 7px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--seal);
  font-size: 12px;
  white-space: normal;
}
.unified-meter {
  position: relative;
  height: 7px;
  margin: 15px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.unified-meter span {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--u), var(--seal), var(--v));
  box-shadow: 0 0 22px rgba(246,237,200,0.26);
}
.unified-metric,
.unified-detail,
.unified-prompt {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}
.unified-metric {
  color: rgba(238,247,245,0.86);
}
.unified-detail {
  margin-top: 5px;
  color: rgba(238,247,245,0.60);
}
.unified-prompt {
  margin-top: 10px;
  color: rgba(246,237,200,0.78);
}
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 6px;
  border-radius: 999px;
  vertical-align: -1px;
  box-shadow: 0 0 14px currentColor;
}
.dot.u { color: var(--u); background: var(--u); }
.dot.v { color: var(--v); background: var(--v); }
.dot.seal { color: var(--seal); background: var(--seal); }

.story-overlay {
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 96px 22px 28px;
  background:
    radial-gradient(circle at 50% 24%, rgba(115,226,255,0.10), transparent 30%),
    radial-gradient(circle at 72% 68%, rgba(255,176,111,0.10), transparent 36%),
    rgba(2, 5, 10, 0.58);
  backdrop-filter: blur(18px) saturate(1.05);
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}
.story-overlay.visible { opacity: 1; pointer-events: auto; }
.story-card {
  position: relative;
  width: min(860px, calc(100vw - 44px));
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 34px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)),
    linear-gradient(135deg, rgba(12,19,30,0.94), rgba(8,13,21,0.82));
  box-shadow: 0 30px 90px rgba(0,0,0,0.56), inset 0 1px 0 rgba(255,255,255,0.10);
}
.card-glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(115,226,255,0.18), transparent 28%, transparent 68%, rgba(255,176,111,0.16));
  mask: linear-gradient(#000, transparent 72%);
  opacity: 0.86;
}
.story-card > *:not(.card-glow) { position: relative; }
.story-card h1 {
  margin: 8px 0 12px;
  font-size: clamp(38px, 7vw, 76px);
  line-height: 1;
  letter-spacing: 0.16em;
  font-weight: 760;
}
.lead {
  max-width: 780px;
  margin: 0 0 20px;
  color: rgba(238,247,245,0.84);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.8;
}
.story-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.body-card, .insight-card {
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255,255,255,0.045);
}
.body-card h3, .insight-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.08em;
}
.body-card p, .insight-card p {
  margin: 0;
  color: rgba(238,247,245,0.70);
  line-height: 1.65;
  font-size: 13px;
}
.formula-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 10px;
}
.formula-chip {
  border: 1px solid rgba(246,237,200,0.20);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(246,237,200,0.06);
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  box-shadow: 0 0 24px rgba(246,237,200,0.07);
}
.insight-panel {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.insight-panel:empty { display: none; }
.action-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 24px;
}
.primary {
  border-color: rgba(246,237,200,0.42);
  background: linear-gradient(90deg, rgba(115,226,255,0.18), rgba(246,237,200,0.18), rgba(255,176,111,0.16));
  color: #fff9df;
  padding-inline: 22px;
  box-shadow: 0 0 30px rgba(246,237,200,0.12);
}
.secondary { color: rgba(238,247,245,0.82); }
.ghost {
  margin-top: 12px;
  color: rgba(238,247,245,0.68);
}
.hidden { display: none !important; }

.loading-veil {
  z-index: 4;
  display: grid;
  place-items: center;
  gap: 14px;
  color: rgba(238,247,245,0.72);
  background: rgba(4, 8, 14, 0.34);
  pointer-events: none;
}
.loader-mark {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(246,237,200,0.16);
  border-top-color: rgba(246,237,200,0.82);
  border-right-color: rgba(115,226,255,0.7);
  animation: spin 1.2s linear infinite;
  box-shadow: 0 0 28px rgba(115,226,255,0.12);
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; align-items: stretch; gap: 10px; }
  .chapter-nav { justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .shell-actions { overflow-x: auto; }
  .coop-ribbon { border-radius: 22px; }
  .story-overlay { padding-top: 150px; }
  .story-body, .insight-panel { grid-template-columns: 1fr; }
  .story-card { padding: 24px; max-height: calc(100vh - 176px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  /* main.js 在此模式下不再驱动 math-cursor 的位置；隐藏元素并回到系统指针，避免出现一颗静止的 λ 圆点。 */
  .math-cursor { display: none !important; }
}

body.level-running .topbar {
  left: 50%;
  right: auto;
  width: min(590px, calc(100vw - 40px));
  transform: translateX(-50%);
  grid-template-columns: auto 1fr auto;
  padding: 8px 10px;
  border-radius: 999px;
  opacity: 0.76;
  transition: opacity 200ms ease, transform 200ms ease;
}
body.level-running .topbar:hover,
body.level-running .topbar:focus-within { opacity: 1; }
body.level-running .brand-block .eyebrow { display: none; }
body.level-running .brand-title {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}
body.level-running .chapter-nav { gap: 5px; }
body.level-running .chapter-node { padding: 5px 6px; gap: 4px; }
body.level-running .chapter-node span:not(.num) { display: none; }
body.level-running .chapter-node .num { width: 20px; height: 20px; font-size: 11px; }
body.level-running .shell-actions { gap: 5px; }
body.level-running .shell-actions button { padding: 6px 8px; font-size: 12px; }
body.level-running .coop-ribbon {
  opacity: 0;
  transform: translateY(12px);
}
@media (max-width: 900px) {
  body.level-running .topbar {
    top: 10px;
    width: min(620px, calc(100vw - 20px));
    grid-template-columns: auto 1fr;
  }
  body.level-running .shell-actions { grid-column: 1 / -1; justify-content: center; }
}

/* Cinematic chapter transitions */
.cinematic-overlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  overflow: hidden;
  pointer-events: auto;
  background:
    radial-gradient(circle at 50% 24%, rgba(246,237,200,0.10), transparent 32%),
    radial-gradient(circle at 16% 68%, rgba(115,226,255,0.12), transparent 38%),
    radial-gradient(circle at 78% 64%, rgba(255,176,111,0.10), transparent 40%),
    rgba(2, 5, 10, 0.42);
  opacity: 1;
  transition: opacity 420ms ease;
}
.cinematic-vignette {
  position: absolute;
  inset: -3%;
  background:
    radial-gradient(ellipse at center, transparent 0%, transparent 42%, rgba(0,0,0,0.36) 74%, rgba(0,0,0,0.72) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.22), transparent 28%, rgba(0,0,0,0.30));
  pointer-events: none;
}
.cinematic-stage {
  position: absolute;
  inset: 0;
  perspective: 920px;
  transform-style: preserve-3d;
}
.cinematic-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform-style: preserve-3d;
}
body.cinematic-active .topbar,
body.cinematic-active .coop-ribbon {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px);
}
body.cinematic-active .level-frame.cinematic-frame {
  opacity: 0.88;
  transform: scale(1.07);
  filter: blur(5px) saturate(1.25) contrast(1.12) brightness(0.78);
  transition: opacity 900ms ease, transform 6800ms cubic-bezier(.18,.82,.24,1), filter 900ms ease;
}
.cinematic-01-02 .level-frame.cinematic-frame { transform-origin: 50% 58%; }
.cinematic-02-03 .level-frame.cinematic-frame { transform-origin: 50% 50%; }
.skip-cinematic {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 4;
  padding: 9px 13px;
  font-size: 12px;
  color: rgba(238,247,245,0.70);
  background: rgba(8,13,20,0.40);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.cinematic-caption {
  position: absolute;
  z-index: 3;
  left: clamp(18px, 6vw, 78px);
  bottom: clamp(28px, 7vh, 84px);
  width: min(620px, calc(100vw - 88px));
  padding: 22px 24px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)),
    rgba(7, 12, 19, 0.58);
  box-shadow: 0 28px 84px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(18px) saturate(1.08);
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
  animation: captionRise 900ms ease both;
}
.cinematic-caption.next-loading::after {
  content: "正在进入下一章";
  position: absolute;
  right: 18px;
  top: 16px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(179,255,215,0.78);
}
.cinematic-kicker {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(246,237,200,0.66);
}
.cinematic-caption h2 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  letter-spacing: 0.12em;
}
.cinematic-caption p {
  margin: 0;
  color: rgba(238,247,245,0.78);
  line-height: 1.75;
  font-size: 15px;
}
.cinematic-math-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.cinematic-math-strip span {
  border: 1px solid rgba(246,237,200,0.22);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--seal);
  background: rgba(246,237,200,0.07);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.duet-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
  color: rgba(238,247,245,0.66);
  font-size: 12px;
}
.duet-note span {
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.045);
}
@keyframes captionRise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

.star-field,
.forward-aura,
.bridge-perspective,
.destination-courtyard,
.det-plane-wrap,
.axis-chamber,
.closing-seal,
.formula-breath {
  position: absolute;
}
.cinematic-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(246,237,200,0.84);
  box-shadow: 0 0 16px rgba(246,237,200,0.72);
  opacity: 0;
  animation: particleDrift 4.8s ease-in-out var(--d) infinite;
}
@keyframes particleDrift {
  0%, 100% { opacity: 0.05; transform: translate3d(-12px, 10px, 0) scale(0.7); }
  45% { opacity: 0.82; transform: translate3d(12px, -20px, 0) scale(1.2); }
}
.formula-breath {
  top: 22%;
  left: 50%;
  z-index: 2;
  max-width: min(560px, 88vw);
  transform: translateX(-50%);
  padding: 12px 16px;
  border: 1px solid rgba(246,237,200,0.15);
  border-radius: 999px;
  color: rgba(246,237,200,0.76);
  background: rgba(8,13,20,0.34);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  opacity: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: formulaBreath 5.3s 700ms ease both;
}
@keyframes formulaBreath {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.96); }
  24%, 72% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(1.02); }
}

/* Chapter 01 to 02: bridge dolly into the determinant courtyard */
.bridge-scene {
  background:
    linear-gradient(180deg, rgba(2,5,10,0.12), rgba(4,8,14,0.68)),
    radial-gradient(circle at 50% 42%, rgba(115,226,255,0.18), transparent 34%);
}
.forward-aura {
  left: 50%;
  top: 36%;
  width: 34vw;
  height: 34vw;
  min-width: 330px;
  min-height: 330px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(246,237,200,0.24), rgba(115,226,255,0.13) 34%, transparent 67%);
  filter: blur(14px);
  animation: auraForward 7.2s cubic-bezier(.16,.82,.22,1) both;
}
@keyframes auraForward {
  0% { opacity: 0.22; transform: translate(-50%, -50%) scale(0.64); }
  52% { opacity: 0.78; transform: translate(-50%, -48%) scale(1.28); }
  100% { opacity: 0.14; transform: translate(-50%, -52%) scale(2.1); }
}
.bridge-perspective {
  left: 50%;
  bottom: -16vh;
  width: min(820px, 92vw);
  height: 92vh;
  transform: translateX(-50%) rotateX(63deg);
  transform-origin: 50% 100%;
  perspective: 900px;
  animation: bridgeDolly 7.2s cubic-bezier(.14,.78,.22,1) both;
}
.bridge-road {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 34%;
  height: 112%;
  transform: translateX(-50%);
  border-left: 1px solid rgba(115,226,255,0.36);
  border-right: 1px solid rgba(255,176,111,0.34);
  background:
    linear-gradient(90deg, rgba(115,226,255,0.05), rgba(246,237,200,0.10), rgba(255,176,111,0.05)),
    repeating-linear-gradient(0deg, transparent 0 42px, rgba(246,237,200,0.18) 43px, transparent 45px);
  box-shadow: inset 0 0 60px rgba(246,237,200,0.08), 0 0 70px rgba(115,226,255,0.13);
  overflow: hidden;
}
.bridge-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.10) 1px, transparent 1px),
    repeating-linear-gradient(0deg, transparent 0 40px, rgba(255,255,255,0.12) 41px, transparent 43px);
  background-size: 34px 100%, 100% 78px;
  animation: bridgeGridRun 1.25s linear infinite;
}
.bridge-current {
  position: absolute;
  left: 50%;
  bottom: -18%;
  width: 14px;
  height: 120%;
  transform: translateX(-50%);
  background: linear-gradient(0deg, transparent, rgba(246,237,200,0.92), transparent);
  filter: blur(5px);
  opacity: 0.82;
  animation: currentSurge 2.4s ease-in-out infinite;
}
.bridge-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(0deg, transparent, currentColor, transparent);
  filter: drop-shadow(0 0 10px currentColor);
  opacity: 0.82;
}
.rail-left { left: -16px; color: var(--u); }
.rail-right { right: -16px; color: var(--v); }
.bridge-slab {
  position: absolute;
  left: 50%;
  top: calc(var(--i) * 7% - 8%);
  width: 118%;
  height: 2px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(246,237,200,0.78), transparent);
  box-shadow: 0 0 20px rgba(246,237,200,0.24);
  animation: slabFlow 1.5s linear infinite;
  animation-delay: calc(var(--i) * -0.09s);
}
.vector-comet {
  position: absolute;
  z-index: 2;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  letter-spacing: 0.1em;
  opacity: 0;
}
.vector-comet::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: inherit;
  background: currentColor;
  filter: blur(24px);
  opacity: 0.42;
}
.vector-comet span { position: relative; }
.comet-u {
  left: 22%;
  top: 54%;
  color: var(--u);
  animation: cometU 4.8s 220ms cubic-bezier(.18,.76,.18,1) both;
}
.comet-v {
  right: 22%;
  top: 58%;
  color: var(--v);
  animation: cometV 4.8s 220ms cubic-bezier(.18,.76,.18,1) both;
}
.comet-r {
  left: 50%;
  top: 48%;
  color: var(--seal);
  animation: cometR 5.6s 850ms cubic-bezier(.18,.76,.18,1) both;
}
.destination-courtyard {
  left: 50%;
  top: 36%;
  width: min(390px, 52vw);
  height: min(390px, 52vw);
  transform: translate(-50%, -50%) scale(0.32);
  opacity: 0;
  animation: courtyardArrive 7.2s cubic-bezier(.14,.84,.2,1) both;
}
.gate-arch {
  position: absolute;
  left: 50%;
  top: 3%;
  width: 52%;
  height: 48%;
  transform: translateX(-50%);
  border: 2px solid rgba(246,237,200,0.36);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  box-shadow: 0 0 48px rgba(246,237,200,0.18), inset 0 0 40px rgba(115,226,255,0.10);
}
.courtyard-disk {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  transform: rotateX(64deg) rotateZ(-18deg);
  background:
    radial-gradient(circle, rgba(179,255,215,0.10), transparent 62%),
    rgba(246,237,200,0.055);
  border: 1px solid rgba(179,255,215,0.36);
  box-shadow: 0 0 62px rgba(179,255,215,0.16);
  overflow: hidden;
}
.courtyard-lattice {
  position: absolute;
  inset: -40%;
  background:
    linear-gradient(rgba(179,255,215,0.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(179,255,215,0.24) 1px, transparent 1px);
  background-size: 22px 22px;
  transform: rotate(45deg);
  animation: latticeWake 2.8s 3.3s ease both;
}
.courtyard-parallelogram {
  position: absolute;
  left: 32%;
  top: 34%;
  width: 44%;
  height: 34%;
  transform: skewX(-24deg);
  border: 1px solid rgba(255,143,184,0.76);
  background: rgba(255,143,184,0.10);
  box-shadow: 0 0 36px rgba(255,143,184,0.18);
  opacity: 0;
  animation: parallelogramBloom 1.8s 4.2s ease both;
}
@keyframes bridgeDolly {
  0% { opacity: 0.16; transform: translateX(-50%) rotateX(63deg) translateY(18vh) scale(0.78); }
  22% { opacity: 0.78; }
  68% { opacity: 0.94; transform: translateX(-50%) rotateX(63deg) translateY(-14vh) scale(1.34); }
  100% { opacity: 0; transform: translateX(-50%) rotateX(63deg) translateY(-42vh) scale(2.1); }
}
@keyframes bridgeGridRun { to { background-position: 0 0, 0 78px; } }
@keyframes currentSurge { 0%,100% { opacity: 0.3; transform: translateX(-50%) translateY(12%); } 50% { opacity: 0.9; transform: translateX(-50%) translateY(-8%); } }
@keyframes slabFlow { from { transform: translateX(-50%) translateY(0) scaleX(0.68); opacity: 0.1; } to { transform: translateX(-50%) translateY(78px) scaleX(1.1); opacity: 0.72; } }
@keyframes cometU {
  0% { opacity: 0; transform: translate3d(-12vw, 18vh, 0) scale(0.6); }
  34% { opacity: 1; }
  70% { opacity: 1; transform: translate3d(17vw, -12vh, 0) scale(0.82); }
  100% { opacity: 0; transform: translate3d(24vw, -20vh, 0) scale(0.18); }
}
@keyframes cometV {
  0% { opacity: 0; transform: translate3d(12vw, 18vh, 0) scale(0.6); }
  34% { opacity: 1; }
  70% { opacity: 1; transform: translate3d(-17vw, -10vh, 0) scale(0.82); }
  100% { opacity: 0; transform: translate3d(-24vw, -20vh, 0) scale(0.18); }
}
@keyframes cometR {
  0% { opacity: 0; transform: translate(-50%, 12vh) scale(0.48); }
  26%, 68% { opacity: 1; transform: translate(-50%, -10vh) scale(0.86); }
  100% { opacity: 0; transform: translate(-50%, -28vh) scale(0.2); }
}
@keyframes courtyardArrive {
  0%, 34% { opacity: 0; transform: translate(-50%, -50%) scale(0.22); }
  62% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
  88% { opacity: 1; transform: translate(-50%, -50%) scale(1.14); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.42); }
}
@keyframes latticeWake { from { opacity: 0; transform: rotate(45deg) scale(0.82); } to { opacity: 1; transform: rotate(45deg) scale(1); } }
@keyframes parallelogramBloom { from { opacity: 0; transform: skewX(-24deg) scale(0.72); } to { opacity: 1; transform: skewX(-24deg) scale(1); } }

/* Chapter 02 to 03: determinant plane folds into eigen axes */
.fold-scene {
  background:
    radial-gradient(circle at 50% 52%, rgba(255,143,184,0.13), transparent 34%),
    radial-gradient(circle at 50% 34%, rgba(115,226,255,0.13), transparent 42%),
    rgba(2,5,10,0.28);
}
.det-plane-wrap {
  left: 50%;
  top: 50%;
  width: min(540px, 70vw);
  height: min(420px, 56vw);
  transform: translate(-50%, -50%);
  perspective: 820px;
  animation: planeWrapTravel 7.6s cubic-bezier(.16,.78,.2,1) both;
}
.det-plane {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(179,255,215,0.42);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(179,255,215,0.10), rgba(255,143,184,0.08)),
    rgba(255,255,255,0.035);
  box-shadow: 0 0 90px rgba(179,255,215,0.12), inset 0 0 42px rgba(255,255,255,0.04);
  overflow: hidden;
  transform: rotateX(62deg) rotateZ(-14deg);
  transform-origin: 50% 50%;
  animation: determinantFold 7.6s cubic-bezier(.16,.78,.2,1) both;
}
.det-grid {
  position: absolute;
  inset: -20%;
  background:
    linear-gradient(rgba(179,255,215,0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(179,255,215,0.22) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: detGridShear 3.6s ease-in-out infinite alternate;
}
.det-parallelogram {
  position: absolute;
  left: 26%;
  top: 26%;
  width: 46%;
  height: 42%;
  transform: skewX(-27deg) rotate(4deg);
  border: 2px solid rgba(255,143,184,0.86);
  background: rgba(255,143,184,0.12);
  box-shadow: 0 0 42px rgba(255,143,184,0.24);
  animation: areaPulse 1.6s ease-in-out infinite alternate;
}
.det-label {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  color: rgba(246,237,200,0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
}
.matrix-rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.matrix-rain span {
  position: absolute;
  top: -8%;
  left: calc(14% + var(--i) * 13%);
  color: rgba(246,237,200,0.52);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  filter: drop-shadow(0 0 12px rgba(246,237,200,0.36));
  animation: matrixFall 4.8s calc(var(--i) * 0.28s) linear infinite;
}
.axis-chamber {
  left: 50%;
  top: 50%;
  width: min(520px, 74vw);
  height: min(520px, 74vw);
  transform: translate(-50%, -50%) scale(0.42);
  opacity: 0;
  animation: axisChamberRise 7.6s cubic-bezier(.16,.78,.2,1) both;
}
.axis-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 94%;
  height: 2px;
  transform-origin: 50% 50%;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  box-shadow: 0 0 38px currentColor;
  opacity: 0.84;
}
.axis-one { color: var(--u); transform: translate(-50%, -50%) rotate(31deg); }
.axis-two { color: var(--v); transform: translate(-50%, -50%) rotate(126deg); }
.image-line { color: var(--seal); transform: translate(-50%, -50%) rotate(31deg) scaleX(0.54); animation: imageLineSweep 2.6s 4.3s ease-in-out infinite alternate; }
.axis-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 116px;
  height: 116px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246,237,200,0.26), rgba(115,226,255,0.10) 42%, transparent 70%);
  border: 1px solid rgba(246,237,200,0.22);
  box-shadow: 0 0 70px rgba(246,237,200,0.15);
  animation: axisCorePulse 1.8s ease-in-out infinite alternate;
}
@keyframes planeWrapTravel {
  0% { opacity: 0; transform: translate(-50%, -43%) scale(0.78); }
  20%, 62% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -53%) scale(1.36); }
}
@keyframes determinantFold {
  0% { transform: rotateX(62deg) rotateZ(-14deg) scale(0.86); }
  36% { transform: rotateX(62deg) rotateZ(-14deg) scale(1); }
  64% { transform: rotateX(78deg) rotateZ(8deg) scale(0.88); border-radius: 34px; }
  88%, 100% { transform: rotateX(88deg) rotateZ(34deg) scale(0.18); opacity: 0; }
}
@keyframes detGridShear { from { transform: skewX(-12deg) translateX(-10px); } to { transform: skewX(18deg) translateX(10px); } }
@keyframes areaPulse { from { opacity: 0.42; } to { opacity: 1; } }
@keyframes matrixFall { from { transform: translateY(-10vh); opacity: 0; } 26% { opacity: 0.85; } to { transform: translateY(112vh); opacity: 0; } }
@keyframes axisChamberRise {
  0%, 48% { opacity: 0; transform: translate(-50%, -50%) scale(0.28) rotate(-8deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(0.92) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2) rotate(4deg); }
}
@keyframes imageLineSweep { from { transform: translate(-50%, -50%) rotate(31deg) scaleX(0.42); } to { transform: translate(-50%, -50%) rotate(31deg) scaleX(1.04); } }
@keyframes axisCorePulse { from { transform: translate(-50%, -50%) scale(0.86); } to { transform: translate(-50%, -50%) scale(1.16); } }

/* Final closing transition */
.ending-scene {
  background:
    radial-gradient(circle at 50% 50%, rgba(246,237,200,0.14), transparent 34%),
    radial-gradient(circle at 28% 62%, rgba(115,226,255,0.10), transparent 36%),
    radial-gradient(circle at 70% 62%, rgba(255,176,111,0.10), transparent 36%);
}
.closing-seal {
  left: 50%;
  top: 48%;
  width: min(420px, 64vw);
  height: min(420px, 64vw);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(246,237,200,0.28);
  box-shadow: 0 0 90px rgba(246,237,200,0.15), inset 0 0 60px rgba(115,226,255,0.08);
  animation: sealClose 6.4s cubic-bezier(.16,.78,.2,1) both;
}
.seal-orbit {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(520px, 72vw);
  height: min(520px, 72vw);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.13);
  transform: translate(-50%, -50%);
}
.orbit-a { animation: orbitSpin 6.4s linear infinite; color: var(--u); border-color: rgba(115,226,255,0.20); }
.orbit-b { width: min(430px, 60vw); height: min(430px, 60vw); animation: orbitSpin 5.4s linear infinite reverse; border-color: rgba(255,176,111,0.20); }
.orbit-c { width: min(310px, 45vw); height: min(310px, 45vw); animation: orbitSpin 4.6s linear infinite; border-color: rgba(246,237,200,0.22); }
.seal-mark {
  position: absolute;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 1px solid rgba(246,237,200,0.20);
  background: rgba(255,255,255,0.045);
  box-shadow: 0 0 38px rgba(246,237,200,0.12);
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}
.mark-line { left: 50%; top: 4%; transform: translateX(-50%); color: var(--u); }
.mark-area { right: 7%; bottom: 17%; color: var(--v); }
.mark-axis { left: 7%; bottom: 17%; color: var(--green); }
.closing-bridge,
.closing-garden,
.closing-axis {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.closing-bridge {
  width: min(620px, 82vw);
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--u), var(--seal), var(--v), transparent);
  box-shadow: 0 0 42px rgba(246,237,200,0.20);
  animation: closingBridge 6.4s ease both;
}
.closing-garden {
  width: min(260px, 42vw);
  height: min(180px, 30vw);
  border: 1px solid rgba(179,255,215,0.30);
  transform: translate(-50%, -50%) rotateX(62deg) rotateZ(-18deg);
  background: repeating-linear-gradient(90deg, rgba(179,255,215,0.18) 0 1px, transparent 1px 22px), repeating-linear-gradient(0deg, rgba(179,255,215,0.14) 0 1px, transparent 1px 22px);
  animation: closingGarden 6.4s ease both;
}
.closing-axis {
  width: min(540px, 78vw);
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(246,237,200,0.84), transparent);
  box-shadow: 0 0 46px rgba(246,237,200,0.24);
  animation: closingAxis 6.4s ease both;
}
@keyframes sealClose {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55) rotate(-18deg); }
  28%, 76% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.45) rotate(8deg); }
}
@keyframes orbitSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes closingBridge { 0% { opacity: 0; transform: translate(-50%, 20vh) scaleX(0.2); } 32%, 70% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scaleX(0.08); } }
@keyframes closingGarden { 0%, 22% { opacity: 0; transform: translate(-50%, -50%) rotateX(62deg) rotateZ(-18deg) scale(0.54); } 46%, 74% { opacity: 0.86; transform: translate(-50%, -50%) rotateX(62deg) rotateZ(-18deg) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) rotateX(80deg) rotateZ(18deg) scale(0.12); } }
@keyframes closingAxis { 0%, 46% { opacity: 0; transform: translate(-50%, -50%) rotate(26deg) scaleX(0.3); } 66%, 82% { opacity: 1; transform: translate(-50%, -50%) rotate(26deg) scaleX(1); } 100% { opacity: 0; transform: translate(-50%, -50%) rotate(26deg) scaleX(0.1); } }

@media (max-width: 760px) {
  .cinematic-caption {
    left: 16px;
    right: 16px;
    bottom: 72px;
    width: auto;
    padding: 18px;
  }
  .skip-cinematic { right: 16px; bottom: 16px; }
  .formula-breath { display: none; }
  .bridge-perspective { width: 112vw; }
  .destination-courtyard { width: 72vw; height: 72vw; }
}

/* Storybook/WebGL-inspired enhancement layer */
:root {
  --mx: 0;
  --my: 0;
  --tx: 0;
  --ty: 0;
}

.storybook-world {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.78;
  transition: opacity 600ms ease, filter 600ms ease;
}
.storybook-sky {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(circle at calc(50% + var(--mx) * 14%) calc(20% + var(--my) * 8%), rgba(205, 246, 255, 0.18), transparent 32%),
    radial-gradient(circle at calc(20% + var(--mx) * -8%) 66%, rgba(179, 255, 215, 0.10), transparent 28%),
    linear-gradient(180deg, rgba(47, 85, 104, 0.28), rgba(5, 10, 17, 0.04) 48%, rgba(5, 10, 17, 0));
  transform: translate3d(calc(var(--mx) * -22px), calc(var(--my) * -14px), 0);
}
.storybook-river {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -20%;
  height: 46%;
  border-radius: 50% 50% 0 0;
  background:
    radial-gradient(ellipse at 50% 12%, rgba(255,255,255,0.12), transparent 30%),
    repeating-linear-gradient(110deg, rgba(179,255,215,0.08) 0 2px, transparent 2px 24px),
    linear-gradient(180deg, rgba(23,60,72,0.34), rgba(4,9,15,0.88));
  filter: blur(0.4px);
  transform: translate3d(calc(var(--mx) * 18px), calc(var(--my) * 8px), 0) rotate(-1deg);
  box-shadow: inset 0 32px 120px rgba(115,226,255,0.05);
}
.storybook-hill {
  position: absolute;
  bottom: 18%;
  width: 58vw;
  height: 28vh;
  border-radius: 52% 48% 0 0;
  background: linear-gradient(180deg, rgba(70,125,97,0.14), rgba(12,29,31,0.02));
  filter: blur(8px);
}
.hill-left { left: -16vw; transform: translate3d(calc(var(--mx) * 16px), calc(var(--my) * 4px), 0) rotate(4deg); }
.hill-right { right: -18vw; transform: translate3d(calc(var(--mx) * -18px), calc(var(--my) * 5px), 0) rotate(-5deg); }
.storybook-reeds {
  position: absolute;
  bottom: 13%;
  width: 120px;
  height: 240px;
  opacity: 0.38;
  background:
    linear-gradient(85deg, transparent 48%, rgba(179,255,215,0.26) 49% 51%, transparent 52%),
    linear-gradient(97deg, transparent 43%, rgba(179,255,215,0.20) 44% 46%, transparent 47%),
    linear-gradient(78deg, transparent 54%, rgba(246,237,200,0.20) 55% 57%, transparent 58%);
  background-size: 28px 100%, 34px 100%, 42px 100%;
  filter: blur(0.2px);
}
.reeds-left { left: 5vw; transform: translate3d(calc(var(--mx) * 18px), 0, 0); }
.reeds-right { right: 7vw; transform: translate3d(calc(var(--mx) * -16px), 0, 0) scaleX(-1); }
.duet-token {
  position: absolute;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.88);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 16px 46px rgba(0,0,0,0.28), 0 0 30px currentColor;
}
.token-u {
  left: 18vw;
  bottom: 24vh;
  background: rgba(115,226,255,0.16);
  color: var(--u);
  animation: tokenFloat 6.2s ease-in-out infinite;
}
.token-v {
  right: 21vw;
  bottom: 27vh;
  background: rgba(255,176,111,0.14);
  color: var(--v);
  animation: tokenFloat 7.1s 400ms ease-in-out infinite;
}
@keyframes tokenFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-16px) rotate(4deg); }
}
body.level-running .storybook-world { opacity: 0.24; filter: saturate(0.75) brightness(0.8); }
body.cinematic-active .storybook-world { opacity: 0; }

.math-cursor {
  position: fixed;
  z-index: 11;
  left: -18px;
  top: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  pointer-events: none;
  display: grid;
  place-items: center;
  color: rgba(246,237,200,0.78);
  border: 1px solid rgba(246,237,200,0.28);
  background: radial-gradient(circle, rgba(246,237,200,0.18), rgba(115,226,255,0.06) 54%, transparent 68%);
  box-shadow: 0 0 22px rgba(246,237,200,0.18);
  mix-blend-mode: screen;
  opacity: 0.76;
  transition: opacity 220ms ease;
}
.math-cursor span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  transform: translateY(-1px);
}
body.level-running .math-cursor { opacity: 0.16; }
body.cinematic-active .math-cursor { opacity: 0; }

.story-card {
  width: min(980px, calc(100vw - 44px));
  background:
    linear-gradient(180deg, rgba(255,255,255,0.11), rgba(255,255,255,0.032)),
    radial-gradient(circle at calc(78% + var(--mx) * 8%) 12%, rgba(115,226,255,0.12), transparent 28%),
    linear-gradient(135deg, rgba(12,19,30,0.94), rgba(8,13,21,0.84));
}
.story-card h1 {
  text-shadow: 0 0 30px rgba(246,237,200,0.10);
}
.story-visual {
  position: relative;
  min-height: 182px;
  margin: 4px 0 18px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 60% 20%, rgba(246,237,200,0.10), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.025));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 18px 54px rgba(0,0,0,0.22);
}
.storybook-panel {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform-style: preserve-3d;
}
.storybook-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(110deg, transparent 0 42%, rgba(255,255,255,0.05) 48%, transparent 56% 100%),
    radial-gradient(circle at 10% 100%, rgba(179,255,215,0.08), transparent 34%);
  transform: translateX(calc(var(--mx) * 14px));
  pointer-events: none;
}
.mini-dot {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: rgba(246,237,200,0.55);
  box-shadow: 0 0 16px rgba(246,237,200,0.45);
  animation: miniSpark 4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.17s);
}
@keyframes miniSpark {
  0%, 100% { opacity: 0.08; transform: translateY(8px) scale(0.7); }
  48% { opacity: 0.9; transform: translateY(-8px) scale(1.15); }
}
.story-bubble {
  position: absolute;
  z-index: 2;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px;
  background: rgba(238,247,245,0.88);
  color: rgba(10,18,25,0.84);
  font-size: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
  animation: bubbleFloat 5.4s ease-in-out infinite;
}
.story-bubble::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: inherit;
  border-right: 1px solid rgba(255,255,255,0.22);
  border-bottom: 1px solid rgba(255,255,255,0.22);
}
.bubble-one { left: 8%; top: 14%; }
.bubble-two { right: 8%; top: 24%; animation-delay: -1.4s; }
@keyframes bubbleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.panel-skyline {
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: 20%;
  height: 44%;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, rgba(179,255,215,0.12), rgba(115,226,255,0.04));
  filter: blur(8px);
}
.paper-bridge {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 26%;
  height: 30%;
  perspective: 700px;
}
.paper-bridge i,
.stone-path i {
  position: absolute;
  top: 48%;
  left: calc(8% + var(--i) * 12%);
  width: 68px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(238,247,245,0.86), rgba(186,207,207,0.42));
  box-shadow: 0 18px 28px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.66);
  transform: rotateX(62deg) rotateZ(calc(var(--i) * 3deg - 10deg));
  opacity: 0;
  animation: stoneAppear 4.8s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.16s);
}
@keyframes stoneAppear {
  0%, 10% { opacity: 0; transform: translateY(10px) rotateX(62deg) scale(0.85); }
  28%, 82% { opacity: 0.84; transform: translateY(0) rotateX(62deg) scale(1); }
  100% { opacity: 0.16; transform: translateY(-4px) rotateX(62deg) scale(0.96); }
}
.mini-player {
  position: absolute;
  bottom: 30%;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.25);
}
.mini-u { left: 18%; color: var(--u); background: rgba(115,226,255,0.14); }
.mini-v { right: 18%; color: var(--v); background: rgba(255,176,111,0.14); }
.mini-seal {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--seal);
  background: rgba(246,237,200,0.07);
  border: 1px solid rgba(246,237,200,0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.vector-grid,
.det-mini-grid {
  position: absolute;
  inset: 16px;
  border-radius: 20px;
  background:
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  transform: translate3d(calc(var(--mx) * 8px), calc(var(--my) * 6px), 0);
  opacity: 0.58;
}
.vec {
  position: absolute;
  left: 23%;
  bottom: 30%;
  height: 3px;
  transform-origin: 0 50%;
  border-radius: 999px;
  box-shadow: 0 0 20px currentColor;
}
.vec::after,
.det-vector::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 9px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transform: translateY(-50%);
}
.vec span {
  position: absolute;
  right: 12px;
  top: -26px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}
.vec-u { width: 30%; transform: rotate(-22deg); color: var(--u); background: currentColor; animation: vecPulse 2.6s ease-in-out infinite; }
.vec-v { width: 26%; transform: translate(30%, -30%) rotate(42deg); color: var(--v); background: currentColor; animation: vecPulse 2.6s 350ms ease-in-out infinite; }
.vec-r { width: 50%; transform: rotate(12deg); color: var(--seal); background: currentColor; animation: vecPulse 2.6s 700ms ease-in-out infinite; }
@keyframes vecPulse { 0%,100% { opacity: 0.48; } 50% { opacity: 1; } }
.target-gate {
  position: absolute;
  right: 18%;
  top: 24%;
  width: 76px;
  height: 82px;
  border: 2px solid rgba(246,237,200,0.42);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  box-shadow: 0 0 30px rgba(246,237,200,0.18);
}
.stone-path {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 7%;
  height: 38px;
}
.stone-path i { top: 6px; left: calc(var(--i) * 11.5%); width: 44px; height: 14px; animation-duration: 5.6s; }

.det-mini-para {
  position: absolute;
  left: 34%;
  top: 31%;
  width: 34%;
  height: 38%;
  transform: skewX(-21deg) rotate(-9deg);
  background: linear-gradient(135deg, rgba(179,255,215,0.28), rgba(246,237,200,0.10));
  border: 1px solid rgba(179,255,215,0.54);
  box-shadow: 0 0 40px rgba(179,255,215,0.12), inset 0 1px 0 rgba(255,255,255,0.16);
  animation: paraBreath 3.8s ease-in-out infinite;
}
@keyframes paraBreath { 0%,100% { transform: skewX(-21deg) rotate(-9deg) scale(0.94); } 50% { transform: skewX(-21deg) rotate(-9deg) scale(1.06); } }
.det-vector {
  position: absolute;
  left: 34%;
  top: 62%;
  width: 32%;
  height: 3px;
  transform-origin: 0 50%;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 0 18px currentColor;
}
.det-u { color: var(--u); background: currentColor; transform: rotate(-31deg); }
.det-v { color: var(--v); background: currentColor; transform: rotate(-84deg); }
.water-lilies i {
  position: absolute;
  bottom: calc(16% + var(--i, 0) * 4%);
  width: 34px;
  height: 15px;
  border-radius: 50%;
  background: rgba(179,255,215,0.22);
  border: 1px solid rgba(179,255,215,0.24);
}
.water-lilies i:nth-child(1) { left: 14%; transform: rotate(-8deg); }
.water-lilies i:nth-child(2) { left: 20%; bottom: 22%; transform: rotate(12deg); }
.water-lilies i:nth-child(3) { right: 16%; bottom: 16%; transform: rotate(-18deg); }
.det-badge,
.lambda-readout {
  position: absolute;
  right: 8%;
  bottom: 13%;
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid rgba(246,237,200,0.22);
  color: var(--seal);
  background: rgba(246,237,200,0.07);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.iso-room {
  position: absolute;
  width: 112px;
  height: 88px;
  transform: rotateX(58deg) rotateZ(-36deg);
  background: linear-gradient(135deg, rgba(255,143,184,0.18), rgba(115,226,255,0.08));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 24px 24px 0 rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.10);
}
.room-one { left: 24%; top: 22%; animation: isoDrift 5s ease-in-out infinite; }
.room-two { right: 22%; bottom: 20%; animation: isoDrift 5.4s 500ms ease-in-out infinite reverse; }
@keyframes isoDrift { 0%,100% { transform: rotateX(58deg) rotateZ(-36deg) translateY(0); } 50% { transform: rotateX(58deg) rotateZ(-36deg) translateY(-12px); } }
.axis-beam {
  position: absolute;
  left: 18%;
  top: 50%;
  width: 64%;
  height: 3px;
  transform-origin: 50% 50%;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 34px currentColor;
}
.beam-a { color: var(--seal); transform: rotate(18deg); animation: beamLock 3.8s ease-in-out infinite; }
.beam-b { color: var(--u); transform: rotate(-42deg); opacity: 0.76; animation: beamLock 3.8s 700ms ease-in-out infinite; }
@keyframes beamLock { 0%,100% { opacity: 0.38; } 50% { opacity: 0.95; } }
.matrix-cube {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%) rotateX(58deg) rotateZ(45deg);
  border: 1px solid rgba(246,237,200,0.36);
  background: rgba(246,237,200,0.11);
  color: var(--seal);
  box-shadow: 0 0 42px rgba(246,237,200,0.16);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}
.lambda-readout { left: 8%; right: auto; bottom: 13%; }

.coop-orbit,
.coop-center {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
}
.coop-center {
  width: 82px;
  height: 82px;
  color: var(--seal);
  border: 1px solid rgba(246,237,200,0.26);
  background: rgba(246,237,200,0.08);
  box-shadow: 0 0 34px rgba(246,237,200,0.12);
}
.coop-orbit {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255,255,255,0.20);
  animation: coopOrbit 7s linear infinite;
}
.orbit-u { color: var(--u); background: rgba(115,226,255,0.12); --r: 92px; }
.orbit-v { color: var(--v); background: rgba(255,176,111,0.12); --r: -92px; animation-delay: -3.5s; }
@keyframes coopOrbit {
  0% { transform: translate(-50%, -50%) rotate(0) translateX(var(--r)) rotate(0); }
  100% { transform: translate(-50%, -50%) rotate(360deg) translateX(var(--r)) rotate(-360deg); }
}
.guide-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246,237,200,0.42), transparent);
  transform-origin: 50% 50%;
}
.line-a { transform: translate(-50%, -50%) rotate(18deg); }
.line-b { transform: translate(-50%, -50%) rotate(-44deg); }

.transition-path {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 30%;
  height: 4px;
  background: linear-gradient(90deg, var(--u), var(--seal), var(--v));
  border-radius: 999px;
  box-shadow: 0 0 34px rgba(246,237,200,0.24);
  animation: pathWrite 3.8s ease-in-out infinite;
}
@keyframes pathWrite { 0%,100% { transform: scaleX(0.25); opacity: 0.36; } 50% { transform: scaleX(1); opacity: 1; } }
.transition-door {
  position: absolute;
  left: 50%;
  top: 22%;
  width: 112px;
  height: 126px;
  transform: translateX(-50%);
  border: 2px solid rgba(246,237,200,0.34);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  box-shadow: 0 0 44px rgba(246,237,200,0.17), inset 0 0 30px rgba(115,226,255,0.08);
}
.transition-glyph {
  position: absolute;
  left: 50%;
  top: 49%;
  transform: translate(-50%, -50%);
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 36px;
  font-weight: 800;
  text-shadow: 0 0 30px rgba(246,237,200,0.46);
}
.ending-rune {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(246,237,200,0.24);
  background: rgba(246,237,200,0.08);
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  box-shadow: 0 0 34px rgba(246,237,200,0.16);
}
.rune-line { transform: translate(-160%, -50%); }
.rune-area { transform: translate(-50%, -50%); }
.rune-axis { transform: translate(60%, -50%); }
.ending-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  border: 1px solid rgba(246,237,200,0.15);
  transform: translate(-50%, -50%);
  animation: ringPulse 4s ease-in-out infinite;
}
.ring-a { width: 220px; height: 220px; }
.ring-b { width: 300px; height: 300px; animation-delay: -1s; }
@keyframes ringPulse { 0%,100% { opacity: 0.25; transform: translate(-50%, -50%) scale(0.95); } 50% { opacity: 0.82; transform: translate(-50%, -50%) scale(1.04); } }

.dialogue-card {
  isolation: isolate;
}
.dialogue-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(circle at calc(20% + var(--mx) * 16%) 0%, rgba(255,255,255,0.06), transparent 36%);
}
.dialogue-tail {
  position: absolute;
  left: 28px;
  top: -6px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  background: rgba(255,255,255,0.045);
  border-left: 1px solid rgba(255,255,255,0.09);
  border-top: 1px solid rgba(255,255,255,0.09);
}
.dialogue-0 { border-color: rgba(115,226,255,0.20); }
.dialogue-1 { border-color: rgba(255,176,111,0.20); }
.dialogue-2 { border-color: rgba(246,237,200,0.18); }

.loading-veil {
  grid-template-rows: auto auto auto;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 48%, rgba(246,237,200,0.13), transparent 22%),
    rgba(4, 8, 14, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.loader-stack {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}
.loader-stack .loader-mark {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
}
.loader-stack b {
  position: relative;
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
}
.loading-veil small {
  color: rgba(238,247,245,0.56);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Extra cinematic detail inspired by storybook and isometric WebGL sites */
.storybook-cinematic .painted-cloud {
  position: absolute;
  width: 34vw;
  height: 14vw;
  min-width: 280px;
  min-height: 110px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 22% 54%, rgba(255,255,255,0.22), transparent 42%),
    radial-gradient(circle at 55% 42%, rgba(205,246,255,0.16), transparent 40%),
    radial-gradient(circle at 74% 60%, rgba(246,237,200,0.12), transparent 38%);
  filter: blur(8px);
  opacity: 0.58;
  animation: cloudDrift 8s ease-in-out infinite;
}
.cloud-a { left: 8%; top: 10%; }
.cloud-b { right: 6%; top: 20%; animation-delay: -2.8s; }
@keyframes cloudDrift { 0%,100% { transform: translateX(-18px); } 50% { transform: translateX(18px); } }
.river-foreground {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -18%;
  height: 38%;
  border-radius: 50% 50% 0 0;
  background:
    repeating-linear-gradient(104deg, rgba(115,226,255,0.08) 0 2px, transparent 2px 30px),
    radial-gradient(ellipse at 50% 0%, rgba(179,255,215,0.18), transparent 52%),
    rgba(4,13,20,0.32);
  filter: blur(1px);
  animation: riverSlide 5.4s linear infinite;
}
@keyframes riverSlide { to { background-position: 80px 0, 0 0, 0 0; } }
.reed-silhouette {
  position: absolute;
  bottom: 0;
  width: 170px;
  height: 330px;
  opacity: 0.32;
  background:
    linear-gradient(84deg, transparent 48%, rgba(179,255,215,0.32) 49% 51%, transparent 52%),
    linear-gradient(96deg, transparent 48%, rgba(246,237,200,0.22) 49% 51%, transparent 52%),
    linear-gradient(76deg, transparent 48%, rgba(115,226,255,0.20) 49% 51%, transparent 52%);
  background-size: 30px 100%, 46px 100%, 58px 100%;
  filter: blur(0.4px);
}
.reeds-a { left: 4%; }
.reeds-b { right: 5%; transform: scaleX(-1); }
.cinematic-dialogues {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.cinematic-dialogues .talk {
  position: absolute;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(238,247,245,0.88);
  color: rgba(7,13,20,0.82);
  border: 1px solid rgba(255,255,255,0.36);
  box-shadow: 0 12px 32px rgba(0,0,0,0.24);
  font-size: 12px;
  opacity: 0;
  animation: talkPop 6.2s ease both;
}
.cinematic-dialogues .talk::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -5px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: inherit;
}
.talk-0 { left: 16%; top: 24%; animation-delay: 900ms !important; }
.talk-1 { right: 16%; top: 30%; animation-delay: 1800ms !important; }
.talk-2 { left: 50%; top: 18%; transform: translateX(-50%); animation-delay: 2900ms !important; }
@keyframes talkPop {
  0%, 10% { opacity: 0; transform: translateY(12px) scale(0.96); }
  24%, 72% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.98); }
}
.paper-shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 52%;
  height: 28%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.34), transparent 66%);
  filter: blur(18px);
  opacity: 0.58;
}
.isometric-neighborhood {
  position: absolute;
  right: 9%;
  top: 16%;
  width: min(430px, 46vw);
  height: min(430px, 46vw);
  perspective: 900px;
  transform: translate3d(calc(var(--mx) * -18px), calc(var(--my) * -12px), 0);
}
.iso-card {
  position: absolute;
  left: 18%;
  top: 18%;
  width: 92px;
  height: 78px;
  transform: rotateX(58deg) rotateZ(-35deg);
  transform-origin: center;
  background: linear-gradient(135deg, rgba(255,143,184,0.24), rgba(246,237,200,0.08));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 24px 24px 0 rgba(0,0,0,0.13);
  opacity: 0;
  animation: isoFold 5.8s ease both;
  animation-delay: calc(var(--i) * 120ms + 700ms);
}
.iso-card span {
  position: absolute;
  right: 10px;
  top: 14px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(238,247,245,0.86);
  box-shadow: 0 0 24px rgba(238,247,245,0.4);
}
@keyframes isoFold {
  0% { opacity: 0; transform: rotateX(85deg) rotateZ(-35deg) translateY(40px) scale(0.6); }
  40%, 82% { opacity: 0.9; transform: rotateX(58deg) rotateZ(-35deg) translateY(0) scale(1); }
  100% { opacity: 0.12; transform: rotateX(58deg) rotateZ(-35deg) translateY(-34px) scale(0.86); }
}
.paper-rider {
  position: absolute;
  left: 42%;
  top: 54%;
  width: 26px;
  height: 34px;
  border-radius: 6px 6px 12px 12px;
  background: rgba(238,247,245,0.92);
  box-shadow: 0 20px 28px rgba(0,0,0,0.22);
  animation: riderMove 5.8s ease both;
}
.paper-rider::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -18px;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(7,13,20,0.72);
  border-radius: 50%;
  transform: translateX(-50%);
}
@keyframes riderMove {
  0% { opacity: 0; transform: translate(-90px, 42px) rotate(-8deg); }
  34%, 78% { opacity: 1; transform: translate(0, 0) rotate(3deg); }
  100% { opacity: 0; transform: translate(92px, -54px) rotate(8deg); }
}
.storybook-pages {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(460px, 60vw);
  height: min(300px, 40vw);
  transform: translate(-50%, -50%);
  perspective: 900px;
}
.storybook-pages .page {
  position: absolute;
  top: 50%;
  width: 32%;
  height: 54%;
  display: grid;
  place-items: center;
  border-radius: 22px;
  border: 1px solid rgba(246,237,200,0.24);
  background: linear-gradient(180deg, rgba(246,237,200,0.16), rgba(115,226,255,0.06));
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  box-shadow: 0 30px 70px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.1);
  animation: pageTurn 6.8s ease both;
}
.page-line { left: 0; transform: translateY(-50%) rotateY(-24deg) rotateZ(-7deg); }
.page-area { left: 34%; transform: translateY(-50%) rotateY(0deg); animation-delay: 350ms !important; }
.page-axis { right: 0; transform: translateY(-50%) rotateY(24deg) rotateZ(7deg); animation-delay: 700ms !important; }
@keyframes pageTurn {
  0% { opacity: 0; transform: translateY(-50%) rotateY(-86deg) scale(0.8); }
  32%, 78% { opacity: 0.88; }
  100% { opacity: 0; transform: translateY(-50%) rotateY(0deg) scale(0.62); }
}

@media (max-width: 900px) {
  .story-visual { min-height: 150px; }
  .story-bubble { font-size: 11px; }
  .paper-bridge i { width: 46px; }
  .math-cursor { display: none; }
}
@media (max-width: 760px) {
  .storybook-world { opacity: 0.48; }
  .story-card h1 { letter-spacing: 0.08em; }
  .story-visual { min-height: 138px; border-radius: 22px; }
  .storybook-panel .bubble-two { display: none; }
  .cinematic-dialogues .talk { display: none; }
  .isometric-neighborhood { opacity: 0.7; right: -6%; top: 22%; }
}
.isometric-neighborhood .iso-card:nth-child(1) { left: 10%; top: 12%; }
.isometric-neighborhood .iso-card:nth-child(2) { left: 34%; top: 18%; }
.isometric-neighborhood .iso-card:nth-child(3) { left: 58%; top: 14%; }
.isometric-neighborhood .iso-card:nth-child(4) { left: 20%; top: 38%; }
.isometric-neighborhood .iso-card:nth-child(5) { left: 45%; top: 44%; }
.isometric-neighborhood .iso-card:nth-child(6) { left: 64%; top: 58%; }
.isometric-neighborhood .iso-card:nth-child(7) { left: 30%; top: 65%; }
.paper-bridge i:nth-child(1) { left: 8%; }
.paper-bridge i:nth-child(2) { left: 20%; }
.paper-bridge i:nth-child(3) { left: 32%; }
.paper-bridge i:nth-child(4) { left: 44%; }
.paper-bridge i:nth-child(5) { left: 56%; }
.paper-bridge i:nth-child(6) { left: 68%; }
.paper-bridge i:nth-child(7) { left: 80%; }
.stone-path i:nth-child(1) { left: 0%; }
.stone-path i:nth-child(2) { left: 12%; }
.stone-path i:nth-child(3) { left: 24%; }
.stone-path i:nth-child(4) { left: 36%; }
.stone-path i:nth-child(5) { left: 48%; }
.stone-path i:nth-child(6) { left: 60%; }
.stone-path i:nth-child(7) { left: 72%; }
.stone-path i:nth-child(8) { left: 84%; }

/* Seamless WebGL world transitions: replacing card-like chapter interstitials with camera travel. */
.cinematic-overlay.world-cinematic {
  background: #061019;
}
.cinematic-overlay.world-cinematic .cinematic-vignette {
  z-index: 2;
  background:
    radial-gradient(ellipse at center, transparent 0%, transparent 48%, rgba(0,0,0,0.34) 78%, rgba(0,0,0,0.82) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.14), transparent 40%, rgba(0,0,0,0.28));
}
.world-transition-host {
  position: absolute;
  inset: 0;
  background: #061019;
}
.world-transition-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  animation: worldCanvasIn 780ms ease forwards;
}
@keyframes worldCanvasIn {
  from { opacity: 0; filter: saturate(0.8) brightness(0.7); }
  to { opacity: 1; filter: saturate(1) brightness(1); }
}
body.cinematic-active.world-cinematic .level-frame.cinematic-frame {
  opacity: 0;
  transform: none;
  filter: none;
  transition: opacity 420ms ease;
}
.world-cinematic .cinematic-caption {
  left: 50%;
  right: auto;
  bottom: clamp(20px, 4.6vh, 42px);
  width: min(680px, calc(100vw - 48px));
  transform: translateX(-50%);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: none;
  pointer-events: none;
  text-align: center;
}
.world-cinematic .cinematic-caption.next-loading::after {
  content: "";
}
.world-whisper {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  border: 1px solid rgba(246,237,200,0.14);
  border-radius: 999px;
  background: rgba(4, 9, 14, 0.26);
  color: rgba(238,247,245,0.72);
  text-shadow: 0 2px 18px rgba(0,0,0,0.55);
  box-shadow: 0 0 42px rgba(115,226,255,0.08);
}
.world-whisper b {
  font-size: clamp(13px, 1.7vw, 16px);
  font-weight: 650;
  letter-spacing: 0.16em;
  color: rgba(246,237,200,0.86);
}
.world-whisper span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(11px, 1.4vw, 13px);
  color: rgba(179,255,215,0.68);
}
.world-whisper small {
  max-width: min(620px, 78vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(238,247,245,0.48);
  font-size: 11px;
}
.world-cinematic .skip-cinematic {
  right: 18px;
  bottom: 18px;
  z-index: 5;
  padding: 8px 12px;
  border-color: rgba(246,237,200,0.12);
  background: rgba(3, 8, 13, 0.22);
  color: rgba(238,247,245,0.46);
  box-shadow: none;
}
.world-cinematic .skip-cinematic:hover,
.world-cinematic .skip-cinematic:focus-visible {
  color: rgba(238,247,245,0.86);
  background: rgba(8, 13, 20, 0.46);
}
.minimal-fallback-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(115,226,255,0.10), transparent 38%),
    linear-gradient(180deg, #10243a 0%, #071018 58%, #05080e 100%);
}
.fallback-water {
  position: absolute;
  left: -10%; right: -10%; bottom: -16%;
  height: 54%;
  background:
    repeating-linear-gradient(110deg, rgba(179,255,215,0.11) 0 1px, transparent 1px 32px),
    linear-gradient(180deg, rgba(22,70,86,0.76), rgba(4,10,15,1));
  transform: perspective(620px) rotateX(62deg);
  transform-origin: 50% 0;
  animation: fallbackWater 6.8s linear infinite;
}
.fallback-bridge-road {
  position: absolute;
  left: 50%; bottom: 10%;
  width: 18vw; height: 78vh;
  transform: translateX(-50%) perspective(720px) rotateX(68deg);
  transform-origin: 50% 100%;
  background:
    repeating-linear-gradient(0deg, rgba(246,237,200,0.42) 0 2px, transparent 2px 46px),
    linear-gradient(90deg, transparent, rgba(246,237,200,0.22), transparent);
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
  animation: fallbackForward 7.2s cubic-bezier(.16,.82,.24,1) both;
}
.fallback-gate {
  position: absolute;
  left: 50%; top: 32%;
  width: min(240px, 34vw); height: min(210px, 30vw);
  border: 2px solid rgba(179,255,215,0.36);
  border-bottom: 0;
  border-radius: 120px 120px 0 0;
  transform: translateX(-50%);
  box-shadow: 0 0 70px rgba(179,255,215,0.16);
  animation: fallbackGate 7.2s ease both;
}
.fallback-garden {
  position: absolute;
  left: 50%; top: 52%;
  width: min(380px, 52vw); height: min(380px, 52vw);
  border-radius: 50%;
  border: 1px solid rgba(179,255,215,0.30);
  background: radial-gradient(circle, rgba(179,255,215,0.16), transparent 62%);
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  animation: fallbackGarden 7.2s ease both;
}
.fallback-area {
  position: absolute;
  left: 50%; top: 54%;
  width: min(430px, 58vw); height: min(290px, 40vw);
  transform: translate(-50%, -50%) skewX(-26deg) rotateX(58deg);
  border: 2px solid rgba(255,143,184,0.68);
  background: rgba(255,143,184,0.10);
  box-shadow: 0 0 60px rgba(255,143,184,0.18);
  animation: fallbackFold 7.4s cubic-bezier(.16,.82,.24,1) both;
}
.fallback-axis-line {
  position: absolute;
  left: 50%; top: 50%;
  width: min(740px, 88vw); height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  box-shadow: 0 0 42px currentColor;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(32deg);
  animation: fallbackAxis 7.4s ease both;
}
.fallback-axis-line.one { color: var(--seal); }
.fallback-axis-line.two { color: var(--u); transform: translate(-50%, -50%) rotate(126deg); animation-delay: 120ms; }
.fallback-seal {
  position: absolute;
  left: 50%; top: 50%;
  width: min(420px, 64vw); height: min(420px, 64vw);
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(246,237,200,0.26);
  color: rgba(246,237,200,0.86);
  font: 800 clamp(28px, 8vw, 58px) ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 90px rgba(246,237,200,0.14), inset 0 0 80px rgba(115,226,255,0.06);
  animation: fallbackSeal 6.2s ease both;
}
@keyframes fallbackWater { to { background-position: 120px 0, 0 0; } }
@keyframes fallbackForward { from { opacity: 0; transform: translateX(-50%) perspective(720px) rotateX(68deg) translateY(24vh); } to { opacity: 1; transform: translateX(-50%) perspective(720px) rotateX(68deg) translateY(-12vh); } }
@keyframes fallbackGate { 0%, 18% { opacity: 0; transform: translateX(-50%) scale(0.72); } 48%, 78% { opacity: 1; transform: translateX(-50%) scale(1); } 100% { opacity: 0; transform: translateX(-50%) scale(1.35); } }
@keyframes fallbackGarden { 42% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); } 76%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes fallbackFold { 0%, 36% { opacity: 1; } 72%, 100% { opacity: 0; transform: translate(-50%, -50%) skewX(-8deg) rotateX(88deg) scale(0.2); } }
@keyframes fallbackAxis { 0%, 48% { opacity: 0; transform: translate(-50%, -50%) rotate(32deg) scaleX(0.2); } 74%, 100% { opacity: 1; transform: translate(-50%, -50%) rotate(32deg) scaleX(1); } }
@keyframes fallbackSeal { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } 35%, 82% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.26); } }

/* Seamless in-level handoff: no separate 3D transition canvas. The outer shell only double-buffers levels. */
.level-frame {
  pointer-events: none;
  opacity: 0;
  transition: opacity 850ms ease, filter 850ms ease;
}
.level-frame.ready { opacity: 0; }
.level-frame.ready.active {
  z-index: 2;
  opacity: 1;
  pointer-events: auto;
  filter: saturate(0.96) contrast(1.04);
}
.level-frame.standby,
.level-frame.preloading {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}
.level-frame.swapping-out {
  opacity: 0;
  filter: saturate(1.08) brightness(0.88) blur(2px);
}
.level-frame.swapping-in {
  animation: seamlessFrameIn 980ms ease both;
}
@keyframes seamlessFrameIn {
  from { opacity: 0; filter: saturate(1.2) brightness(1.1) blur(2px); }
  to { opacity: 1; filter: saturate(0.96) contrast(1.04) blur(0); }
}
body.inline-transitioning .topbar,
body.inline-transitioning .coop-ribbon,
body.inline-transitioning .storybook-world,
body.inline-transitioning .math-cursor {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-12px);
  transition: opacity 420ms ease, transform 420ms ease;
}
#cinematicOverlay {
  display: none !important;
}
.compact-panel {
  min-height: 170px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.compact-water {
  position: absolute;
  inset: 42% -12% -18%;
  background:
    radial-gradient(ellipse at center, rgba(115,226,255,0.20), transparent 58%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.10) 0 1px, transparent 1px 18px);
  transform: rotateX(62deg);
  opacity: 0.72;
}
.compact-path {
  position: absolute;
  left: 50%;
  top: 0;
  width: 28%;
  height: 105%;
  transform: translateX(-50%) perspective(600px) rotateX(62deg);
  border-left: 1px solid rgba(115,226,255,0.40);
  border-right: 1px solid rgba(255,176,111,0.36);
  background: linear-gradient(90deg, rgba(115,226,255,0.08), rgba(246,237,200,0.13), rgba(255,176,111,0.08));
  box-shadow: 0 0 50px rgba(246,237,200,0.10);
}
.compact-glyph {
  position: relative;
  z-index: 2;
  padding: 12px 18px;
  border: 1px solid rgba(246,237,200,0.20);
  border-radius: 999px;
  background: rgba(8,13,20,0.34);
  color: var(--seal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  box-shadow: 0 0 30px rgba(246,237,200,0.10);
}

/* Continuous-channel handoff: two adjacent levels overlap inside the same forward passage. */
:root {
  --current-level-opacity: 1;
  --next-level-opacity: 0;
  --handoff-mist-opacity: 0;
  --next-level-scale: 1;
  --next-level-y: 0vh;
  --next-level-clip-x: 220%;
  --next-level-clip-y: 220%;
}
body.inline-transitioning::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: var(--handoff-mist-opacity, 0);
  background:
    radial-gradient(ellipse at 50% 48%, rgba(215, 250, 255, 0.24), transparent 24%),
    radial-gradient(ellipse at 50% 68%, rgba(255, 240, 204, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(7, 14, 22, 0.18), transparent 30%, transparent 72%, rgba(7, 14, 22, 0.20)),
    linear-gradient(90deg, rgba(6, 12, 19, 0.30), transparent 24%, transparent 76%, rgba(6, 12, 19, 0.30));
  mix-blend-mode: screen;
  transition: opacity 180ms linear;
}
body.inline-transitioning .level-frame.ready.active {
  opacity: var(--current-level-opacity, 1);
  filter: saturate(1.02) contrast(1.02);
  transition: opacity 180ms linear, filter 280ms ease;
}
body.inline-transitioning .level-frame.ready.standby.channel-revealing,
body.inline-transitioning .level-frame.ready.preloading.channel-revealing {
  z-index: 3;
  opacity: var(--next-level-opacity, 0);
  pointer-events: none;
  transform: translate3d(0, var(--next-level-y, 0vh), 0) scale(var(--next-level-scale, 1));
  transform-origin: 50% 58%;
  clip-path: none;
  -webkit-mask-image: radial-gradient(ellipse var(--next-level-clip-x, 220%) var(--next-level-clip-y, 220%) at 50% 57%, #000 0%, rgba(0,0,0,0.92) 42%, rgba(0,0,0,0.34) 68%, transparent 84%);
  mask-image: radial-gradient(ellipse var(--next-level-clip-x, 220%) var(--next-level-clip-y, 220%) at 50% 57%, #000 0%, rgba(0,0,0,0.92) 42%, rgba(0,0,0,0.34) 68%, transparent 84%);
  filter: saturate(1.04) brightness(1.03) contrast(1.01);
  transition: opacity 180ms linear, transform 180ms linear, -webkit-mask-image 180ms linear, mask-image 180ms linear, filter 280ms ease;
}
body.inline-transitioning .level-frame.swapping-out {
  transition: opacity 260ms ease, filter 260ms ease;
}
body.inline-transitioning .level-frame.swapping-in {
  animation: none;
  opacity: 1;
}


/* Minimal shell pass: let the garden lead, keep text as a quiet caption. */
.story-card {
  max-width: 860px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.025)),
    linear-gradient(135deg, rgba(8, 13, 21, 0.90), rgba(8, 13, 21, 0.74));
}
.story-card h1 { letter-spacing: .14em; font-weight: 520; }
.story-card .lead { max-width: 680px; }
.body-card p, .insight-card p { line-height: 1.62; }
.unified-hud {
  max-width: 360px;
  background: linear-gradient(180deg, rgba(8,13,20,0.56), rgba(8,13,20,0.34));
  border-color: rgba(246,237,200,0.16);
}
.unified-detail, .unified-prompt { line-height: 1.55; }
body.level-running .coop-ribbon { opacity: .54; }
body.level-running .topbar { opacity: .70; }


/* Clarity/stability pass: quieter opening cards and a much simpler pointer. */
.story-card {
  width: min(720px, calc(100vw - 44px));
  padding: 28px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(238,247,245,0.060), rgba(238,247,245,0.022)),
    linear-gradient(135deg, rgba(6, 12, 19, 0.88), rgba(6, 12, 19, 0.72));
  box-shadow: 0 24px 86px rgba(0,0,0,0.50), inset 0 1px 0 rgba(255,255,255,0.07);
}
.story-card h1 {
  font-size: clamp(36px, 6vw, 62px);
  letter-spacing: .18em;
}
.story-visual { max-height: 120px; opacity: .82; }
.lead { font-size: clamp(15px, 1.8vw, 18px); line-height: 1.62; margin-bottom: 14px; }
.story-body { gap: 10px; margin-top: 12px; }
.body-card, .insight-card {
  padding: 12px 13px;
  border-radius: 18px;
  background: rgba(255,255,255,0.030);
}
.insight-panel:empty { display: none; }
.formula-chip { padding: 8px 12px; background: rgba(246,237,200,0.045); }
.math-cursor {
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-color: rgba(246,237,200,0.18);
  background: radial-gradient(circle, rgba(246,237,200,0.35), rgba(115,226,255,0.08) 46%, transparent 72%);
  box-shadow: 0 0 10px rgba(246,237,200,0.12);
  opacity: .42;
}
.math-cursor span { display: none; }
body.level-running .math-cursor { opacity: 0; }
/* 给 canvas filter 统一一份 (saturate+contrast+brightness) 三函数列表，
   并把过渡态的差值压小到肉眼几乎不可见的程度。CSS filter 只有在两侧
   function list 完全一致时才会平滑插值（已声明 transition: filter 420ms）；
   否则会退化为 discrete 切换——这正是之前"过渡开始/结束那一瞬间整画面颜色突变"的根因。 */
.unified-world-canvas { filter: saturate(0.96) contrast(0.99) brightness(1); }
body.single-world-transitioning .unified-world-canvas { filter: saturate(0.95) contrast(0.99) brightness(0.98); }

/* 第一关「数学化」UI 的样式已迁到 shared/l1-math-ui.css（index.html 直接 link，
   与各关 standalone 页面共用同一份）——这里原先那份复制品会盖掉新样式，已删。 */

/* ===== 手势控制预览部件（gesture-input）===== */
.gesture-widget {
  position: fixed;
  z-index: 6;
  left: 18px;
  bottom: 76px; /* coop-ribbon 上方 */
  width: 208px;
  padding: 8px 8px 9px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px var(--shadow);
}
.gesture-widget[hidden] { display: none; }
.gesture-widget canvas {
  display: block;
  width: 100%;
  border-radius: 10px;
  background: #05080e;
}
.gesture-chips {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}
.gesture-chip {
  flex: 1;
  text-align: center;
  font-size: 11px;
  padding: 3px 0 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--soft);
  transition: color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.gesture-chip.live.chip-u {
  color: var(--u);
  border-color: rgba(115, 226, 255, 0.55);
  box-shadow: 0 0 12px rgba(115, 226, 255, 0.22);
}
.gesture-chip.live.chip-v {
  color: var(--v);
  border-color: rgba(255, 176, 111, 0.55);
  box-shadow: 0 0 12px rgba(255, 176, 111, 0.22);
}
.gesture-hint {
  margin: 7px 2px 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--soft);
}
body.cinematic-active .gesture-widget,
body.overlay-open .gesture-widget { opacity: 0.25; pointer-events: none; }
body.hide-ui .gesture-widget { display: none; }

/* ===== 拍摄辅助（统一模式）：H = hide-ui 全隐界面；P = presentation 隐操作提示、留淡数据 HUD ===== */
body.hide-ui .topbar,
body.hide-ui .coop-ribbon,
body.hide-ui .unified-hud,
body.hide-ui #l1Math,
body.hide-ui #l2Math,
body.hide-ui #l3Math,
body.hide-ui #mathCursor {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 260ms ease;
}
body.presentation .topbar,
body.presentation .coop-ribbon,
body.presentation #mathCursor {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 260ms ease;
}
body.presentation .unified-hud,
body.presentation #l1Math,
body.presentation #l2Math,
body.presentation #l3Math {
  opacity: 0.42;
  transition: opacity 260ms ease;
}

/* ══════════════════════════════════════════════════════════════════════════
   2026-07-28 UI 改版：开场/说明卡重排 + 通关印记
   放在文件末尾，靠后置覆盖前面同名同权重的旧规则（不再去改上面那几段）。
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 开场 / 章节说明卡 ── */
.story-overlay {
  padding: 84px 24px 24px;
  background:
    radial-gradient(circle at 50% 18%, rgba(115,226,255,0.09), transparent 34%),
    radial-gradient(circle at 76% 74%, rgba(255,176,111,0.08), transparent 38%),
    radial-gradient(circle at 50% 50%, rgba(2,5,10,0.42), rgba(2,5,10,0.78) 78%);
  backdrop-filter: blur(14px) saturate(1.06);
  -webkit-backdrop-filter: blur(14px) saturate(1.06);
}
/* 说明卡打开时把顶栏抬到遮罩之上：章节切换按钮保持清晰可点，而不是被糊成一团 */
body.overlay-open .topbar { z-index: 11; }

.story-card {
  width: min(1020px, calc(100vw - 48px));
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  padding: 30px 32px 22px;
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,0.13);
  overflow: hidden;
  box-shadow: 0 34px 100px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.09);
}
.story-card .card-glow {
  background: linear-gradient(118deg, rgba(115,226,255,0.16), transparent 26%, transparent 70%, rgba(255,176,111,0.14));
  mask: linear-gradient(#000, transparent 62%);
}
/* 卡片四角的细金线：像一块挂在门上的展签，而不是一个圆角矩形 */
.story-card::before,
.story-card::after {
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  border: 1px solid rgba(246,237,200,0.28);
  pointer-events: none;
}
.story-card::before { left: 14px; top: 14px; border-right: none; border-bottom: none; border-radius: 12px 0 0 0; }
.story-card::after { right: 14px; bottom: 14px; border-left: none; border-top: none; border-radius: 0 0 12px 0; }

.story-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 12px 34px;
  align-items: center;   /* 两列高度差很大（开场时左列很短），居中比顶对齐平衡 */
  overflow: auto;
  scrollbar-width: thin;
  padding-right: 6px;
}
.story-col-text, .story-col-side { min-width: 0; }

.story-card .eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: rgba(246,237,200,0.6);
}
.story-card h1 {
  margin: 10px 0 0;
  font-size: clamp(34px, 5.4vw, 58px);
  font-weight: 680;
  letter-spacing: 0.12em;
  line-height: 1.04;
}
/* 标题下的短金线：把标题和正文分开，省掉一层卡片 */
.story-card h1::after {
  content: "";
  display: block;
  width: 54px; height: 1px;
  margin: 16px 0 15px;
  background: linear-gradient(90deg, rgba(246,237,200,0.66), rgba(246,237,200,0));
}
.story-card .lead {
  margin: 0 0 16px;
  max-width: 46ch;
  font-size: clamp(14px, 1.35vw, 16px);
  line-height: 1.86;
  color: rgba(238,247,245,0.76);
}
.story-card .formula-row { gap: 7px; margin: 0 0 14px; }
.story-card .formula-chip {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 9px;
  border-color: rgba(246,237,200,0.18);
  background: rgba(246,237,200,0.05);
  box-shadow: none;
}

/* 目标：一行带竖线的提示，不再是一张卡 */
.story-card .insight-panel { display: block; margin: 0; }
.story-card .insight-card {
  padding: 0 0 0 13px;
  border: none;
  border-left: 2px solid rgba(179,255,215,0.45);
  border-radius: 0;
  background: none;
}
.story-card .insight-card h3 {
  margin: 0 0 3px;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(179,255,215,0.72);
}
.story-card .insight-card p { font-size: 13.5px; line-height: 1.7; color: rgba(238,247,245,0.78); }
.story-card .guide-extra { margin: 0; font-size: 13px; line-height: 1.8; color: rgba(238,247,245,0.7); }
.story-card .guide-extra b { color: var(--seal); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* 右列：会动的概念图 + 角色分工清单（不再是三个方块卡） */
.story-card .story-visual {
  /* 上面还有两条旧规则给它压了 max-height:120px / overflow:hidden / opacity:.82，
     那是给以前那个装饰盒子用的；现在里面是概念动图，必须让它自己撑开。 */
  min-height: 0;
  max-height: none;
  overflow: visible;
  opacity: 1;
  margin: 2px 0 14px;
  padding: 11px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background:
    radial-gradient(circle at 62% 22%, rgba(246,237,200,0.07), transparent 46%),
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.018));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.story-card .story-visual .ca-svg { border: none; background: rgba(4,8,14,0.34); }
.story-card .story-visual .ca-caption { margin-top: 8px; font-size: 12px; color: rgba(238,247,245,0.62); }
.story-card .story-visual .ca-caption b { font-size: 12px; color: rgba(238,247,245,0.9); }

.story-card .story-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  grid-template-columns: none;
}
.story-card .body-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 9px 0;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  border-radius: 0;
  background: none;
}
.story-card .body-card:first-child { border-top: none; }
.story-card .body-card h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(246,237,200,0.86);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}
.story-card .body-card p { font-size: 12.8px; line-height: 1.65; color: rgba(238,247,245,0.68); }

.story-card .action-row {
  flex: none;
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.story-card .primary {
  padding: 11px 24px;
  border-color: rgba(246,237,200,0.5);
  background: linear-gradient(100deg, rgba(115,226,255,0.16), rgba(246,237,200,0.22), rgba(255,176,111,0.16));
  letter-spacing: 0.06em;
}
.story-card .secondary { padding: 11px 18px; }
.story-card .ghost { margin: 0 0 0 auto; padding: 11px 16px; border-color: transparent; background: none; font-size: 13px; }
.story-card .ghost:hover { border-color: rgba(255,255,255,0.2); }

@media (max-width: 880px) {
  .story-overlay { padding-top: 132px; }
  .story-card { padding: 22px; max-height: calc(100vh - 160px); }
  .story-grid { grid-template-columns: 1fr; gap: 4px; }
  .story-col-side { order: -1; }
}

/* ── 通关印记：每章完成的一刻 ── */
.chapter-seal {
  position: fixed;
  z-index: 9;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 20px;
  width: min(520px, calc(100vw - 48px));
  padding: 18px 26px 18px 20px;
  border: 1px solid rgba(246,237,200,0.24);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(11,16,25,0.80), rgba(8,12,19,0.58));
  backdrop-filter: blur(16px) saturate(1.08);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
  box-shadow: 0 30px 90px rgba(0,0,0,0.52), 0 0 70px rgba(246,237,200,0.07);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.965);
  transition: opacity 560ms ease, transform 560ms cubic-bezier(0.22, 0.85, 0.3, 1);
}
.chapter-seal[hidden] { display: none; }
.chapter-seal.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.chapter-seal::before {
  content: "";
  position: absolute;
  inset: -44px;
  border-radius: 44px;
  background: radial-gradient(ellipse at 22% 50%, rgba(246,237,200,0.13), transparent 62%);
  pointer-events: none;
  z-index: -1;
}
.seal-ring { flex: none; width: 66px; height: 66px; overflow: visible; }
.seal-ring circle { fill: none; }
.seal-ring-track { stroke: rgba(255,255,255,0.10); stroke-width: 2; }
.seal-ring-draw {
  stroke: var(--seal);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 295.3;
  stroke-dashoffset: 295.3;
  transform: rotate(-90deg);
  transform-origin: 52px 52px;
  filter: drop-shadow(0 0 6px rgba(246,237,200,0.55));
}
.chapter-seal.is-visible .seal-ring-draw { animation: sealDraw 1150ms cubic-bezier(0.3, 0.75, 0.25, 1) 120ms forwards; }
.seal-ring-core { fill: var(--seal); opacity: 0; }
.chapter-seal.is-visible .seal-ring-core { animation: sealCore 900ms ease 900ms forwards; }
@keyframes sealDraw { to { stroke-dashoffset: 0; } }
@keyframes sealCore {
  0% { opacity: 0; transform: scale(0.2); transform-origin: 52px 52px; }
  60% { opacity: 1; transform: scale(1.5); transform-origin: 52px 52px; }
  100% { opacity: 0.85; transform: scale(1); transform-origin: 52px 52px; }
}
.seal-body { min-width: 0; }
.seal-eyebrow {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(246,237,200,0.66);
}
.seal-title {
  margin: 5px 0 7px;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: 0.1em;
  color: var(--text);
}
.seal-eq {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  color: var(--seal);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.seal-eq::-webkit-scrollbar { display: none; }
.seal-note { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: rgba(238,247,245,0.6); }
.chapter-seal .seal-eyebrow,
.chapter-seal .seal-title,
.chapter-seal .seal-eq,
.chapter-seal .seal-note { opacity: 0; transform: translateY(6px); }
.chapter-seal.is-visible .seal-eyebrow { animation: sealIn 520ms ease 260ms forwards; }
.chapter-seal.is-visible .seal-title { animation: sealIn 520ms ease 380ms forwards; }
.chapter-seal.is-visible .seal-eq { animation: sealIn 520ms ease 520ms forwards; }
.chapter-seal.is-visible .seal-note { animation: sealIn 520ms ease 660ms forwards; }
@keyframes sealIn { to { opacity: 1; transform: translateY(0); } }

body.hide-ui .chapter-seal { opacity: 0 !important; }

body.capture-render {
  cursor: none;
  overflow: hidden;
}

body.capture-render #unifiedWorldCanvas {
  cursor: none;
  /* The capture surface is intentionally wider than the exported plate. Shift
     the 4008 px render so its optical centre lands in the 2697 px plate. */
  transform: translateX(-655.5px);
}
@media (max-width: 620px) {
  .chapter-seal { gap: 14px; padding: 15px 18px; }
  .seal-ring { width: 52px; height: 52px; }
  .seal-title { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .chapter-seal.is-visible .seal-ring-draw { animation: none; stroke-dashoffset: 0; }
  .chapter-seal .seal-eyebrow,
  .chapter-seal .seal-title,
  .chapter-seal .seal-eq,
  .chapter-seal .seal-note { opacity: 1; transform: none; animation: none !important; }
}

/* 顶栏在英文下会被撑爆（章节名变长 + 品牌名两行）。说明卡打开时顶栏被抬到遮罩之上，
   这个溢出就露出来了——这里给它一套「可压缩」的规则，中英文都不越界。 */
.chapter-nav { overflow: hidden; }
.chapter-node { min-width: 0; }
.chapter-node span:not(.num) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[lang="en"] .topbar { grid-template-columns: minmax(110px, 168px) 1fr auto; gap: 12px; }
html[lang="en"] .brand-title { font-size: 15px; letter-spacing: 0.1em; }
html[lang="en"] .brand-block .eyebrow { display: none; }
html[lang="en"] .shell-actions button { padding: 8px 10px; font-size: 12.5px; }
@media (max-width: 1180px) {
  .chapter-node span:not(.num) { display: none; }
  .chapter-node { padding: 7px 8px; }
}

/* 游玩时顶栏是一颗居中的胶囊，原来写死 590px——中文刚好、英文就把章节按钮挤成 0 宽
   （1fr 那一列先被压扁），操作按钮还折成两行。改成按内容取宽，两种语言都不越界。 */
body.level-running .topbar {
  width: max-content;
  max-width: calc(100vw - 40px);
  grid-template-columns: auto auto auto;
}
body.level-running .chapter-nav { min-width: fit-content; justify-content: center; }
body.level-running .shell-actions { flex-wrap: nowrap; }
