:root {
  --paper: #ece3cf;
  --dim: #b5ab95;
  --muted: #7f786a;
  --gold: #d6b46e;
  --cinnabar: #b8402f;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --kai: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #020306; color: var(--paper); }
body { font-family: var(--serif); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
#sky { position: fixed; inset: 0; display: block; z-index: 0; }

/* ---------- text blocks ---------- */
#story { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.blk {
  position: absolute;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(14px);
  transition: opacity 1.2s ease, filter 1.4s ease, transform 1.6s cubic-bezier(.2, .7, .2, 1);
  text-shadow: 0 0 18px rgba(0, 0, 0, .85), 0 0 3px rgba(0, 0, 0, .9);
}
.blk.on { opacity: 1; filter: none; transform: none; pointer-events: auto; }
.blk p { margin: 0 0 .7em; font-size: 19px; line-height: 2; letter-spacing: .08em; }
.blk em { font-style: normal; color: var(--gold); }
.pos-l { left: 7vw; top: 50%; translate: 0 -50%; max-width: min(30rem, 38vw); }
.pos-r { right: 7vw; top: 50%; translate: 0 -50%; max-width: min(30rem, 38vw); }
.pos-c { left: 50%; top: 50%; translate: -50% -50%; text-align: center; width: min(46rem, 88vw); }
.pos-card { left: 50%; top: 50%; translate: -50% -50%; text-align: center; width: min(46rem, 90vw); }
.kick { color: var(--gold); letter-spacing: .4em; font-size: 14px; margin-bottom: 18px; }
.big-line { font-family: var(--kai); font-size: clamp(28px, 3.4vw, 44px) !important; letter-spacing: .3em !important; }
.big-line.dim { color: var(--dim); font-size: clamp(20px, 2.4vw, 30px) !important; }
.big-word { font-family: var(--kai); font-size: clamp(56px, 8vw, 104px) !important; line-height: 1.2 !important; color: #f6e7c2; letter-spacing: .2em !important; margin-bottom: .2em !important; }

/* title */
.title h1 {
  margin: 0;
  font-family: var(--kai);
  font-weight: 400;
  font-size: clamp(56px, 9vw, 132px);
  white-space: nowrap;
  letter-spacing: .32em;
  text-indent: .32em;
  color: #f4e8cc;
  line-height: 1.15;
}
.title p { color: var(--dim); letter-spacing: .6em; text-indent: .6em; font-size: 17px; margin-top: 14px; }
.title .hint { display: block; margin-top: 70px; color: var(--muted); font-size: 13px; letter-spacing: .4em; animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* chapter card */
.card b { display: block; font-weight: 400; color: var(--gold); letter-spacing: .8em; text-indent: .8em; font-size: 15px; }
.card h2 {
  margin: 14px 0 16px;
  font-family: var(--kai);
  font-weight: 400;
  font-size: clamp(40px, 5.6vw, 76px);
  letter-spacing: .24em;
  text-indent: .24em;
  color: #f4e8cc;
  line-height: 1.25;
}
.card span { color: var(--dim); font-size: 15px; letter-spacing: .22em; }
.card::before, .card::after {
  content: ""; display: block; width: 0; height: 1px; margin: 0 auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transition: width 2.2s cubic-bezier(.2, .7, .2, 1) .3s;
}
.card::before { margin-bottom: 26px; }
.card::after { margin-top: 26px; }
.blk.on .card::before, .blk.on .card::after { width: 260px; }

/* vertical quotations, revealed character by character */
.quote { display: flex; flex-direction: row-reverse; align-items: flex-start; gap: 16px; max-width: none; }
.quote .q {
  writing-mode: vertical-rl;
  font-family: var(--kai);
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.9;
  letter-spacing: .2em;
  max-height: 72vh;
  color: #f3e7c9;
}
.quote .q span { opacity: 0; filter: blur(4px); transition: opacity .9s ease, filter 1.1s ease; }
.quote.on .q span { opacity: 1; filter: none; }
.quote:not(.on) .q span { transition-delay: 0ms !important; transition-duration: .5s; }
.quote .cite {
  writing-mode: vertical-rl;
  font-size: 13px;
  letter-spacing: .3em;
  color: var(--cinnabar);
  border: 1px solid rgba(184, 64, 47, .7);
  padding: 8px 3px;
  margin-top: 6px;
  border-radius: 2px;
  text-shadow: none;
  background: rgba(10, 4, 3, .35);
}
.quote.pos-l { flex-direction: row; }

/* finale */
.finale .date { font-family: var(--kai); font-size: clamp(26px, 3.4vw, 46px); letter-spacing: .12em; color: #f6e8c6; white-space: nowrap; }
.finale .motto { font-family: var(--kai); font-size: clamp(22px, 2.6vw, 32px); letter-spacing: .5em; text-indent: .5em; color: var(--gold); margin: 22px 0 34px; }
.finale .src { font-size: 13px !important; color: var(--dim); letter-spacing: .06em !important; line-height: 1.9 !important; }
.finale .links { margin-top: 26px; display: flex; gap: 34px; justify-content: center; }
.finale a { color: var(--gold); text-decoration: none; border-bottom: 1px solid rgba(214, 180, 110, .4); letter-spacing: .2em; font-size: 15px; }
.finale a:hover { border-bottom-color: var(--gold); }

/* ---------- HUD ---------- */
.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 30px;
  pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
  text-shadow: 0 0 10px rgba(0, 0, 0, .9);
}
body.started .hud { opacity: 1; }
.hud-l { display: flex; align-items: center; gap: 14px; font-family: var(--kai); font-size: 18px; letter-spacing: .2em; color: var(--paper); }
.pov { font-family: var(--serif); font-size: 12px; letter-spacing: .3em; padding: 2px 9px; border: 1px solid transparent; color: var(--dim); }
.pov:empty { display: none; }
.pov.star { border-color: rgba(143, 168, 200, .55); color: #a9bdd8; }
.pov.march { border-color: rgba(184, 64, 47, .7); color: #d98b7c; }
.hud-r { text-align: right; font-size: 14px; letter-spacing: .12em; color: var(--dim); line-height: 1.8; }
#hudDate b { font-weight: 400; color: var(--paper); margin-left: 12px; font-family: Consolas, monospace; letter-spacing: .05em; }
#hudLoc { color: var(--muted); font-size: 13px; letter-spacing: .3em; }
.hud-bar { position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 4; }
.hud-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cinnabar), var(--gold)); transform-origin: left; transform: scaleX(0); }

#phrases {
  position: fixed; left: 50%; bottom: 26px; translate: -50% 0; z-index: 3;
  display: flex; gap: 22px;
  opacity: 0; transition: opacity 1.2s ease;
}
body.started #phrases { opacity: 1; }
#phrases span {
  font-family: var(--kai); font-size: 18px; width: 34px; height: 34px;
  display: grid; place-items: center;
  color: rgba(236, 227, 207, .22);
  border: 1px solid rgba(236, 227, 207, .12);
  transform: rotate(0);
  transition: color 1s ease, border-color 1s ease, box-shadow 1.4s ease, background 1s ease;
}
#phrases span.lit { color: #f4e3b8; border-color: rgba(214, 180, 110, .8); box-shadow: 0 0 18px rgba(214, 180, 110, .35); }
#phrases span.ding.lit { color: #fff0e6; background: rgba(184, 64, 47, .85); border-color: var(--cinnabar); box-shadow: 0 0 22px rgba(184, 64, 47, .6); }

#snd, .back {
  position: fixed; bottom: 24px; z-index: 5;
  font: inherit; font-size: 13px; letter-spacing: .25em;
  color: var(--dim); background: rgba(5, 6, 10, .4);
  border: 1px solid rgba(236, 227, 207, .22);
  padding: 7px 14px; cursor: pointer; text-decoration: none;
  transition: color .3s ease, border-color .3s ease;
}
#snd { right: 28px; }
.back { left: 28px; }
#snd:hover, .back:hover { color: var(--gold); border-color: var(--gold); }
#snd.on { color: var(--gold); border-color: rgba(214, 180, 110, .7); }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; color: var(--dim); }

@media (max-width: 820px) {
  .pos-l, .pos-r { left: 6vw; right: 6vw; max-width: none; top: auto; bottom: 90px; translate: none; }
  .quote.pos-l, .quote.pos-r { left: auto; right: 6vw; top: 80px; bottom: auto; }
  .blk p { font-size: 16px; }
  #phrases { gap: 10px; }
  .hud { padding: 16px; }
  .hud-l { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .blk, .quote .q span { transition-duration: .01ms !important; transition-delay: 0ms !important; }
}
