/* =========================================================
   The Atelier Trials — retro storybook, ink & glyph
   ========================================================= */
:root {
  --night: #1b2747;
  --night-deep: #111a33;
  --vellum: #ecdcb4;
  --vellum-dark: #d9c38f;
  --paper: #d6c39a;
  --gold: #d6a03c;
  --gold-hi: #f0c869;
  --teal: #2c6a6c;
  --teal-deep: #1d4a4c;
  --rose: #b0475c;
  --ink: #1c1612;
  --ink-soft: #4a3b2e;
  --wood: #7a4f2c;
  --wood-dark: #4f3019;
  --display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --display-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --body: "Alegreya", Georgia, serif;
  --ease-ink: cubic-bezier(.65, .05, .36, 1);
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night-deep);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px dashed var(--gold-hi); outline-offset: 3px; }

.grain {
  position: fixed; inset: -50%;
  pointer-events: none; z-index: 90;
  opacity: .18; mix-blend-mode: multiply;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.9'/></svg>");
  animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); }
}

/* Print-misregistration headings */
.ink-title, .chapter-title {
  font-family: var(--display);
  font-weight: 400;
  color: var(--ink);
  text-shadow: 1.5px 1px 0 rgba(44, 106, 108, .45), -.6px 0 0 rgba(176, 71, 92, .3);
  letter-spacing: .005em;
  line-height: 1.1;
  margin: 0;
}
.ink-title { font-size: clamp(2.1rem, 5.4vw, 3.4rem); text-wrap: balance; }
.chapter-title { font-size: clamp(1.6rem, 3.6vw, 2.3rem); }

/* ---------- Scenes ---------- */
.scene {
  position: relative;
  min-height: 100vh; min-height: 100dvh;
  display: none;
  overflow: hidden;
  overflow: clip;
  padding: 84px 16px 48px;
}
.scene.is-active { display: block; }

/* ---------- Progress glyphs ---------- */
.trials {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; z-index: 50;
  padding: 6px 14px;
  border-radius: 40px;
  background: rgba(30, 18, 64, .6);
  border: 1px solid rgba(201, 182, 255, .2);
  box-shadow: 0 0 24px rgba(143, 111, 216, .25);
  backdrop-filter: blur(4px);
  transition: opacity .6s;
}
body[data-scene="intro"] .trials { opacity: 0; pointer-events: none; }
.trial-glyph { width: 40px; height: 40px; display: block; color: rgba(236, 220, 180, .35); }
.trial-glyph .glyph-svg { width: 100%; height: 100%; }
.trial-glyph.is-current { color: rgba(236, 220, 180, .85); }
.trial-glyph.is-done { color: var(--gold-hi); filter: drop-shadow(0 0 6px rgba(240, 200, 105, .7)); }
.trial-glyph.is-done .gl { animation: draw 1.6s var(--ease-ink) both; }
.trial-glyph.is-done .glyph-svg { animation: spin 40s linear infinite; }

.gl { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 400; }
.gl.thin { stroke-width: 1; }
.gl path, .gl rect { fill: none; stroke: currentColor; }
@keyframes draw { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   NIGHT SKY + SCROLL (start / end)
   ========================================================= */
.scene-night {
  background:
    radial-gradient(ellipse 70% 50% at 50% 115%, rgba(143, 111, 216, .45) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 15% 20%, rgba(110, 70, 180, .25), transparent 70%),
    radial-gradient(ellipse 40% 30% at 85% 60%, rgba(70, 60, 170, .22), transparent 70%),
    linear-gradient(#07051a 0%, #140d33 45%, #241746 80%, #2f1d55 100%);
  display: none;
}
.scene-night.is-active { display: grid; justify-items: center; align-content: start; padding-top: max(120px, 18vh); padding-bottom: 120px; }
.sky { position: absolute; inset: 0; pointer-events: none; }
.stars, .stars::after {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 72%, #fff9 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 44% 34%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 12%, #fffa 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 78% 58%, #fff8 50%, transparent 51%),
    radial-gradient(1.8px 1.8px at 88% 26%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 82%, #fff9 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 52% 88%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 8%, #fffa 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 94% 84%, #ffe9b0 50%, transparent 51%);
  background-size: 420px 420px;
  animation: twinkle 4s ease-in-out infinite alternate;
}
.stars::after { content: ""; background-size: 290px 290px; animation-delay: -2s; opacity: .7; }
@keyframes twinkle { from { opacity: .45; } to { opacity: 1; } }
.moon {
  position: absolute; top: 9%; right: 10%;
  width: 84px; height: 84px; border-radius: 50%;
  box-shadow: -18px 8px 0 0 #f3e2b3;
  filter: drop-shadow(0 0 22px rgba(243, 226, 179, .45));
  animation: bob 7s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px); } }

.scroll-stage { position: relative; width: min(620px, 100%); }
.scroll { position: relative; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
/* parchment roll: a paper cylinder with spiral ends and turned handles */
.rod {
  position: relative; z-index: 2;
  height: 44px; margin: 0 -14px;
  border-radius: 9px / 22px;
  background:
    repeating-linear-gradient(90deg, transparent 0 37px, rgba(90, 60, 30, .07) 37px 38px, transparent 38px 71px),
    linear-gradient(180deg, #4e3519 0%, #9c7a48 12%, #dcc596 30%, #f3e6c0 42%, #e2cd9c 56%, #b8955f 76%, #7a5a30 90%, #3e2a12 100%);
  box-shadow: 0 6px 10px rgba(0, 0, 0, .35);
}
.rod-top { margin-bottom: -8px; }
.rod-bottom { margin-top: -8px; }
.rod-bottom { animation: none; }
.scroll.is-open .rod-bottom { animation: rollSettle 1.7s var(--ease-ink); }
@keyframes rollSettle { 0% { transform: rotate(0); } 85% { transform: rotate(.6deg); } 100% { transform: none; } }
.rod .cap-wrap { position: absolute; top: 0; bottom: 0; width: 16px; }
.rod .cap-wrap.l { left: -6px; }
.rod .cap-wrap.r { right: -6px; }
.rod .cap { width: 100%; height: 100%; display: block; }
.rod .handle { position: absolute; top: 50%; width: 46px; height: 34px; margin-top: -17px; z-index: -1; }
.rod .handle.l { left: -42px; }
.rod .handle.r { right: -42px; transform: scaleX(-1); }
.paper { margin: 0 2px; height: 0; overflow: hidden; }
.paper-inner {
  overflow: hidden; min-height: 0;
  color: #3a2412;
  background:
    radial-gradient(ellipse 13% 9% at 84% 80%, transparent 62%, rgba(120, 80, 30, .25) 68%, transparent 76%),
    radial-gradient(ellipse 30% 20% at 15% 25%, rgba(140, 95, 40, .2), transparent 70%),
    radial-gradient(ellipse 22% 16% at 78% 14%, rgba(110, 70, 30, .16), transparent 70%),
    radial-gradient(ellipse 35% 22% at 38% 88%, rgba(140, 95, 40, .18), transparent 70%),
    linear-gradient(96deg, transparent 47%, rgba(255, 248, 225, .28) 48.6%, rgba(90, 60, 25, .14) 50%, transparent 51.6%),
    linear-gradient(180deg, transparent 49%, rgba(255, 248, 225, .22) 50%, rgba(90, 60, 25, .12) 51%, transparent 52%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.014' numOctaves='4' seed='7'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .3  0 0 0 0 .12  0 0 0 .55 -.12'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>"),
    radial-gradient(ellipse at 50% 45%, #eedfb3 0%, #dcc590 62%, #bf9f62 100%);
  box-shadow: inset 0 0 16px rgba(80, 40, 10, .6), inset 0 0 70px rgba(120, 75, 30, .38);
  padding: 0 clamp(30px, 7vw, 64px);
  text-align: center;
  position: relative;
}
.paper-inner > * { position: relative; z-index: 1; }
.scroll .paper-inner > .paper-glyph,
.scroll.is-open .paper-inner > .paper-glyph {
  position: absolute; z-index: 0; left: 50%; top: 50%;
  width: min(460px, 90%); margin: 0; translate: -50% -50%;
  color: var(--teal); opacity: .09; filter: none; transform: none;
  animation: spin 90s linear infinite; pointer-events: none;
}
.paper-inner > :first-child { margin-top: 44px; }
.paper-inner > .ink-title { margin-top: 58px; }
.paper-inner > .btn { margin-bottom: 64px; }
.paper-inner .seal { display: none; }
.paper-inner .ink-title { color: #2b1708; text-shadow: 1px 1px 0 rgba(122, 31, 36, .18); }
.paper-inner .to-line { color: #6b4520; }
.paper-inner .message p:first-child::first-letter { color: #7a1f24; text-shadow: 1px 1px 0 rgba(214, 160, 60, .5); }

/* decorations that live on the paper */
.scroll .paper-inner > .deco,
.scroll.is-open .paper-inner > .deco { position: absolute; opacity: 1; filter: none; transform: none; animation: none; pointer-events: none; z-index: 0; margin: 0; }
.ink-frame { inset: 22px 20px; border: 3px double rgba(70, 40, 15, .42); border-radius: 2px; color: rgba(70, 40, 15, .6); }
.ink-frame .corner { position: absolute; width: 34px; height: 34px; }
.ink-frame .corner svg { width: 100%; height: 100%; display: block; }
.ink-frame .tl { left: 4px; top: 4px; }
.ink-frame .tr { right: 4px; top: 4px; transform: scaleX(-1); }
.ink-frame .bl { left: 4px; bottom: 4px; transform: scaleY(-1); }
.ink-frame .br { right: 4px; bottom: 4px; transform: scale(-1); }
.ink-blot { left: 44px; top: 70px; width: 46px; fill: rgba(43, 23, 8, .5); transform: rotate(-12deg); }
.paws { right: 36px; bottom: 38px; width: 120px; height: 90px; }
.paw { position: absolute; width: 20px; fill: rgba(60, 30, 10, .35); opacity: 0; }
.paw:nth-child(1) { left: 0; bottom: 0; transform: rotate(-30deg); }
.paw:nth-child(2) { left: 30px; bottom: 26px; transform: rotate(-24deg); }
.paw:nth-child(3) { left: 52px; bottom: 6px; transform: rotate(-30deg); }
.paw:nth-child(4) { left: 82px; bottom: 34px; transform: rotate(-24deg); }
.scroll.is-open .paw { animation: pawStep .3s ease-out forwards; animation-delay: calc(1.3s + var(--i) * .35s); }
@keyframes pawStep { from { opacity: 0; scale: 1.5; } to { opacity: 1; scale: 1; } }

/* ribbon hanging from the top roll */
.ribbon { position: absolute; left: 13%; top: 8px; width: 46px; z-index: 3; transform-origin: 50% 0; opacity: 0; pointer-events: none; }
.ribbon svg { width: 100%; display: block; filter: drop-shadow(2px 4px 3px rgba(0, 0, 0, .35)); }
.scroll.is-open .ribbon { animation: ribbonIn .6s .1s ease-out forwards, ribbonSway 4s .7s ease-in-out infinite alternate; }
@keyframes ribbonIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: none; } }
@keyframes ribbonSway { from { rotate: -2deg; } to { rotate: 3deg; } }
.ribbon-seal {
  position: absolute; left: 50%; top: -6px; width: 54px; height: 54px; margin-left: -27px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'><path d='M35 3 C46 5 52 2 58 10 C66 16 66 24 67 34 C68 46 64 54 56 60 C48 67 40 67 32 67 C22 66 14 62 8 54 C2 46 3 38 3 30 C4 20 10 12 18 7 C24 3 30 4 35 3Z' fill='%23a3283a'/><circle cx='35' cy='35' r='22' fill='none' stroke='%23701726' stroke-width='2'/><g fill='%23701726'><ellipse cx='35' cy='41' rx='9' ry='7'/><circle cx='24' cy='31' r='4'/><circle cx='31' cy='25' r='4'/><circle cx='39' cy='25' r='4'/><circle cx='46' cy='31' r='4'/></g></svg>") center/contain no-repeat;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4));
  transform: rotate(-10deg);
}
.ribbon-seal.gold { filter: hue-rotate(52deg) saturate(1.5) brightness(1.2) drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }

/* quill resting against the scroll */
.quill { position: absolute; width: 46px; z-index: 3; pointer-events: none; filter: drop-shadow(3px 6px 6px rgba(0, 0, 0, .45)); animation: quillBob 5s ease-in-out infinite; }
.quill svg { width: 100%; display: block; }
.q-left { left: -40px; bottom: 30px; rotate: -28deg; }
.q-right { right: -36px; bottom: 34px; rotate: 26deg; }
@keyframes quillBob { 50% { translate: 0 -6px; } }
.seal {
  width: 70px; height: 70px; margin: 0 auto 18px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'><path d='M35 3 C46 5 52 2 58 10 C66 16 66 24 67 34 C68 46 64 54 56 60 C48 67 40 67 32 67 C22 66 14 62 8 54 C2 46 3 38 3 30 C4 20 10 12 18 7 C24 3 30 4 35 3Z' fill='%23b0475c'/><circle cx='35' cy='35' r='22' fill='none' stroke='%23862f42' stroke-width='2'/><g fill='%23862f42'><ellipse cx='35' cy='41' rx='9' ry='7'/><circle cx='24' cy='31' r='4'/><circle cx='31' cy='25' r='4'/><circle cx='39' cy='25' r='4'/><circle cx='46' cy='31' r='4'/></g></svg>") center/contain no-repeat;
  transform: rotate(-8deg);
}
.seal-gold { filter: hue-rotate(52deg) saturate(1.5) brightness(1.2); }
.to-line { font-style: italic; color: var(--ink-soft); margin: 6px 0 22px; }
.message { max-width: 34em; margin: 0 auto 28px; text-align: left; }
.message p { margin: 0 0 1em; font-size: 1.08rem; line-height: 1.7; }
.message p:first-child { display: flow-root; }
.message p:first-child::first-letter {
  font-family: var(--display); float: left;
  font-size: 3.4em; line-height: .8; padding: 6px 8px 0 0;
  color: var(--teal);
}
/* ink-in reveal for scroll content */
.scroll .paper-inner > * { opacity: 0; filter: blur(4px); transform: translateY(6px); }
.scroll.is-open .paper-inner > * {
  animation: inkIn .9s var(--ease-ink) forwards;
  animation-delay: calc(.1s + var(--i, 0) * .22s);
}
@keyframes inkIn { to { opacity: 1; filter: blur(0); transform: none; } }

/* ---------- Mascot ---------- */
.mascot { position: absolute; width: 120px; z-index: 3; }
.mascot-intro { right: -40px; bottom: -36px; }
.mascot-finale { left: -46px; bottom: -36px; }
.cat { display: block; width: 100%; height: auto; overflow: visible; }
.cat .tail { transform-origin: 88px 124px; animation: swish 3.2s ease-in-out infinite; }
@keyframes swish { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-10deg); } }
.cat .eyes { transform-origin: 60px 58px; animation: blink 5s infinite; }
.cat-peek .eyes { transform-origin: 60px 48px; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.cat .ear-l { transform-origin: 40px 44px; animation: twitch 6s infinite; }
@keyframes twitch { 0%, 80%, 100% { transform: rotate(0); } 83% { transform: rotate(-12deg); } 86% { transform: rotate(0); } }
.cat .pupil { transition: transform .3s; }
.eye-happy { fill: none; stroke: var(--gold-hi); stroke-width: 3; stroke-linecap: round; }
.cat .head { transform-origin: 60px 80px; transition: transform .4s var(--ease-pop); }
.mascot:hover .head, .mascot.cheer .head { transform: rotate(-8deg); }
.mascot.cheer { animation: hop .5s var(--ease-pop) 3; }
@keyframes hop { 50% { transform: translateY(-22px); } }
.mascot.sulk .head { transform: translateY(4px) rotate(6deg); }

/* Finale hat drop */
.falling-hat {
  position: absolute; left: 0; top: 0; width: 120px; height: 176px; pointer-events: none;
  opacity: 0;
}
.falling-hat svg { width: 100%; height: 100%; overflow: visible; }
#finale .scroll.is-open ~ .mascot .falling-hat { animation: hatDrop 1.4s 1.3s var(--ease-pop) forwards; }
@keyframes hatDrop {
  0% { opacity: 0; transform: translateY(-260px) rotate(-30deg); }
  20% { opacity: 1; }
  70% { transform: translateY(6px) rotate(4deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}

/* ---------- Buttons ---------- */
.btn {
  border: 0; position: relative;
  font-family: var(--display); font-size: 1.2rem;
  padding: 14px 30px 15px;
  transition: transform .25s var(--ease-pop), box-shadow .25s;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn-wax {
  color: #fbe9d8;
  background: radial-gradient(circle at 40% 30%, #c95a70, var(--rose) 50%, #7c2b3c);
  border-radius: 46% 54% 50% 50% / 60% 55% 45% 40%;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), 0 6px 0 #5b1f2c, 0 10px 18px rgba(0, 0, 0, .3);
  text-shadow: 0 1px 0 #5b1f2c;
}
.btn-wax:hover { transform: translateY(-3px) rotate(-1.5deg); }
.btn-wax::after {
  content: ""; position: absolute; inset: -10px; border-radius: inherit;
  border: 2px solid rgba(240, 200, 105, .0);
  animation: halo 2.4s ease-out infinite;
}
@keyframes halo { 0% { border-color: rgba(240, 200, 105, .7); transform: scale(.9); } 100% { border-color: rgba(240, 200, 105, 0); transform: scale(1.15); } }
.btn-plank {
  color: #fbecd2;
  background:
    repeating-linear-gradient(92deg, transparent 0 22px, rgba(0, 0, 0, .08) 22px 24px),
    linear-gradient(#9a6537, var(--wood) 60%, #643d1f);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 5px 0 var(--wood-dark), 0 8px 14px rgba(0, 0, 0, .3);
}
.btn-plank:hover { transform: translateY(-2px); }

/* =========================================================
   WORDLE — candlelit study, open book
   ========================================================= */
.scene-study {
  background:
    radial-gradient(ellipse 60% 45% at 50% 42%, rgba(240, 180, 90, .28), transparent 70%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .12) 0 2px, transparent 2px 38px),
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(90, 50, 140, .35), transparent 70%),
    linear-gradient(#1c1022, #2e1c22 55%, #1a0f14);
}
.scene-study.is-active { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 76px; }
.candle {
  position: absolute; left: 6%; top: 18%; width: 26px; height: 90px;
  background: linear-gradient(90deg, #e6d6b0, #fff4d8 40%, #cdb98b);
  border-radius: 4px 4px 2px 2px;
}
.candle::before { content: ""; position: absolute; left: -14px; right: -14px; bottom: -8px; height: 12px; border-radius: 50%; background: #8a6a3a; }
.flame {
  position: absolute; left: 50%; top: -34px; width: 16px; height: 30px; margin-left: -8px;
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse at 50% 75%, #fff 0 15%, #ffd36b 35%, #f08a2c 75%, transparent 80%);
  transform-origin: 50% 100%;
  animation: flicker .18s infinite alternate;
}
.glow { position: absolute; left: 50%; top: -60px; width: 220px; height: 220px; margin-left: -110px; border-radius: 50%; background: radial-gradient(rgba(255, 200, 110, .35), transparent 65%); animation: glow 2.4s ease-in-out infinite alternate; pointer-events: none; }
@keyframes flicker { from { transform: rotate(-3deg) scaleY(1); } to { transform: rotate(3deg) scaleY(1.08); } }
@keyframes glow { from { opacity: .7; } to { opacity: 1; transform: scale(1.06); } }

.book {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  width: min(960px, 100%);
  padding: 12px;
  background: linear-gradient(90deg, #5a2a26, #7a3a30 49%, #3a1a17 50%, #7a3a30 51%, #5a2a26);
  border-radius: 10px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(214, 160, 60, .45);
  transform-origin: 50% 100%;
}
#wordle.is-active .book { animation: bookOpen 1.1s var(--ease-ink) both; }
@keyframes bookOpen { from { transform: perspective(1200px) rotateX(35deg) translateY(40px); opacity: 0; } }
.page {
  position: relative; min-height: 440px;
  padding: 30px clamp(18px, 3.4vw, 40px);
  background:
    repeating-linear-gradient(transparent 0 31px, rgba(44, 106, 108, .08) 31px 32px),
    var(--paper);
}
.page-left {
  border-radius: 6px 0 0 6px;
  background:
    linear-gradient(90deg, transparent 80%, rgba(90, 60, 30, .3)),
    repeating-linear-gradient(transparent 0 31px, rgba(44, 106, 108, .08) 31px 32px),
    var(--paper);
}
.page-right {
  border-radius: 0 6px 6px 0;
  background:
    linear-gradient(270deg, transparent 80%, rgba(90, 60, 30, .3)),
    var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.page-text { margin: 14px 0 22px; max-width: 26em; }
.legend p { display: flex; align-items: center; gap: 12px; margin: 8px 0; font-size: .98rem; }
.legend .key-tile { width: 34px; height: 34px; font-size: 1.1rem; flex: none; }
.glyph-doodle { position: absolute; right: 22px; bottom: 26px; width: 120px; color: rgba(44, 106, 108, .35); animation: spin 60s linear infinite; }
.glyph-doodle .gl { animation: draw 3s var(--ease-ink) both; }
.peek-cat { position: absolute; left: 34px; top: -58px; width: 92px; z-index: -1; animation: peek 7s ease-in-out infinite; }
@keyframes peek { 0%, 20%, 100% { transform: translateY(75%); } 32%, 78% { transform: translateY(8%); } }
.peek-cat .paw-l { animation: pat 6s infinite; transform-origin: 38px 68px; }
@keyframes pat { 0%, 45%, 55%, 100% { transform: none; } 50% { transform: translateY(-6px); } }

.wordle-board { display: grid; gap: 7px; }
.w-row { display: grid; gap: 7px; grid-template-columns: repeat(var(--len, 5), 1fr); }
.w-row.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.w-tile {
  width: clamp(42px, 5.4vw, 56px); aspect-ratio: 1;
  display: grid; place-items: center;
  font-family: var(--display-sc); font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: var(--ink);
  border: 2px solid rgba(28, 22, 18, .25);
  border-radius: 3px;
  background: rgba(255, 250, 235, .35);
  transform-style: preserve-3d;
}
.w-tile.filled { border-color: var(--ink-soft); animation: stamp .14s ease-out; }
@keyframes stamp { 50% { transform: scale(1.12); } }
.w-tile.flip { animation: flip .6s ease-in-out both; animation-delay: calc(var(--i) * .22s); }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.w-tile.correct, .k-correct { background: var(--teal); border-color: var(--teal-deep); color: #f6ecd2; }
.w-tile.present, .k-present { background: var(--gold); border-color: #a87924; color: var(--ink); }
.w-tile.absent, .k-absent { background: #8a7a64; border-color: #6e604d; color: #efe3c8; }
.w-tile.win { animation: winBounce .6s var(--ease-pop) both; animation-delay: calc(var(--i) * .1s); }
@keyframes winBounce { 40% { transform: translateY(-16px) rotate(-4deg); } }
.wordle-status { min-height: 1.6em; margin: 0; font-style: italic; text-align: center; color: var(--ink-soft); }
.spine { position: absolute; top: 12px; bottom: 12px; left: 50%; width: 30px; margin-left: -15px; background: linear-gradient(90deg, transparent, rgba(60, 35, 15, .35), transparent); pointer-events: none; }

.keyboard { width: min(640px, 100%); display: grid; gap: 7px; }
.k-row { display: flex; justify-content: center; gap: 6px; }
.key-tile, .k {
  display: grid; place-items: center;
  font-family: var(--display-sc); font-size: 1.15rem;
  border-radius: 5px;
}
.k {
  flex: 1 1 0; max-width: 46px; height: 54px; padding: 0;
  border: 0; color: var(--ink);
  background: linear-gradient(#ddcaa0, #bfa774);
  box-shadow: 0 3px 0 #9c8456, 0 5px 8px rgba(0, 0, 0, .3);
  transition: transform .1s, background .3s;
}
.k.wide { max-width: 78px; flex-grow: 1.6; font-size: .9rem; }
.k:active, .k.pressed { transform: translateY(3px); box-shadow: 0 0 0 #9c8456; }
.k.k-correct { background: var(--teal); color: #f6ecd2; box-shadow: 0 3px 0 var(--teal-deep); }
.k.k-present { background: var(--gold); box-shadow: 0 3px 0 #a87924; }
.k.k-absent { background: #6b5d4a; color: #d8ccb2; box-shadow: 0 3px 0 #4c4234; }
.after-win .btn { margin-top: 6px; }

/* =========================================================
   CROSSWORD — plank bridge over the sea
   ========================================================= */
.scene-sea { background: linear-gradient(#07051a 0%, #160e38 30%, #2a1d5a 55%, #3a2c6e 63%, #0b1630 100%); }
.scene-sea.is-active { display: block; }
.sea-sky { position: absolute; inset: 0; pointer-events: none; }
.sea-sky .stars { bottom: 40%; }
.night-moon {
  position: absolute; left: 50%; top: 20%; width: 150px; height: 150px; margin-left: -75px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fff8e2, #f3e2b3 55%, #d9c38f 100%);
  box-shadow: 0 0 60px 18px rgba(243, 226, 179, .28), 0 0 160px 60px rgba(150, 170, 230, .14);
  animation: moonPulse 6s ease-in-out infinite;
}
.night-moon::before, .night-moon::after { content: ""; position: absolute; border-radius: 50%; background: rgba(170, 150, 110, .28); }
.night-moon::before { width: 26px; height: 26px; left: 30%; top: 46%; }
.night-moon::after { width: 14px; height: 14px; left: 62%; top: 30%; box-shadow: -40px 50px 0 4px rgba(170, 150, 110, .2); }
@keyframes moonPulse { 50% { box-shadow: 0 0 80px 24px rgba(243, 226, 179, .34), 0 0 180px 70px rgba(150, 170, 230, .18); } }
.cloud { position: absolute; height: 26px; border-radius: 30px; background: rgba(120, 135, 190, .3); animation: drift 60s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 44px; height: 44px; left: 18px; top: -22px; }
.cloud::after { width: 32px; height: 32px; left: 52px; top: -14px; }
.c1 { width: 120px; top: 14%; left: -10%; }
.c2 { width: 90px; top: 30%; left: -30%; animation-duration: 80s; animation-delay: -30s; opacity: .7; }
.c3 { width: 150px; top: 8%; left: -50%; animation-duration: 95s; animation-delay: -60s; }
@keyframes drift { to { transform: translateX(160vw); } }
/* little bats flapping past the moon */
.bat { position: absolute; width: 26px; height: 12px; animation: batFly 18s linear infinite; }
.bat::before, .bat::after { content: ""; position: absolute; top: 0; width: 13px; height: 10px; background: #050816; animation: flap .25s ease-in-out infinite alternate; }
.bat::before { left: 0; clip-path: polygon(100% 30%, 0 0, 20% 60%, 45% 50%, 60% 100%, 100% 70%); transform-origin: right center; }
.bat::after { right: 0; clip-path: polygon(0 30%, 100% 0, 80% 60%, 55% 50%, 40% 100%, 0 70%); transform-origin: left center; }
@keyframes flap { to { transform: scaleY(-.6); } }
.b1 { top: 24%; left: -5%; } .b2 { top: 34%; left: -15%; animation-delay: -7s; scale: .7; }
@keyframes batFly { 0% { translate: 0 0; } 25% { translate: 30vw -3vh; } 50% { translate: 60vw 2vh; } 100% { translate: 120vw -2vh; } }

.sea { position: absolute; left: 0; right: 0; bottom: 0; height: 46%; pointer-events: none; background: linear-gradient(#16264a, #070d20); }
/* moon path on the water */
.sea::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 220px; margin-left: -110px; z-index: 1;
  background: repeating-linear-gradient(0deg, transparent 0 9px, rgba(243, 226, 179, .35) 9px 11px);
  -webkit-mask: radial-gradient(ellipse 50% 100% at 50% 0, #000 20%, transparent 75%);
  mask: radial-gradient(ellipse 50% 100% at 50% 0, #000 20%, transparent 75%);
  animation: shimmer 2.4s ease-in-out infinite alternate;
}
@keyframes shimmer { from { opacity: .55; transform: scaleX(.92); } to { opacity: 1; transform: scaleX(1.06); } }
.wave { position: absolute; left: 0; width: 200%; height: 90px; }
.wave path { fill: currentColor; }
.w1 { top: -50px; color: #213660; animation: wave 14s linear infinite; }
.w2 { top: 20%; color: #18294d; animation: wave 10s linear infinite reverse; opacity: .85; z-index: 2; }
.w3 { top: 55%; color: #0f1d3b; animation: wave 18s linear infinite; z-index: 2; }
@keyframes wave { to { transform: translateX(-50%); } }

.cross-wrap { position: relative; z-index: 2; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.sign {
  text-align: center; padding: 18px 32px 16px;
  color: var(--vellum);
  background: repeating-linear-gradient(0deg, transparent 0 18px, rgba(0, 0, 0, .12) 18px 20px), linear-gradient(#5e3a1e, #43280f);
  border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(214, 160, 60, .35), 0 6px 0 #2a1708, 0 12px 24px rgba(0, 0, 0, .45);
  transform: rotate(-1deg);
  animation: swing 5s ease-in-out infinite;
}
.sign p { margin: 6px 0 0; }
.sign .chapter-title { color: var(--gold-hi); text-shadow: 2px 1px 0 rgba(0, 0, 0, .5); }
@keyframes swing { 50% { transform: rotate(1deg); } }
.active-clue {
  min-height: 2.2em; padding: 6px 18px; border-radius: 30px;
  background: rgba(28, 22, 18, .75); color: var(--vellum);
  font-style: italic; text-align: center; max-width: 100%;
}
.active-clue b { font-style: normal; color: var(--gold-hi); font-family: var(--display); font-weight: 400; margin-right: 6px; }

.bridge { position: relative; padding: 76px 20px 44px; max-width: 100%; overflow-x: auto; }
.ropes { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; }
.cell.deck { display: flex; align-items: center; }
.cell.deck .plank { --plank-hi: #7a4f2c; --plank: #5a361b; height: 34%; border-radius: 2px; box-shadow: 0 3px 0 #3a2210; }
.bridge-grid { display: grid; gap: 4px; position: relative; z-index: 1; }
.cell { --size: clamp(20px, calc((100vw - 72px) / var(--cols, 10) - 4px), 50px); width: var(--size); aspect-ratio: 1; position: relative; }
.plank {
  position: relative; width: 100%; height: 100%;
  border-radius: 3px;
  background:
    radial-gradient(circle at 12% 18%, #3a2614 0 1.6px, transparent 2px),
    radial-gradient(circle at 88% 18%, #3a2614 0 1.6px, transparent 2px),
    radial-gradient(circle at 12% 82%, #3a2614 0 1.6px, transparent 2px),
    radial-gradient(circle at 88% 82%, #3a2614 0 1.6px, transparent 2px),
    repeating-linear-gradient(var(--grain-a, 3deg), transparent 0 5px, rgba(60, 35, 15, .14) 5px 6px),
    linear-gradient(var(--plank-hi, #a8774a), var(--plank, #7d5230));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25), 0 4px 0 #4f3019, 0 8px 10px rgba(0, 0, 0, .3);
  animation: plankDrop .5s var(--ease-pop) both;
  animation-delay: calc(var(--d, 0) * 25ms + .3s);
  transform: rotate(var(--tilt, 0deg));
}
@keyframes plankDrop { from { opacity: 0; transform: translateY(-40px) rotate(-10deg); } }
.plank input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; background: transparent; padding: 0;
  text-align: center; text-transform: uppercase;
  font-family: var(--display-sc); font-size: calc(var(--size) * .56);
  color: #fbecd2; text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  caret-color: transparent; border-radius: 3px;
  outline: none;
}
.plank .num { position: absolute; top: -9px; left: -7px; z-index: 2; pointer-events: none; min-width: 19px; height: 19px; padding: 0 4px; border-radius: 10px; display: grid; place-items: center; font: 700 .72rem/1 var(--body); color: var(--ink); background: var(--vellum); box-shadow: 0 1px 0 #8e6b3c; }
.cell.in-word .plank { --plank-hi: #d9a466; --plank: #b37843; }
.cell.focus .plank { --plank-hi: #f0c869; --plank: #d6a03c; transform: translateY(-4px); }
.cell.focus .plank input { color: var(--ink); text-shadow: none; }
.cell.good .plank { --plank-hi: #5f9a8c; --plank: var(--teal); }
.cell.bad .plank { animation: creak .5s; --plank-hi: #c56a7a; --plank: var(--rose); }
@keyframes creak { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.cell.solved .plank { animation: wobble .6s var(--ease-pop) both; animation-delay: calc(var(--d, 0) * 30ms); }
@keyframes wobble { 40% { transform: translateY(-8px); } }

.clue-boards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: min(760px, 100%); }
.clue-board {
  padding: 16px 22px;
  color: #e6d8b8;
  background: rgba(12, 18, 40, .82);
  border: 1px solid rgba(214, 160, 60, .35);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .45);
  backdrop-filter: blur(3px);
}
.clue-board h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 1.35rem; color: var(--gold-hi); }
.clue-board ol { list-style: none; margin: 0; padding: 0; }
.clue-board li { padding: 4px 6px; border-radius: 3px; cursor: pointer; display: flex; gap: 8px; line-height: 1.4; transition: background .2s; }
.clue-board li b { font-family: var(--display); font-weight: 400; color: #e88aa0; min-width: 1.3em; }
.clue-board li.active { background: rgba(214, 160, 60, .22); }
.clue-board li.done { color: rgba(230, 216, 184, .5); text-decoration: line-through; text-decoration-color: #7fc0b4; }
.cross-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.walker { position: absolute; top: 0; left: 0; width: 86px; opacity: 0; pointer-events: none; z-index: 3; }
.walker.go { animation: walkAcross 5s linear forwards; }
@keyframes walkAcross { 0% { opacity: 1; transform: translateX(-90px); } 95% { opacity: 1; } 100% { opacity: 0; transform: translateX(var(--walk, 600px)); } }
.walker .leg-a { animation: legA .35s ease-in-out infinite alternate; transform-origin: top; transform-box: fill-box; }
.walker .leg-b { animation: legA .35s ease-in-out infinite alternate-reverse; transform-origin: top; transform-box: fill-box; }
@keyframes legA { from { transform: rotate(18deg); } to { transform: rotate(-18deg); } }
.walker .cat-walk { animation: walkBob .35s ease-in-out infinite alternate; }
@keyframes walkBob { to { transform: translateY(-3px); } }

/* =========================================================
   GALLERY — salon wall
   ========================================================= */
.scene-gallery {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='120' viewBox='0 0 80 120'><g fill='none' stroke='%23d6a03c' stroke-opacity='.13' stroke-width='1.4'><path d='M40 8 C58 26 58 44 40 60 C22 44 22 26 40 8Z'/><path d='M40 60 C58 76 58 94 40 112 C22 94 22 76 40 60Z'/><circle cx='0' cy='60' r='9'/><circle cx='80' cy='60' r='9'/><path d='M40 34 L40 86'/></g></svg>"),
    linear-gradient(115deg, transparent 30%, rgba(190, 205, 255, .07) 42%, transparent 55%),
    linear-gradient(90deg, rgba(0, 0, 0, .35), transparent 20%, transparent 80%, rgba(0, 0, 0, .35)),
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(143, 111, 216, .18), transparent 70%),
    #161034;
}
.scene-gallery.is-active { display: block; }
.scene-gallery::after {
  /* wainscot */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 18%;
  background: repeating-linear-gradient(90deg, #22130a 0 2px, #3a2312 2px 120px), #2f1c0e;
  border-top: 8px solid #5a3a1c; z-index: 0;
}
.wall { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.gallery-head { text-align: center; color: var(--vellum); }
.gallery-head .chapter-title { color: var(--vellum); text-shadow: 2px 1px 0 rgba(176, 71, 92, .55); }
.gallery-head p { margin: 8px 0 0; }
.frames { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 34px 30px; padding-top: 18px; }
.frame-unit { display: flex; flex-direction: column; align-items: center; gap: 12px; transform: rotate(var(--rot, 0deg)); animation: hang 1s var(--ease-pop) both; animation-delay: calc(var(--i) * .12s + .2s); }
@keyframes hang { from { opacity: 0; transform: translateY(-60px) rotate(calc(var(--rot) * 4)); } }
.frame {
  position: relative; padding: 14px;
  background: linear-gradient(135deg, #f3d27c, #b47e2a 40%, #f0c869 60%, #8c5f1c);
  border-radius: 2px;
  box-shadow: inset 0 0 0 3px #7a5218, inset 0 0 0 6px #e9c46a, 0 14px 22px rgba(0, 0, 0, .45);
  transform-origin: 50% -24px;
  animation: sway 6s ease-in-out infinite; animation-delay: calc(var(--i) * -1.3s);
}
.frame::before { /* hanging wire */
  content: ""; position: absolute; left: 50%; top: -26px; width: 50%; height: 26px; transform: translateX(-50%);
  border: 1.5px solid rgba(236, 220, 180, .45); border-bottom: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(to bottom right, transparent 49%, rgba(236,220,180,.5) 50%, transparent 52%), linear-gradient(to bottom left, transparent 49%, rgba(236,220,180,.5) 50%, transparent 52%);
  border: 0;
}
@keyframes sway { 50% { transform: rotate(1.2deg); } }
.frame img { display: block; width: var(--w, 200px); height: var(--h, 240px); object-fit: cover; box-shadow: inset 0 0 0 1px #000; background: #222; filter: sepia(.12) contrast(1.02); }
.frame-unit:hover .frame { animation-play-state: paused; }
.plaque {
  min-width: 170px; min-height: 48px; padding: 6px 12px;
  display: grid; place-items: center;
  border-radius: 4px;
  background: linear-gradient(#c49a4a, #8d6424);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 6px rgba(0, 0, 0, .35);
  position: relative; transition: transform .2s, box-shadow .2s;
}
.plaque::before { content: ""; position: absolute; inset: 4px; border: 1px dashed rgba(60, 35, 15, .55); border-radius: 2px; pointer-events: none; }
.plaque .placeholder { font-size: .8rem; font-style: italic; color: rgba(40, 25, 10, .65); }
.plaque.hover { transform: scale(1.07); box-shadow: 0 0 0 3px var(--gold-hi), 0 0 22px rgba(240, 200, 105, .6); }
.plaque.right { background: linear-gradient(#5f9a8c, var(--teal)); }
.plaque.wrong { animation: shake .45s; }
.frame-unit .piece-title { margin: -4px 0 0; font-size: .82rem; font-style: italic; color: rgba(236, 220, 180, .75); }

.tray-wrap { position: sticky; bottom: 10px; z-index: 6; width: min(860px, 100%); }
.tray {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  min-height: 84px; padding: 18px 20px 22px;
  background: repeating-linear-gradient(90deg, transparent 0 40px, rgba(0, 0, 0, .06) 40px 41px), linear-gradient(#8a5a2e, #6b4021);
  border-radius: 6px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .15), 0 10px 18px rgba(0, 0, 0, .4);
}
.gallery-cat { position: absolute; right: 14px; top: -42px; width: 76px; pointer-events: none; }
.gallery-cat .tail { transform-origin: 80px 50px; }
.name-tag {
  font-family: var(--display); font-size: 1.12rem;
  color: var(--ink);
  padding: 8px 18px 9px;
  background: var(--vellum);
  border-radius: 3px;
  box-shadow: 0 3px 0 #b49a66, 0 6px 10px rgba(0, 0, 0, .3);
  cursor: grab; touch-action: none; user-select: none;
  border: 0;
  transition: transform .2s var(--ease-pop), box-shadow .2s;
  position: relative;
}
.name-tag::before { content: ""; position: absolute; left: 8px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--night); opacity: .5; }
.name-tag:hover { transform: rotate(-2deg) translateY(-2px); }
.name-tag.selected { box-shadow: 0 0 0 3px var(--gold-hi), 0 6px 10px rgba(0, 0, 0, .3); }
.plaque .name-tag { background: transparent; box-shadow: none; padding: 4px 10px; color: #2a1a08; font-size: 1.05rem; }
.plaque .name-tag::before { display: none; }
.plaque.right .name-tag { color: #f6ecd2; cursor: default; }
.name-tag.dragging { position: fixed; z-index: 100; pointer-events: none; transform: rotate(-4deg) scale(1.08); box-shadow: 0 18px 26px rgba(0, 0, 0, .4); cursor: grabbing; }
.gallery-status { margin: 0; min-height: 1.6em; color: var(--vellum); font-style: italic; text-align: center; }

/* =========================================================
   Glyph veil transition
   ========================================================= */
.glyph-veil {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; align-content: center;
  background: radial-gradient(circle, rgba(27, 39, 71, .97), rgba(10, 14, 28, 1));
  opacity: 0; pointer-events: none;
  transition: opacity .5s;
}
.glyph-veil.on { opacity: 1; pointer-events: all; }
.veil-glyph { width: min(64vmin, 420px); color: var(--gold-hi); filter: drop-shadow(0 0 10px rgba(240, 200, 105, .6)); }
.g-line, .g-runes path { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 700; stroke-dashoffset: 700; }
.g-line.thin { stroke-width: .6; }
.g-runes path { stroke-width: .3; stroke-dasharray: 10; stroke-dashoffset: 10; }
.glyph-veil.on .g-line { animation: veilDraw 1.3s var(--ease-ink) forwards; }
.glyph-veil.on .g-runes path { animation: veilDraw .5s ease forwards; animation-delay: .7s; }
.glyph-veil.on .veil-glyph { animation: spin 14s linear infinite; }
@keyframes veilDraw { to { stroke-dashoffset: 0; } }
.veil-label { margin: 22px 0 0; font-family: var(--display); font-size: clamp(1.3rem, 3vw, 1.8rem); color: var(--vellum); text-align: center; opacity: 0; }
.glyph-veil.on .veil-label { animation: inkIn .8s .6s var(--ease-ink) forwards; }

/* Confetti stars */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.confetti i {
  position: absolute; top: -20px; width: 12px; height: 12px;
  background: var(--c, var(--gold-hi));
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: fall var(--t, 5s) linear forwards; animation-delay: var(--dl, 0s);
}
.confetti i.paw { clip-path: none; background: none; width: 16px; height: 16px; }
@keyframes fall { to { transform: translate(var(--x, 0), 110vh) rotate(var(--r, 540deg)); } }

/* Sparkle burst used on success */
.spark { position: fixed; width: 8px; height: 8px; border-radius: 50%; background: var(--gold-hi); pointer-events: none; z-index: 95; box-shadow: 0 0 8px var(--gold-hi); animation: spark .8s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--x), var(--y)) scale(0); opacity: 0; } }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 760px) {
  body { font-size: 17px; }
  .scene { padding: 74px 16px 40px; }
  .book { grid-template-columns: 1fr; background: #5a2a26; }
  .page { min-height: 0; }
  .page-left { border-radius: 6px 6px 0 0; padding-bottom: 70px; }
  .page-right { border-radius: 0 0 6px 6px; padding: 26px 12px; }
  .spine, .candle, .glyph-doodle { display: none; }
  .legend { display: grid; gap: 0; }
  .clue-boards { grid-template-columns: 1fr; }
  .mascot { width: 88px; }
  .mascot-intro { right: -6px; bottom: -48px; }
  .mascot-finale { left: -6px; bottom: -48px; }
  .rod { margin: 0 -4px; height: 36px; }
  .rod .handle { width: 32px; height: 24px; margin-top: -12px; }
  .rod .handle.l { left: -28px; } .rod .handle.r { right: -28px; }
  .scroll-stage { width: calc(100% - 40px); margin: 0 auto; }
  .ink-frame { inset: 14px 12px; }
  .ink-frame .corner { width: 24px; height: 24px; }
  .ink-blot { left: 26px; top: 46px; width: 30px; }
  .ribbon { width: 34px; left: 8%; }
  .ribbon-seal { width: 40px; height: 40px; margin-left: -20px; }
  .quill { width: 32px; }
  .q-left { left: -26px; } .q-right { right: -24px; }
  .paws { right: 18px; bottom: 26px; transform: scale(.75); }
  .k { height: 50px; font-size: 1rem; }
  .k-row { gap: 4px; }
  .frames { gap: 28px 18px; }
  .frame { padding: 10px; }
  .plaque { min-width: 130px; }
  .trial-glyph { width: 34px; height: 34px; }
  .bridge { padding-left: 8px; padding-right: 8px; }
  .frame img { width: calc(var(--w) * .68); height: calc(var(--h) * .68); }
  .frames { gap: 26px 14px; }
  .plaque { min-width: 0; width: 100%; max-width: 170px; }
  .name-tag { font-size: 1rem; padding: 6px 12px 7px 16px; }
  .tray { gap: 8px; padding: 12px; }
  .gallery-cat { width: 56px; top: -32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .grain { animation: none; }
}

/* =========================================================
   Night ambience shared by every scene
   ========================================================= */
.moon-window {
  position: absolute; top: 74px; right: 5%; width: 150px; height: 210px; z-index: 0;
  border-radius: 75px 75px 4px 4px;
  background:
    radial-gradient(circle at 62% 34%, #fff6dc 0 22px, rgba(243, 226, 179, .35) 23px, transparent 46px),
    radial-gradient(1.2px 1.2px at 20% 20%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 78% 64%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 48%, #fff 50%, transparent 51%),
    linear-gradient(#0b1230, #1c2a58);
  border: 10px solid #3b2413;
  box-shadow: inset 0 0 0 3px #5a3a1c, 0 0 60px rgba(160, 180, 255, .12);
  pointer-events: none;
}
.moon-window::before, .moon-window::after { content: ""; position: absolute; background: #3b2413; }
.moon-window::before { left: 50%; top: 0; bottom: 0; width: 6px; margin-left: -3px; }
.moon-window::after { left: 0; right: 0; top: 52%; height: 6px; }
.moon-window .sill-cat { position: absolute; left: -16px; bottom: -14px; width: 64px; }
.scene-gallery .moon-window { left: 3%; right: auto; top: 110px; }

.fireflies { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.firefly {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: #ffe9a8; box-shadow: 0 0 10px 3px rgba(255, 220, 120, .6);
  animation: fly var(--t, 14s) ease-in-out infinite, glim 2.2s ease-in-out infinite alternate;
  animation-delay: var(--dl, 0s);
}
@keyframes fly {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(var(--x1), var(--y1)); }
  50% { transform: translate(var(--x2), var(--y2)); }
  75% { transform: translate(var(--x1), var(--y2)); }
}
@keyframes glim { from { opacity: .15; } to { opacity: 1; } }

.shooting-star {
  position: absolute; width: 120px; height: 2px; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 245, 220, 0), #fff6dc);
  border-radius: 2px; transform: rotate(-24deg); opacity: 0;
  animation: shoot 1.1s ease-out forwards;
}
.shooting-star::after { content: ""; position: absolute; right: -2px; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; }
@keyframes shoot { 0% { opacity: 0; translate: 0 0; } 15% { opacity: 1; } 100% { opacity: 0; translate: -340px 150px; } }

@media (max-width: 760px) {
  .moon-window { width: 84px; height: 118px; top: 64px; right: 10px; border-width: 6px; opacity: .8; }
  .scene-gallery .moon-window, .scene-study .moon-window { display: none; }
  .night-moon { width: 100px; height: 100px; margin-left: -50px; top: 14%; }
}
.scene-study .moon-window { right: auto; left: 3%; top: 70px; width: 130px; height: 182px; }
.scene-study .candle { top: auto; bottom: 22%; }
.scene-gallery .moon-window { left: 1.5%; top: 120px; width: 104px; height: 146px; border-width: 8px; }
@media (max-width: 1200px) {
  .scene-study .moon-window, .scene-gallery .moon-window { display: none; }
}

/* =========================================================
   WITCHY REVAMP — sparkles, star friends, hanging moons,
   constellations, mist, rune halo, potions
   ========================================================= */
:root { --violet: #2a1b52; --amethyst: #8f6fd8; --lilac: #c9b6ff; --pink-star: #ffb3c7; --star: #ffd96a; }

.ambience { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.scene > *:not(.ambience):not(.fireflies):not(.sky):not(.sea-sky):not(.sea):not(.moon-window):not(.candle):not(.confetti):not(.shooting-star):not(.potions):not(.mist):not(.moon-clouds):not(.card-frame):not(.moth):not(.folk-band):not(.bookcase):not(.rustic-hang) { position: relative; z-index: 2; }

/* four-point twinkles */
.twinkle { position: absolute; width: var(--s, 14px); height: var(--s, 14px); color: var(--c, #fff3c4); animation: tw var(--t, 3s) ease-in-out infinite; animation-delay: var(--dl, 0s); filter: drop-shadow(0 0 4px currentColor); }
.twinkle svg { width: 100%; height: 100%; display: block; }
@keyframes tw { 0%, 100% { transform: scale(.25) rotate(0); opacity: .3; } 50% { transform: scale(1) rotate(45deg); opacity: 1; } }

/* cute star friends */
.star-friend {
  position: absolute; width: var(--s, 54px); pointer-events: auto; cursor: pointer;
  animation: floaty var(--t, 5s) ease-in-out infinite; animation-delay: var(--dl, 0s);
  filter: drop-shadow(0 0 10px rgba(255, 217, 106, .55));
  border: 0; background: none; padding: 0;
}
.star-friend svg { width: 100%; display: block; overflow: visible; }
.star-friend .sf-eyes { transform-origin: 50px 52px; animation: blink 4.4s infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg); } }
.star-friend.spin svg { animation: starSpin .8s var(--ease-pop); }
@keyframes starSpin { from { transform: rotate(0) scale(1.3); } to { transform: rotate(360deg) scale(1); } }
.star-bubble {
  position: absolute; left: 50%; bottom: 105%; translate: -50% 0; white-space: nowrap;
  font: italic .95rem/1.2 var(--body); color: #2a1b52; background: #fff4d6;
  padding: 5px 11px; border-radius: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  animation: bubble 2.2s ease forwards; pointer-events: none;
}
.star-bubble::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: #fff4d6; }
@keyframes bubble { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 12%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

/* hanging stars & moons */
.hang { position: absolute; top: 0; transform-origin: 50% 0; animation: dangle var(--t, 5s) ease-in-out infinite alternate; animation-delay: var(--dl, 0s); }
.hang .string { width: 1px; height: var(--len, 100px); margin: 0 auto; background: linear-gradient(rgba(201, 182, 255, .1), rgba(201, 182, 255, .6)); }
.hang .orn { width: var(--s, 30px); margin-top: -2px; filter: drop-shadow(0 0 8px rgba(255, 217, 106, .6)); }
.hang .orn svg { width: 100%; display: block; }
@keyframes dangle { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

/* constellations */
.constellation { position: absolute; width: 210px; color: var(--lilac); opacity: .85; }
.constellation line { stroke: currentColor; stroke-width: .9; stroke-dasharray: 3 4; opacity: .55; }
.constellation .cdot { fill: #fff6dc; filter: drop-shadow(0 0 3px #fff); animation: glim 2.6s ease-in-out infinite alternate; }
.constellation .cdot:nth-child(3n) { animation-delay: -1.2s; }
.constellation .clabel { fill: var(--lilac); font: italic 11px var(--body); opacity: .7; }

/* drifting mist */
.mist { position: absolute; left: -20%; right: -20%; bottom: -4%; height: 34%; pointer-events: none; z-index: 1; opacity: .55; }
.mist::before, .mist::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 22% 40% at 20% 70%, rgba(201, 182, 255, .35), transparent 70%),
    radial-gradient(ellipse 26% 45% at 55% 80%, rgba(170, 150, 240, .3), transparent 70%),
    radial-gradient(ellipse 20% 38% at 85% 70%, rgba(201, 182, 255, .3), transparent 70%);
  filter: blur(14px);
  animation: mistDrift 26s ease-in-out infinite alternate;
}
.mist::after { animation-duration: 34s; animation-direction: alternate-reverse; opacity: .7; transform: translateX(10%); }
@keyframes mistDrift { from { translate: -8% 0; } to { translate: 8% -4%; } }

/* rune halo behind the scrolls */
.rune-halo {
  position: absolute; left: 50%; top: 50%; width: 150%; aspect-ratio: 1; translate: -50% -50%;
  color: var(--lilac); opacity: .22; z-index: -1; pointer-events: none;
  animation: spin 70s linear infinite;
}
.rune-halo::before { content: ""; position: absolute; inset: 18%; border-radius: 50%; background: radial-gradient(rgba(143, 111, 216, .55), transparent 70%); filter: blur(20px); }
.rune-halo .glyph-svg { position: relative; width: 100%; height: 100%; }
.scroll { filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .5)) drop-shadow(0 0 28px rgba(143, 111, 216, .35)); }

/* book glow */
.book { box-shadow: 0 24px 50px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(214, 160, 60, .45), 0 0 60px rgba(143, 111, 216, .25); }

/* potion shelf (study) */
.potions { position: absolute; right: 3%; bottom: 16%; width: 170px; height: 120px; z-index: 1; pointer-events: none; }
.potions::after { content: ""; position: absolute; left: -10px; right: -10px; bottom: -10px; height: 12px; border-radius: 3px; background: linear-gradient(#5a3a1c, #3b2413); box-shadow: 0 6px 12px rgba(0, 0, 0, .4); }
.bottle { position: absolute; bottom: 2px; }
.bottle svg { display: block; overflow: visible; }
.bottle .liq { animation: liq 3s ease-in-out infinite alternate; }
@keyframes liq { to { opacity: .75; } }
.bottle .bub { animation: bub 2.6s ease-in infinite; }
.bottle .bub:nth-of-type(2) { animation-delay: -1.1s; }
.bottle .bub:nth-of-type(3) { animation-delay: -1.9s; }
@keyframes bub { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-34px); opacity: 0; } }
.p1 { left: 0; } .p2 { left: 58px; } .p3 { left: 112px; }

/* frame corner glints */
.frame::after {
  content: ""; position: absolute; right: -9px; top: -9px; width: 20px; height: 20px;
  background: var(--star); filter: drop-shadow(0 0 5px var(--star));
  clip-path: path("M10 0 C10.8 6.5 13.5 9.2 20 10 C13.5 10.8 10.8 13.5 10 20 C9.2 13.5 6.5 10.8 0 10 C6.5 9.2 9.2 6.5 10 0Z");
  animation: tw 3.4s ease-in-out infinite; animation-delay: calc(var(--i) * -.7s);
}

/* cursor sparkle trail */
.trail { position: fixed; z-index: 96; pointer-events: none; width: 12px; height: 12px; color: var(--c, var(--star)); animation: trail .9s ease-out forwards; filter: drop-shadow(0 0 4px currentColor); }
.trail svg { width: 100%; height: 100%; display: block; }
@keyframes trail { 0% { transform: scale(1) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), 22px) scale(0) rotate(120deg); opacity: 0; } }

/* stamp sparkle on wordle tiles */
.w-tile.filled { box-shadow: 0 0 0 1px rgba(143, 111, 216, .25), 0 0 14px rgba(143, 111, 216, .25); }
.w-tile.correct { box-shadow: 0 0 14px rgba(127, 192, 180, .55); }
.w-tile.present { box-shadow: 0 0 14px rgba(255, 217, 106, .5); }

/* gold-violet button aura */
.btn-wax::before {
  content: "✦"; position: absolute; left: -16px; top: -10px; font-size: 1rem; color: var(--star);
  text-shadow: 0 0 6px var(--star); animation: tw 2.4s ease-in-out infinite;
}

/* misc tints */
.active-clue { background: rgba(30, 18, 64, .82); border: 1px solid rgba(201, 182, 255, .25); }
.clue-board { background: rgba(26, 16, 58, .84); border-color: rgba(201, 182, 255, .28); }
.glyph-veil { background: radial-gradient(circle, rgba(42, 27, 82, .97), rgba(8, 5, 24, 1)); }
.veil-glyph { color: var(--star); filter: drop-shadow(0 0 10px rgba(255, 217, 106, .6)) drop-shadow(0 0 30px rgba(143, 111, 216, .6)); }

@media (max-width: 1200px) { .potions { display: none; } }
@media (max-width: 760px) {
  .constellation { width: 130px; opacity: .6; }
  .rune-halo { width: 130%; }
  .star-friend { --s: 40px !important; }
}
@media (prefers-reduced-motion: reduce) { .trail { display: none; } }
.rune-halo .gl, .rune-halo .gl * { vector-effect: non-scaling-stroke; stroke-width: 1.3; }
.rune-halo .gl.thin { stroke-width: .7; }
.ink-blot { left: auto; right: 58px; top: 64px; width: 34px; fill: rgba(43, 23, 8, .62); }
.rod .handle { width: 58px; height: 42px; margin-top: -21px; }
.rod .handle.l { left: -52px; }
.rod .handle.r { right: -52px; }
.ribbon { width: 52px; }
@media (max-width: 760px) {
  .rod .handle { width: 34px; height: 26px; margin-top: -13px; }
  .rod .handle.l { left: -30px; } .rod .handle.r { right: -30px; }
  .ink-blot { right: 30px; top: 40px; width: 24px; }
  .ribbon { width: 36px; }
}

/* =========================================================
   Manual unrolling
   ========================================================= */
.rod-bottom { touch-action: none; user-select: none; background-position: 0 0, 0 var(--roll, 0px), 0 0; }
.rod-bottom {
  background:
    repeating-linear-gradient(90deg, transparent 0 37px, rgba(90, 60, 30, .07) 37px 38px, transparent 38px 71px),
    repeating-linear-gradient(180deg, transparent 0 9px, rgba(90, 60, 30, .1) 9px 10px),
    linear-gradient(180deg, #4e3519 0%, #9c7a48 12%, #dcc596 30%, #f3e6c0 42%, #e2cd9c 56%, #b8955f 76%, #7a5a30 90%, #3e2a12 100%);
  background-position: 0 0, 0 var(--roll, 0px), 0 0;
}
.scroll:not(.is-open) .rod-bottom {
  cursor: grab;
  animation: tug 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255, 217, 106, .55));
}
.scroll.dragging .rod-bottom { cursor: grabbing; animation: none; filter: drop-shadow(0 0 16px rgba(255, 217, 106, .8)); }
@keyframes tug { 0%, 60%, 100% { transform: translateY(0); } 75% { transform: translateY(10px); } 88% { transform: translateY(-2px); } }

.unroll-hint {
  position: absolute; left: 0; right: 0; top: 100%; margin: 22px 0 0;
  text-align: center; font-style: italic; font-size: 1.1rem;
  color: var(--lilac); text-shadow: 0 0 10px rgba(143, 111, 216, .8);
  pointer-events: none; transition: opacity .3s;
}
.unroll-hint .chev {
  display: block; width: 18px; height: 26px; margin: 0 auto 6px;
  background:
    linear-gradient(135deg, transparent 45%, var(--star) 46% 56%, transparent 57%) 0 0 / 50% 13px no-repeat,
    linear-gradient(225deg, transparent 45%, var(--star) 46% 56%, transparent 57%) 100% 0 / 50% 13px no-repeat,
    linear-gradient(135deg, transparent 45%, var(--star) 46% 56%, transparent 57%) 0 13px / 50% 13px no-repeat,
    linear-gradient(225deg, transparent 45%, var(--star) 46% 56%, transparent 57%) 100% 13px / 50% 13px no-repeat;
  filter: drop-shadow(0 0 4px var(--star));
  animation: chev 1.4s ease-in-out infinite;
}
@keyframes chev { 0%, 100% { transform: translateY(0) scaleY(-1); opacity: .6; } 50% { transform: translateY(8px) scaleY(-1); opacity: 1; } }
.scroll.is-open .unroll-hint, .scroll.dragging .unroll-hint { opacity: 0; }
.scroll.nudge .unroll-hint { animation: shake .45s; }
.rod-bottom:focus-visible { outline: 3px dashed var(--gold-hi); outline-offset: 6px; }
.scroll:not(.is-open) ~ .quill { opacity: 0; }
.quill { transition: opacity .5s .4s; }

/* =========================================================
   VINTAGE STORYBOOK — royal navy, plum, mustard; engraved moon,
   tarot frame, long-ray stars, moths, folk bands
   ========================================================= */
:root { --navy: #16215e; --plum: #3d2440; --mustard: #d9a03a; --cream: #f0e0bc; --lav: #a58bc0; }

.scene-night {
  background:
    radial-gradient(ellipse 60% 40% at 50% 105%, rgba(240, 224, 188, .22), transparent 70%),
    radial-gradient(ellipse 45% 35% at 12% 18%, rgba(165, 139, 192, .2), transparent 70%),
    radial-gradient(ellipse 40% 30% at 88% 70%, rgba(61, 36, 64, .55), transparent 70%),
    linear-gradient(#0c1240 0%, #16215e 42%, #1f2a72 70%, #3d2440 100%);
}
.scene-sea { background: linear-gradient(#0c1240 0%, #16215e 34%, #2b3484 56%, #4a3a7a 63%, #0b1630 100%); }
.scene-gallery {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><g fill='none' stroke='%23d9a03a' stroke-opacity='.22' stroke-width='1.3'><path d='M60 20c6 10 6 20 0 30-6-10-6-20 0-30zM60 50c10-6 20-6 30 0-10 6-20 6-30 0zM60 50c-10-6-20-6-30 0 10 6 20 6 30 0zM60 50v22'/><path d='M0 100c10-12 20-12 30 0s20 12 30 0 20-12 30 0 20 12 30 0'/></g><g fill='%23d9a03a' fill-opacity='.3'><path d='M15 15l1.5 4 4 1.5-4 1.5L15 26l-1.5-4-4-1.5 4-1.5zM105 75l1.2 3 3 1.2-3 1.2-1.2 3-1.2-3-3-1.2 3-1.2z'/></g></svg>"),
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(217, 160, 58, .14), transparent 70%),
    linear-gradient(90deg, rgba(0, 0, 0, .35), transparent 20%, transparent 80%, rgba(0, 0, 0, .35)),
    var(--plum);
}
.trials { background: rgba(22, 33, 94, .7); border-color: rgba(217, 160, 58, .45); top: 22px; }
.clue-board, .active-clue { background: rgba(14, 20, 64, .86); border-color: rgba(217, 160, 58, .4); }

/* tarot-card frame around every scene */
.card-frame {
  position: absolute; inset: 12px; z-index: 3; pointer-events: none;
  border: 1.5px solid rgba(217, 160, 58, .75); border-radius: 6px;
  box-shadow: inset 0 0 0 6px rgba(217, 160, 58, .0), inset 0 0 0 7px rgba(217, 160, 58, .35);
}
.card-frame::before { content: ""; position: absolute; inset: 12px; border: 1px dashed rgba(217, 160, 58, .32); border-radius: 3px; }
.cf-star { position: absolute; width: 34px; height: 34px; filter: drop-shadow(0 0 5px rgba(232, 180, 74, .6)); }
.cf-star svg { width: 100%; height: 100%; display: block; animation: tw 4s ease-in-out infinite; }
.cf-star.tl { left: -17px; top: -17px; } .cf-star.tr { right: -17px; top: -17px; }
.cf-star.bl { left: -17px; bottom: -17px; } .cf-star.br { right: -17px; bottom: -17px; }
.cf-star.tr svg { animation-delay: -1s; } .cf-star.bl svg { animation-delay: -2s; } .cf-star.br svg { animation-delay: -3s; }
.cf-moon { position: absolute; left: 50%; bottom: -12px; width: 60px; margin-left: -30px; }
.cf-moon svg { display: block; width: 100%; filter: drop-shadow(0 0 4px rgba(232, 180, 74, .5)); }

/* long-ray glinting stars */
.ray-star { position: absolute; width: calc(var(--s) * .5); height: var(--s); translate: -50% -50%; filter: drop-shadow(0 0 8px rgba(255, 220, 130, .6)); animation: glint 5s ease-in-out infinite; animation-delay: var(--dl, 0s); pointer-events: none; }
.ray-star svg { width: 100%; height: 100%; display: block; overflow: visible; }
@keyframes glint { 0%, 100% { transform: scale(.82); opacity: .75; } 45% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12) rotate(8deg); opacity: 1; } 55% { transform: scale(1); } }

/* engraved moon in clouds */
.moon-clouds { position: absolute; left: 50%; bottom: -10px; width: min(820px, 130vw); translate: -50% 0; z-index: 1; pointer-events: none; }
.moon-clouds svg { display: block; width: 100%; height: auto; }
.mc-moon { animation: moonRise 9s ease-in-out infinite alternate; }
@keyframes moonRise { from { transform: translateY(8px); } to { transform: translateY(-8px); } }
.mc-cloud.back { animation: cloudSlide 14s ease-in-out infinite alternate; }
.mc-cloud.front { animation: cloudSlide 18s ease-in-out infinite alternate-reverse; }
@keyframes cloudSlide { from { transform: translateX(-14px); } to { transform: translateX(14px); } }
.leaper { position: absolute; left: 22%; bottom: 46%; width: 15%; opacity: 0; }
.leaper svg { display: block; width: 100%; }
.moon-clouds .leaper { animation: leap 11s ease-in-out infinite 2s; }
@keyframes leap {
  0%, 62% { opacity: 0; transform: translate(0, 0) rotate(10deg); }
  66% { opacity: 1; transform: translate(40%, -60%) rotate(-10deg); }
  76% { opacity: 1; transform: translate(220%, -150%) rotate(0deg); }
  86% { opacity: 1; transform: translate(400%, -60%) rotate(14deg); }
  90%, 100% { opacity: 0; transform: translate(440%, 0) rotate(20deg); }
}

/* moths */
.moth { position: absolute; width: 46px; z-index: 3; pointer-events: none; filter: drop-shadow(0 0 6px rgba(255, 210, 120, .45)); }
.moth svg { display: block; width: 100%; overflow: visible; }
.moth .wing-l, .moth .wing-r { transform-origin: 50px 36px; animation: flut .18s ease-in-out infinite alternate; }
@keyframes flut { to { transform: scaleX(.35); } }
.m-candle { left: calc(6% + 2px); bottom: calc(22% + 110px); animation: orbit 7s linear infinite; }
.m-candle.two { width: 34px; animation-duration: 9.5s; animation-direction: reverse; }
@keyframes orbit {
  0% { transform: translate(-60px, 0) rotate(-10deg); } 25% { transform: translate(0, -50px) rotate(8deg); }
  50% { transform: translate(70px, -10px) rotate(-6deg); } 75% { transform: translate(10px, 30px) rotate(10deg); }
  100% { transform: translate(-60px, 0) rotate(-10deg); }
}
.m-wall { left: 8%; top: 46%; width: 40px; animation: wander 16s ease-in-out infinite; }
@keyframes wander { 0%, 100% { transform: translate(0, 0) rotate(-8deg); } 30% { transform: translate(14vw, -18vh) rotate(10deg); } 60% { transform: translate(4vw, -30vh) rotate(-4deg); } 80% { transform: translate(-2vw, -10vh) rotate(6deg); } }

/* folk-art frieze along the top of the gallery wall */
.folk-band.frieze {
  position: absolute; left: 0; right: 0; top: 0; height: 30px; z-index: 0;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='30' viewBox='0 0 60 30'><path d='M0 15c8-12 22-12 30 0s22 12 30 0' fill='none' stroke='%23d9a03a' stroke-width='2'/><circle cx='15' cy='9' r='2.4' fill='%23d9a03a'/><circle cx='45' cy='21' r='2.4' fill='%23d9a03a'/></svg>") repeat-x center,
    var(--navy);
  border-bottom: 3px double rgba(217, 160, 58, .7);
}
.folk-band.frieze::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px;
  background: repeating-linear-gradient(90deg, var(--mustard) 0 10px, var(--plum) 10px 20px);
  opacity: .85;
}
.scene-gallery { padding-top: 96px; }

/* book cover: plum with gold tooling */
.book {
  background: linear-gradient(90deg, #3d2440, #573356 49%, #24142a 50%, #573356 51%, #3d2440);
  box-shadow: 0 24px 50px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(217, 160, 58, .7), inset 0 0 0 7px #3d2440, inset 0 0 0 8px rgba(217, 160, 58, .5), 0 0 60px rgba(165, 139, 192, .25);
}

@media (max-width: 760px) {
  .card-frame { inset: 6px; }
  .cf-star { width: 24px; height: 24px; }
  .cf-star.tl { left: -12px; top: -12px; } .cf-star.tr { right: -12px; top: -12px; }
  .cf-star.bl { left: -12px; bottom: -12px; } .cf-star.br { right: -12px; bottom: -12px; }
  .m-candle { display: none; }
  .moon-clouds { width: 170vw; }
}
@media (prefers-reduced-motion: reduce) { .moon-clouds .leaper { display: none; } }

/* =========================================================
   CONNECTIONS — tarot reading on a velvet table
   ========================================================= */
.scene-cards {
  background:
    radial-gradient(ellipse 70% 55% at 50% 55%, rgba(120, 60, 110, .55), transparent 75%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90'><g fill='%23d9a03a' fill-opacity='.18'><path d='M45 30l3 9 9 3-9 3-3 9-3-9-9-3 9-3z'/><circle cx='10' cy='10' r='1.5'/><circle cx='80' cy='70' r='1.5'/></g><path d='M0 80c8-8 16-8 22 0' fill='none' stroke='%23d9a03a' stroke-opacity='.14'/></svg>"),
    linear-gradient(#1a0f2a, #2e1838 50%, #3d2440);
}
.scene-cards.is-active { display: block; }
.reading { position: relative; z-index: 2; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cards-head { text-align: center; color: var(--cream); }
.cards-head .chapter-title { color: var(--gold-hi); text-shadow: 2px 1px 0 rgba(61, 36, 64, .9), 0 0 20px rgba(217, 160, 58, .35); }
.cards-head p { margin: 8px auto 0; max-width: 32em; color: #e8d6f0; }

.conn-solved, .conn-board { width: 100%; display: grid; gap: 10px; }
.conn-board { grid-template-columns: repeat(4, 1fr); perspective: 900px; }

.t-card {
  position: relative; height: clamp(74px, 12vw, 92px); padding: 6px;
  border: 0; border-radius: 8px;
  font-family: var(--display-sc); font-size: clamp(.82rem, 2.2vw, 1.18rem); letter-spacing: .02em;
  color: #2b1708;
  background:
    radial-gradient(circle at 50% 12%, var(--mustard) 0 2.4px, transparent 3px),
    radial-gradient(circle at 50% 88%, var(--mustard) 0 2.4px, transparent 3px),
    radial-gradient(ellipse at 50% 40%, #f6ead0, #e6d0a2 80%);
  box-shadow: inset 0 0 0 4px #f3e6c6, inset 0 0 0 5.5px var(--mustard), inset 0 0 0 8px #f3e6c6, inset 0 0 0 9px rgba(61, 36, 64, .35), 0 4px 0 #8a6a3a, 0 8px 16px rgba(0, 0, 0, .4);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .25s var(--ease-pop), background .25s, color .25s, box-shadow .25s;
}
.t-card.long { font-size: clamp(.7rem, 1.8vw, 1rem); }
.t-card .t-word { position: relative; z-index: 1; overflow-wrap: normal; word-break: keep-all; }
.t-card::before, .t-card::after { content: "✦"; position: absolute; left: 50%; translate: -50% 0; font-size: .6rem; color: var(--mustard); opacity: 0; }
.t-card:hover { transform: translateY(-4px) rotate(0); }
.t-card.selected {
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 12%, var(--gold-hi) 0 2.4px, transparent 3px),
    radial-gradient(circle at 50% 88%, var(--gold-hi) 0 2.4px, transparent 3px),
    radial-gradient(ellipse at 50% 40%, #2b3790, #16215e 80%);
  box-shadow: inset 0 0 0 4px #16215e, inset 0 0 0 5.5px var(--gold-hi), inset 0 0 0 8px #16215e, 0 4px 0 #0b1238, 0 0 22px rgba(240, 200, 105, .55);
  transform: translateY(-6px) rotate(0);
}
.t-card.deal { animation: deal .55s var(--ease-pop) both; animation-delay: calc(var(--i) * 40ms); }
@keyframes deal { from { opacity: 0; transform: translate(0, -60px) rotateY(180deg) scale(.6); } }
.t-card.hop { animation: cardHop .45s ease-in-out both; animation-delay: calc(var(--hop) * 110ms); }
@keyframes cardHop { 50% { transform: translateY(-16px) rotateY(180deg); } 100% { transform: translateY(-6px) rotateY(360deg); } }
.t-card.shake { animation: shake .45s; }
.t-card.nope { animation: shake .3s; }
.t-card.gather { animation: gather .45s ease-in forwards; }
@keyframes gather { to { transform: translateY(-30px) scale(.4); opacity: 0; } }

.conn-group {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0 10px;
  min-height: clamp(74px, 12vw, 92px); padding: 8px 18px; border-radius: 8px;
  color: #241208; text-align: center;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .35), inset 0 0 0 4.5px rgba(43, 23, 8, .35), 0 6px 16px rgba(0, 0, 0, .4);
  animation: bannerIn .6s var(--ease-pop) both;
}
@keyframes bannerIn { from { opacity: 0; transform: scale(.8) rotateX(70deg); } }
.conn-group h3 { margin: 0; font: 400 clamp(1rem, 2.6vw, 1.3rem)/1.2 var(--display-sc); grid-column: 2; }
.conn-group p { margin: 2px 0 0; grid-column: 2; font-size: .95rem; letter-spacing: .03em; }
.conn-group .g-star { grid-row: 1 / span 2; font-size: 1.2rem; opacity: .7; }
.conn-group .g-star:last-child { grid-column: 3; }
.lvl-0 { background: linear-gradient(#f0c869, #d9a03a); }
.lvl-1 { background: linear-gradient(#8fcabd, #5fa59a); }
.lvl-2 { background: linear-gradient(#c8b2e2, #a58bc0); }
.lvl-3 { background: linear-gradient(#e7a0b6, #c46a86); }

.conn-meta { display: flex; align-items: center; gap: 12px; color: #e8d6f0; font-style: italic; }
.conn-candles { display: inline-flex; gap: 12px; }
.mini-candle { position: relative; width: 10px; height: 24px; border-radius: 2px; background: linear-gradient(90deg, #e6d6b0, #fff4d8 40%, #cdb98b); }
.mini-candle .f { position: absolute; left: 50%; top: -15px; width: 9px; height: 14px; margin-left: -4.5px; border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%; background: radial-gradient(ellipse at 50% 75%, #fff 0 15%, #ffd36b 40%, #f08a2c 75%, transparent 80%); filter: drop-shadow(0 0 6px #ffb84a); animation: flicker .18s infinite alternate; transform-origin: 50% 100%; }
.mini-candle.out .f { opacity: 0; transition: opacity .3s; }
.mini-candle .smoke { position: absolute; left: 50%; top: -14px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: rgba(220, 210, 230, .6); opacity: 0; }
.mini-candle.snuff .smoke { animation: smoke 1.4s ease-out; }
@keyframes smoke { 0% { opacity: .8; transform: none; } 100% { opacity: 0; transform: translate(6px, -30px) scale(3); } }
.conn-status { margin: 0; min-height: 1.6em; color: var(--cream); font-style: italic; text-align: center; }
.conn-actions .btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.conn-actions .btn[disabled]::after, .conn-actions .btn[disabled]::before { display: none; }

/* crystal ball on the corner of the table */
.crystal { position: absolute; right: 5%; bottom: 8%; width: 110px; z-index: 1; pointer-events: none; }
.crystal .orb {
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .85) 0 6%, rgba(201, 182, 255, .55) 20%, rgba(110, 80, 180, .45) 55%, rgba(40, 20, 80, .7) 100%);
  box-shadow: 0 0 40px rgba(165, 139, 192, .6), inset 0 0 30px rgba(255, 255, 255, .2);
  animation: orbGlow 4s ease-in-out infinite alternate;
}
.crystal .orb::after { content: ""; position: absolute; left: 30px; top: 34px; width: 50px; height: 40px; border-radius: 50%; background: radial-gradient(rgba(255, 220, 240, .6), transparent 70%); filter: blur(6px); animation: swirl 6s linear infinite; }
@keyframes swirl { to { transform: rotate(360deg) translateX(8px); } }
@keyframes orbGlow { to { box-shadow: 0 0 60px rgba(201, 182, 255, .8), inset 0 0 30px rgba(255, 255, 255, .3); } }
.crystal .stand { width: 80px; height: 26px; margin: -10px auto 0; border-radius: 6px 6px 14px 14px; background: linear-gradient(#c9963e, #7a5212); box-shadow: 0 6px 10px rgba(0, 0, 0, .4); }

@media (max-width: 1100px) { .crystal { display: none; } }
@media (max-width: 760px) {
  .conn-board, .conn-solved { gap: 6px; }
  .t-card { padding: 4px; border-radius: 6px; font-size: .74rem; letter-spacing: 0; }
  .t-card.long { font-size: .6rem; }
  .conn-group p { font-size: .8rem; }
}

/* =========================================================
   RUSTIC LIBRARY — walnut, oak, brass, worn books, candlelight.
   Overrides the brighter storybook layer above.
   ========================================================= */
:root {
  --walnut: #20150d; --oak: #5b3a1f; --oak-hi: #7c5530; --brass: #b08d57; --brass-hi: #d8b67c;
  --moss: #55603d; --oxblood: #6e2a26; --parch: #e3d2a8; --slate: #1a222c;
  --gold-hi: #e2c07e; --star: #f1dca8; --lilac: #c9b89a;
}

/* --- night library (start + end) --- */
.scene-night {
  background:
    radial-gradient(ellipse 55% 45% at 50% 100%, rgba(255, 170, 80, .18), transparent 70%),
    radial-gradient(ellipse 40% 50% at 50% 35%, rgba(140, 160, 190, .12), transparent 70%),
    linear-gradient(#0d1219 0%, #141c27 45%, #1c2430 75%, #2a2018 100%);
}
.bookcase {
  position: absolute; top: 0; bottom: 0; z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-evenly;
  padding: 18px 16px;
  background:
    repeating-linear-gradient(92deg, rgba(0, 0, 0, .0) 0 40px, rgba(0, 0, 0, .18) 40px 42px),
    linear-gradient(90deg, #2b1a0e, #3a2414 50%, #2b1a0e);
  box-shadow: inset 0 0 0 10px #3e2716, inset 0 0 0 12px #1a0f08, 0 0 60px rgba(0, 0, 0, .7);
  overflow: hidden;
}
.bookcase::after { /* candlelit vignette */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 120% 70% at 50% 100%, rgba(255, 170, 80, .14), transparent 60%), linear-gradient(rgba(0, 0, 0, .35), transparent 30%, transparent 70%, rgba(0, 0, 0, .45));
}
.bc-left { left: 0; width: 21vw; }
.bc-right { right: 0; width: 21vw; }
.bc-back { left: 0; right: 0; height: 100%; opacity: .55; filter: saturate(.8) brightness(.75); }
.bk-row {
  position: relative; flex: 1; display: flex; align-items: flex-end; gap: 1px;
  padding: 0 4px; margin-bottom: 4px;
  border-bottom: 9px solid #4a2e18;
  box-shadow: 0 6px 6px -2px rgba(0, 0, 0, .55);
  max-height: 110px;
}
.book {
  flex: none; position: relative; border-radius: 2px 2px 0 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .35), transparent 22%, rgba(255, 240, 210, .12) 45%, transparent 60%, rgba(0, 0, 0, .4)),
    var(--spine);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .06);
}
.book.banded::before, .book.banded::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: rgba(216, 182, 124, .65); }
.book.banded::before { top: 14%; } .book.banded::after { bottom: 16%; }
.book.lean { transform: rotate(-9deg); transform-origin: bottom right; margin: 0 6px 0 4px; }
.bk-stack { display: flex; flex-direction: column-reverse; align-items: center; gap: 1px; margin: 0 4px; }
.bk-stack i { display: block; height: 9px; border-radius: 1px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .3); }
.bk-jar { width: 20px; height: 30px; margin: 0 3px; border-radius: 4px 4px 6px 6px; background: linear-gradient(90deg, rgba(200, 220, 200, .25), rgba(160, 190, 150, .45) 50%, rgba(200, 220, 200, .2)); box-shadow: inset 0 -12px 0 rgba(120, 140, 70, .55), inset 0 4px 0 #8a6a3a; }

.rustic-hang { position: absolute; top: 0; z-index: 3; pointer-events: none; transform-origin: 50% 0; animation: dangle var(--t, 5s) ease-in-out infinite alternate; animation-delay: var(--dl, 0s); }
.rustic-hang .rope { width: 2px; height: var(--len, 40px); margin: 0 auto; background: #3a2a1a; }
.rustic-hang svg { display: block; width: 100%; margin-top: -2px; }
.rustic-hang.lantern svg { filter: drop-shadow(0 0 18px rgba(255, 190, 90, .55)); }
.rustic-hang .glowcore { animation: lanternFlicker 2.6s ease-in-out infinite alternate; }
@keyframes lanternFlicker { 0% { opacity: .75; } 40% { opacity: 1; } 70% { opacity: .85; } 100% { opacity: 1; } }

/* calm the cartoon layer */
.star-friend, .hang, .cf-star, .cf-moon, .btn-wax::before, .potions, .moth.m-wall { display: none !important; }
.twinkle { color: #f1e2bc !important; filter: drop-shadow(0 0 3px rgba(255, 230, 180, .6)); opacity: .8; }
.twinkle svg { transform: scale(.7); }
.ray-star { filter: drop-shadow(0 0 6px rgba(255, 220, 160, .35)) saturate(.7); opacity: .85; }
.constellation { color: #c9b48a; opacity: .55; }
.constellation .clabel { fill: #c9b48a; }
.mist::before, .mist::after {
  background:
    radial-gradient(ellipse 22% 40% at 20% 70%, rgba(200, 190, 175, .22), transparent 70%),
    radial-gradient(ellipse 26% 45% at 55% 80%, rgba(180, 170, 155, .2), transparent 70%),
    radial-gradient(ellipse 20% 38% at 85% 70%, rgba(200, 190, 175, .2), transparent 70%);
}
.rune-halo { color: var(--brass); opacity: .12; }
.rune-halo::before { background: radial-gradient(rgba(255, 180, 90, .35), transparent 70%); }
.scroll { filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .6)) drop-shadow(0 0 30px rgba(255, 170, 80, .18)); }
.trail { --c: #ffb35a !important; color: #ffb35a !important; filter: drop-shadow(0 0 4px #ff9a3a); }
.unroll-hint { color: var(--parch); text-shadow: 0 0 8px rgba(255, 170, 80, .6); }
.moon-clouds { filter: sepia(.35) saturate(.75) brightness(.92); opacity: .85; }
.card-frame { border-color: rgba(176, 141, 87, .55); box-shadow: inset 0 0 0 7px rgba(176, 141, 87, .18); }
.card-frame::before { border-color: rgba(176, 141, 87, .22); }
.trials { background: rgba(32, 21, 13, .82); border: 1px solid rgba(176, 141, 87, .5); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.trial-glyph.is-done { color: var(--brass-hi); filter: drop-shadow(0 0 6px rgba(255, 190, 100, .6)); }
.glyph-veil { background: radial-gradient(circle, rgba(40, 26, 16, .97), rgba(12, 8, 5, 1)); }
.veil-glyph { color: var(--brass-hi); filter: drop-shadow(0 0 10px rgba(255, 180, 90, .55)); }
.spark { background: #ffcf7a; box-shadow: 0 0 8px #ffb35a; }

/* --- study (wordle) --- */
.scene-study { background: radial-gradient(ellipse 60% 45% at 50% 42%, rgba(240, 170, 80, .25), transparent 70%), #1a110a; }
.scene-study::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse 70% 60% at 50% 45%, transparent 30%, rgba(10, 6, 3, .75) 100%); }
.book { background: linear-gradient(90deg, #4a2a18, #6b3d22 49%, #2e1a0e 50%, #6b3d22 51%, #4a2a18); box-shadow: 0 24px 50px rgba(0, 0, 0, .65), inset 0 0 0 3px rgba(176, 141, 87, .6), inset 0 0 0 7px #4a2a18, inset 0 0 0 8px rgba(176, 141, 87, .35); }
.w-tile.filled, .w-tile.correct, .w-tile.present { box-shadow: none; }
.w-tile.correct, .k.k-correct, .k-correct { background: #55603d; border-color: #3e4a2c; }
.w-tile.present, .k.k-present, .k-present { background: #c4953e; border-color: #8a6524; }

/* --- bridge (crossword) --- */
.scene-sea { background: linear-gradient(#0c1118 0%, #131c27 35%, #233040 57%, #3a4552 63%, #0d151d 100%); }
.night-moon { background: radial-gradient(circle at 38% 36%, #f6ecd2, #e2d2a8 55%, #c3ad7e 100%); box-shadow: 0 0 50px 14px rgba(240, 220, 170, .2); }
.sea { background: linear-gradient(#1a2733, #0a1016); }
.w1 { color: #22313f; } .w2 { color: #1a2733; } .w3 { color: #121c25; }
.clue-board { background: linear-gradient(#e8d7ae, #d6c08e); color: #2b1a0e; border: 0; box-shadow: inset 0 0 18px rgba(90, 55, 20, .45), 0 8px 18px rgba(0, 0, 0, .45); }
.clue-board h3 { color: var(--oxblood); }
.clue-board li b { color: #6e2a26; }
.clue-board li.active { background: rgba(110, 42, 38, .15); }
.clue-board li.done { color: rgba(43, 26, 14, .5); text-decoration-color: var(--moss); }
.active-clue { background: rgba(32, 21, 13, .88); border-color: rgba(176, 141, 87, .45); }
.cell { --size: clamp(26px, calc((100vw - 72px) / var(--cols, 10) - 4px), 50px); }
.sign .how { font-size: .9rem; font-style: italic; opacity: .75; }
.sign { max-width: 640px; }

/* --- gallery --- */
.scene-gallery {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='120' viewBox='0 0 80 120'><g fill='none' stroke='%23b08d57' stroke-opacity='.13' stroke-width='1.3'><path d='M40 8 C58 26 58 44 40 60 C22 44 22 26 40 8Z'/><path d='M40 60 C58 76 58 94 40 112 C22 94 22 76 40 60Z'/><circle cx='0' cy='60' r='9'/><circle cx='80' cy='60' r='9'/></g></svg>"),
    radial-gradient(ellipse 70% 50% at 50% 30%, rgba(255, 190, 110, .12), transparent 70%),
    linear-gradient(90deg, rgba(0, 0, 0, .4), transparent 20%, transparent 80%, rgba(0, 0, 0, .4)),
    #2c3122;
}
.folk-band.frieze { background: repeating-linear-gradient(90deg, #4a2e18 0 2px, #5b3a1f 2px 60px); border-bottom: 3px double rgba(176, 141, 87, .6); }
.folk-band.frieze::after { background: repeating-linear-gradient(90deg, #8a6a3a 0 10px, #3e2716 10px 20px); opacity: .7; }
.frame::after { display: none; }

/* --- apothecary (connections) --- */
.scene-cards {
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(255, 180, 90, .14), transparent 70%),
    repeating-linear-gradient(90deg, #2a1a0f 0 3px, #3b2515 3px 92px, #34200f 92px 95px, #432a17 95px 180px),
    #33200f;
}
.scene-cards::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 40%, rgba(10, 6, 3, .7) 100%); }
.cards-head .chapter-title { color: var(--brass-hi); text-shadow: 2px 2px 0 rgba(0, 0, 0, .6); }
.cards-head p { color: #e6d6b8; }
.reading { max-width: 760px; }
.apothecary { width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px 4px; border-radius: 6px; background: linear-gradient(#24160c, #2e1d10); box-shadow: inset 0 0 0 8px #4a2e18, inset 0 0 0 10px #1a0f08, inset 0 0 40px rgba(0, 0, 0, .6), 0 18px 30px rgba(0, 0, 0, .5); }
.shelf { position: relative; padding: 18px 8px 0; }
.shelf-bottles { display: grid; grid-template-columns: repeat(4, 1fr); justify-items: center; align-items: end; min-height: clamp(112px, 19vw, 176px); position: relative; z-index: 1; }
.plank-shelf { height: 14px; margin: -4px -8px 0; border-radius: 2px; background: repeating-linear-gradient(91deg, transparent 0 30px, rgba(0, 0, 0, .12) 30px 31px), linear-gradient(#8a5a2e, #5b3a1f 60%, #3a2412); box-shadow: 0 6px 8px rgba(0, 0, 0, .55); }
.shelf-label {
  position: absolute; left: 50%; top: -2px; translate: -50% 0; z-index: 2;
  padding: 2px 14px; border-radius: 3px; white-space: nowrap;
  font: 400 .95rem/1.4 var(--display-sc); color: #2b1a0e;
  background: linear-gradient(#e3d2a8, #c9b07a); box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(-6px); transition: opacity .4s, transform .4s;
}
.shelf.filled .shelf-label { opacity: 1; transform: none; }
.shelf[data-color="yellow"] .shelf-label { background: linear-gradient(#f2d77a, #d4b04a); }
.shelf[data-color="green"] .shelf-label { background: linear-gradient(#a9c78a, #7ea35a); }
.shelf[data-color="blue"] .shelf-label { background: linear-gradient(#9fbfdc, #6f97bd); }
.shelf[data-color="purple"] .shelf-label { background: linear-gradient(#c7aede, #9a7cbc); }

.bottle {
  --liquid: var(--murk);
  position: relative; width: clamp(66px, 15vw, 116px); padding: 0; border: 0; background: none;
  transform: rotate(var(--tilt, 0deg)); transition: transform .25s var(--ease-pop), filter .25s;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .45));
}
.bottle svg { display: block; width: 100%; overflow: visible; }
.bottle .glass { fill: rgba(220, 235, 225, .12); stroke: rgba(240, 250, 240, .55); stroke-width: 1.6; }
.bottle .glass.body { fill: rgba(220, 235, 225, .06); }
.bottle .cork { fill: #a07a4a; }
.bottle .lip { fill: rgba(220, 235, 225, .35); stroke: rgba(240, 250, 240, .5); }
.bottle .liquid, .bottle .liquid-top { fill: var(--liquid); transition: fill .8s; }
.bottle .liquid-top { opacity: .7; }
.bottle .shine { fill: none; stroke: rgba(255, 255, 255, .45); stroke-width: 3; stroke-linecap: round; }
.bottle .bub { fill: rgba(255, 255, 255, .55); animation: bub 2.6s ease-in infinite; }
.bottle .b2 { animation-delay: -1s; } .bottle .b3 { animation-delay: -1.8s; }
.bottle .tag {
  position: absolute; left: 50%; top: 60%; translate: -50% -50%;
  min-width: 82%; padding: 4px 4px 5px; border-radius: 2px;
  font: 400 clamp(.62rem, 1.7vw, .98rem)/1.1 var(--display-sc); color: #2b1a0e; letter-spacing: .02em;
  background: linear-gradient(#efe1bd, #dcc795);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(110, 70, 30, .4);
  white-space: nowrap;
}
.bottle .tag.long { font-size: clamp(.52rem, 1.4vw, .84rem); }
.bottle:hover { transform: translateY(-4px) rotate(0); }
.bottle.selected { transform: translateY(-14px) rotate(0); filter: drop-shadow(0 0 12px rgba(255, 200, 110, .9)) drop-shadow(0 6px 4px rgba(0, 0, 0, .45)); }
.bottle.selected .tag { color: var(--oxblood); box-shadow: 0 0 0 2px #e2c07e, 0 1px 2px rgba(0, 0, 0, .5); }
.bottle.hop { animation: bottleHop .5s ease-in-out both; animation-delay: calc(var(--hop) * 110ms); }
@keyframes bottleHop { 50% { transform: translateY(-26px) rotate(-8deg); } 100% { transform: translateY(-14px); } }
.bottle.shake { animation: shake .45s; }
.bottle.nope { animation: shake .3s; }
.bottle[data-color="yellow"] { --liquid: #e2b93a; }
.bottle[data-color="green"] { --liquid: #6fa04a; }
.bottle[data-color="blue"] { --liquid: #3f78b0; }
.bottle[data-color="purple"] { --liquid: #8a55b0; }
.bottle.brewed { cursor: default; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--liquid) 60%, transparent)) drop-shadow(0 6px 4px rgba(0, 0, 0, .45)); }
.conn-meta { color: #e6d6b8; }

/* --- music box --- */
.musicbox {
  position: fixed; left: 18px; bottom: 18px; z-index: 70;
  width: 228px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(#5b3a1f, #3a2412);
  box-shadow: inset 0 0 0 2px rgba(176, 141, 87, .7), 0 8px 20px rgba(0, 0, 0, .55);
  color: var(--parch); font-family: var(--body);
}
.mb-screen { padding: 8px 14px 0; height: 129px; transition: height .35s; }
.mb-screen iframe { display: block; border-radius: 4px; box-shadow: 0 0 0 2px #2a1a0e; }
.musicbox.collapsed .mb-screen { height: 0; padding-top: 0; }
.mb-controls { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.mb-btn { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #e2c07e, #a07a3a); color: #2b1a0e; box-shadow: 0 2px 0 #4a2e18; }
.mb-btn svg { width: 18px; height: 18px; fill: currentColor; }
.mb-btn .i-pause { display: none; }
.musicbox.playing .i-play { display: none; }
.musicbox.playing .i-pause { display: inline; }
.mb-title { flex: 1; min-width: 0; font-size: .82rem; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.musicbox.playing .mb-title { animation: none; }
.mb-expand { width: 26px; height: 26px; background: rgba(226, 192, 126, .25); color: var(--parch); box-shadow: none; }
.musicbox.collapsed .mb-expand svg { transform: rotate(180deg); }
.musicbox.playing .mb-toggle { animation: mbPulse 2s ease-in-out infinite; }
@keyframes mbPulse { 50% { box-shadow: 0 2px 0 #4a2e18, 0 0 12px rgba(255, 200, 110, .7); } }

@media (max-width: 760px) {
  .musicbox { left: 10px; bottom: 10px; width: 200px; }
  .mb-screen { height: 113px; padding: 6px 0 0; display: grid; place-items: center; }
  .mb-title { display: none; }
  .apothecary { padding: 10px 4px 2px; }
  .shelf { padding: 16px 2px 0; }
  .shelf-label { font-size: .78rem; }
  .bottle .tag { min-width: 90%; }
}

/* fixes */
.mb-screen { overflow: hidden; }
.ribbon { left: 4%; }
.ink-blot { right: auto; top: auto; left: 48px; bottom: 52px; }
.cell { --size: clamp(22px, calc((min(100vw, 1040px) - 116px) / var(--cols, 10) - 4px), 50px); }
.paper-inner > .ink-title { padding: 0 24px; }

/* keep the YouTube player fully out of sight when the music box is folded */
.musicbox.collapsed .mb-screen { position: fixed; left: -9999px; top: 0; width: 200px; height: 113px; padding: 0; opacity: 0; pointer-events: none; }
.mb-controls { position: relative; z-index: 1; background: linear-gradient(#5b3a1f, #3a2412); }
