:root {
  color-scheme: dark;
  --ink-night: #030914;
  --deep-river: #071324;
  --moon-white: #f2e7cd;
  --mist-blue: #a9bbc3;
  --warm-copper: #b58c58;
  --dawn-rose: #c78475;
  --body-white: #e5e8e1;
  --safe-x: max(24px, env(safe-area-inset-left));
  --safe-right: max(24px, env(safe-area-inset-right));
  --safe-top: max(16px, env(safe-area-inset-top));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--ink-night);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink-night);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

body {
  color: var(--body-white);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 300;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.experience {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  outline: none;
  background: var(--ink-night);
  touch-action: none;
}

#scene-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  cursor: default;
}

.screen-vignette {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 48% 45%, transparent 34%, rgba(0, 2, 8, .18) 68%, rgba(0, 2, 8, .72) 112%);
}

.boot {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ink-night);
  transition: opacity 900ms cubic-bezier(.4, 0, .2, 1), visibility 900ms;
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-ink {
  width: clamp(90px, 14vw, 190px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 231, 205, .38), rgba(169, 187, 195, .08) 37%, transparent 72%);
  filter: blur(8px);
  animation: ink-breathe 2.8s ease-in-out infinite;
}

@keyframes ink-breathe {
  0%, 100% { transform: scale(.55); opacity: .20; }
  50% { transform: scale(1.12); opacity: .72; }
}

.title-card,
.poem-layer,
.cue,
.hold-feedback,
.epilogue-panel,
.favourite-echo {
  position: absolute;
  pointer-events: none;
}

.title-card {
  z-index: 8;
  top: clamp(72px, 13vh, 132px);
  left: 50%;
  width: min(82vw, 620px);
  transform: translateX(-50%) translateY(12px);
  text-align: center;
  opacity: 0;
  transition: opacity 1500ms cubic-bezier(.4, 0, .2, 1), transform 1500ms cubic-bezier(.4, 0, .2, 1);
}

.title-card.is-visible {
  opacity: 1;
  transform: translateX(-50%);
}

.title-card h1 {
  margin: 0;
  color: rgba(242, 231, 205, .94);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: clamp(22px, 3.2vw, 36px);
  font-weight: 400;
  letter-spacing: .34em;
  text-indent: .34em;
}

.title-card p {
  margin: 18px 0 0;
  color: rgba(169, 187, 195, .48);
  font-size: clamp(11px, 1.25vw, 14px);
  letter-spacing: .32em;
  text-indent: .32em;
}

.poem-layer {
  z-index: 7;
  left: var(--safe-x);
  right: var(--safe-right);
  top: 50%;
  max-width: 32em;
  margin: 0 auto;
  transform: translateY(-50%);
  transition: transform 1000ms cubic-bezier(.4, 0, .2, 1), opacity 900ms;
  opacity: 0;
  text-align: center;
}

.poem-layer.is-visible { opacity: 1; }

.poem-layer[data-placement="upper-left"] { top: 31%; left: 10%; right: auto; margin: 0; text-align: left; }
.poem-layer[data-placement="upper-center"] { top: 31%; }
.poem-layer[data-placement="center-left"] { top: 53%; left: 9%; right: auto; margin: 0; text-align: left; }
.poem-layer[data-placement="lower-center"] { top: 67%; }

.poem-line {
  max-width: 32em;
  margin: 0;
  color: rgba(229, 232, 225, .92);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: clamp(17px, 1.55vw, 25px);
  font-weight: 400;
  line-height: 2;
  letter-spacing: .11em;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0, 3, 10, .88);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 850ms cubic-bezier(.4, 0, .2, 1), transform 850ms cubic-bezier(.4, 0, .2, 1);
}

.poem-line.is-visible { opacity: 1; transform: none; }
.poem-secondary { margin-top: 10px; color: rgba(229, 232, 225, .76); font-size: .88em; }

.cue {
  z-index: 9;
  left: var(--safe-x);
  right: var(--safe-right);
  bottom: calc(52px + var(--safe-bottom));
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 800ms, transform 800ms;
}

.cue.is-visible { opacity: 1; transform: none; }

.cue[data-idle="1"] span { color: rgba(242, 231, 205, .92); animation-duration: 1.8s; }
.cue[data-idle="2"] { transform: translateY(-3px); }
.cue[data-idle="2"] span { color: var(--moon-white); text-shadow: 0 0 18px rgba(242, 231, 205, .32); animation-duration: 1.15s; }

.cue span {
  display: inline-block;
  color: rgba(181, 140, 88, .78);
  font-size: clamp(11px, 1.15vw, 13px);
  letter-spacing: .34em;
  text-indent: .34em;
  animation: cue-breathe 3.4s ease-in-out infinite;
}

@keyframes cue-breathe { 0%, 100% { opacity: .42; } 50% { opacity: 1; } }

.sound-toggle {
  position: absolute;
  z-index: 13;
  top: var(--safe-top);
  right: var(--safe-right);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--moon-white);
  background: rgba(3, 9, 20, .16);
  cursor: pointer;
  opacity: .58;
  transition: opacity 300ms, background 300ms, transform 300ms;
}

.sound-toggle:hover,
.sound-toggle:focus-visible { opacity: 1; background: rgba(181, 140, 88, .16); transform: scale(1.06); }
.sound-toggle[aria-pressed="true"] { color: var(--warm-copper); }

.sound-glyph,
.sound-glyph::before,
.sound-glyph::after { display: block; position: relative; }
.sound-glyph { width: 16px; height: 14px; }
.sound-glyph::before { content: ""; position: absolute; left: 0; top: 5px; width: 4px; height: 5px; border-radius: 1px; background: currentColor; box-shadow: 4px -3px 0 -1px currentColor; }
.sound-glyph::after { content: ")  )"; position: absolute; left: 5px; top: -4px; color: currentColor; font-size: 13px; letter-spacing: -3px; transform: scaleY(1.25); }
.sound-toggle[aria-pressed="true"] .sound-glyph::after { content: "×"; left: 7px; top: -5px; font-size: 19px; letter-spacing: 0; }

.hold-feedback {
  z-index: 12;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(.84);
  opacity: 0;
  transition: opacity 180ms, transform 180ms;
}

.hold-feedback.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hold-ring { width: 68px; height: 68px; display: block; padding: 3px; border-radius: 50%; background: conic-gradient(var(--moon-white) var(--hold-progress, 0%), rgba(242, 231, 205, .18) 0); }
.hold-ring span { display: block; width: 100%; height: 100%; border-radius: 50%; background: rgba(3, 9, 20, .46); }
.hold-label { position: absolute; color: rgba(242, 231, 205, .76); font-size: 11px; letter-spacing: .2em; text-indent: .2em; }

.favourite-echo {
  z-index: 5;
  left: 50%;
  top: 70%;
  width: min(82vw, 560px);
  transform: translateX(-50%);
  text-align: center;
  color: rgba(242, 231, 205, .34);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: clamp(15px, 1.6vw, 22px);
  letter-spacing: .12em;
  opacity: 0;
  transition: opacity 900ms;
}

.favourite-echo.is-visible { opacity: 1; }

.epilogue-panel {
  z-index: 14;
  left: var(--safe-x);
  right: var(--safe-right);
  bottom: calc(34px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1200ms, transform 1200ms;
}

.epilogue-panel.is-visible { opacity: 1; transform: none; }
.epilogue-panel.is-visible { pointer-events: auto; }
.epilogue-kicker { margin: 0 0 8px; color: rgba(181, 140, 88, .64); font-size: 11px; letter-spacing: .28em; text-indent: .28em; }
.epilogue-panel h2 { margin: 0 0 18px; color: rgba(242, 231, 205, .92); font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif; font-size: clamp(22px, 2.6vw, 31px); font-weight: 400; letter-spacing: .24em; text-indent: .24em; }
.favourite-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; max-width: min(920px, 92vw); }
.favourite-option,
.quiet-button { min-height: 44px; border: 1px solid rgba(181, 140, 88, .24); border-radius: 999px; padding: 10px 16px; color: rgba(229, 232, 225, .78); background: rgba(3, 9, 20, .20); cursor: pointer; transition: color 300ms, border-color 300ms, background 300ms, transform 300ms; }
.favourite-option { font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif; font-size: 15px; }
.favourite-option:hover, .favourite-option:focus-visible, .favourite-option.is-selected { color: var(--moon-white); border-color: rgba(242, 231, 205, .72); background: rgba(181, 140, 88, .16); transform: translateY(-2px); }
.epilogue-actions { display: flex; gap: 10px; margin-top: 18px; }
.quiet-button { border-color: transparent; color: rgba(181, 140, 88, .74); font-size: 12px; letter-spacing: .22em; text-indent: .22em; }
.quiet-button:hover, .quiet-button:focus-visible { color: var(--moon-white); border-color: rgba(181, 140, 88, .42); background: rgba(181, 140, 88, .10); }

.degraded { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; overflow: auto; padding: 40px; color: var(--body-white); background: var(--ink-night); }
.degraded-inner { width: min(720px, 100%); text-align: center; }
.degraded-kicker, .dialog-kicker { color: var(--warm-copper); font-size: 11px; letter-spacing: .28em; text-indent: .28em; }
.degraded h1 { font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif; font-weight: 400; }

.full-text-dialog { width: min(820px, calc(100vw - 32px)); max-height: min(82vh, 760px); padding: 0; color: var(--body-white); border: 1px solid rgba(181, 140, 88, .34); border-radius: 14px; background: rgba(7, 19, 36, .96); box-shadow: 0 28px 100px rgba(0, 0, 0, .52); }
.full-text-dialog::backdrop { background: rgba(0, 3, 10, .72); backdrop-filter: blur(8px); }
.dialog-shell { max-height: min(82vh, 760px); overflow: auto; padding: 30px clamp(24px, 5vw, 56px) 44px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.dialog-head h2 { margin: 4px 0 0; font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif; font-size: clamp(26px, 4vw, 38px); font-weight: 400; letter-spacing: .18em; }
.dialog-kicker { margin: 0; }
.dialog-close { width: 44px; height: 44px; border: 0; color: rgba(242, 231, 205, .76); background: transparent; cursor: pointer; font-size: 28px; line-height: 1; }
.dialog-close:hover, .dialog-close:focus-visible { color: var(--moon-white); }
.full-text { color: rgba(229, 232, 225, .88); font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif; font-size: clamp(17px, 1.55vw, 22px); line-height: 2.05; letter-spacing: .08em; }
.full-text p { margin: 0 0 1.15em; }

:focus-visible { outline: 2px solid rgba(242, 231, 205, .86); outline-offset: 4px; }

@media (max-aspect-ratio: .82) {
  .poem-layer[data-placement="upper-left"], .poem-layer[data-placement="center-left"] { left: var(--safe-x); right: var(--safe-right); margin: 0 auto; text-align: center; }
  .poem-layer[data-placement="upper-left"] { top: 28%; }
  .poem-layer[data-placement="center-left"] { top: 45%; }
  .poem-layer[data-placement="lower-center"] { top: 64%; }
  .cue { bottom: calc(42px + var(--safe-bottom)); }
  .epilogue-panel { bottom: calc(20px + var(--safe-bottom)); }
  .favourite-options { width: min(100%, 360px); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; overflow: visible; padding: 2px 4px; gap: 8px; }
  .favourite-option { width: 100%; min-width: 0; padding: 8px 5px; font-size: 12px; line-height: 1.35; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .boot-ink, .cue span { animation: none; }
  .poem-line, .title-card, .cue, .epilogue-panel, .hold-feedback, .favourite-echo { transition-duration: 300ms; }
}
