
:root {
  color-scheme: dark;
  --space: #050807;
  --paper: #f4eddf;
  --orange: #ef7651;
  --teal: #69d2c9;
  --muted: #a59f92;
  --line: rgba(244,237,223,.22);
  --sans: "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --serif: "Iowan Old Style", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--space); scroll-behavior: smooth; }
body {
  margin: 0; min-width: 20rem; min-height: 100dvh; overflow-x: hidden;
  background: var(--space); color: var(--paper); font-family: var(--sans); line-height: 1.5;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
::selection { background: var(--orange); color: var(--paper); }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
#scene { position: fixed; z-index: 0; inset: 0; width: 100vw; height: 100dvh; outline: 0; }
.story-ui { position: fixed; z-index: 2; inset: 0; pointer-events: none; }
.story-ui::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(3,6,5,.76) 0, rgba(3,6,5,.24) 40%, transparent 68%), linear-gradient(0deg, rgba(3,6,5,.54), transparent 24%); pointer-events: none; }
.story-header, .title-card, .chapter-caption, .progress-rail, .scroll-hint { z-index: 1; }
.title-card h1 { text-shadow: 0 2px 32px rgba(0,0,0,.32); }
.story-header { position: absolute; inset-block-start: clamp(1.2rem, 3vw, 2.4rem); inset-inline: clamp(1.2rem, 3.2vw, 3.2rem); display: flex; justify-content: space-between; gap: 1rem; color: rgba(244,237,223,.62); font-family: var(--mono); font-size: .625rem; letter-spacing: .08em; text-transform: uppercase; }
.title-card {
  position: absolute; inset-block-start: 18%; inset-inline-start: clamp(1.2rem, 5vw, 5.5rem); max-width: min(50rem, 75vw);
  transition: opacity .7s ease, translate .7s cubic-bezier(.22,1,.36,1);
  pointer-events: none;
}
.title-card.is-hidden { opacity: 0; translate: 0 -1.5rem; }
.eyebrow { color: var(--teal); font-family: var(--mono); font-size: .625rem; letter-spacing: .08em; line-height: 1.55; text-transform: uppercase; }
.title-card h1 { max-width: 11ch; margin-block-start: 1.1rem; font-size: clamp(3.5rem, 8.8vw, 9rem); font-weight: 800; letter-spacing: -.075em; line-height: .84; }
.title-card h1 em { color: var(--orange); font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -.085em; }
.title-card > p:last-child { max-width: 30rem; margin-block-start: 1.8rem; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.25rem); line-height: 1.55; }
.chapter-caption {
  position: absolute; inset-inline-start: clamp(1.2rem, 5vw, 5.5rem); inset-block-end: clamp(2rem, 6vh, 5rem);
  display: grid; grid-template-columns: 3.3rem minmax(0, 34rem); gap: 1rem; align-items: start;
  opacity: 0; translate: 0 1rem; transition: opacity .55s ease, translate .55s cubic-bezier(.22,1,.36,1);
}
.chapter-caption.is-visible { opacity: 1; translate: 0; }
.chapter-caption::before { content: ""; position: absolute; inset-block-start: -.1rem; inset-inline-start: 2.75rem; width: 1px; height: 4rem; background: linear-gradient(var(--orange), transparent); }
.chapter-number { color: var(--orange); font-family: var(--mono); font-size: .6875rem; padding-block-start: .1rem; }
.chapter-kicker { color: var(--teal); font-family: var(--mono); font-size: .625rem; letter-spacing: .08em; text-transform: uppercase; }
.chapter-copy { max-width: 36rem; margin-block-start: .55rem; font-family: var(--serif); font-size: clamp(1.35rem, 2.1vw, 2.15rem); letter-spacing: -.03em; line-height: 1.12; text-wrap: pretty; }
.progress-rail { position: absolute; inset-inline-end: clamp(1.2rem, 3.2vw, 3.2rem); inset-block-start: 50%; translate: 0 -50%; display: grid; gap: 1rem; pointer-events: auto; }
.progress-rail button { display: flex; align-items: center; justify-content: end; gap: .65rem; border: 0; padding: .1rem 0; background: transparent; color: rgba(244,237,223,.38); text-align: right; }
.progress-rail button span { font-family: var(--mono); font-size: .55rem; }
.progress-rail button b { max-width: 0; overflow: hidden; font-family: var(--mono); font-size: .55rem; font-weight: 500; white-space: nowrap; opacity: 0; transition: max-width .25s ease, opacity .25s ease; }
.progress-rail button:hover b,
.progress-rail button.is-active b { max-width: 8rem; opacity: 1; }
.progress-rail button::after { content: ""; width: .45rem; height: .45rem; border: 1px solid rgba(244,237,223,.48); border-radius: 50%; transition: background .25s ease, border-color .25s ease, scale .25s ease; }
.progress-rail button.is-active { color: var(--paper); }
.progress-rail button.is-active::after { background: var(--orange); border-color: var(--orange); scale: 1.35; }
.scroll-hint { position: absolute; inset-block-end: 1.6rem; inset-inline-start: 50%; translate: -50% 0; display: flex; align-items: center; gap: .7rem; color: rgba(244,237,223,.56); font-family: var(--mono); font-size: .56rem; letter-spacing: .07em; text-transform: uppercase; transition: opacity .35s ease; }
.scroll-hint span { width: 1.8rem; height: 1px; background: var(--orange); }
.scroll-hint.is-hidden { opacity: 0; }
.loading { position: fixed; z-index: 100; inset: 0; display: grid; place-content: center; gap: .8rem; background: var(--space); text-align: center; transition: opacity .8s ease, visibility .8s ease; }
.loading.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading__brand { font-size: clamp(2.5rem, 7vw, 5rem); font-weight: 850; letter-spacing: -.075em; }
.loading__line { color: var(--teal); font-family: var(--mono); font-size: .625rem; letter-spacing: .1em; text-transform: uppercase; }
.fallback { position: fixed; z-index: 200; inset: 50% auto auto 50%; translate: -50% -50%; width: min(calc(100% - 2rem), 34rem); padding: 1.5rem; border: 1px solid var(--line); background: #0b1110; }
.fallback p { color: var(--muted); }
.story-scroll { position: relative; z-index: 1; width: 100%; }
.chapter { height: 100dvh; }
@media (max-width: 700px) {
  .story-header { font-size: .55rem; }
  .title-card { inset-block-start: 19%; max-width: calc(100% - 2.4rem); }
  .title-card h1 { max-width: 9ch; font-size: clamp(3.1rem, 16vw, 5.5rem); }
  .title-card > p:last-child { max-width: 23rem; font-size: .95rem; }
  .chapter-caption { inset-inline: 1.2rem; inset-block-end: 4.4rem; grid-template-columns: 2.2rem minmax(0, 1fr); gap: .7rem; }
  .chapter-caption::before { inset-inline-start: 1.85rem; height: 3rem; }
  .chapter-copy { font-size: clamp(1.2rem, 5.7vw, 1.6rem); }
  .progress-rail { inset-inline-end: 1rem; gap: .85rem; }
  .progress-rail button b { display: none; }
  .scroll-hint { inset-block-end: 1.1rem; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .title-card, .chapter-caption, .scroll-hint, .loading { transition-duration: .01ms; }
}
