/* ============================================================================
 * Choose Wisely — storybook styling. Engine-agnostic, no platform assets.
 * ========================================================================== */
:root {
  --ink: #f4ecd8;
  --ink-dim: #c9bfa6;
  --panel: rgba(28, 22, 34, 0.86);
  --panel-edge: rgba(255, 220, 150, 0.25);
  --gold: #ffcf7a;
  --gold-strong: #ffb347;
  --good: #7be08a;
  --bad: #ff7b7b;
  --funny: #ffd166;
  --cursed: #ff8a5c;
  --secret: #c79bff;
  --true: #8ad7ff;
  --nightmare: #b0304a;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-ui: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font-body); color: var(--ink); background: #0c0910; overflow: hidden; }

/* ---- scene background ---------------------------------------------------- */
.scene { position: fixed; inset: 0; z-index: 0; transition: background 1.2s ease; background: radial-gradient(120% 100% at 50% 0%, #2a2036 0%, #140f1c 70%, #0b0810 100%); }
.scene .vignette { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, transparent 40%, rgba(0,0,0,0.55) 100%); pointer-events: none; }
.scene .particles {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,220,160,0.6), transparent),
    radial-gradient(2px 2px at 70% 60%, rgba(255,220,160,0.4), transparent),
    radial-gradient(1.5px 1.5px at 45% 80%, rgba(255,220,160,0.5), transparent),
    radial-gradient(1.5px 1.5px at 85% 25%, rgba(255,220,160,0.35), transparent),
    radial-gradient(2px 2px at 30% 70%, rgba(255,220,160,0.4), transparent);
  animation: drift 18s linear infinite; opacity: 0.7;
}
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-40px); } }
.theme-street  { background: radial-gradient(120% 100% at 50% -10%, #35415e 0%, #1a2036 60%, #0d1120 100%); }
.theme-shop    { background: radial-gradient(120% 100% at 50% 0%, #4a3420 0%, #2a1d16 60%, #140d0b 100%); }
.theme-teddy   { background: radial-gradient(120% 100% at 50% 0%, #5a3b1e 0%, #2f1e14 60%, #170f0b 100%); }
.theme-candle  { background: radial-gradient(120% 100% at 50% 10%, #6a3a12 0%, #341a0c 60%, #170c07 100%); }
.theme-balloon { background: radial-gradient(120% 100% at 50% 0%, #3a3a72 0%, #241f4a 60%, #120f28 100%); }
.theme-dragon  { background: radial-gradient(120% 100% at 50% 5%, #5e2a1c 0%, #331512 60%, #180a09 100%); }
.theme-party   { background: radial-gradient(120% 100% at 50% 0%, #5e4a1e 0%, #34260f 60%, #171008 100%); }
.theme-secret  { background: radial-gradient(120% 100% at 50% 0%, #3d2a5e 0%, #221534 60%, #100a1c 100%); }

/* ---- living scene art ---------------------------------------------------- */
.scene-image { position: absolute; inset: 0; z-index: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity 1s ease; }
.scene-image.shown { opacity: 1; animation: sceneFade 1s ease; }
.scene.has-image .scene-art { display: none; }
.scene-art { position: absolute; inset: 0; z-index: 1; }
/* Living video layer: sits over the still (its poster/fallback), fades in when it
   can play. Falls back to the still under reduce-motion or if the clip fails. */
.scene-video { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.1s ease; pointer-events: none; }
.scene-video.shown { opacity: 1; }
#scene-video { transition: opacity 1.1s ease, filter 2s ease; }
body[data-dread="1"] #scene-video { filter: saturate(0.8) brightness(0.92) contrast(1.03); }
body[data-dread="2"] #scene-video { filter: saturate(0.66) brightness(0.85) contrast(1.06); }
body[data-dread="3"] #scene-video { filter: saturate(0.42) brightness(0.7) contrast(1.16) hue-rotate(-10deg); }
body[data-dread="4"] #scene-video { filter: saturate(0.16) brightness(0.46) contrast(1.4) hue-rotate(-18deg) sepia(0.28); }
.scene-svg { width: 100%; height: 100%; display: block; animation: sceneFade 0.8s ease; }
.scene .particles { opacity: 0.4; z-index: 2; }
.scene .vignette { z-index: 3; }
@keyframes sceneFade { from { opacity: 0; } to { opacity: 1; } }

/* scene motion */
@keyframes sRain   { from { transform: translateY(0); } to { transform: translateY(600px); } }
@keyframes sFlame  { 0%,100% { transform: scaleY(1) scaleX(1); opacity: .95; } 50% { transform: scaleY(1.14) scaleX(.9); opacity: 1; } }
@keyframes sFlick  { 0%,100% { opacity: .92; } 45% { opacity: .5; } 70% { opacity: 1; } }
@keyframes sFloat  { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes sSpin   { to { transform: rotate(360deg); } }
@keyframes sTwinkle{ 0%,100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes sRise   { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: .8; } 100% { transform: translateY(-170px); opacity: 0; } }
@keyframes sBreathe{ 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes sSway   { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes sDriftR { 0% { transform: translateX(-40px); } 100% { transform: translateX(40px); } }
@keyframes sDriftL { 0% { transform: translateX(40px); } 100% { transform: translateX(-40px); } }
@keyframes sFall   { 0% { transform: translateY(-20px) rotate(0); opacity: 0; } 10% { opacity: .85; } 100% { transform: translateY(340px) rotate(240deg); opacity: 0; } }
.scene-svg .rain     { animation: sRain 1.1s linear infinite; }
.scene-svg .flame    { animation: sFlame .5s ease-in-out infinite; }
.scene-svg .flick    { animation: sFlick 2.6s ease-in-out infinite; }
.scene-svg .float    { animation: sFloat 4s ease-in-out infinite; }
.scene-svg .spin     { animation: sSpin 9s linear infinite; }
.scene-svg .spin-rev { animation: sSpin 7s linear infinite reverse; }
.scene-svg .twinkle  { animation: sTwinkle 3s ease-in-out infinite; }
.scene-svg .rise     { animation: sRise 6s linear infinite; }
.scene-svg .rise-slow{ animation: sRise 10s linear infinite; }
.scene-svg .breathe  { animation: sBreathe 4.5s ease-in-out infinite; }
.scene-svg .sway     { animation: sSway 3.6s ease-in-out infinite; }
.scene-svg .drift-r  { animation: sDriftR 18s ease-in-out infinite alternate; }
.scene-svg .drift-l  { animation: sDriftL 22s ease-in-out infinite alternate; }
.scene-svg .fall     { animation: sFall 5s linear infinite; }
body.reduce-motion .scene-svg, body.reduce-motion .scene-svg * { animation: none !important; }

/* ---- location caption ---------------------------------------------------- */
.scene-caption {
  position: fixed; top: 56px; left: 18px; z-index: 15;
  font-family: var(--font-ui); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--ink-dim); background: rgba(0,0,0,0.35); border: 1px solid var(--panel-edge);
  border-radius: 999px; padding: 5px 12px; backdrop-filter: blur(4px); pointer-events: none;
}
.scene-caption:empty { display: none; }

/* ---- character layer ----------------------------------------------------- */
/* Top band so full figures read above the dialogue plate (not behind it). */
.characters { position: fixed; top: 40px; left: 0; right: 0; height: 56vh; z-index: 6; pointer-events: none; }
#char-svg { width: 100%; height: 100%; display: block; }
.char.in  { animation: charIn 0.5s ease; }
.char.out { animation: charOut 0.38s ease forwards; }
.char .fig { transform-box: fill-box; transform-origin: bottom center; animation: charBreathe 4.6s ease-in-out infinite; }
.char .fig.floaty { transform-origin: center; animation: charFloatFig 3.6s ease-in-out infinite; }
.char .fig.loom   { animation: charLoom 5s ease-in-out infinite; }
.char .fig.march  { animation: charMarch 0.9s ease-in-out infinite; }
.char.speaking { filter: drop-shadow(0 0 9px rgba(255,220,150,0.8)); }
.char.speaking .fig        { animation: charTalk 0.55s ease-in-out infinite; }
.char.speaking .fig.floaty { animation: charTalkFloat 0.6s ease-in-out infinite; }
#char-svg .flame2 { transform-box: fill-box; transform-origin: center bottom; animation: sFlame 0.5s ease-in-out infinite; }
#char-svg .spin2  { animation: sSpin 6s linear infinite; }
#char-svg .km-shadow { animation: kmFlick 3.2s ease-in-out infinite; }
@keyframes charIn        { 0% { opacity: 0; transform: translateY(26px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes charOut       { to { opacity: 0; transform: translateY(14px); } }
@keyframes charBreathe   { 0%,100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-3px) scaleY(1.015); } }
@keyframes charFloatFig  { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes charLoom      { 0%,100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-4px) scaleY(1.03); } }
@keyframes charMarch     { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes charTalk      { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes charTalkFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes kmFlick       { 0%,100% { opacity: 0.95; } 50% { opacity: 0.5; } }
body.reduce-motion .characters, body.reduce-motion #char-svg * { animation: none !important; }

/* the shopkeeper leans in and looms taller whenever he is the one speaking */
#char-svg [data-char="shopkeeper"] { transition: transform 0.7s cubic-bezier(.2,.8,.2,1); transform-box: fill-box; transform-origin: bottom center; }
#char-svg [data-char="shopkeeper"].speaking { transform: translateX(-30px) translateY(-8px) scale(1.08); }
/* a character re-posing in place (same actor, new beat) settles in softly */
#char-svg .char.reposed { animation: charRepose 0.42s ease; }
@keyframes charRepose { 0% { opacity: 0.3; transform: translateY(7px); } 100% { opacity: 1; transform: translateY(0); } }
body.reduce-motion #char-svg [data-char="shopkeeper"] { transition: none; }

/* ---- the descent: dread levels ------------------------------------------ */
.dread-overlay {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  transition: opacity 1.6s ease, background 1.6s ease;
  background: radial-gradient(120% 100% at 50% 40%, transparent 30%, rgba(60,0,0,0.25) 80%, rgba(20,0,0,0.6) 100%);
}
#scene-art, #scene-image, #char-svg { transition: filter 2s ease; }
.story-panel, .story-text, .node-title, .speaker, .scene .particles { transition: color 1.6s ease, border-color 1.6s ease, background 1.6s ease, filter 1.6s ease; }

body[data-dread="1"] #scene-art, body[data-dread="1"] #scene-image { filter: saturate(0.8) brightness(0.92) contrast(1.03); }
body[data-dread="1"] #char-svg { filter: saturate(0.86) brightness(0.94); }
body[data-dread="2"] #scene-art, body[data-dread="2"] #scene-image { filter: saturate(0.66) brightness(0.85) contrast(1.06); }
body[data-dread="3"] #scene-art, body[data-dread="3"] #scene-image { filter: saturate(0.42) brightness(0.7) contrast(1.16) hue-rotate(-10deg); }
body[data-dread="4"] #scene-art, body[data-dread="4"] #scene-image { filter: saturate(0.2) brightness(0.52) contrast(1.34) hue-rotate(-16deg); }
body[data-dread="4"] #scene-art { animation: dreadBreathe 9s ease-in-out infinite; transform-origin: center; }
body[data-dread="2"] #char-svg { filter: saturate(0.7) brightness(0.9); }
body[data-dread="3"] #char-svg { filter: saturate(0.45) brightness(0.74) contrast(1.1); }
body[data-dread="4"] #char-svg { filter: saturate(0.2) brightness(0.54) contrast(1.25); }

body[data-dread="1"] .dread-overlay { opacity: 0.32; }
body[data-dread="2"] .dread-overlay { opacity: 0.5; }
body[data-dread="3"] .dread-overlay { opacity: 0.82; background: radial-gradient(120% 100% at 50% 40%, transparent 18%, rgba(80,0,0,0.36) 68%, rgba(14,0,0,0.78) 100%); }
body[data-dread="4"] .dread-overlay { opacity: 1; background: radial-gradient(120% 90% at 50% 46%, transparent 6%, rgba(92,0,0,0.5) 58%, rgba(6,0,0,0.93) 100%); animation: dreadPulse 1.5s ease-in-out infinite; }
@keyframes dreadPulse { 0%,100% { opacity: 0.8; } 50% { opacity: 1; } }
@keyframes dreadBreathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }

body[data-dread="3"] .scene .particles, body[data-dread="4"] .scene .particles { filter: hue-rotate(-40deg) saturate(2.2) brightness(0.7); opacity: 0.55; }

body[data-dread="1"] .story-panel { border-top-color: rgba(200,150,120,0.32); }
body[data-dread="2"] .story-panel { border-top-color: rgba(220,120,90,0.5); }
body[data-dread="3"] .story-panel { border-top-color: rgba(200,50,50,0.7); background: linear-gradient(to bottom, rgba(26,14,16,0.86), rgba(13,6,8,0.96)); }
body[data-dread="4"] .story-panel { border-top-color: rgba(210,20,20,0.9); border-color: rgba(120,20,20,0.5); background: linear-gradient(to bottom, rgba(24,10,12,0.9), rgba(10,4,6,0.97)); box-shadow: var(--shadow), 0 -10px 50px rgba(90,0,0,0.5); }
body[data-dread="3"] .story-text { color: #e7d3cf; }
body[data-dread="4"] .story-text { color: #eccccc; text-shadow: 0 0 6px rgba(180,20,20,0.35); animation: dreadShake 7s ease-in-out infinite; }
@keyframes dreadShake { 0%,90%,100% { transform: translateX(0); } 93% { transform: translateX(-1px); } 95% { transform: translateX(1.5px); } 97% { transform: translateX(-1px); } }
body[data-dread="4"] .node-title { color: #d05a5a; }
body[data-dread="4"] .speaker { color: #d76b6b; }
body[data-dread="3"] .char.speaking { filter: drop-shadow(0 0 9px rgba(255,120,90,0.85)); }
body[data-dread="4"] .char.speaking { filter: drop-shadow(0 0 12px rgba(230,40,40,0.9)); }

body.reduce-motion .dread-overlay, body.reduce-motion #scene-art, body.reduce-motion .story-text { animation: none !important; }

/* ---- character corruption (rises with dread + haunt) --------------------- */
.char .corrupt { opacity: 0; transition: opacity 1.6s ease; }
body[data-dread="1"] .char .corrupt { opacity: 0.08; } /* the doorway: a barely-there wrongness */
body[data-dread="2"] .char .corrupt { opacity: 0.2; }
body[data-dread="3"] .char .corrupt { opacity: 0.6; }
body[data-dread="4"] .char .corrupt { opacity: 1; }
/* persistent haunt shows corruption even before a run gets deep */
body[data-haunt="2"] .char .corrupt { opacity: 0.35; }
body[data-haunt="3"] .char .corrupt { opacity: 0.7; }
body[data-haunt="4"] .char .corrupt { opacity: 1; }
/* the shopkeeper's shadow detaches and the boy's second shadow drifts on its own */
.char .detach-shadow  { transform-box: fill-box; transform-origin: center; animation: detachDrift 6s ease-in-out infinite; }
.char .detach-shadow2 { transform-box: fill-box; transform-origin: bottom center; animation: detachRear 7s ease-in-out infinite; }
@keyframes detachDrift { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-16px); } }
@keyframes detachRear  { 0%,100% { transform: scaleY(1) skewX(0deg); } 50% { transform: scaleY(1.09) skewX(-7deg); } }
/* the whole cast twitches wrong at the bottom of the descent */
body[data-dread="4"] #char-svg .char { animation: charTwitch 5s steps(1) infinite; }
@keyframes charTwitch { 0%,85%,100% { transform: translate(0,0) rotate(0); } 87% { transform: translate(1px,-1px) rotate(0.4deg); } 89% { transform: translate(-1px,0) rotate(-0.3deg); } 91% { transform: translate(0,0); } }
body.reduce-motion .char .detach-shadow, body.reduce-motion .char .detach-shadow2, body.reduce-motion #char-svg .char { animation: none !important; }

/* Nightmare ending colour */
.cat-nightmare { --cc: var(--nightmare); }
.ending-card.cat-nightmare { box-shadow: 0 0 44px rgba(176,48,74,0.4); }

/* ---- the shopkeeper's asides -------------------------------------------- */
/* A reactive murmur under the narration. Present only when he has something
   personal to say; fades in a beat late so it reads as an interjection. */
.sk-aside {
  position: relative;
  margin: 0.55rem 0 0.15rem;
  padding: 0.4rem 0 0.4rem 0.85rem;
  border-left: 2px solid rgba(255,200,120,0.42);
  font-style: italic;
  color: #d9c39a;
  line-height: 1.5;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(6px);
  transition: opacity 0.7s ease, transform 0.7s ease, max-height 0.7s ease;
  pointer-events: none;
}
.sk-aside.show { max-height: 12rem; opacity: 0.96; transform: translateY(0); }
.sk-aside::before {
  content: "The shopkeeper, low —";
  display: block;
  font-style: normal;
  font-size: 0.64rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,200,120,0.62);
  margin-bottom: 0.22rem;
}
/* his voice reaching you when he isn't even on screen */
.sk-aside.disembodied { border-left-color: rgba(200,60,60,0.5); color: #ccafa7; }
.sk-aside.disembodied::before { content: "From somewhere behind you —"; color: rgba(205,90,90,0.72); }
/* tones tint the murmur without changing the attribution */
.sk-aside.tone-taunt   { color: #e2c398; }
.sk-aside.tone-bargain { border-left-color: rgba(170,120,210,0.55); color: #cebfe2; }
.sk-aside.tone-slip    { border-left-color: rgba(210,40,40,0.72); color: #e8b9b1; text-shadow: 0 0 8px rgba(180,20,20,0.28); }
/* the shop itself talking through him — a sick, wet green, from everywhere */
.sk-aside.tone-sick { border-left-color: rgba(90,155,60,0.8); color: #c0d6a2; text-shadow: 0 0 11px rgba(70,150,40,0.4); animation: skRot 6.5s ease-in-out infinite; }
.sk-aside.tone-sick.disembodied::before { content: "the shop, from everywhere —"; color: rgba(130,195,95,0.8); letter-spacing: 0.12em; }
@keyframes skRot { 0%,100% { filter: none; } 50% { filter: hue-rotate(-14deg) contrast(1.12); } }
body.reduce-motion .sk-aside.tone-sick { animation: none; }
/* the mask off: deep-dread slips flicker faintly */
body[data-dread="4"] .sk-aside.tone-slip { animation: skFlicker 4.5s steps(1) infinite; }
@keyframes skFlicker { 0%,92%,100% { opacity: 0.96; } 94% { opacity: 0.5; } 96% { opacity: 0.98; } }
body.reduce-motion .sk-aside { transition: none; animation: none !important; }

/* ---- the other children: environmental traces --------------------------- */
/* Cold, apart from the narration and from his voice: a note, a bracelet, a face
   at the glass, the toy whispering. Each surfaces at most once per run. */
.trace {
  margin: 0.5rem 0 0.15rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(150,160,175,0.16);
  border-radius: 6px;
  background: rgba(20,24,32,0.4);
  font-size: 0.92rem;
  font-style: italic;
  color: #a9b0bd;
  line-height: 1.5;
  max-height: 0; opacity: 0; overflow: hidden;
  transform: translateY(6px);
  transition: opacity 0.8s ease, transform 0.8s ease, max-height 0.8s ease;
  pointer-events: none;
}
.trace.show { max-height: 16rem; opacity: 0.94; transform: translateY(0); }
.trace::before {
  display: block;
  font-style: normal; font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(150,160,175,0.55); margin-bottom: 0.2rem;
}
.trace.kind-note::before     { content: "a note, tucked behind a toy"; }
.trace.kind-bracelet::before { content: "a little frayed bracelet"; }
.trace.kind-window::before   { content: "at the window"; color: rgba(205,120,120,0.62); }
.trace.kind-whisper::before  { content: "the toy, in a child's voice"; color: rgba(205,90,90,0.66); }
.trace.kind-window  { border-color: rgba(190,110,110,0.24); }
.trace.kind-whisper { border-color: rgba(190,70,70,0.3); color: #c3aab0; }
body.reduce-motion .trace { transition: none; }

/* ---- faces at the window (the other children, watching) ------------------ */
.faces { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity 2s ease; }
.faces.on { opacity: 0.72; }
body[data-dread="3"] .faces.on { opacity: 0.86; }
body[data-dread="4"] .faces.on { opacity: 1; }
#faces .face { animation: faceSway 6s ease-in-out infinite; }
#faces .face .eye { transform-box: fill-box; transform-origin: center; animation: faceBlink 7s steps(1) infinite; }
@keyframes faceSway  { 0%,100% { opacity: 0.82; } 50% { opacity: 1; } }
@keyframes faceBlink { 0%,95%,100% { transform: scaleY(1); } 97% { transform: scaleY(0.12); } }
body.reduce-motion .faces { transition: none; }
body.reduce-motion #faces .face, body.reduce-motion #faces .eye { animation: none !important; }

/* ---- the rot: the sickest end of the descent (dread 4) ------------------- */
/* the faces' mouths stay a hairline until the very bottom — then they gape */
#faces .mouth { transform-box: fill-box; transform-origin: center; transform: scaleY(0.06); opacity: 0.85; transition: transform 1.6s ease; }
body[data-dread="4"] #faces .mouth { animation: faceGape 5s ease-in-out infinite; }
@keyframes faceGape { 0%,100% { transform: scaleY(0.85); } 50% { transform: scaleY(1.3); } }
/* and the faces press in toward the glass */
body[data-dread="4"] #faces > svg { animation: facesPress 7s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes facesPress { 0%,100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.13) translateY(9px); } }
/* a wet, breathing throat closes over everything, tinged sick and meat-dark */
body[data-dread="4"] .dread-overlay {
  background: radial-gradient(78% 62% at 50% 44%, transparent 0%, rgba(58,6,10,0.55) 42%, rgba(30,2,6,0.9) 72%, rgba(6,0,2,0.99) 100%);
  animation: throat 4.2s ease-in-out infinite;
}
@keyframes throat { 0%,100% { opacity: 0.92; transform: scale(1); } 45% { opacity: 1; transform: scale(1.03); } 55% { opacity: 0.98; transform: scale(0.99); } }
body[data-dread="4"] #scene-art, body[data-dread="4"] #scene-image { filter: saturate(0.16) brightness(0.46) contrast(1.4) hue-rotate(-18deg) sepia(0.28); }
/* the narration itself sickens: wet, doubled, faintly green-lit */
body[data-dread="3"] .story-text { text-shadow: 0 0 1px rgba(120,150,90,0.25); }
body[data-dread="4"] .story-text { color: #e7cccc; text-shadow: 0.6px 0 rgba(160,20,20,0.45), -0.6px 0 rgba(60,120,90,0.4), 0 0 10px rgba(120,20,20,0.3); }
/* individual glyphs the shop has begun to eat (marked by JS at high dread) */
.rot-char { color: #8fae6a; text-shadow: 0 0 6px rgba(90,150,50,0.65); }
body.reduce-motion #faces .mouth, body.reduce-motion[data-dread="4"] #faces > svg,
body.reduce-motion[data-dread="4"] .dread-overlay { animation: none !important; }

/* ---- main menu ----------------------------------------------------------- */
.main-menu { background: rgba(6,4,10,0.55); backdrop-filter: blur(4px); }

/* ---- the cold open: the menu reveals itself against the title film ------- */
/* Staged pieces start hidden; TitleSequence adds show-* classes on the film's
   own timeline. Without .cold-open (or with all show-*) everything is visible. */
.main-menu.cold-open .menu-kicker, .main-menu.cold-open .menu-title, .main-menu.cold-open .menu-rule {
  opacity: 0; transform: translateY(10px); transition: opacity 1.8s ease, transform 1.8s ease;
}
.main-menu.cold-open.show-title .menu-kicker, .main-menu.cold-open.show-title .menu-title, .main-menu.cold-open.show-title .menu-rule {
  opacity: 1; transform: none;
}
.main-menu.cold-open .menu-tag { opacity: 0; transition: opacity 1.4s ease; }
.main-menu.cold-open.show-tagline .menu-tag { opacity: 1; }
.main-menu.cold-open .menu-haunt.show { opacity: 0; }
.main-menu.cold-open.show-tagline .menu-haunt.show { opacity: 1; }
.main-menu.cold-open .menu-actions, .main-menu.cold-open .menu-more {
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 1s ease, transform 1s ease;
}
.main-menu.cold-open.show-actions .menu-actions, .main-menu.cold-open.show-actions .menu-more {
  opacity: 1; transform: none; pointer-events: auto;
}
.main-menu.cold-open .menu-progress.show { opacity: 0; }
.main-menu.cold-open.show-actions .menu-progress.show { opacity: 1; }
body.reduce-motion .main-menu.cold-open .menu-kicker, body.reduce-motion .main-menu.cold-open .menu-title,
body.reduce-motion .main-menu.cold-open .menu-rule, body.reduce-motion .main-menu.cold-open .menu-tag,
body.reduce-motion .main-menu.cold-open .menu-actions, body.reduce-motion .main-menu.cold-open .menu-more {
  transition: none;
}

/* THE OMEN — one wrong blink of the world when the shop notices you. */
.scene.omen #scene-video, .scene.omen .scene-image {
  animation: omenBlink 0.6s steps(1) both;
}
@keyframes omenBlink {
  0%   { filter: brightness(0.35) saturate(0.2) hue-rotate(-28deg) contrast(1.35); }
  18%  { filter: none; }
  30%  { filter: brightness(0.5) saturate(0.35) contrast(1.3) hue-rotate(-18deg); }
  46%  { filter: none; }
  62%  { filter: brightness(0.42) saturate(0.25) contrast(1.32) hue-rotate(-24deg); }
  100% { filter: none; }
}
body.reduce-motion .scene.omen #scene-video, body.reduce-motion .scene.omen .scene-image { animation: none; }
.menu-card { text-align: center; padding: 22px 24px; animation: fadeUp 0.7s ease; max-width: 460px; }
.menu-kicker { display: flex; align-items: center; justify-content: center; gap: 14px; font-family: var(--font-ui); letter-spacing: 5px; text-transform: uppercase; font-size: 11px; color: var(--gold-strong); opacity: 0.9; }
.menu-kicker::before, .menu-kicker::after { content: ""; height: 1px; width: 40px; }
.menu-kicker::before { background: linear-gradient(to left, rgba(255,180,80,0.65), transparent); }
.menu-kicker::after { background: linear-gradient(to right, rgba(255,180,80,0.65), transparent); }
.menu-title {
  font-size: clamp(46px, 9vw, 74px); margin: 12px 0 8px; letter-spacing: 5px; line-height: 1;
  background: linear-gradient(180deg, #ffe9bc 0%, #ffcf7a 46%, #d98a34 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,0.5)) drop-shadow(0 0 34px rgba(255,180,80,0.32));
}
.menu-rule { color: rgba(255,190,110,0.75); line-height: 0; margin: 2px 0 10px; }
.menu-tag { font-style: italic; color: var(--ink-dim); letter-spacing: 0.3px; margin-bottom: 12px; }
.menu-haunt { min-height: 18px; margin-bottom: 6px; font-family: var(--font-ui); font-size: 13px; letter-spacing: 1px; color: var(--nightmare); opacity: 0; transition: opacity 1.4s ease; text-shadow: 0 0 10px rgba(176,48,74,0.5); }
.menu-haunt.show { opacity: 0.9; }
.haunt-stat { color: var(--nightmare) !important; font-style: italic; }

/* primary actions (Begin / Continue) */
.menu-actions { display: flex; flex-direction: column; gap: 11px; width: min(300px, 82vw); margin: 16px auto 0; }
.menu-actions button { width: 100%; }
.menu-cta { font-size: 16px; padding: 14px 22px; letter-spacing: 0.5px; }
.ghost-btn.disabled, .menu-cta.disabled { opacity: 0.4; cursor: not-allowed; }

/* secondary row (Endings / Settings / About) */
.menu-more { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; width: min(300px, 82vw); margin: 12px auto 0; }
.chip-btn {
  font-family: var(--font-ui); font-size: 13px; cursor: pointer; color: var(--ink-dim);
  background: rgba(0,0,0,0.28); border: 1px solid var(--panel-edge); border-radius: 999px;
  padding: 8px 14px; transition: 0.16s; display: inline-flex; align-items: center; gap: 6px;
}
.chip-btn::before { content: attr(data-icon); font-size: 13px; opacity: 0.9; }
.chip-btn:hover { color: var(--ink); border-color: var(--gold); background: rgba(255,200,120,0.12); transform: translateY(-1px); }

/* returning-player progress */
.menu-progress { margin-top: 16px; min-height: 15px; font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-dim); letter-spacing: 0.5px; opacity: 0; transition: opacity 1s ease; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.menu-progress.show { opacity: 0.85; }
.menu-progress b { color: var(--gold); font-weight: 700; }
.menu-progress .mp-dot { opacity: 0.4; }

/* trilogy cross-link */
.menu-shelf { margin-top: 14px; font-family: var(--font-ui); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-dim); opacity: 0.65; }
.menu-shelf a { color: var(--gold); text-decoration: none; }
.menu-shelf a:hover { color: var(--gold-strong); }

/* the title's storybook gold gives way to the glitch once the shop remembers you */
body[data-haunt="3"] .menu-title, body[data-haunt="4"] .menu-title { background: none; -webkit-text-fill-color: currentColor; filter: none; }
.menu-title.glitch-flash { background: none; -webkit-text-fill-color: currentColor; }

/* ---- top bar ------------------------------------------------------------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: none;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(10,8,14,0.85), transparent); font-family: var(--font-ui);
}
#topbar.visible { display: flex; }
.hud-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-chip { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-edge); font-size: 13px; backdrop-filter: blur(4px); }
.stat-name { color: var(--ink-dim); }
.stat-val { font-weight: 700; color: var(--gold); min-width: 12px; text-align: center; }
.stat-val.pulse { animation: pop 0.5s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.6); color: #fff; } 100% { transform: scale(1); } }
.hud-right { display: flex; align-items: center; gap: 6px; }
.hud-endings { font-size: 13px; color: var(--ink-dim); padding: 4px 8px; border-radius: 8px; background: rgba(0,0,0,0.3); }
.hud-bracelet { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 999px; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-edge); }
.hud-bracelet svg { display: block; }
.hud-bracelet .brc-label { font-family: var(--font-ui); font-size: 11px; color: var(--ink-dim); letter-spacing: 0.5px; }
.hud-bracelet.snapped { border-color: rgba(200,60,60,0.5); }
.hud-bracelet.snapped .brc-label { color: var(--bad); }
.hud-bracelet.pulse { animation: brcPulse 0.6s ease; }
@keyframes brcPulse { 0% { transform: scale(1); } 40% { transform: scale(1.18); box-shadow: 0 0 14px rgba(255,207,122,0.5); } 100% { transform: scale(1); } }
.popup.bond { font-size: 14px; font-family: var(--font-ui); font-weight: 700; }
.popup.bond.pos { color: var(--good); }
.popup.bond.neg { color: var(--bad); }
.icon-btn { border: 1px solid var(--panel-edge); background: rgba(0,0,0,0.35); color: var(--ink); border-radius: 10px; width: 34px; height: 34px; font-size: 15px; cursor: pointer; transition: 0.15s; }
.icon-btn:hover { background: rgba(255,200,120,0.2); transform: translateY(-1px); }

/* ---- story panel --------------------------------------------------------- */
#stage { position: relative; z-index: 10; height: 100%; display: none; align-items: flex-end; justify-content: center; padding: 74px max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
#stage.visible { display: flex; }
.story-panel {
  width: min(820px, 96vw); max-height: 48vh; overflow-y: auto;
  /* a faint paper grain over the plate so it reads like a page */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E") repeat,
    linear-gradient(to bottom, rgba(24,18,30,0.82), rgba(16,11,22,0.94));
  border: 1px solid var(--panel-edge); border-top: 2px solid rgba(255,207,122,0.4);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,220,150,0.28), var(--shadow), 0 -10px 40px rgba(0,0,0,0.4);
  padding: 18px 30px 22px; backdrop-filter: blur(10px);
}
.story-panel.fade-in { animation: fadeUp 0.5s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.node-title { font-family: var(--font-ui); font-weight: 700; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold-strong); margin-bottom: 10px; }
.art { display: flex; align-items: center; min-height: 46px; border: 1px dashed var(--panel-edge); border-radius: 10px; background: rgba(0,0,0,0.2); padding: 8px 12px; margin-bottom: 14px; }
.art-prompt { font-family: var(--font-ui); font-size: 11.5px; color: var(--ink-dim); font-style: italic; line-height: 1.4; }
.speaker { font-family: var(--font-ui); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: var(--gold-strong); margin-bottom: 6px; font-weight: 700; }
.story-text { font-size: 19px; line-height: 1.6; margin: 0 0 6px; min-height: 1.6em; }
.subtle { font-style: italic; color: var(--secret); opacity: 0; transition: opacity 0.6s; margin: 6px 0; font-size: 15px; }
.subtle.show { opacity: 0.85; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.choice { position: relative; overflow: hidden; text-align: left; font-family: var(--font-body); font-size: 16px; color: var(--ink); cursor: pointer; background: linear-gradient(to bottom, rgba(60,48,40,0.6), rgba(40,32,28,0.6)); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 12px 15px 12px 17px; transition: 0.15s; display: flex; flex-direction: column; gap: 6px; }
/* a gold accent bar lights up along the left edge on hover/focus */
.choice::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); opacity: 0; transition: opacity 0.15s ease; }
.choice:hover { border-color: var(--gold); background: linear-gradient(to bottom, rgba(90,70,45,0.7), rgba(55,42,30,0.7)); transform: translateX(3px); }
.choice:hover::before { opacity: 0.85; }
.choice.locked::before { display: none; }
.choice.locked { opacity: 0.5; filter: grayscale(0.5); cursor: not-allowed; }
.choice.locked:hover { transform: none; border-color: var(--bad); }
.choice-text { line-height: 1.35; }
.choice-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--font-ui); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.tag-req { background: rgba(199,155,255,0.18); color: var(--secret); border: 1px solid rgba(199,155,255,0.4); }
.tag-cost { background: rgba(255,123,123,0.15); color: var(--bad); border: 1px solid rgba(255,123,123,0.35); }
.tag-gain { background: rgba(123,224,138,0.15); color: var(--good); border: 1px solid rgba(123,224,138,0.35); }
.tag-lockchip { background: rgba(0,0,0,0.4); color: var(--ink-dim); border: 1px solid rgba(255,255,255,0.15); }

/* keyboard accessibility: a clear, on-brand focus ring (mouse clicks unaffected) */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.choice:focus-visible { border-color: var(--gold); transform: translateX(3px); }
.choice:focus-visible::before { opacity: 0.85; }
.icon-btn:focus-visible, .chip-btn:focus-visible { outline-offset: 1px; }
/* a small press so choosing feels tactile */
.choice:active { transform: translateX(3px) scale(0.992); }
/* number badges tie the choices to the 1-9 keyboard shortcuts (keyboard devices
   only; hidden on touch, where there are no number keys). Counter skips locked. */
@media (hover: hover) and (pointer: fine) {
  .choices { counter-reset: choicenum; }
  .choice:not(.locked) { counter-increment: choicenum; padding-right: 38px; }
  .choice:not(.locked)::after {
    content: counter(choicenum);
    position: absolute; top: 10px; right: 10px;
    width: 18px; height: 18px; line-height: 17px; text-align: center;
    font-family: var(--font-ui); font-size: 11px; font-weight: 700;
    color: var(--ink-dim); background: rgba(0,0,0,0.28);
    border: 1px solid var(--panel-edge); border-radius: 6px;
    opacity: 0.5; transition: 0.15s ease;
  }
  .choice:not(.locked):hover::after,
  .choice:not(.locked):focus-visible::after {
    opacity: 1; color: var(--gold); border-color: rgba(255,207,122,0.6); background: rgba(255,200,120,0.12);
  }
}

.inventory { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--panel-edge); font-family: var(--font-ui); font-size: 12px; }
.inv-label { color: var(--ink-dim); }
.inv-empty { color: var(--ink-dim); font-style: italic; }
.inv-item { background: rgba(255,200,120,0.12); border: 1px solid var(--panel-edge); border-radius: 999px; padding: 4px 10px; }

/* ---- popups & toast ------------------------------------------------------ */
.popups { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.popup { font-family: var(--font-ui); font-weight: 800; font-size: 18px; padding: 4px 14px; border-radius: 999px; animation: floatUp 1.6s ease forwards; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.popup.pos { color: var(--good); }
.popup.neg { color: var(--bad); }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(12px) scale(0.8); } 20% { opacity: 1; transform: translateY(0) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 60; max-width: 90vw; background: rgba(20,15,26,0.95); color: var(--ink); border: 1px solid var(--bad); border-radius: 12px; padding: 12px 18px; font-family: var(--font-ui); font-size: 14px; opacity: 0; pointer-events: none; transition: 0.25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- overlays ------------------------------------------------------------ */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; background: rgba(6,4,10,0.72); backdrop-filter: blur(6px); padding: 20px; }
.overlay.open { display: flex; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* category colors */
.cat-good, .cat-good.ending-card { --cc: var(--good); }
.cat-bad { --cc: var(--bad); }
.cat-funny { --cc: var(--funny); }
.cat-cursed { --cc: var(--cursed); }
.cat-secret { --cc: var(--secret); }
.cat-true { --cc: var(--true); }

/* ending card */
.ending-card { width: min(580px, 96vw); max-height: 90vh; overflow-y: auto; text-align: center; background: var(--panel); border: 2px solid var(--cc, var(--gold)); border-radius: 20px; padding: 26px 30px; box-shadow: var(--shadow); filter: drop-shadow(0 0 15px var(--cc, var(--gold))); animation: fadeUp 0.5s ease; }
.ending-card.cat-secret, .ending-card.cat-true { box-shadow: 0 0 40px rgba(199,155,255,0.35); }
.ending-number { font-family: var(--font-ui); font-size: 12px; color: var(--ink-dim); letter-spacing: 2px; }
.ending-new { font-family: var(--font-ui); font-size: 13px; color: var(--ink-dim); margin: 2px 0 4px; }
.ending-new.is-new { color: var(--secret); font-weight: 700; }
.ending-name { font-size: 30px; margin: 4px 0 10px; }
.ending-cat-chip { display: inline-block; font-family: var(--font-ui); font-size: 12px; font-weight: 700; padding: 3px 12px; border-radius: 999px; margin-bottom: 12px; background: rgba(255,255,255,0.08); border: 1px solid var(--panel-edge); color: var(--cc, var(--ink)); }
.ending-art { font-family: var(--font-ui); font-size: 11.5px; color: var(--ink-dim); font-style: italic; border: 1px dashed var(--panel-edge); border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; text-align: left; }
.ending-art.has-img { padding: 0; border: 1px solid var(--panel-edge); overflow: hidden; }
.ending-art.has-img img { display: block; width: 100%; height: auto; }
.cc-thumb { height: 62px; margin: -10px -12px 8px; background-size: cover; background-position: center; border-bottom: 1px solid var(--panel-edge); }
.coll-card.found { overflow: hidden; }
.ending-text { font-size: 17px; line-height: 1.55; margin: 0 0 14px; }
.ending-stats { display: flex; gap: 12px; justify-content: center; font-family: var(--font-ui); font-weight: 700; color: var(--gold); margin-bottom: 12px; }
.ending-choices { text-align: left; font-family: var(--font-ui); font-size: 13px; color: var(--ink-dim); margin-bottom: 12px; }
.ending-choices h4 { color: var(--gold); margin: 0 0 6px; font-size: 13px; }
.ec-row { margin: 2px 0; }
.ending-unlock { color: var(--secret); font-family: var(--font-ui); font-size: 13px; margin: 4px 0; }
.ending-progress { font-family: var(--font-ui); font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.ending-hint { font-family: var(--font-ui); font-size: 13px; color: var(--gold); min-height: 16px; margin-bottom: 10px; }
.ending-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.primary-btn { position: relative; overflow: hidden; font-family: var(--font-ui); font-weight: 700; font-size: 15px; cursor: pointer; background: linear-gradient(to bottom, #ffe1a0, var(--gold) 45%, var(--gold-strong)); color: #2a1a08; border: none; border-radius: 12px; padding: 12px 22px; box-shadow: 0 6px 18px rgba(255,170,60,0.35), inset 0 1px 0 rgba(255,255,255,0.4); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(255,170,60,0.45), inset 0 1px 0 rgba(255,255,255,0.5); }
/* a slow sheen sweeps the primary call-to-action */
.primary-btn::after { content: ""; position: absolute; top: 0; left: -60%; width: 45%; height: 100%; background: linear-gradient(105deg, transparent, rgba(255,255,255,0.5), transparent); transform: skewX(-18deg); animation: btnSheen 5s ease-in-out infinite; }
@keyframes btnSheen { 0%, 22% { left: -60%; } 42%, 100% { left: 130%; } }
.ghost-btn { font-family: var(--font-ui); font-size: 14px; cursor: pointer; background: rgba(255,255,255,0.06); color: var(--ink); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 12px 16px; transition: 0.15s; }
.ghost-btn:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,207,122,0.5); }
/* Share = a gold-tinted ghost so the viral action reads as inviting, not loud. */
.share-btn { color: var(--gold); border-color: rgba(255,207,122,0.45); background: rgba(255,200,120,0.09); font-weight: 700; }
.share-btn:hover { background: rgba(255,200,120,0.18); border-color: var(--gold); color: #fff2d6; }
.detail-actions { display: flex; justify-content: center; margin-top: 16px; }
body.reduce-motion .primary-btn::after { animation: none; display: none; }

/* sheets (tracker / settings / history) */
.sheet { width: min(720px, 96vw); max-height: 86vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--gold); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--panel-edge); }
.sheet-head h2 { margin: 0; font-size: 22px; }
.sheet-body { padding: 18px 20px; overflow-y: auto; font-family: var(--font-ui); }

.coll-summary { font-size: 15px; color: var(--gold); margin-bottom: 14px; font-weight: 700; }
.coll-route { margin-bottom: 18px; }
.coll-route h3 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; border-bottom: 1px dashed var(--panel-edge); padding-bottom: 4px; }
.coll-route h3 span { color: var(--ink-dim); font-size: 13px; font-weight: 400; }
.coll-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.coll-card { border-radius: 10px; padding: 10px 12px; border: 1px solid var(--panel-edge); background: rgba(0,0,0,0.25); border-left: 3px solid var(--cc, var(--panel-edge)); }
.coll-card.hidden { opacity: 0.55; border-style: dashed; border-left-color: var(--panel-edge); }
.cc-num { font-family: var(--font-ui); font-size: 10px; color: var(--ink-dim); }
.cc-name { font-weight: 700; font-size: 14px; }
.cc-type { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.memory-list { display: flex; flex-direction: column; gap: 6px; }
.memory-clue { font-style: italic; color: var(--ink); background: rgba(255,207,122,0.08); border-radius: 8px; padding: 6px 10px; font-family: var(--font-body); }
.memory-empty { color: var(--ink-dim); font-style: italic; }
.unlock-status { font-size: 13px; color: var(--ink-dim); margin-top: 8px; }
.truth-row { margin: 8px 0; padding: 8px 10px; border-radius: 8px; }
.truth-row.known { background: rgba(138,215,255,0.08); border-left: 3px solid var(--true); }
.truth-row.unknown { color: var(--ink-dim); font-style: italic; border-left: 3px solid var(--panel-edge); }
.truth-title { font-weight: 700; color: var(--true); font-size: 14px; }
.truth-text { font-size: 13px; color: var(--ink); margin-top: 3px; font-family: var(--font-body); }
.child-row { margin: 7px 0; padding: 8px 10px; border-radius: 8px; }
.child-row.freed { background: rgba(123,224,138,0.09); border-left: 3px solid var(--good); }
.child-row.trapped { border-left: 3px solid var(--panel-edge); color: var(--ink-dim); }
.child-name { font-weight: 700; font-size: 14px; }
.child-row.freed .child-name { color: var(--good); }
.child-fate { font-size: 12.5px; color: var(--ink-dim); margin-top: 3px; font-family: var(--font-body); font-style: italic; }
.child-row.freed .child-fate { color: var(--ink); }

/* The Ledger — the book of what you did */
.ledger-panel h3 span { color: var(--bad); }
.ledger-note { font-size: 12.5px; color: var(--ink-dim); font-style: italic; margin-bottom: 10px; }
.ledger-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,0.06); font-size: 13.5px; color: var(--ink-dim); }
.ledger-row .lg-text { font-family: var(--font-body); }
.ledger-row .lg-n { font-family: var(--font-ui); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.ledger-row.inked { color: var(--ink); }
.ledger-row.inked .lg-n { color: var(--bad); text-shadow: 0 0 8px rgba(255,60,60,0.3); }
.ledger-row.freed .lg-text, .ledger-row.freed .lg-n { color: var(--good); }
.ledger-verdict { margin-top: 12px; font-style: italic; font-family: var(--font-body); color: #e0c9a0; line-height: 1.5; }

/* ---- cinematic front door ------------------------------------------------ */
/* Title screen over the illustrated cover */
.main-menu { background: radial-gradient(120% 95% at 50% 42%, rgba(6,4,10,0.32) 0%, rgba(6,4,10,0.72) 78%, rgba(4,2,8,0.9) 100%); backdrop-filter: blur(2px); }
.menu-card { background: none; }

/* Menu decay: the title screen corrupts as the shop remembers you. */
body[data-haunt="3"] .main-menu { background: radial-gradient(120% 95% at 50% 42%, rgba(34,2,8,0.5) 0%, rgba(12,0,4,0.85) 72%, rgba(6,0,2,0.96) 100%); }
body[data-haunt="4"] .main-menu { background: radial-gradient(110% 90% at 50% 46%, rgba(70,0,10,0.6) 0%, rgba(12,0,4,0.9) 58%, rgba(3,0,1,0.98) 100%); animation: menuPulse 2.6s ease-in-out infinite; }
@keyframes menuPulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18) saturate(1.35); } }
body[data-haunt="3"] .menu-title, body[data-haunt="4"] .menu-title { color: #e0aa6a; text-shadow: 2px 0 rgba(255,40,40,0.45), -2px 0 rgba(60,120,255,0.35), 0 0 30px rgba(255,80,60,0.4); }
body[data-haunt="4"] .menu-title { animation: titleGlitch 5.5s steps(1) infinite; }
@keyframes titleGlitch { 0%,93%,100% { transform: translate(0,0); } 94% { transform: translate(-3px,1px) skewX(-3deg); } 95% { transform: translate(3px,-1px); } 96% { transform: translate(-1px,0); } 97% { transform: translate(2px,1px) skewX(2deg); } }
.menu-title.glitch-flash { color: #ff4444; text-shadow: 4px 0 rgba(60,120,255,0.75), -4px 0 rgba(255,40,40,0.75), 0 0 24px rgba(255,40,40,0.6); }
body[data-haunt="3"] .menu-tag, body[data-haunt="4"] .menu-tag { color: var(--nightmare); font-style: italic; }
body[data-haunt="4"] .menu-actions .ghost-btn, body[data-haunt="4"] .menu-actions .primary-btn, body[data-haunt="4"] .chip-btn { border-color: rgba(160,20,20,0.5); }
body.reduce-motion .main-menu, body.reduce-motion .menu-title { animation: none !important; }

/* Intro sequence */
.intro-screen { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; background: #05040a; padding: 30px; cursor: pointer; }
.intro-screen.open { display: flex; animation: fade 0.8s ease; }
.intro-line { max-width: 620px; text-align: center; font-family: var(--font-body); font-size: 26px; line-height: 1.6; color: var(--ink); opacity: 0; }
.intro-line.show { animation: introLine 3.2s ease forwards; }
@keyframes introLine { 0% { opacity: 0; transform: translateY(8px); } 18% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; } 100% { opacity: 0.15; } }
.intro-skip { position: fixed; bottom: 24px; right: 26px; font-family: var(--font-ui); font-size: 12px; color: var(--ink-dim); letter-spacing: 1px; }
body.reduce-motion .intro-line.show { animation: none; opacity: 1; }

/* About / credits */
.about-title { font-size: 30px; letter-spacing: 3px; color: var(--gold); text-align: center; text-shadow: 0 0 20px rgba(255,180,80,0.3); }
.about-tag { text-align: center; font-style: italic; color: var(--ink-dim); margin-bottom: 16px; }
.about-p { font-family: var(--font-body); font-size: 15px; line-height: 1.6; }
.about-sec { margin: 14px 0; font-size: 13.5px; }
.about-sec > b { color: var(--gold); display: block; margin-bottom: 3px; }
.about-sec div { color: var(--ink-dim); line-height: 1.5; }
.about-sec b, .about-p b { color: var(--ink); }
.about-foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--panel-edge); text-align: center; font-family: var(--font-ui); font-size: 12px; color: var(--ink-dim); }

/* The Cast — Coraline-style character portraits */
.cast-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 6px; }
.cast-card { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--panel-edge); background: rgba(0,0,0,0.3); box-shadow: var(--shadow); }
.cast-card img { display: block; width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; }
.cast-card figcaption { padding: 7px 10px 9px; font-family: var(--font-ui); font-weight: 700; font-size: 13px; color: var(--gold); }
.cast-card figcaption span { display: block; font-weight: 400; font-size: 11px; font-style: italic; color: var(--ink-dim); margin-top: 2px; }
.cast-card.creep { border-color: rgba(160,40,40,0.4); }
.cast-card.creep figcaption { color: #d98a6a; }
@media (max-width: 640px) { .cast-gallery { gap: 6px; } .cast-card figcaption { padding: 5px 7px 7px; font-size: 11.5px; } .cast-card figcaption span { font-size: 10px; } }

/* Gallery: filters + clickable cards + detail */
.coll-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter-chip { font-family: var(--font-ui); font-size: 12px; cursor: pointer; background: rgba(0,0,0,0.3); color: var(--ink-dim); border: 1px solid var(--panel-edge); border-radius: 999px; padding: 5px 12px; }
.filter-chip:hover { color: var(--ink); }
.filter-chip.active { background: rgba(255,200,120,0.18); color: var(--gold); border-color: var(--gold); }
.coll-card.clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.coll-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.4); }
.ending-detail-screen { z-index: 55; }
.detail-card { position: relative; width: min(560px, 96vw); max-height: 90vh; overflow-y: auto; text-align: center; background: var(--panel); border: 2px solid var(--cc, var(--gold)); border-radius: 20px; box-shadow: var(--shadow); animation: fadeUp 0.4s ease; }
.detail-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.detail-art { border-radius: 18px 18px 0 0; overflow: hidden; background: #0c0910; min-height: 40px; }
.detail-art img { display: block; width: 100%; height: auto; }
.detail-card .ending-number, .detail-card .ending-name, .detail-card .ending-cat-chip, .detail-card .ending-text { padding-left: 26px; padding-right: 26px; }
.detail-card .ending-number { margin-top: 14px; }
.detail-clue { font-style: italic; color: var(--ink-dim); font-size: 13px; padding: 0 26px 22px; }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.set-name { font-weight: 700; font-size: 15px; }
.set-desc { font-size: 13px; color: var(--ink-dim); margin-top: 2px; max-width: 440px; }
.set-row select { background: rgba(0,0,0,0.4); color: var(--ink); border: 1px solid var(--panel-edge); border-radius: 8px; padding: 7px 9px; font-family: var(--font-ui); }
.set-text { background: rgba(0,0,0,0.4); color: var(--ink); border: 1px solid var(--panel-edge); border-radius: 8px; padding: 8px 10px; font-family: var(--font-ui); width: 150px; text-align: center; }
.set-text:focus { outline: none; border-color: var(--gold); }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-edge); border-radius: 999px; transition: 0.2s; }
.slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: var(--ink-dim); border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: rgba(255,180,80,0.4); }
.switch input:checked + .slider:before { transform: translateX(20px); background: var(--gold); }

/* history */
.hist-row { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 14px; }
.hist-i { color: var(--ink-dim); }
.hist-d { color: var(--good); font-size: 12px; }

/* ---- debug panel --------------------------------------------------------- */
.debug-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: 340px; max-width: 92vw; transform: translateX(105%); background: rgba(12,10,16,0.97); border-left: 1px solid var(--gold); box-shadow: -10px 0 40px rgba(0,0,0,0.5); transition: transform 0.3s ease; font-family: var(--font-ui); font-size: 13px; overflow-y: auto; padding-bottom: 30px; }
.debug-panel.open { transform: translateX(0); }
.dbg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-weight: 700; color: var(--gold); border-bottom: 1px solid var(--panel-edge); position: sticky; top: 0; background: rgba(12,10,16,0.98); }
.dbg-head button { background: none; border: none; color: var(--ink); font-size: 16px; cursor: pointer; }
.dbg-section { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.dbg-section > label { display: block; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.dbg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.debug-panel input, .debug-panel select { background: rgba(0,0,0,0.4); color: var(--ink); border: 1px solid var(--panel-edge); border-radius: 8px; padding: 7px 9px; font-family: var(--font-ui); font-size: 13px; }
.debug-panel #dbg-node { flex: 1; min-width: 80px; }
.debug-panel #dbg-ending { flex: 1; min-width: 120px; }
.debug-panel button { background: rgba(255,200,120,0.15); color: var(--gold); border: 1px solid var(--panel-edge); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-family: var(--font-ui); font-weight: 600; }
.debug-panel button:hover { background: rgba(255,200,120,0.3); }
.debug-panel button.danger { color: var(--bad); border-color: rgba(255,123,123,0.4); }
.dbg-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.dbg-stat { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--ink-dim); }
.dbg-stat input { width: 56px; }
.dbg-flags { color: var(--secret); font-size: 12px; word-break: break-word; min-height: 18px; }
.dbg-report { margin-top: 10px; font-size: 12px; max-height: 180px; overflow-y: auto; }
.dbg-report .ok { color: var(--good); }
.dbg-report .error { color: var(--bad); }
.dbg-report .warn { color: var(--funny); }

/* ---- reduced motion ------------------------------------------------------ */
body.reduce-motion .scene .particles { animation: none; }
body.reduce-motion .story-panel.fade-in,
body.reduce-motion .ending-card,
body.reduce-motion .menu-card,
body.reduce-motion .popup { animation: none; }
@media (prefers-reduced-motion: reduce) { .scene .particles { animation: none; } }

/* ---- scrollbars ---------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: rgba(255,200,120,0.28) transparent; } /* Firefox */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,200,120,0.25); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,200,120,0.45); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- UI polish: progress bar, drop-cap, image load-in, gallery ----------- */
.prog-bar { position: relative; width: 100%; height: 7px; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-edge); border-radius: 999px; overflow: hidden; margin: 10px 0 2px; }
.prog-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-strong), var(--gold)); box-shadow: 0 0 10px rgba(255,200,120,0.5); transition: width 0.85s cubic-bezier(0.22,1,0.36,1); }
.menu-progress .prog-bar.mp-bar { flex: 1 1 100%; height: 6px; margin: 8px auto 0; max-width: 280px; }

/* storybook illuminated first letter (only when the beat opens on a letter) */
.story-text.dropcap::first-letter {
  float: left; font-family: var(--font-body); font-weight: 700;
  font-size: 3em; line-height: 0.82; margin: 0.06em 0.1em -0.02em 0;
  color: var(--gold); text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* ending art loads in behind a shimmer, then fades up (no pop) */
.ending-art.has-img { position: relative; min-height: 120px; }
.ending-art.has-img.loading { background: linear-gradient(100deg, rgba(255,255,255,0.03) 30%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.03) 70%); background-size: 220% 100%; animation: shimmer 1.25s linear infinite; }
.ending-art.has-img img { opacity: 0; transition: opacity 0.6s ease; }
.ending-art.has-img:not(.loading) img { opacity: 1; }
@keyframes shimmer { from { background-position: 220% 0; } to { background-position: -220% 0; } }

/* ending tracker gallery: category-topped found cards, deeper hover, ? silhouette */
.coll-card { position: relative; }
.coll-card.found { border-top: 2px solid var(--cc, var(--gold)); }
.coll-card.clickable:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,0.5); filter: drop-shadow(0 0 6px var(--cc, var(--gold))); }
.coll-card.hidden::after { content: "?"; position: absolute; top: 50%; right: 12px; transform: translateY(-50%); font-family: var(--font-body); font-size: 30px; font-weight: 700; color: var(--ink-dim); opacity: 0.16; pointer-events: none; }

body.reduce-motion .prog-fill { transition: none; }
body.reduce-motion .ending-art.has-img.loading { animation: none; }
body.reduce-motion .ending-art.has-img img { transition: none; }

/* ---- UI polish 2: scene load-in, stat bumps, richer bracelet, overlays ---- */
.scene-loader { position: absolute; inset: 0; z-index: 0; opacity: 0; pointer-events: none; transition: opacity 0.45s ease;
  background: linear-gradient(110deg, rgba(255,240,220,0.015) 30%, rgba(255,240,220,0.06) 50%, rgba(255,240,220,0.015) 70%);
  background-size: 240% 100%; }
.scene-loader.show { opacity: 1; animation: shimmer 1.5s linear infinite; }

/* stat chips flash by direction when a stat changes */
.stat-chip.bumped { animation: statBump 0.76s ease; }
.stat-chip.dropped { animation: statDrop 0.76s ease; }
@keyframes statBump { 0%,100% { transform: none; box-shadow: none; border-color: var(--panel-edge); }
  28% { transform: translateY(-3px) scale(1.09); box-shadow: 0 0 15px rgba(123,224,138,0.6); border-color: var(--good); } }
@keyframes statDrop { 0%,100% { transform: none; box-shadow: none; border-color: var(--panel-edge); }
  20% { transform: translateX(-2px); border-color: var(--bad); box-shadow: 0 0 13px rgba(255,123,123,0.5); }
  45% { transform: translateX(2px); } 70% { transform: translateX(-1px); } }

/* richer bracelet: whole glows gold, mend/fray flash by direction, idle breathe */
.hud-bracelet.whole { border-color: rgba(255,207,122,0.6); box-shadow: 0 0 12px rgba(255,207,122,0.35); }
.hud-bracelet.mended { animation: brcMend 0.85s ease; }
.hud-bracelet.frayed { animation: brcFray 0.85s ease; }
@keyframes brcMend { 0%,100% { box-shadow: none; } 35% { box-shadow: 0 0 16px rgba(123,224,138,0.65); border-color: var(--good); } }
@keyframes brcFray { 0%,100% { transform: none; box-shadow: none; } 20% { transform: translateX(-2px); box-shadow: 0 0 14px rgba(255,123,123,0.55); border-color: var(--bad); } 50% { transform: translateX(2px); } 75% { transform: translateX(-1px); } }
.hud-bracelet svg { animation: brcBreathe 3.6s ease-in-out infinite; }
@keyframes brcBreathe { 0%,100% { opacity: 0.86; } 50% { opacity: 1; } }

/* overlay contents settle in (menu excluded — it runs its own cold-open) */
.overlay.open:not(.main-menu) > * { animation: overlayIn 0.42s cubic-bezier(0.22,1,0.36,1); }
@keyframes overlayIn { from { opacity: 0; transform: translateY(14px) scale(0.972); } to { opacity: 1; transform: none; } }

body.reduce-motion .scene-loader.show { animation: none; }
body.reduce-motion .stat-chip.bumped, body.reduce-motion .stat-chip.dropped,
body.reduce-motion .hud-bracelet.mended, body.reduce-motion .hud-bracelet.frayed,
body.reduce-motion .hud-bracelet svg { animation: none; }
body.reduce-motion .overlay.open:not(.main-menu) > * { animation: none; }

/* ---- UI polish 4: menu ambience, haunt-reactive chrome, how-to hint ------ */
.menu-motes {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.55;
  background-image:
    radial-gradient(2px 2px at 18% 82%, rgba(255,220,160,0.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 62% 66%, rgba(255,220,160,0.4), transparent 60%),
    radial-gradient(2px 2px at 42% 44%, rgba(255,220,160,0.35), transparent 60%),
    radial-gradient(1px 1px at 82% 32%, rgba(255,220,160,0.45), transparent 60%),
    radial-gradient(2.5px 2.5px at 28% 22%, rgba(255,220,160,0.3), transparent 60%),
    radial-gradient(1.5px 1.5px at 72% 88%, rgba(255,220,160,0.4), transparent 60%);
  animation: moteDrift 26s linear infinite;
}
@keyframes moteDrift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  to   { background-position: 0 -520px, 0 -760px, 0 -480px, 0 -880px, 0 -640px, 0 -700px; }
}
.menu-card { position: relative; z-index: 1; }
.menu-card::before {
  content: ""; position: absolute; left: 50%; top: 30%; width: 300px; height: 190px;
  transform: translate(-50%, -50%); z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255,180,90,0.13), transparent 70%);
  filter: blur(10px); animation: menuBreathe 6.5s ease-in-out infinite;
}
@keyframes menuBreathe { 0%,100% { opacity: 0.55; transform: translate(-50%,-50%) scale(1); } 50% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); } }
body[data-haunt="3"] .menu-motes, body[data-haunt="4"] .menu-motes { filter: hue-rotate(-45deg) saturate(1.4) brightness(0.8); opacity: 0.4; }
body[data-haunt="4"] .menu-card::before { background: radial-gradient(ellipse at center, rgba(200,40,40,0.16), transparent 70%); }

/* haunt-reactive chrome: the shop's presence tints the UI as it remembers you */
#haunt-veil { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; transition: opacity 2s ease;
  background: radial-gradient(135% 105% at 50% 50%, transparent 55%, rgba(40,0,8,0.55) 100%); }
body[data-haunt="2"] #haunt-veil { opacity: 0.28; }
body[data-haunt="3"] #haunt-veil { opacity: 0.55; }
body[data-haunt="4"] #haunt-veil { opacity: 0.85; background: radial-gradient(130% 100% at 50% 50%, transparent 44%, rgba(64,0,10,0.62) 100%); }
body[data-haunt="2"] #topbar { filter: saturate(0.9); }
body[data-haunt="3"] #topbar { filter: saturate(0.72) brightness(0.94); }
body[data-haunt="4"] #topbar { filter: saturate(0.5) brightness(0.88) hue-rotate(-6deg); }
body[data-haunt="3"] .stat-chip, body[data-haunt="3"] .hud-bracelet { border-color: rgba(180,80,80,0.4); }
body[data-haunt="4"] .stat-chip, body[data-haunt="4"] .hud-bracelet { border-color: rgba(200,50,50,0.5); }

/* first-run how-to hint */
.howto-hint { position: relative; margin: 14px 0 4px; padding: 12px 34px 12px 14px; border-radius: 12px;
  font-family: var(--font-ui); font-size: 13.5px; line-height: 1.5; color: var(--ink);
  background: linear-gradient(to bottom, rgba(255,200,120,0.12), rgba(255,200,120,0.05));
  border: 1px solid rgba(255,207,122,0.4); box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  animation: overlayIn 0.5s cubic-bezier(0.22,1,0.36,1); transition: opacity 0.6s ease; }
.howto-hint.fade { opacity: 0; }
.howto-hint b { color: var(--gold); }
.howto-hint em { color: var(--gold-strong); font-style: italic; }
.howto-x { position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border: none; background: transparent; color: var(--ink-dim); font-size: 14px; cursor: pointer; border-radius: 6px; }
.howto-x:hover { color: var(--gold); background: rgba(255,255,255,0.08); }

body.reduce-motion .menu-motes, body.reduce-motion .menu-card::before, body.reduce-motion .howto-hint { animation: none; }
body.reduce-motion #haunt-veil { transition: none; }

/* "The Other You": full-screen event when the shop notices a second open tab */
.other-you { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 26px; pointer-events: none; opacity: 0; transition: opacity 0.9s ease;
  background: radial-gradient(circle at 50% 50%, rgba(22,0,7,0.5) 0%, rgba(4,0,2,0.88) 100%); backdrop-filter: blur(3px); }
.other-you.show { opacity: 1; }
.oy-bg { position: absolute; inset: 0; z-index: 0; background: url("assets/art/the_other_you.png") center/cover no-repeat; opacity: 0.3; filter: saturate(0.7) brightness(0.55); }
.oy-inner { position: relative; z-index: 1; max-width: 640px; text-align: center; }
.oy-line { font-family: var(--font-body); font-size: clamp(20px, 3.4vw, 30px); line-height: 1.5; margin: 0 0 16px; color: #ecd8c4;
  text-shadow: 2px 0 rgba(255,44,44,0.4), -2px 0 rgba(60,120,255,0.3), 0 0 26px rgba(255,60,50,0.35); animation: oyWaver 3s ease-in-out infinite; }
.oy-attr { font-family: var(--font-ui); font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--nightmare); opacity: 0.85; }
@keyframes oyWaver { 0%,100% { text-shadow: 2px 0 rgba(255,44,44,0.4), -2px 0 rgba(60,120,255,0.3), 0 0 26px rgba(255,60,50,0.35); } 50% { text-shadow: -2px 0 rgba(255,44,44,0.4), 2px 0 rgba(60,120,255,0.3), 0 0 30px rgba(255,60,50,0.45); } }
body.reduce-motion .other-you { transition: opacity 0.25s ease; backdrop-filter: none; }
body.reduce-motion .oy-line { animation: none; }

/* ---- shop whisper: the shop's voice reaching you outside the story --------
 * Idle ("still there?"), right-click / copy ("trying to remember me?"). A
 * disembodied line that floats in from the top over anything on screen. */
#shop-whisper { position: fixed; left: 50%; top: 12%; transform: translate(-50%, -10px); z-index: 64;
  max-width: min(560px, 88vw); text-align: center; padding: 13px 20px; border-radius: 13px;
  font-family: var(--font-body); font-size: clamp(15px, 2vw, 18px); font-style: italic; line-height: 1.5;
  color: #ecd8c4; background: rgba(12,4,10,0.92); border: 1px solid rgba(176,48,74,0.5);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), 0 0 28px rgba(120,0,20,0.35); backdrop-filter: blur(5px);
  text-shadow: 0 0 13px rgba(255,70,55,0.28); opacity: 0; pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s ease; }
#shop-whisper.show { opacity: 1; transform: translate(-50%, 0); }
body.reduce-motion #shop-whisper { transition: opacity 0.25s ease; backdrop-filter: none; }

/* ---- responsive: phones & small tablets --------------------------------- */
/* On touch devices a tap shouldn't leave a button stuck in its hover state. */
@media (hover: none) {
  .choice:hover, .icon-btn:hover, .primary-btn:hover, .ghost-btn:hover,
  .filter-chip:hover, .coll-card.clickable:hover { transform: none; }
  .choice:active { transform: translateX(2px); border-color: var(--gold); }
  .primary-btn:active, .ghost-btn:active, .icon-btn:active { transform: translateY(1px); }
}

@media (max-width: 640px) {
  /* fluid type */
  .menu-title { font-size: clamp(38px, 12vw, 56px); letter-spacing: 3px; }
  .story-text { font-size: 17px; line-height: 1.55; }
  .intro-line { font-size: 21px; }
  .about-title { font-size: 24px; }

  /* topbar: two tidy rows on a phone — stats + bracelet up top, controls below */
  #topbar { gap: 5px 8px; flex-wrap: wrap; padding-bottom: 6px; }
  .hud-stats { gap: 4px; flex: 1 1 auto; }
  .stat-chip { padding: 3px 7px; font-size: 12px; gap: 3px; }
  .stat-name { display: none; }
  .hud-right { gap: 6px; flex: 1 1 100%; justify-content: flex-end; }
  .hud-endings { display: none; }              /* progress lives in the tracker */
  .hud-bracelet { padding: 3px 8px 3px 5px; }
  .icon-btn { width: 31px; height: 31px; font-size: 14px; border-radius: 9px; }
  #btn-debug { display: none; }                 /* dev-only; no keyboard on phones */

  /* stage + panel: more room for the story, still tappable */
  #stage { padding-top: 60px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .story-panel { width: 100%; max-height: 66vh; padding: 16px 16px 20px; border-radius: 14px; }
  .choices { gap: 9px; }
  .choice { padding: 13px 14px; font-size: 15.5px; }
  .characters { height: 44vh; }
  .scene-caption { top: 54px; left: 12px; font-size: 11px; padding: 4px 10px; }

  /* overlays: use the height, ease the padding */
  .sheet { max-height: 92vh; }
  .sheet-head { padding: 14px 16px; }
  .sheet-head h2 { font-size: 19px; }
  .sheet-body { padding: 14px 16px; }
  .ending-card { padding: 22px 18px; max-height: 92vh; }
  .ending-name { font-size: 24px; }
  .ending-text { font-size: 16px; }
  .detail-card .ending-number, .detail-card .ending-name,
  .detail-card .ending-cat-chip, .detail-card .ending-text { padding-left: 18px; padding-right: 18px; }
  .detail-clue { padding: 0 18px 18px; }
  .coll-cards { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .set-row { flex-wrap: wrap; gap: 8px; }
  .set-desc { max-width: 100%; }
  .set-text { width: 130px; }
  .menu-actions, .menu-more { width: min(320px, 86vw); }
  .intro-skip { bottom: max(18px, env(safe-area-inset-bottom)); }
}

/* short viewports (landscape phones): let tall overlays scroll instead of clip */
@media (max-height: 480px) {
  .overlay { align-items: flex-start; overflow-y: auto; }
  .menu-card { padding: 10px 16px; }
  .menu-kicker { display: none; }
  .menu-tag { margin-bottom: 6px; }
  .menu-haunt { min-height: 0; margin-bottom: 8px; }
  .menu-actions { gap: 8px; margin-top: 10px; }
  .menu-more, .menu-progress { margin-top: 8px; }
  .ghost-btn, .primary-btn { padding: 10px 16px; }
}
/* landscape phones: reclaim vertical space in the story view */
@media (max-height: 480px) and (orientation: landscape) {
  .characters { height: 80vh; }
  #stage { padding-top: 50px; }
  .story-panel { max-height: 82vh; }
  .menu-title { font-size: clamp(28px, 8vh, 44px); }
  .intro-line { font-size: 18px; }
}

/* ---- the night's account: the run-ledger interstitial ------------------- */
.run-ledger { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(7,5,11,0.94); opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
.run-ledger.show { opacity: 1; pointer-events: auto; }
.rl-page { max-width: min(560px, 90vw); width: 100%; padding: 26px 30px 20px; background: linear-gradient(160deg, #17101e, #100a16); border: 1px solid rgba(232,192,122,0.22); border-radius: 6px; box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 0 60px rgba(0,0,0,0.5); font-family: Georgia, 'Times New Roman', serif; }
.rl-head { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: rgba(232,192,122,0.65); margin-bottom: 12px; text-align: center; }
.rl-head::after { content: ""; display: block; margin: 10px auto 0; width: 120px; border-bottom: 1px solid rgba(232,192,122,0.25); }
.rl-line { font-style: italic; color: #d8c9b8; font-size: 15.5px; line-height: 1.55; margin: 9px 0; animation: rlInk 0.7s ease both; }
.rl-line::before { content: "\2014  "; color: rgba(232,192,122,0.55); }
@keyframes rlInk { from { opacity: 0; transform: translateY(4px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
.rl-balance { margin-top: 16px; padding-top: 12px; border-top: 1px dashed rgba(232,192,122,0.3); color: #e8c07a; font-size: 13px; letter-spacing: 1.2px; line-height: 1.6; opacity: 0; transition: opacity 0.8s ease; }
.rl-balance.shown { opacity: 1; }
.rl-skip { margin-top: 14px; text-align: center; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: rgba(216,201,184,0.35); }
body.reduce-motion .rl-line { animation: none; }
body.reduce-motion .run-ledger, body.reduce-motion .rl-balance { transition: none; }

/* ---- the shop's margin note on the ending card --------------------------- */
.ending-stinger { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 13.5px; line-height: 1.55; color: rgba(232,192,122,0.78); margin: 10px 0 0; opacity: 0; }
.ending-screen.open .ending-stinger { animation: stingIn 1.4s ease 3.2s both; }
@keyframes stingIn { from { opacity: 0; transform: translateY(3px); filter: blur(2px); } to { opacity: 0.9; transform: none; filter: none; } }
body.reduce-motion .ending-screen.open .ending-stinger { animation: none; opacity: 0.9; }

/* ---- the bracelet answers: her counter-voice under his asides ------------ */
.br-voice { display: none; margin: 10px 0 0; padding: 8px 12px; font-style: italic; font-size: 14px; line-height: 1.55; color: #cfe9d8; border-left: 3px solid; border-image: linear-gradient(180deg, #ff9db1, #ffd166, #8ad7ff, #7be08a) 1; background: rgba(58, 143, 122, 0.08); border-radius: 0 6px 6px 0; }
.br-voice.show { display: block; animation: brIn 0.9s ease both; }
.br-voice.silent { color: rgba(207, 233, 216, 0.35); border-image: none; border-left-color: rgba(207, 233, 216, 0.18); background: none; letter-spacing: 5px; }
@keyframes brIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#hud-bracelet.br-pulse { animation: brPulse 1.6s ease 2; }
@keyframes brPulse { 0%, 100% { filter: none; } 50% { filter: drop-shadow(0 0 7px rgba(123, 224, 138, 0.9)); } }
body.reduce-motion .br-voice.show { animation: none; }
body.reduce-motion #hud-bracelet.br-pulse { animation: none; }

/* ---- the receipt: choice history in the shopkeeper's hand ---------------- */
#history-body { font-family: Georgia, 'Times New Roman', serif; }
.hr-head { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: rgba(232,192,122,0.65); text-align: center; margin-bottom: 12px; }
.hr-head::after { content: ""; display: block; margin: 10px auto 0; width: 110px; border-bottom: 1px dashed rgba(232,192,122,0.3); }
#history-body .hist-row { display: flex; align-items: baseline; gap: 8px; margin: 7px 0; font-size: 14px; line-height: 1.5; }
#history-body .hist-i { color: rgba(232,192,122,0.55); font-size: 12px; flex: none; }
#history-body .hist-t { flex: 1; font-style: italic; color: #d8c9b8; }
#history-body .hist-t::after { content: ""; display: inline-block; width: 2em; border-bottom: 1px dotted rgba(216,201,184,0.25); margin-left: 6px; vertical-align: 3px; }
#history-body .hist-d { flex: none; color: rgba(232,192,122,0.8); font-size: 12px; white-space: nowrap; }
.hr-balance { margin-top: 14px; padding-top: 10px; border-top: 1px dashed rgba(232,192,122,0.3); color: #e8c07a; font-size: 12.5px; letter-spacing: 1px; line-height: 1.6; }
.hr-note { margin-top: 10px; font-style: italic; font-size: 13px; color: rgba(216,120,120,0.85); }
.hr-foot { margin-top: 14px; text-align: center; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: rgba(216,201,184,0.35); }

/* ---- the gallery misremembers -------------------------------------------- */
.detail-stinger { opacity: 0.9 !important; animation: none !important; margin: 8px 0 0; }
.detail-clue.haunted { color: rgba(216,120,120,0.85); font-style: italic; }
