/* 鬼怪志异 · The Haunted Atlas */

:root {
  --night: #07060a;
  --ink: #1d1813;
  --ink-soft: #5b4b38;
  --paper: #efe3c6;
  --paper-dim: #a99a7c;
  --silk: #c9b48a;
  --silk-dark: #a98f62;
  --cinnabar: #b3261e;
  --cinnabar-bright: #d8432c;
  --gold: #d9b04a;
  --wisp: #9effd6;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --brush: 'Ma Shan Zheng', 'STKaiti', 'KaiTi', serif;
  --serif-zh: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --serif-en: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--paper);
  font-family: var(--serif-zh);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body[data-lang="en"] { font-family: var(--serif-en), var(--serif-zh); }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

/* ================================================================ GATE */
#intro {
  position: fixed; inset: 0; z-index: 60;
  display: none; place-items: center;
  background:
    radial-gradient(ellipse 50% 40% at 50% 46%, rgba(90, 50, 30, .18), transparent 70%),
    radial-gradient(ellipse at 50% 40%, #110d0a, var(--night) 72%);
  transition: opacity 1.1s ease, filter 1.1s ease;
}
#intro.is-active { display: grid; }
#intro.is-leaving { opacity: 0; filter: blur(6px); }
#intro-ink { position: absolute; inset: 0; width: 100%; height: 100%; }
.gate-inner {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px;
  padding: 24px 16px; text-align: center;
}
.gate-mark {
  writing-mode: vertical-rl; white-space: nowrap;
  font-family: var(--brush); font-size: clamp(40px, 6vh, 60px); letter-spacing: .3em; line-height: 1;
  color: rgba(241, 228, 198, .88); filter: url(#f-ink);
  text-shadow: 0 0 30px rgba(255, 140, 70, .18);
  opacity: 0; animation: charIn 2.2s var(--ease-out) .2s forwards;
}
.gate-line { margin: 0; color: var(--paper-dim); font-size: 15px; letter-spacing: .25em; opacity: 0; animation: fadeUp 1.4s ease 1.2s forwards; }
body[data-lang="en"] .gate-line { font-style: italic; font-size: 17px; letter-spacing: .02em; }
.gate-inner .btn-seal { opacity: 0; animation: fadeUp 1.2s ease 1.8s forwards; }
.gate-inner .lang-row { opacity: 0; animation: fadeUp 1.2s ease 2.2s forwards; display: flex; gap: 10px; align-items: center; color: var(--paper-dim); }
.link-btn {
  background: none; border: 0; padding: 4px 6px; cursor: pointer;
  color: #8a7c63; font-size: 13px; letter-spacing: .12em;
  border-bottom: 1px solid rgba(138, 124, 99, .35);
}
.link-btn:hover { color: var(--paper); border-bottom-color: var(--cinnabar-bright); }
.gate-inner .link-btn { opacity: 0; animation: fadeUp 1.2s ease 2.5s forwards; }
@keyframes charIn {
  0% { opacity: 0; filter: blur(14px); transform: translateY(14px) scale(1.15); }
  60% { opacity: 1; }
  100% { opacity: 1; filter: blur(0); transform: none; }
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.lang-btn {
  background: none; border: 0; padding: 4px 6px; cursor: pointer;
  color: var(--paper-dim); font-size: 14px; letter-spacing: .1em;
  border-bottom: 1px solid transparent;
}
.lang-btn[aria-pressed="true"] { color: var(--paper); border-bottom-color: var(--cinnabar-bright); }

/* the seal button: press it like a stamp */
.btn-seal {
  display: inline-flex; flex-direction: column; align-items: center; gap: 12px;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.seal-face {
  display: grid; place-items: center;
  width: 92px; height: 92px;
  writing-mode: vertical-rl; white-space: nowrap;
  font-family: var(--brush); font-size: 36px; line-height: 1; letter-spacing: .08em;
  color: #f6e8ca; background: var(--cinnabar);
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 5px rgba(246, 232, 202, .7), 0 0 0 0 rgba(216, 67, 44, .5);
  filter: url(#f-ink);
  transform: rotate(-4deg);
  transition: transform .25s ease, box-shadow .4s ease;
  animation: sealPulse 3.2s ease-in-out infinite 3s;
}
.btn-seal.small .seal-face { width: 78px; height: 78px; font-size: 30px; }
.btn-seal:hover .seal-face { transform: rotate(-4deg) scale(1.06); }
.btn-seal:active .seal-face { transform: rotate(-4deg) scale(.94); }
.btn-seal:focus-visible { outline: none; }
.btn-seal:focus-visible .seal-face { outline: 2px solid var(--gold); outline-offset: 6px; }
@keyframes sealPulse {
  0%, 100% { box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 5px rgba(246, 232, 202, .7), 0 0 0 0 rgba(216, 67, 44, 0); }
  50% { box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 5px rgba(246, 232, 202, .7), 0 0 40px 6px rgba(216, 67, 44, .35); }
}
.seal-sub { font-size: 13px; letter-spacing: .25em; color: var(--paper-dim); }
body[data-lang="en"] .seal-sub { font-family: var(--serif-en); font-style: italic; letter-spacing: .04em; font-size: 15px; }

/* ================================================================ PROLOGUE */
.prologue {
  position: fixed; inset: 0; z-index: 55; overflow: hidden;
  background: #020204;
  opacity: 0; transition: opacity 1.2s ease;
}
.prologue.is-on { opacity: 1; }
.prologue.is-done { opacity: 0; }
#pro-cv { position: absolute; inset: 0; width: 100%; height: 100%; }
#pro-stage { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.letterbox { position: absolute; left: 0; right: 0; height: 0; z-index: 3; background: #000; transition: height 1.8s cubic-bezier(.6, 0, .2, 1); }
.letterbox.top { top: 0; }
.letterbox.bottom { bottom: 0; }
.prologue.is-on .letterbox { height: 9vh; }
.prologue.is-done .letterbox { height: 0; }
.pro-caption {
  position: absolute; left: 50%; bottom: 12.5vh; z-index: 4;
  width: min(1100px, 94vw); transform: translateX(-50%);
  text-align: center; pointer-events: none; text-wrap: balance;
}
.cap-main {
  margin: 0;
  font-family: var(--serif-zh); font-weight: 600;
  font-size: clamp(18px, 1.95vw, 28px); line-height: 1.6; letter-spacing: .26em;
  color: #f2e7cd; text-shadow: 0 2px 20px #000, 0 0 2px #000;
  opacity: 0; filter: blur(8px);
  transition: opacity .9s ease, filter 1.1s ease, letter-spacing 2.6s ease;
}
body[data-lang="en"] .cap-main { font-family: var(--serif-en); font-weight: 400; letter-spacing: .06em; font-size: clamp(20px, 2.1vw, 30px); line-height: 1.4; }
.cap-sub {
  margin: 10px 0 0;
  font-family: var(--serif-en); font-style: italic; font-size: clamp(14px, 1.15vw, 17px);
  color: #a39477; text-shadow: 0 1px 10px #000;
  opacity: 0; transition: opacity 1s ease .35s;
}
body[data-lang="en"] .cap-sub { font-family: var(--serif-zh); font-style: normal; letter-spacing: .2em; }
.cap-src {
  margin: 12px 0 0; min-height: 1em;
  font-size: 13px; letter-spacing: .08em; color: rgba(217, 176, 74, .85); text-shadow: 0 1px 8px #000;
  opacity: 0; transition: opacity 1.2s ease .9s;
}
body[data-lang="en"] .cap-src { font-family: var(--serif-en); font-style: italic; letter-spacing: .01em; font-size: 14px; }
.pro-caption.is-on .cap-main { opacity: 1; filter: blur(0); letter-spacing: .16em; }
body[data-lang="en"] .pro-caption.is-on .cap-main { letter-spacing: .02em; }
.pro-caption.is-on .cap-sub, .pro-caption.is-on .cap-src { opacity: 1; }
.pro-skip {
  position: absolute; right: 22px; bottom: 2.4vh; z-index: 5;
  padding: 6px 16px; border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(239, 227, 198, .18); background: rgba(0, 0, 0, .4);
  color: rgba(239, 227, 198, .55); font-size: 13px; letter-spacing: .2em;
  transition: color .2s ease, border-color .2s ease;
}
.pro-skip:hover { color: var(--paper); border-color: rgba(239, 227, 198, .5); }

/* ghost flashes of the stranded */
.flash {
  position: absolute; top: 50%; height: 70vh; aspect-ratio: 2 / 3;
  opacity: 0; animation: ghostFlash 2.1s ease forwards;
}
.flash.left { left: 20vw; }
.flash.right { right: 20vw; }
.flash img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: invert(1) hue-rotate(180deg) saturate(.5) brightness(1.15) contrast(1.4);
  mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(ellipse 46% 48% at 50% 48%, #000 48%, transparent 80%);
  mask-image: radial-gradient(ellipse 46% 48% at 50% 48%, #000 48%, transparent 80%);
}
.flash-text {
  position: absolute; top: 6%;
  writing-mode: vertical-rl; max-height: 62vh;
  font-family: var(--brush); font-size: clamp(24px, 2.8vw, 40px); line-height: 1.5; letter-spacing: .2em;
  color: rgba(195, 255, 230, .9); text-shadow: 0 0 18px rgba(110, 255, 200, .6);
}
.flash.left .flash-text { left: calc(100% + 1.5vw); }
.flash.right .flash-text { right: calc(100% + 1.5vw); }
.flash-en {
  position: absolute; left: 50%; bottom: -1vh; transform: translateX(-50%);
  width: 120%; text-align: center;
  font-family: var(--serif-en); font-style: italic; font-size: clamp(15px, 1.3vw, 19px);
  color: rgba(200, 240, 225, .75); text-shadow: 0 1px 10px #000;
}
@keyframes ghostFlash {
  0% { opacity: 0; transform: translateY(-50%) scale(1.08); filter: blur(8px); }
  10% { opacity: 1; filter: blur(0); }
  14% { opacity: .35; }
  18% { opacity: 1; transform: translateY(-50%) translateX(6px) scale(1.04); }
  20% { transform: translateY(-50%) scale(1.04); }
  70% { opacity: .9; transform: translateY(-50%) scale(1); }
  100% { opacity: 0; transform: translateY(-50%) scale(.98); filter: blur(5px); }
}

/* the lost Atlas of Mountains and Seas */
.handscroll {
  position: absolute; left: 3vw; right: 3vw; top: 46%; height: 46vh;
  display: flex; transform: translateY(-50%);
  animation: hsIn 1.6s var(--ease-out) both;
  transition: opacity .8s ease;
}
.handscroll.is-out { opacity: 0; }
@keyframes hsIn { from { opacity: 0; clip-path: inset(0 50% 0 50%); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
.hs-rod { flex: none; width: 20px; border-radius: 8px; background: linear-gradient(90deg, #2a170c, #85552f 50%, #2a170c); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
.hs-band {
  position: relative; flex: 1; overflow: hidden;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .03) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, #cdb88f, #c2aa7c);
  border-top: 9px solid #5f4329; border-bottom: 9px solid #5f4329;
  box-shadow: inset 0 0 70px rgba(60, 40, 20, .55);
}
.hs-img {
  position: absolute; top: 0; bottom: 0; left: 0; width: 160%;
  background: url(../assets/pro_scroll.webp) center / cover;
  animation: hsPan 15s linear forwards;
  transition: opacity 2.8s ease, filter 2.8s ease;
}
@keyframes hsPan { to { transform: translateX(-37.5%); } }
.hs-text {
  position: absolute; inset: 7% 5%;
  display: flex; flex-direction: row-reverse; justify-content: center; gap: 2vw;
  opacity: 0; transition: opacity 2.6s ease .9s;
}
.hs-text p {
  margin: 0; max-height: 100%;
  writing-mode: vertical-rl;
  font-family: var(--serif-zh); font-size: clamp(12px, 1.25vw, 17px); line-height: 1.7; letter-spacing: .22em;
  color: rgba(35, 24, 14, .88);
}
.handscroll.is-lost .hs-img { opacity: 0; filter: blur(14px) sepia(1); }
.handscroll.is-lost .hs-text { opacity: 1; }

/* the dossier */
.pile { position: absolute; left: 50%; top: 42%; width: 0; height: 0; }
.page {
  position: absolute; left: 0; top: 0;
  width: min(24vw, 30vh); aspect-ratio: 2 / 3; padding: 5% 5% 0;
  background: #ece0c4; box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) rotate(var(--rot));
  animation: pageDrop .75s cubic-bezier(.2, .9, .3, 1.15) both;
  transition: opacity .4s linear;
}
.page img { width: 100%; height: 86%; object-fit: cover; display: block; filter: sepia(.25); }
.page span { font-family: var(--brush); font-size: 15px; color: var(--ink); margin-top: 3%; }
@keyframes pageDrop {
  from { opacity: 0; transform: translate(-50%, -170%) rotate(calc(var(--rot) * 3)); }
  to { opacity: 1; transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}
.cover {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%) rotate(-2deg);
  animation: coverDrop 1s cubic-bezier(.2, .9, .3, 1.1) both;
}
@keyframes coverDrop {
  from { opacity: 0; transform: translate(-50%, -150%) rotate(-12deg) scale(1.05); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(-2deg); }
}

/* ================================================================ TITLE CARD */
.title-card {
  position: fixed; inset: 0; z-index: 58;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% 42%, rgba(120, 70, 40, .2), transparent 70%),
    radial-gradient(ellipse at 50% 40%, #15110d, var(--night) 72%);
  opacity: 0; transition: opacity 1.4s ease, filter 1s ease, transform 1.2s ease;
}
.title-card.is-on { opacity: 1; }
.title-card.is-leaving { opacity: 0; filter: blur(8px); transform: scale(1.05); }
.title-inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 24px 16px; text-align: center; max-width: 760px;
}
.intro-title {
  margin: 0;
  font-family: var(--brush); font-weight: 400;
  font-size: clamp(72px, 14vw, 168px); line-height: 1;
  letter-spacing: .06em;
  color: #f1e4c6;
  text-shadow: 0 0 50px rgba(255, 140, 70, .25), 0 0 2px rgba(0, 0, 0, .8);
  filter: url(#f-ink);
}
.intro-title span { display: inline-block; opacity: 0; animation: charIn 1.6s var(--ease-out) forwards; }
.intro-title span:nth-child(1) { animation-delay: .3s; }
.intro-title span:nth-child(2) { animation-delay: .65s; }
.intro-title span:nth-child(3) { animation-delay: 1s; }
.intro-title span:nth-child(4) { animation-delay: 1.35s; }
.intro-seal {
  position: absolute; top: 34px; right: 4px;
  width: 58px; height: 58px; padding: 4px;
  display: grid; place-items: center;
  font-family: var(--brush); font-size: 19px; line-height: 1.05;
  color: #f6e8ca; background: var(--cinnabar);
  border-radius: 4px; transform: rotate(6deg);
  box-shadow: inset 0 0 0 2px rgba(246, 232, 202, .5);
  filter: url(#f-ink);
  opacity: 0; animation: stampIn .5s cubic-bezier(.3, 1.6, .5, 1) 2.2s forwards;
}
@keyframes stampIn {
  0% { opacity: 0; transform: rotate(6deg) scale(2.4); }
  100% { opacity: .95; transform: rotate(6deg) scale(1); }
}
.title-inner .intro-sub, .title-inner .intro-lede, .title-inner .btn-seal, .title-inner .link-btn { opacity: 0; animation: fadeUp 1.2s ease forwards; }
.intro-sub { animation-delay: 2s !important; margin: 0; font-size: 17px; letter-spacing: .5em; color: #d6c39a; }
body[data-lang="en"] .intro-sub { font-family: 'IM Fell English SC', var(--serif-en); letter-spacing: .12em; font-size: 19px; }
.intro-lede { animation-delay: 2.4s !important; margin: 0; max-width: 560px; color: var(--paper-dim); font-size: 15px; line-height: 1.9; }
body[data-lang="en"] .intro-lede { font-style: italic; font-size: 18px; line-height: 1.55; }
.title-inner .btn-seal { animation-delay: 2.9s; margin-top: 8px; }
.title-inner .link-btn { animation-delay: 3.4s; }

@keyframes lampFlicker {
  0%, 100% { opacity: 1; } 42% { opacity: .86; } 45% { opacity: 1; } 71% { opacity: .92; } 73% { opacity: .78; } 76% { opacity: 1; }
}

/* ================================================================ ATLAS */
#atlas {
  position: fixed; inset: 0; z-index: 1; overflow: hidden;
  background: var(--night);
  opacity: 0; visibility: hidden;
  transition: opacity 1.2s ease, visibility 0s linear 1.2s;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
#atlas.is-active { opacity: 1; visibility: visible; transition: opacity 1.2s ease; }
#atlas.is-dragging { cursor: grabbing; }
#atlas[data-scene="china"] { cursor: none; }
#atlas[data-scene="china"] .hud { cursor: auto; }
@media (hover: none) { #atlas[data-scene="china"] { cursor: auto; } }
#atlas[data-scene="china"].is-dragging { cursor: grabbing; }

.scene { position: absolute; inset: 0; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.layer-map { z-index: 1; }
.layer-top { z-index: 3; pointer-events: none; }
.map-img {
  display: block; width: 100%; height: 100%;
  background-size: cover; /* low-res placeholder while the full map streams in */
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
.map-labels { position: absolute; inset: 0; pointer-events: none; }
.map-label {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--brush); font-size: 46px; letter-spacing: .4em;
  writing-mode: vertical-rl; white-space: nowrap;
  color: rgba(30, 22, 14, .55); mix-blend-mode: multiply;
}

#fog { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
#mist {
  position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none;
  width: calc(100% + 1024px); height: calc(100% + 1024px);
  background-size: 1024px 1024px; opacity: .5; mix-blend-mode: screen;
  animation: mistDrift 140s linear infinite;
}
@keyframes mistDrift { to { transform: translate3d(-1024px, -1024px, 0); } }
#whispers { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.vignette {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 48%, rgba(0, 0, 0, .62) 100%);
}

/* pins keep a constant on-screen size while the map zooms */
.pin { position: absolute; left: 0; top: 0; transform: scale(var(--inv, 1)); transform-origin: 0 0; }

/* ---- China gate on the world map ---- */
.china-gate {
  position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none;
  pointer-events: auto; cursor: pointer;
}
.gate-seal {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  width: 62px; height: 62px; display: grid; place-items: center;
  font-family: var(--brush); font-size: 25px; line-height: 1;
  writing-mode: vertical-rl; letter-spacing: .1em;
  color: #f6e8ca; background: var(--cinnabar); border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(246, 232, 202, .55), 0 0 40px 12px rgba(255, 140, 60, .45);
  transition: transform .3s ease, box-shadow .3s ease;
}
.china-gate:hover .gate-seal { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 0 0 3px rgba(246, 232, 202, .8), 0 0 60px 18px rgba(255, 150, 70, .6); }
.gate-ring {
  position: absolute; left: -48px; top: -48px; width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid rgba(255, 205, 130, .75);
  animation: ring 2.8s ease-out infinite;
}
.gate-ring.r2 { animation-delay: 1.4s; }
@keyframes ring { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(2.2); opacity: 0; } }
.gate-label {
  position: absolute; left: 0; top: 44px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  white-space: nowrap; text-shadow: 0 2px 8px #000, 0 0 2px #000;
}
.gl-1 { font-family: var(--brush); font-weight: 400; font-size: 19px; color: #ffe3b0; letter-spacing: .1em; }
body[data-lang="en"] .gl-1 { font-family: var(--serif-en); font-size: 17px; letter-spacing: .02em; }
.gl-2 { font-size: 12px; color: var(--paper-dim); font-style: italic; }

/* ---- talismans (sealed lands) ---- */
.talisman {
  position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none;
  pointer-events: auto; cursor: pointer;
}
.talisman .paper {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -22%) rotate(var(--r, 0deg));
  transform-origin: 50% 0;
  display: flex; flex-direction: column; align-items: center;
  width: 40px; padding: 8px 0 10px;
  font-family: var(--brush); color: #a11d14;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 245, 200, .35), transparent 60%),
    linear-gradient(180deg, #ebc95e, #d6aa38);
  box-shadow:
    inset 0 0 0 3px #e2bb4c, inset 0 0 0 4px rgba(161, 29, 20, .55),
    0 8px 18px rgba(0, 0, 0, .55);
  transition: filter .3s ease;
}
.talisman .paper::before {
  /* the nail pinning it to the map */
  content: ''; position: absolute; top: -4px; left: 50%; width: 7px; height: 7px; border-radius: 50%;
  transform: translateX(-50%); background: radial-gradient(circle at 35% 35%, #e6e0d4, #6b6255); box-shadow: 0 1px 3px #000;
}
.tl-top { font-size: 11px; letter-spacing: .25em; writing-mode: vertical-rl; white-space: nowrap; }
.tl-main { font-size: 31px; line-height: 1.1; margin: 4px 0 3px; text-shadow: 0 0 1px rgba(161, 29, 20, .5); }
.tl-name { font-size: 13px; letter-spacing: .15em; writing-mode: vertical-rl; white-space: nowrap; }
.talisman:hover .paper, .talisman:focus-visible .paper { filter: brightness(1.12); animation: flutter 1.4s ease-in-out infinite; }
.talisman.is-shaking .paper { animation: sealShake .55s ease; }
@keyframes flutter {
  0%, 100% { transform: translate(-50%, -22%) rotate(var(--r)); }
  30% { transform: translate(-50%, -22%) rotate(calc(var(--r) + 4deg)) skewY(1deg); }
  65% { transform: translate(-50%, -22%) rotate(calc(var(--r) - 3deg)) skewY(-1deg); }
}
@keyframes sealShake {
  0%, 100% { transform: translate(-50%, -22%) rotate(var(--r)); }
  20% { transform: translate(-54%, -22%) rotate(calc(var(--r) - 7deg)); }
  40% { transform: translate(-46%, -22%) rotate(calc(var(--r) + 6deg)); }
  60% { transform: translate(-52%, -22%) rotate(calc(var(--r) - 4deg)); }
  80% { transform: translate(-49%, -22%) rotate(calc(var(--r) + 2deg)); }
}
.tl-tip {
  position: absolute; left: 0; bottom: 34px; transform: translate(-50%, 6px);
  display: flex; flex-direction: column; gap: 3px; align-items: center;
  padding: 8px 12px; border-radius: 6px; white-space: nowrap;
  background: rgba(10, 8, 12, .88); border: 1px solid rgba(217, 176, 74, .35);
  font-size: 13px; color: var(--paper); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.tl-tip b { font-family: var(--brush); font-weight: 400; font-size: 17px; color: var(--gold); }
body[data-lang="en"] .tl-tip b { font-family: var(--serif-en); font-size: 15px; }
.tl-tip span { color: var(--paper-dim); font-style: italic; font-size: 12px; }
.talisman:hover .tl-tip, .talisman:focus-visible .tl-tip { opacity: 1; transform: translate(-50%, 0); }
.talisman.is-cracking .paper::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 44%, rgba(255, 235, 170, .95) 48%, transparent 52%);
  clip-path: polygon(40% 0, 58% 22%, 44% 40%, 62% 63%, 46% 82%, 56% 100%, 52% 100%, 42% 82%, 58% 63%, 40% 40%, 54% 22%, 36% 0);
  filter: drop-shadow(0 0 6px rgba(255, 220, 140, .9));
  animation: crackPulse 2.2s ease-in-out infinite;
}
@keyframes crackPulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* ---- story markers ---- */
.marker {
  position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none;
  opacity: 0; pointer-events: none; transition: opacity .9s ease;
}
.marker.is-found { opacity: 1; pointer-events: auto; cursor: pointer; }
.m-lamp {
  position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle, #fff0c8 0 18%, #ffa64a 42%, rgba(255, 120, 40, 0) 70%);
  box-shadow: 0 0 22px 8px rgba(255, 150, 60, .42);
  animation: lampFlicker 2.4s infinite;
}
.m-seal {
  position: absolute; left: 0; bottom: 13px; transform: translateX(-50%);
  writing-mode: vertical-rl; white-space: nowrap;
  padding: 7px 3px; min-height: 40px;
  font-family: var(--brush); font-size: 19px; line-height: 1; letter-spacing: .12em;
  color: var(--cinnabar);
  background: rgba(241, 230, 204, .94);
  border: 2px solid var(--cinnabar);
  box-shadow: 0 0 0 2px rgba(241, 230, 204, .5), 0 6px 14px rgba(0, 0, 0, .5);
  transition: transform .25s ease, background .4s ease, color .4s ease;
}
.marker.is-read .m-seal { background: var(--cinnabar); color: #f6e8ca; box-shadow: 0 0 0 2px rgba(246, 232, 202, .45), 0 6px 14px rgba(0, 0, 0, .5); }
.marker:hover .m-seal, .marker:focus-visible .m-seal { transform: translateX(-50%) translateY(-4px) scale(1.08); }
.m-cap {
  position: absolute; left: 0; top: 14px; transform: translateX(-50%);
  white-space: nowrap; font-family: var(--serif-en); font-style: italic; font-size: 14px;
  color: #f4e6c4; text-shadow: 0 1px 4px #000, 0 0 2px #000;
}
.m-cap:empty { display: none; }
.marker.just-found .m-seal { animation: sealIn 1.3s var(--ease-out); }
.marker.just-found .m-lamp { animation: lampBurst 1.3s ease-out; }
@keyframes sealIn {
  0% { opacity: 0; filter: blur(10px); transform: translateX(-50%) translateY(10px) scale(1.5); }
  100% { opacity: 1; filter: blur(0); transform: translateX(-50%); }
}
@keyframes lampBurst {
  0% { box-shadow: 0 0 0 0 rgba(160, 255, 220, .9); }
  100% { box-shadow: 0 0 60px 40px rgba(160, 255, 220, 0); }
}

/* ================================================================ HUD */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 18px 30px;
  background: linear-gradient(rgba(5, 4, 7, .78), rgba(5, 4, 7, 0));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.brand { font-family: var(--brush); font-size: 28px; line-height: 1; letter-spacing: .18em; color: var(--paper); }
.shichen { margin-top: 5px; font-size: 12px; letter-spacing: .2em; color: var(--paper-dim); }
body[data-lang="en"] .shichen { letter-spacing: .04em; font-style: italic; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6px; }
.progress-seals { display: flex; gap: 6px; }
.progress-seals i {
  width: 11px; height: 11px; border: 1px solid rgba(239, 227, 198, .3); transform: rotate(45deg);
  transition: background .4s ease, border-color .4s ease;
}
.progress-seals i.is-found { border-color: var(--cinnabar-bright); }
.progress-seals i.is-read { background: var(--cinnabar-bright); border-color: var(--cinnabar-bright); box-shadow: 0 0 8px rgba(216, 67, 44, .6); }
.progress-label { font-size: 12px; letter-spacing: .15em; color: var(--paper-dim); }
.hud-right { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.hud-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 13px 0 6px; cursor: pointer;
  border: 1px solid rgba(239, 227, 198, .22); border-radius: 18px;
  background: rgba(12, 10, 14, .6); backdrop-filter: blur(4px);
  font-size: 13px; letter-spacing: .08em;
  transition: border-color .25s ease, background .25s ease;
}
.hud-btn:hover { border-color: rgba(239, 227, 198, .55); background: rgba(30, 22, 18, .75); }
.hud-btn .ico {
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--brush); font-size: 15px; color: #f6e8ca; background: var(--cinnabar);
}
#btn-light[aria-pressed="false"] .ico, #btn-sound[aria-pressed="false"] .ico { background: #4a4540; color: #cfc4ac; }
#btn-light[aria-pressed="true"] { border-color: rgba(255, 190, 110, .6); box-shadow: 0 0 18px rgba(255, 150, 60, .3); }

.hint {
  position: absolute; left: 50%; bottom: 30px; z-index: 11;
  transform: translate(-50%, 10px);
  max-width: calc(100vw - 32px); padding: 11px 22px; border-radius: 999px;
  background: rgba(8, 7, 10, .62); border: 1px solid rgba(239, 227, 198, .14);
  font-size: 15px; letter-spacing: .12em; text-align: center; color: var(--paper);
  opacity: 0; pointer-events: none; transition: opacity .6s ease, transform .6s ease;
}
body[data-lang="en"] .hint { letter-spacing: .02em; font-style: italic; font-size: 17px; }
.hint.is-on { opacity: 1; transform: translate(-50%, 0); }

.toast {
  position: absolute; left: 50%; top: 82px; z-index: 11;
  transform: translate(-50%, -8px);
  max-width: calc(100vw - 32px); padding: 9px 18px;
  background: rgba(241, 230, 204, .95); color: var(--ink);
  border-left: 4px solid var(--cinnabar); box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  font-size: 15px; letter-spacing: .06em;
  opacity: 0; pointer-events: none; transition: opacity .35s ease, transform .35s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.whisper {
  position: absolute; transform: translate(-50%, -50%);
  writing-mode: vertical-rl; white-space: nowrap;
  font-family: var(--brush); font-size: 23px; letter-spacing: .25em;
  color: rgba(190, 255, 228, .62);
  text-shadow: 0 0 12px rgba(120, 255, 200, .55);
  opacity: 0; animation: whisper 7s ease forwards;
}
@keyframes whisper {
  0% { opacity: 0; filter: blur(8px); margin-top: 14px; }
  25% { opacity: .75; filter: blur(0); }
  65% { opacity: .55; }
  100% { opacity: 0; filter: blur(6px); margin-top: -26px; }
}

.hovercard {
  position: fixed; z-index: 12; left: 0; top: 0;
  display: flex; gap: 10px; width: 236px; padding: 8px;
  transform: translate(-50%, calc(-100% - 70px)) scale(.96);
  background: rgba(241, 230, 204, .97); color: var(--ink);
  border: 1px solid rgba(80, 50, 20, .35);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.hovercard.below { transform: translate(-50%, 40px) scale(.96); }
.hovercard.is-on { opacity: 1; transform: translate(-50%, calc(-100% - 70px)); }
.hovercard.below.is-on { transform: translate(-50%, 40px); }
.hc-img { width: 74px; height: 100px; flex: none; overflow: hidden; background: #e2d4b4; }
.hc-img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; transform: scale(1.5); transform-origin: 50% 0; }
.hc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hc-kind {
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--brush); font-size: 14px; background: var(--ink); color: var(--paper);
}
.hc-name { font-family: var(--brush); font-size: 24px; line-height: 1.1; }
.hc-en { font-family: var(--serif-en); font-style: italic; font-size: 14px; color: var(--ink-soft); line-height: 1.25; }
.hc-peril { font-size: 12px; color: var(--cinnabar); letter-spacing: .1em; margin-top: auto; }

/* ================================================================ TRANSITION */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 35; pointer-events: none; }
#veil {
  position: fixed; inset: 0; z-index: 34; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(10, 30, 26, .55), #050407 62%);
  opacity: 0; transition-property: opacity; transition-timing-function: ease;
}
#veil.is-on { opacity: 1; }

/* ================================================================ STORY */
.story {
  position: fixed; inset: 0; z-index: 30;
  background:
    radial-gradient(ellipse 70% 80% at 32% 50%, rgba(70, 48, 32, .55), transparent 70%),
    radial-gradient(ellipse at 50% 50%, #120e0b, #050407 75%);
  opacity: 0; transition: opacity .55s ease;
  overflow: hidden;
}
.story.is-on { opacity: 1; }
.story-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.story-glyph {
  position: absolute; right: -2vw; top: 50%;
  transform: translate(calc(var(--mx, 0) * 34px), calc(-50% + var(--my, 0) * 24px));
  font-family: var(--brush); font-size: min(78vh, 62vw); line-height: 1;
  color: rgba(179, 38, 30, .085);
  transition: transform .4s ease-out;
}
.story-layout {
  position: relative; height: 100%;
  display: grid; grid-template-columns: auto minmax(0, 600px);
  justify-content: center; align-items: center;
  gap: clamp(28px, 5vw, 92px);
  padding: 58px clamp(16px, 4vw, 64px) 28px;
}

/* hanging scroll */
.hanging {
  position: relative;
  width: min(36vw, calc((100vh - 150px) * .58));
  transform: translate(calc(var(--mx, 0) * -14px), calc(var(--my, 0) * -10px));
  transition: transform .35s ease-out;
  filter: drop-shadow(0 30px 40px rgba(0, 0, 0, .6));
}
.rod { position: relative; z-index: 2; }
.rod-top {
  height: 13px; border-radius: 3px;
  background: linear-gradient(#3a2414, #7a4e2c 45%, #2a170c);
}
.rod-top::before {
  content: ''; position: absolute; left: 50%; top: -26px; width: 2px; height: 26px; transform: translateX(-50%);
  background: #7a5a36;
}
.rod-top::after {
  content: ''; position: absolute; left: 50%; top: -32px; width: 10px; height: 10px; border-radius: 50%; transform: translateX(-50%);
  background: radial-gradient(circle at 35% 35%, #d6c7a6, #6b5a40);
}
.rod-top i { display: none; }
.mount {
  position: relative;
  padding: 10% 7.5% 13%;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, .035) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, #cdb88f, #bfa678 50%, #c8b286);
  box-shadow: inset 0 0 0 5px #b59a68, inset 0 0 0 6px rgba(90, 60, 30, .35), inset 0 0 50px rgba(80, 50, 20, .25);
  clip-path: inset(0 0 100% 0);
}
.mount::before {
  /* the title slip, 题签 */
  content: attr(data-title);
  position: absolute; z-index: 2; right: 10.5%; top: 12.5%;
  writing-mode: vertical-rl;
  padding: 12px 5px; min-height: 22%;
  font-family: var(--brush); font-size: clamp(18px, 2.2vw, 30px); letter-spacing: .2em; line-height: 1;
  color: var(--ink); background: #f3ead6;
  border: 1px solid rgba(80, 50, 20, .25);
  box-shadow: 0 2px 6px rgba(60, 40, 20, .25);
}
.painting {
  position: relative; aspect-ratio: 2 / 3; overflow: hidden;
  background: #efe3c8;
  box-shadow: 0 0 0 1px rgba(60, 40, 20, .45), inset 0 0 50px rgba(90, 60, 25, .28);
}
.painting img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transform-origin: 50% 85%;
  animation: breathe 7s ease-in-out infinite;
}
.painting::after {
  /* aged paper toning on top of the painting */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(110, 70, 30, .22));
  mix-blend-mode: multiply;
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.014) translateY(-.4%); } }
.ghost-sheen {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(160, 255, 220, .22) 50%, transparent 62%);
  mix-blend-mode: screen; transform: translateX(-130%);
  animation: sheen 9s ease-in-out 1.6s infinite;
}
@keyframes sheen { 0% { transform: translateX(-130%); } 35%, 100% { transform: translateX(130%); } }
.story[data-kind="ghost"] .painting, .story[data-kind="corpse"] .painting, .story[data-kind="soul"] .painting {
  animation: haunt 7.3s steps(1) infinite;
}
@keyframes haunt {
  0%, 57%, 59.5%, 83%, 84.2%, 100% { filter: none; }
  58% { filter: hue-rotate(-25deg) contrast(1.15) brightness(.92); }
  58.8% { filter: blur(1px) brightness(1.08); }
  83.6% { filter: invert(.06) hue-rotate(30deg); }
}
.rod-bottom {
  height: 20px; width: calc(100% + 26px); margin-left: -13px; border-radius: 4px;
  background: linear-gradient(#3e2514, #85552f 45%, #2a170c);
  transform: translateY(calc(-1 * var(--mount-h, 600px)));
}
.rod-bottom::before, .rod-bottom::after {
  content: ''; position: absolute; top: -4px; width: 20px; height: 28px; border-radius: 6px;
  background: radial-gradient(circle at 35% 30%, #f6efdf, #b9a27a 70%, #8a7552);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.rod-bottom::before { left: -16px; }
.rod-bottom::after { right: -16px; }
.hanging.is-unrolled .mount { clip-path: inset(0 0 0 0); transition: clip-path 1.25s cubic-bezier(.3, .75, .25, 1) .12s; }
.hanging.is-unrolled .rod-bottom { transform: none; transition: transform 1.25s cubic-bezier(.3, .75, .25, 1) .12s; }
.hanging.is-rolling .mount { clip-path: inset(0 0 100% 0); transition: clip-path .34s ease-in; }
.hanging.is-rolling .rod-bottom { transform: translateY(calc(-1 * var(--mount-h, 600px))); transition: transform .34s ease-in; }

.collect-seal {
  position: absolute; z-index: 3; left: 11%; bottom: 15%;
  width: 62px; height: 62px; display: grid; place-items: center;
  writing-mode: vertical-rl;
  font-family: var(--brush); font-size: 23px; line-height: 1; letter-spacing: .05em;
  color: #f4e5c4; background: var(--cinnabar);
  border-radius: 5px; transform: rotate(-9deg);
  box-shadow: inset 0 0 0 2px rgba(244, 229, 196, .55);
  filter: url(#f-ink);
  opacity: 0; mix-blend-mode: multiply;
}
.collect-seal.is-on { opacity: .9; }
.collect-seal.is-stamping { animation: stamp .55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes stamp {
  0% { opacity: 0; transform: rotate(-9deg) scale(2.8); }
  55% { opacity: .95; }
  100% { opacity: .9; transform: rotate(-9deg) scale(1); }
}

/* story text */
.story-text {
  max-height: calc(100vh - 110px); overflow-y: auto;
  padding: 6px 12px 6px 2px;
  transform: translate(calc(var(--mx, 0) * 6px), calc(var(--my, 0) * 4px));
  transition: opacity .35s ease, transform .35s ease-out;
  scrollbar-width: thin; scrollbar-color: rgba(216, 67, 44, .55) transparent;
}
.story-text.is-fading { opacity: 0; }
.story-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; letter-spacing: .14em; color: var(--paper-dim); }
body[data-lang="en"] .story-meta { letter-spacing: .04em; font-size: 15px; }
.story-meta .dot { opacity: .5; }
.peril b { color: var(--cinnabar-bright); font-weight: 400; letter-spacing: .05em; }
.story-name {
  margin: 12px 0 4px;
  font-family: var(--brush); font-weight: 400;
  font-size: clamp(44px, 5.6vw, 78px); line-height: 1.05;
  color: #f4e7ca; text-shadow: 0 0 40px rgba(255, 150, 80, .16);
}
body[data-lang="en"] .story-name { font-family: var(--serif-en); font-size: clamp(34px, 4vw, 56px); line-height: 1.08; }
.story-name-sub { font-family: var(--serif-en); font-style: italic; font-size: 19px; color: var(--cinnabar-bright); }
body[data-lang="en"] .story-name-sub { font-family: var(--brush); font-style: normal; font-size: 24px; letter-spacing: .15em; }

.classic {
  display: flex; gap: 20px; align-items: flex-start;
  margin: 22px 0 20px; padding: 18px 0;
  border-top: 1px solid rgba(239, 227, 198, .14);
  border-bottom: 1px solid rgba(239, 227, 198, .14);
}
.classic-zh {
  flex: none; margin: 0;
  writing-mode: vertical-rl; height: 14em;
  padding-left: 14px; border-left: 2px solid var(--cinnabar);
  font-family: var(--serif-zh); font-size: 17px; line-height: 1.95; letter-spacing: .14em;
  color: #eadcbb;
}
.classic figcaption { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; min-height: 14em; }
body[data-lang="zh"] .classic figcaption { min-height: 0; align-self: flex-end; }
.classic-en { margin: 0; font-family: var(--serif-en); font-style: italic; font-size: 16.5px; line-height: 1.55; color: #d6c7a3; }
.classic-en:empty { display: none; }
.classic cite { display: block; margin-top: 10px; font-style: normal; font-size: 13px; letter-spacing: .08em; color: var(--paper-dim); }

.tale p {
  margin: 0 0 1.05em;
  font-size: 17px; line-height: 2; color: #efe3c6;
  opacity: 0;
}
body[data-lang="en"] .tale p { font-size: 19.5px; line-height: 1.6; }
.tale p:first-child::first-letter {
  float: left; margin: 6px 10px 0 0;
  font-family: var(--brush); font-size: 2.5em; line-height: .9; color: var(--cinnabar-bright);
}
body[data-lang="en"] .tale p:first-child::first-letter { font-family: var(--serif-en); font-size: 3.1em; margin-top: 4px; }
.tale.is-in p { animation: inkP 1s ease forwards; animation-delay: calc(1s + var(--i) * .38s); }
@keyframes inkP {
  0% { opacity: 0; filter: blur(5px); transform: translateY(8px); }
  100% { opacity: 1; filter: blur(0); transform: none; }
}

.story-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.nav-btn {
  height: 40px; padding: 0 18px; cursor: pointer;
  border: 1px solid rgba(239, 227, 198, .25); border-radius: 20px;
  background: rgba(20, 16, 14, .6); font-size: 14px; letter-spacing: .1em;
  transition: border-color .2s ease, background .2s ease;
}
.nav-btn:hover:not(:disabled) { border-color: rgba(239, 227, 198, .6); background: rgba(40, 30, 24, .8); }
.nav-btn:disabled { opacity: .35; cursor: default; }
.nav-back { border-color: rgba(216, 67, 44, .6); }
.story-tools { position: absolute; top: 14px; right: 16px; z-index: 2; display: flex; gap: 8px; }
.story-lang {
  height: 40px; min-width: 40px; padding: 0 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid rgba(239, 227, 198, .25); background: rgba(10, 8, 12, .6);
  font-family: var(--brush); font-size: 17px;
}
body[data-lang="zh"] .story-lang { font-family: var(--serif-en); font-size: 15px; }
.story-lang:hover { border-color: rgba(239, 227, 198, .6); }
.story-x {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(239, 227, 198, .25); background: rgba(10, 8, 12, .6);
  font-size: 16px;
}
.story-x:hover { border-color: rgba(239, 227, 198, .6); }

/* ================================================================ CODEX */
.codex {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(580px, 100vw); overflow-y: auto;
  padding: 22px 22px 40px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 250, 235, .6), transparent 60%),
    linear-gradient(180deg, #e9ddc0, #dccca7);
  box-shadow: -24px 0 70px rgba(0, 0, 0, .65);
  transform: translateX(105%); transition: transform .45s var(--ease-out);
}
.codex.is-on { transform: none; }
.codex-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.codex-head h2 { margin: 0; font-family: var(--brush); font-weight: 400; font-size: 36px; letter-spacing: .12em; }
body[data-lang="en"] .codex-head h2 { font-family: var(--serif-en); font-size: 30px; letter-spacing: 0; }
.codex-x {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(60, 40, 20, .3); background: rgba(255, 255, 255, .3); color: var(--ink);
}
.codex-note { margin: 6px 0 18px; color: var(--ink-soft); font-size: 14px; letter-spacing: .08em; }
body[data-lang="en"] .codex-note { font-style: italic; font-size: 16px; letter-spacing: 0; }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 8px 8px 10px; text-align: left; cursor: pointer;
  background: #f3eadb; color: var(--ink);
  border: 1px solid rgba(80, 50, 20, .22);
  box-shadow: 0 2px 8px rgba(60, 40, 20, .14);
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(60, 40, 20, .22); }
.card-img { display: block; aspect-ratio: 2 / 3; overflow: hidden; background: #2a2420; margin-bottom: 6px; }
.card-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: filter .4s ease; }
.card.is-hidden .card-img img { filter: grayscale(1) brightness(.28) blur(7px); transform: scale(1.1); }
.card.is-found .card-img img { filter: grayscale(.8) sepia(.35) brightness(.95); }
.card-kind {
  position: absolute; top: 13px; left: 13px;
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--brush); font-size: 15px; background: var(--ink); color: var(--paper);
}
.card-name { font-family: var(--brush); font-size: 21px; line-height: 1.15; }
body[data-lang="en"] .card-name { font-family: var(--serif-en); font-size: 16px; }
.card.is-hidden .card-name { color: #8a7a62; letter-spacing: .2em; }
.card-sub { font-size: 12px; color: #6e5c45; line-height: 1.35; }
.card-seal {
  position: absolute; right: 14px; bottom: 62px;
  width: 34px; height: 34px; display: grid; place-items: center;
  font-family: var(--brush); font-size: 19px; color: #f4e5c4; background: var(--cinnabar);
  border-radius: 3px; transform: rotate(-10deg); opacity: 0; filter: url(#f-ink);
}
.card.is-read .card-seal { opacity: .92; }

/* ================================================================ FINALE */
.finale {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 50%, rgba(30, 20, 14, .92), rgba(4, 3, 6, .97));
  opacity: 0; transition: opacity .8s ease;
}
.finale.is-on { opacity: 1; }
.finale-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.finale-zh { margin: 0; font-family: var(--brush); font-size: clamp(30px, 5vw, 52px); color: #f1e4c6; letter-spacing: .12em; }
.finale-en { margin: 6px 0 14px; max-width: 520px; font-family: var(--serif-en); font-style: italic; font-size: 19px; color: var(--paper-dim); }
.finale-en:empty { display: none; }

/* ================================================================ RESPONSIVE */
@media (max-width: 880px) {
  .story { overflow-y: auto; }
  .story-layout { height: auto; min-height: 100%; grid-template-columns: 1fr; align-items: start; gap: 26px; padding-top: 68px; }
  .hanging { width: min(70vw, 46vh); margin: 0 auto; }
  .story-text { max-height: none; overflow: visible; padding: 0 2px 30px; }
  .story-glyph { font-size: 90vw; top: 30%; }
}
@media (max-width: 720px) {
  .hud { padding: 10px 10px 24px; }
  .brand { font-size: 22px; }
  .hud-btn { padding: 0 5px; gap: 0; }
  .hud-btn > span:not(.ico) { display: none; }
  .hud-center { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); padding: 0; }
  .progress-seals { gap: 4px; }
  .progress-seals i { width: 8px; height: 8px; }
  .toast { top: 100px; }
  .intro-seal { top: 6px; right: 10px; width: 48px; height: 48px; font-size: 16px; }
  .flash.left { left: 6vw; } .flash.right { right: 6vw; }
  .flash { height: 52vh; }
  .flash-text { font-size: 24px; }
  .handscroll { left: 0; right: 0; height: 40vh; }
  .classic { flex-direction: column; }
  .classic-zh { height: auto; max-height: 16em; writing-mode: horizontal-tb; border-left: 0; border-top: 2px solid var(--cinnabar); padding: 10px 0 0; }
  .classic figcaption { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .1s !important; }
  #mist { animation: none; }
  .intro-title span, .intro-sub, .intro-lede, .btn-seal, .lang-row, .link-btn, .intro-seal, .gate-mark, .gate-line { opacity: 1; }
  .tale p { opacity: 1; }
}

/* zero-size map buttons: draw the focus ring on their visible part */
.china-gate:focus-visible, .talisman:focus-visible, .marker:focus-visible { outline: none; }
.china-gate:focus-visible .gate-seal,
.talisman:focus-visible .paper,
.marker:focus-visible .m-seal { outline: 2px solid var(--gold); outline-offset: 4px; }
