:root { --gold: #f3c96b; --ink: #0b1030; --glow: #7fc8ff; --panel: rgba(10, 16, 48, .82); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: #eef3ff; font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', serif; overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }
button { font-family: inherit; }
.btn { background: linear-gradient(#2a3f8f, #15205a); color: #fff5d6; border: 2px solid var(--gold); border-radius: 14px; padding: .6em 1.4em; font-size: 1.05rem; cursor: pointer; box-shadow: 0 0 14px rgba(127, 200, 255, .45), inset 0 1px 0 rgba(255, 255, 255, .25); text-shadow: 0 1px 2px #000; min-height: 44px; }
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { font-size: 1.35rem; min-width: 210px; }
.btn.small { font-size: .9rem; padding: .4em .9em; }
.btn.danger { border-color: #d77; }

/* menu */
.menu-bg, .map-bg, #game-bg { position: absolute; inset: 0; background: center / cover no-repeat; }
.menu-buttons { position: absolute; right: 6%; bottom: 10%; display: flex; flex-direction: column; gap: 14px; }
.version { position: absolute; left: 10px; bottom: 6px; font-size: .75rem; opacity: .6; }
@media (max-aspect-ratio: 1/1) { .menu-bg { background-position: 18% center; } .menu-buttons { left: 50%; right: auto; transform: translateX(-50%); bottom: 7%; } }

/* intro */
#scr-intro { background: #000; }
#intro-video, #story-page { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.intro-ctrl { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); right: 14px; display: flex; gap: 10px; }

/* map */
.map-bg::after { content: ''; position: absolute; inset: 0; background: rgba(5, 8, 30, .45); }
.map-head { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; gap: 8px; }
.map-head h1 { margin: 0; font-size: clamp(1rem, 3.2vw, 1.8rem); color: var(--gold); text-shadow: 0 0 12px #000, 0 0 8px rgba(127, 200, 255, .6); text-align: center; }
#map-grid { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 10px 4vw; max-width: 1100px; margin: 0 auto; }
@media (max-aspect-ratio: 1/1) { #map-grid { grid-template-columns: repeat(3, 1fr); overflow-y: auto; max-height: calc(100% - 70px); } }
.map-node { position: relative; background: var(--panel); border: 2px solid rgba(243, 201, 107, .6); border-radius: 16px; color: #fff; padding: 6px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.map-node img { height: clamp(70px, 16vh, 150px); filter: drop-shadow(0 0 10px rgba(127, 200, 255, .6)); }
.map-node.locked img { filter: grayscale(.6) brightness(.6); height: clamp(50px, 11vh, 100px); }
.map-node.boss { border-color: #b98cff; box-shadow: 0 0 12px rgba(185, 140, 255, .5); }
.map-node .n { position: absolute; top: 4px; left: 8px; font-weight: bold; color: var(--gold); }
.map-node .pl { font-size: .8rem; text-align: center; }
.map-node .st { color: var(--gold); letter-spacing: 2px; }

/* game layout */
#game-bg::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(5, 8, 30, .15), rgba(5, 8, 30, .6)); }
#hud { position: absolute; top: 0; left: 0; right: 0; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); background: linear-gradient(rgba(5, 8, 30, .85), rgba(5, 8, 30, 0)); z-index: 5; }
.hud-title { display: flex; flex-direction: column; align-items: center; }
#hud-level { color: var(--gold); font-weight: bold; font-size: 1.15rem; }
#hud-place { font-size: .85rem; opacity: .85; }
.hud-stat { background: var(--panel); border: 2px solid var(--gold); border-radius: 12px; padding: 2px 12px; text-align: center; min-width: 84px; }
.hud-stat span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
.hud-stat b { font-size: 1.4rem; }
#hud.danger .hud-stat { border-color: #ff7a7a; animation: pulse .8s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 18px #ff5a5a; } }

#stage { position: absolute; top: 56px; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1vw; padding: 1vh 1.5vw; }
#board-wrap { position: relative; width: min(calc(100vh - 80px), 56vw); aspect-ratio: 1; }
#board { position: absolute; inset: 0; background: rgba(8, 14, 46, .72); border: 3px solid var(--gold); border-radius: 18px; box-shadow: 0 0 30px rgba(127, 200, 255, .45), inset 0 0 30px rgba(127, 200, 255, .2); touch-action: none; overflow: hidden;
  background-image: linear-gradient(rgba(127, 200, 255, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(127, 200, 255, .07) 1px, transparent 1px); background-size: var(--cell) var(--cell); }
#side-left, #side-right { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; height: 100%; }
#vaerkin-wrap { position: relative; width: min(100%, 300px); display: flex; justify-content: center; margin: 0 auto; }
#vaerkin { width: min(100%, 300px); filter: drop-shadow(0 0 14px rgba(127, 200, 255, .55)); }
#vaerkin.bounce { animation: bounce .45s ease-out; }
@keyframes bounce { 30% { transform: translateY(-8%) scale(1.04); } 100% { transform: none; } }
#bubble { display: none; }

/* gems */
#gem-layer, #obs-layer { position: absolute; inset: 0; }
#obs-layer { z-index: 2; pointer-events: none; }
.gem { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); padding: calc(var(--cell) * .07); transition: transform .2s ease-in, opacity .2s, scale .2s; will-change: transform; }
.gem.notrans { transition: none; }
.gem img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 0 4px rgba(255, 255, 255, .35)); }
.gem.sel img { filter: drop-shadow(0 0 10px #fff) brightness(1.25); animation: wob .6s infinite alternate; }
.gem.hint img { animation: wob .5s infinite alternate; filter: drop-shadow(0 0 8px var(--gold)); }
@keyframes wob { to { transform: scale(1.12) rotate(4deg); } }
.gem.pop { opacity: 0; scale: 1.5; }
.gem.pw-lineH::before, .gem.pw-lineV::before { content: ''; position: absolute; border-radius: 6px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .9), transparent); box-shadow: 0 0 12px #9fdcff; animation: shine 1s infinite alternate; }
.gem.pw-lineH::before { left: 0; right: 0; top: 44%; height: 12%; }
.gem.pw-lineV::before { top: 0; bottom: 0; left: 44%; width: 12%; background: linear-gradient(transparent, rgba(255, 255, 255, .9), transparent); }
.gem.pw-burst img:first-child { filter: drop-shadow(0 0 10px #fff) brightness(1.2); }
.gem .burst { position: absolute; inset: 22% 22% 22% 22%; width: 56%; height: 56%; animation: shine 1s infinite alternate; }
@keyframes shine { from { opacity: .55; } to { opacity: 1; } }
.gem.stuck img { filter: grayscale(.4) brightness(.7); }
.obs { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); }
.obs.web img { width: 100%; height: 100%; object-fit: cover; opacity: .72; mix-blend-mode: screen; border-radius: 30%; }
.obs.iron { border: 4px solid #8a8f99; border-radius: 10px; background: repeating-linear-gradient(90deg, rgba(60, 64, 72, .75) 0 14%, transparent 14% 30%); box-shadow: inset 0 0 8px #000, 0 0 6px rgba(0, 0, 0, .8); }
.float { position: absolute; transform: translate(-50%, -50%); color: #fff6c9; font-weight: bold; font-size: 1.2rem; text-shadow: 0 0 6px #000, 0 0 10px var(--glow); pointer-events: none; animation: up 1s forwards; z-index: 4; }
.float.pw { color: #b8e6ff; font-size: 1.4rem; }
@keyframes up { to { transform: translate(-50%, -160%); opacity: 0; } }
#board-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.9); background: var(--panel); border: 2px solid var(--gold); border-radius: 14px; padding: .7em 1em; max-width: 86%; text-align: center; opacity: 0; transition: .25s; pointer-events: none; z-index: 6; font-size: 1rem; }
#board-msg.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#board-msg:empty { display: none; }

/* right panel */
#lantern-panel, #boss-panel { width: 100%; max-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#scr-game.is-boss #lantern-panel, #scr-game.is-boss #lantern-box, #scr-game:not(.is-boss) #boss-panel { display: none; }
.meter { position: relative; width: 100%; height: 22px; background: rgba(0, 0, 0, .55); border: 2px solid var(--gold); border-radius: 12px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, #3d7bff, #9fe3ff); box-shadow: 0 0 10px #8fd3ff; transition: width .35s; }
.meter span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .8rem; text-shadow: 0 1px 2px #000; }
.meter.small { height: 18px; }
#light-fill { background: linear-gradient(90deg, #ffb347, #ffe58a); }
.stars-preview { color: var(--gold); font-size: 1.4rem; letter-spacing: 3px; }
.boss-name { color: #d9b8ff; font-weight: bold; text-shadow: 0 0 8px #000; }
#boss-box { position: relative; width: 100%; aspect-ratio: 1; }
#boss-box img#boss-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 14px rgba(160, 90, 255, .55)); }
#boss-extra { position: absolute; right: -6%; bottom: 0; height: 48%; object-fit: contain; filter: drop-shadow(0 0 10px #8fd3ff); }
#boss-box.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6%); } 40%, 80% { transform: translateX(6%); } }
.pips { display: flex; gap: 5px; }
.pips i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #d9b8ff; background: rgba(0, 0, 0, .5); }
.pips i.on { background: radial-gradient(#fff, #b07bff); box-shadow: 0 0 8px #b07bff; }
.pips.shield i { border-radius: 4px; border-color: #8fd3ff; }
.pips.shield i.on { background: radial-gradient(#fff, #5aa8ff); }
#stage.hit { animation: shake .4s; }
#stage.hit::after { content: ''; position: absolute; inset: 0; background: rgba(150, 60, 255, .25); pointer-events: none; }

/* overlays */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(3, 5, 20, .7); z-index: 20; }
.overlay.open { display: flex; }
.panel { background: var(--panel); border: 2px solid var(--gold); border-radius: 18px; padding: 20px 26px; min-width: min(340px, 90vw); max-width: 92vw; display: flex; flex-direction: column; gap: 12px; align-items: stretch; box-shadow: 0 0 40px rgba(127, 200, 255, .4); }
.panel h2 { margin: 0; color: var(--gold); text-align: center; }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.panel input[type=range] { flex: 1; accent-color: #7fc8ff; }
.panel .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.result { align-items: center; text-align: center; max-width: min(460px, 92vw); }
.result img { max-height: 32vh; max-width: 80%; object-fit: contain; }
.res-stars { font-size: 2.4rem; letter-spacing: 6px; color: #555; }
.res-stars .on { color: var(--gold); text-shadow: 0 0 12px var(--gold); }
#ov-confirm { z-index: 30; }

/* portrait / mobile: board on bottom, characters on top row */
@media (max-aspect-ratio: 1/1) {
  #stage { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) auto; padding: 4px 8px max(8px, env(safe-area-inset-bottom)); gap: 4px; }
  #board-wrap { grid-column: 1 / 3; grid-row: 2; width: min(96vw, calc(100vh - 300px)); justify-self: center; }
  #side-left { grid-column: 1; grid-row: 1; }
  #side-right { grid-column: 2; grid-row: 1; }
  #vaerkin { max-height: 30vh; width: auto; max-width: 100%; }
  #lantern-box { height: 22vh; }
  #boss-box { width: auto; height: 20vh; }
  #lantern-panel, #boss-panel { gap: 4px; }
  .meter { height: 18px; }
}
body.reduced *, body.reduced *::before { animation-duration: .01s !important; animation-iteration-count: 1 !important; }

/* v0.3: Vaer'kin carries the level lantern beside his paw */
#vaerkin-wrap #lantern-box { position: absolute; right: 0; bottom: 0; height: 60%; aspect-ratio: 2/3; pointer-events: none; z-index: 2; transform-origin: 50% 0; animation: sway 3.2s ease-in-out infinite alternate; }
#lantern-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#lantern-dim { filter: grayscale(.85) brightness(.5); }
#lantern-lit { transition: clip-path .45s, filter .45s; filter: drop-shadow(0 0 calc(4px + 18px * var(--fill, 0)) rgba(127, 200, 255, .9)) brightness(calc(.85 + .35 * var(--fill, 0))); }
#lantern-glow { position: absolute; left: 20%; right: 20%; top: 30%; bottom: 25%; border-radius: 50%; background: radial-gradient(rgba(170, 225, 255, .9), rgba(127, 200, 255, 0) 70%); opacity: calc(var(--fill, 0) * .8); transition: opacity .45s; }
#lantern-box.pulse { animation: lpulse .5s ease-out; }
#lantern-box.full #lantern-glow { opacity: 1; animation: shine .8s infinite alternate; }
#vaerkin[data-pose="lantern"] ~ #lantern-box { display: none; } /* vaerkin9 already holds a lantern */
@keyframes sway { from { rotate: -3deg; } to { rotate: 3deg; } }
@keyframes lpulse { 40% { scale: 1.12; filter: brightness(1.5); } 100% { scale: 1; } }
#lantern-panel { max-width: 260px; }
@media (max-aspect-ratio: 1/1) {
  #side-left { grid-column: 1 / 3; }
  #side-right { display: none; }
  #scr-game.is-boss #side-left { grid-column: 1; }
  #scr-game.is-boss #side-right { display: flex; }
  #vaerkin-wrap { width: auto; }
  #vaerkin { max-height: 26vh; }
}

/* ===== v0.4 ===== */
/* Lantern Thief reveal: hooded -> unhooded crossfade with a warm lantern-glow sweep over the face */
#boss-box.revealing { position: relative; }
#boss-reveal { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; animation: revealFace 2.4s ease-in-out forwards; pointer-events: none; }
#boss-box.revealing #boss-img { animation: liftHead 2.4s ease-in-out forwards; }
#reveal-glow { position: absolute; left: 10%; right: 10%; top: 8%; height: 50%; border-radius: 50%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(ellipse at center, rgba(255, 214, 130, .85), rgba(255, 170, 60, .35) 45%, transparent 70%); opacity: 0; transform: translateY(60%) scale(.6);
  animation: glowSweep 2.4s ease-out forwards; }
@keyframes revealFace { 0%, 25% { opacity: 0; transform: translateY(4%); } 75%, 100% { opacity: 1; transform: none; } }
@keyframes liftHead { 0% { transform: translateY(4%); } 60% { transform: none; opacity: 1; } 100% { opacity: 0; } }
@keyframes glowSweep { 0% { opacity: 0; transform: translateY(60%) scale(.6); } 50% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: .15; transform: translateY(-10%) scale(1.3); } }
body.reduced #boss-reveal, body.reduced #boss-box.revealing #boss-img, body.reduced #reveal-glow { animation-duration: .7s; }
/* Cutscene player */
.cutscene { position: fixed; inset: 0; z-index: 1000; background: #000; display: flex; align-items: center; justify-content: center; }
.cutscene video, .cutscene img { width: 100%; height: 100%; object-fit: contain; }
.cutscene .cs-skip { position: absolute; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 2; }
/* Desktop: wider side columns so Vaer'kin and his lantern read bigger */
@media (min-aspect-ratio: 1/1) {
  #stage { grid-template-columns: minmax(0, 1.25fr) auto minmax(0, 1fr); }
  #board-wrap { width: min(calc(100vh - 80px), 50vw); }
  #vaerkin-wrap, #vaerkin { width: min(100%, 380px); }
  #lantern-panel { max-width: 320px; width: 100%; }
}
/* Mobile: keep Vaer'kin / lantern / stars snug against the board (no dead gap) */
@media (max-aspect-ratio: 1/1) {
  #stage { grid-template-rows: auto auto; align-content: center; row-gap: 6px; }
  #side-left, #side-right { height: auto; justify-content: flex-end; align-self: end; }
  #board-wrap { align-self: start; width: min(96vw, calc(100svh - 56px - 34vh)); }
  #lantern-panel { margin-bottom: 0; }
}

/* ===== v0.6 ===== */
/* Main menu centred. Cause: v0.1 pinned it with right: 6% on desktop. */
.menu-buttons { left: 50%; right: auto; transform: translateX(-50%); align-items: stretch; bottom: 9%; }
.menu-buttons .btn.big { min-width: min(260px, 70vw); }
.icon-mute { position: relative; min-width: 44px; padding: .3em .6em; font-size: 1.1rem; }
.icon-mute.muted::after { content: ''; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; background: #ff8a8a; transform: rotate(-35deg); }
#btn-menu-mute { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }
.hud-left { display: inline-flex; gap: 6px; }
/* settings volume rows */
.panel .vol { display: grid; grid-template-columns: 7.5em 1fr 2.6em auto; align-items: center; gap: 10px; }
.panel .vol output { text-align: right; font-variant-numeric: tabular-nums; opacity: .85; }
.panel .vol input[type=range] { accent-color: #7fc8ff; width: 100%; }
.panel .vol input[type=range]:disabled { opacity: .4; }
.panel label.mute { gap: 4px; justify-content: flex-start; font-size: .9rem; }
@media (max-width: 480px) { .panel .vol { grid-template-columns: 1fr 2.6em auto; } .panel .vol > span { grid-column: 1 / -1; margin-bottom: -6px; } }
/* level select: big picture cards */
#scr-map { display: none; flex-direction: column; }
#scr-map.active { display: flex; }
#map-grid { flex: 1; min-height: 0; overflow-y: auto; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(10px, 1.6vw, 22px); padding: 10px clamp(12px, 3vw, 40px) 24px; max-width: 1500px; width: 100%; align-content: start; max-height: none; }
.map-node { padding: 0; overflow: hidden; aspect-ratio: 16 / 11; justify-content: flex-end; gap: 0; background: #0b1030 center / cover no-repeat; border-width: 3px; box-shadow: 0 4px 18px rgba(0, 0, 0, .55); transition: transform .15s, box-shadow .15s; }
.map-node:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 0 22px rgba(243, 201, 107, .6); }
.map-node::before { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(5, 8, 30, 0) 35%, rgba(5, 8, 30, .88)); pointer-events: none; }
.map-node.locked { filter: grayscale(.85) brightness(.55); }
.map-node.locked:disabled { opacity: 1; }
.map-node img.lan { position: absolute; top: 8px; right: 8px; height: 34%; width: auto; filter: drop-shadow(0 0 10px rgba(127, 200, 255, .8)); }
.map-node.locked img.lan { height: 30%; filter: none; }
.map-node .n { z-index: 1; top: 8px; left: 10px; font-size: clamp(1.2rem, 2.2vw, 1.9rem); background: rgba(5, 8, 30, .7); border-radius: 10px; padding: 0 .45em; text-shadow: 0 1px 3px #000; }
.map-node .pl, .map-node .st { position: relative; z-index: 1; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.map-node .pl { font-size: clamp(.85rem, 1.3vw, 1.1rem); font-weight: bold; padding: 0 6px; }
.map-node .st { font-size: clamp(1rem, 1.6vw, 1.4rem); padding-bottom: 6px; }
@media (max-aspect-ratio: 1/1) { #map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; } }
@media (min-aspect-ratio: 1/1) and (max-width: 900px) { #map-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#ov-settings { z-index: 30; } /* v0.6: settings opened from Pause sits above the pause panel */
.panel label.chk { justify-content: flex-start; gap: 8px; }

/* ===== v0.7 ===== */
/* Main menu raised (Twyzzted: "move the menu up more"); still centred and clear of the logo */
.menu-buttons { bottom: auto; top: 50%; }
@media (max-aspect-ratio: 1/1) { .menu-buttons { top: 27%; bottom: auto; } }
/* Prominent Continue at the top of the menu */
#btn-continue[hidden] { display: none; }
#btn-continue.primary { background: linear-gradient(#f6d27c, #c98f2c); color: #2a1600; text-shadow: none; border-color: #fff3c4; font-weight: bold; font-size: 1.5rem; display: flex; flex-direction: column; align-items: center; line-height: 1.15; box-shadow: 0 0 22px rgba(243, 201, 107, .75); }
#btn-continue small { font-size: .72rem; font-weight: normal; opacity: .85; }
.map-node.current { outline: 3px solid #fff3c4; outline-offset: 2px; }

/* ===== v0.9 ===== */
/* Big fancy banner (Cinzel Decorative, css/fonts.css) */
#fancy-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.3); z-index: 7; pointer-events: none; opacity: 0; white-space: nowrap;
  font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: clamp(1.9rem, 6.4vmin, 4.4rem); letter-spacing: .02em; word-spacing: .3em; text-transform: uppercase;
  background: linear-gradient(180deg, #fffbe6 0%, #ffe08a 38%, #e6a93a 62%, #fff1c1 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1.5px #5a3200;
  filter: drop-shadow(0 0 1.5px #1a0c00) drop-shadow(0 0 3px #1a0c00) drop-shadow(0 0 8px rgba(255, 200, 90, .9)) drop-shadow(0 0 18px rgba(127, 200, 255, .85)) drop-shadow(0 3px 2px rgba(0, 0, 0, .8)); }
#fancy-banner.on { animation: bannerPop 1.1s cubic-bezier(.2, 1.4, .4, 1) forwards; }
#fancy-banner.square { -webkit-text-stroke-color: #0b2a55; background-image: linear-gradient(180deg, #ffffff 0%, #c9f0ff 35%, #7fc8ff 60%, #f4e3ff 100%); }
#fancy-banner.cascade { font-size: clamp(1.6rem, 5.4vmin, 3.6rem); }
@keyframes bannerPop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-4deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(1deg); }
  30% { transform: translate(-50%, -50%) scale(1) rotate(0); } 78% { opacity: 1; transform: translate(-50%, -55%) scale(1.02); } 100% { opacity: 0; transform: translate(-50%, -68%) scale(1.06); } }
body.reduced #fancy-banner.on { animation: bannerFade 1s forwards; }
@keyframes bannerFade { 0%, 100% { opacity: 0; transform: translate(-50%, -50%); } 15%, 80% { opacity: 1; transform: translate(-50%, -50%); } }
@media (max-width: 480px) { #fancy-banner { font-size: clamp(1.4rem, 8.6vw, 2.4rem); white-space: normal; text-align: center; width: 96%; line-height: 1.05; } }
/* Square-match HUD pill */
#hud-square { margin-top: 2px; display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; padding: 1px 8px; border-radius: 10px; border: 1px solid #7fc8ff; background: rgba(20, 60, 120, .6); color: #dff4ff; box-shadow: 0 0 8px rgba(127, 200, 255, .6); }
#hud-square[hidden] { display: none; }
#hud-square i { width: 11px; height: 11px; display: inline-block; background: conic-gradient(#9fdcff 0 25%, #fff 0 50%, #9fdcff 0 75%, #fff 0); border-radius: 2px; box-shadow: 0 0 5px #9fdcff; }
#hud-square.used { border-color: #667; background: rgba(30, 30, 50, .6); color: #99a; box-shadow: none; text-decoration: line-through; }
#hud-square.used i { background: #556; box-shadow: none; }

/* ===== v0.10 Magic Book ===== */
.gem.pw-book > img:first-child { position: absolute; width: 34%; height: 34%; right: 4%; bottom: 4%; left: auto; top: auto; z-index: 2; filter: drop-shadow(0 0 3px #fff); }
.gem .book { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; filter: drop-shadow(0 0 8px #d9a6ff) drop-shadow(0 0 3px #fff3c4); animation: bookBob 1.6s ease-in-out infinite alternate; }
@keyframes bookBob { from { transform: translateY(2%) rotate(-3deg); } to { transform: translateY(-4%) rotate(3deg); filter: drop-shadow(0 0 14px #e8c4ff) drop-shadow(0 0 4px #fff3c4); } }
.book-fx { position: absolute; width: 0; height: 0; z-index: 6; pointer-events: none; }
.book-fx::before { content: ''; position: absolute; left: calc(var(--cell) * -1.6); top: calc(var(--cell) * -1.6); width: calc(var(--cell) * 3.2); height: calc(var(--cell) * 3.2); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 200, .95), rgba(214, 160, 255, .6) 40%, transparent 70%); animation: bookBloom .8s ease-out forwards; }
.book-fx i { position: absolute; left: calc(var(--cell) * -.18); top: calc(var(--cell) * -.24); width: calc(var(--cell) * .36); height: calc(var(--cell) * .48); border-radius: 2px 6px 6px 2px;
  background: linear-gradient(90deg, #f3e6c4, #fffaf0 60%, #e9d7ad); box-shadow: 0 0 8px rgba(255, 235, 170, .9); opacity: 0; animation: pageFly .8s ease-out forwards; }
@keyframes pageFly { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0) rotateY(0) scale(.6); } 60% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotateY(540deg) scale(1); } }
@keyframes bookBloom { 0% { opacity: 0; transform: scale(.3); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.4); } }
.gem.book-glow img { filter: drop-shadow(0 0 10px #ffe9a8) drop-shadow(0 0 16px #c99bff) brightness(1.5); }
body.reduced .book-fx i { display: none; }

/* v0.10 Credits */
#ov-credits { z-index: 35; }
.panel.credits { max-width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; text-align: center; }
.panel.credits .cr-owner { font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; color: var(--gold); font-size: clamp(1rem, 2.6vw, 1.25rem); line-height: 1.35; margin: 4px 0; text-shadow: 0 0 10px rgba(243, 201, 107, .5); }
.panel.credits dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 4px 0; text-align: left; }
.panel.credits dt { color: #b8dcff; font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; align-self: center; }
.panel.credits dd { margin: 0; }
.panel.credits .cr-copy { font-weight: bold; margin: 4px 0 0; }
.panel.credits .cr-font { opacity: .7; margin: 0; }
@media (max-width: 480px) { .panel.credits dl { grid-template-columns: 1fr; text-align: center; } .panel.credits dt { margin-top: 6px; } }

/* v0.11 Credits layout (Twyzzted's exact text). Her wording keeps its own capitalization: no text-transform on names/roles. */
.panel.credits { gap: 0; padding: 22px 26px 12px; text-align: center; align-items: center; }
.panel.credits .cr-title { font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: clamp(1.6rem, 4.4vw, 2.3rem); letter-spacing: .12em; color: var(--gold); text-shadow: 0 0 14px rgba(243, 201, 107, .55); margin: 0 0 4px; }
.panel.credits .cr-team { margin: 0 0 14px; font: 600 clamp(.85rem, 2vw, 1rem)/1.2 Georgia, serif; letter-spacing: .22em; color: #cfe8ff; }
.panel.credits .cr-team::before, .panel.credits .cr-team::after { content: '✦'; color: var(--gold); margin: 0 .6em; font-size: .8em; }
.panel.credits .cr-block { margin: 0 0 12px; }
.panel.credits .cr-role { font: italic clamp(.85rem, 1.9vw, .98rem)/1.2 Georgia, serif; color: #9fcfff; letter-spacing: .04em; }
.panel.credits .cr-name { font: bold clamp(1.05rem, 2.6vw, 1.3rem)/1.3 Georgia, serif; color: #fff3d0; }
.panel.credits .cr-note { font: clamp(.78rem, 1.8vw, .9rem)/1.3 Georgia, serif; opacity: .8; }
.panel.credits .cr-copy { margin: 6px 0 8px; font: bold clamp(.9rem, 2vw, 1rem)/1.35 Georgia, serif; }
.panel.credits .cr-owner { font-family: Georgia, serif; font-weight: normal; font-style: italic; color: var(--gold); font-size: clamp(.88rem, 2vw, 1rem); line-height: 1.4; margin: 0 0 12px; text-shadow: none; max-width: 34em; }
.panel.credits .cr-font { margin: 10px 0 0; font-size: .62rem; opacity: .55; }
.panel.credits #btn-credits-close { min-width: 160px; }
.panel.credits { background: rgba(10, 16, 48, .96); }
#btn-watch-vault[hidden] { display: none; }
#btn-watch-warden[hidden] { display: none; }

/* ===== v0.14 ===== */
/* Pre-fight boss card (stays until tapped) */
#boss-card { z-index: 25; cursor: pointer; background: rgba(3, 5, 20, .78); }
#boss-card.open { display: flex; }
#boss-card .bc-panel { max-width: min(860px, 94vw); padding: clamp(18px, 3vw, 34px) clamp(18px, 4vw, 48px); align-items: center; text-align: center; gap: clamp(10px, 2vh, 20px); border-width: 3px; box-shadow: 0 0 60px rgba(185, 140, 255, .45), 0 0 30px rgba(243, 201, 107, .3); animation: bcIn .45s cubic-bezier(.2, 1.3, .4, 1); }
#bc-name { font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: clamp(1.8rem, 5.6vw, 3.4rem); line-height: 1.1;
  background: linear-gradient(180deg, #fffbe6, #ffe08a 40%, #e6a93a 65%, #fff1c1); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1px #5a3200;
  filter: drop-shadow(0 0 2px #1a0c00) drop-shadow(0 0 10px rgba(255, 200, 90, .7)); }
#bc-text { margin: 0; font-size: clamp(1.25rem, 3.3vw, 2rem); line-height: 1.45; color: #fff6dc; text-shadow: 0 2px 4px #000; max-width: 30em; }
.bc-tap { font-size: clamp(.85rem, 2vw, 1.05rem); letter-spacing: .25em; text-transform: uppercase; color: #b8dcff; opacity: .8; animation: tapPulse 1.6s ease-in-out infinite; }
@keyframes tapPulse { 50% { opacity: .35; } }
@keyframes bcIn { from { transform: scale(.85); opacity: 0; } }
body.reduced #boss-card .bc-panel, body.reduced .bc-tap { animation: none; }
/* Battle / lock messages: same fancy lettering as the power-up banners, lower on the board */
#battle-banner { position: absolute; left: 50%; top: 66%; transform: translate(-50%, -50%) scale(.3); z-index: 7; pointer-events: none; opacity: 0; text-align: center; width: 96%;
  font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: clamp(1.5rem, 5vmin, 3.3rem); line-height: 1.1; word-spacing: .2em; text-transform: uppercase;
  background: linear-gradient(180deg, #fffbe6 0%, #ffe08a 38%, #e6a93a 62%, #fff1c1 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1.5px #5a3200;
  filter: drop-shadow(0 0 1.5px #1a0c00) drop-shadow(0 0 3px #1a0c00) drop-shadow(0 0 8px rgba(255, 200, 90, .9)); }
#battle-banner.on { animation: bannerPop 1.3s cubic-bezier(.2, 1.4, .4, 1) forwards; }
#battle-banner.hit { background-image: linear-gradient(180deg, #fff 0%, #ffd27a 40%, #ff8a3d 70%, #fff0c8 100%); }
#battle-banner.ouch, #battle-banner.warn { background-image: linear-gradient(180deg, #fff 0%, #e3c4ff 40%, #a46bff 70%, #f4e3ff 100%); -webkit-text-stroke-color: #2a0a55; }
#battle-banner.stuck { background-image: linear-gradient(180deg, #fff 0%, #d6e3ee 40%, #8fa3b8 70%, #f3f7fb 100%); -webkit-text-stroke-color: #1c2a3a; font-size: clamp(1.3rem, 4.4vmin, 2.8rem); }
body.reduced #battle-banner.on { animation: bannerFade 1.2s forwards; }
@media (max-width: 480px) { #battle-banner { font-size: clamp(1.15rem, 7vw, 2rem); } }

/* ===== v0.15 Lantern Collection Book ===== */
#ov-book { z-index: 26; background: rgba(4, 4, 16, .85); }
.book-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(1100px, 96vw); max-height: 96vh; }
.book-title { margin: 0; font-family: 'Cinzel Decorative', Georgia, serif; font-size: clamp(1.4rem, 4.5vw, 2.4rem); background: linear-gradient(180deg, #fffbe6, #ffe08a 45%, #e6a93a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 8px rgba(255, 200, 90, .6)); }
.book { width: 100%; perspective: 1800px; padding: 12px; border-radius: 14px; background: linear-gradient(135deg, #4a2414, #2a120a 60%, #3c1d10); box-shadow: 0 0 0 3px #b8893a, 0 0 0 6px #3a1c0c, 0 18px 50px rgba(0, 0, 0, .7), 0 0 50px rgba(243, 201, 107, .2); }
.book-spread { display: grid; grid-template-columns: 1fr 1fr; position: relative; transform-style: preserve-3d; }
.book-spread::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 34px; transform: translateX(-50%); background: linear-gradient(90deg, transparent, rgba(60, 30, 5, .45) 45%, rgba(60, 30, 5, .45) 55%, transparent); pointer-events: none; }
.bk-page { position: relative; min-height: min(62vh, 520px); padding: 18px 22px 30px; color: #3b2410; display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(ellipse at center, #f6e8c4 0%, #ead3a0 70%, #d9bb7f 100%); box-shadow: inset 0 0 30px rgba(120, 80, 20, .35); }
.bk-page.left { border-radius: 8px 2px 2px 8px; } .bk-page.right { border-radius: 2px 8px 8px 2px; }
.bk-page.blank { background: radial-gradient(ellipse at center, #efdfb6, #d9bb7f); }
.bk-page h3 { margin: 0; font-family: 'Cinzel Decorative', Georgia, serif; font-size: clamp(1.2rem, 3vw, 1.7rem); color: #5a3200; }
.bk-count { font-size: .9rem; font-style: italic; opacity: .75; margin: 2px 0 10px; }
.bk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px; width: 100%; }
.bk-slot { display: flex; flex-direction: column; align-items: center; text-align: center; }
.bk-lan { width: clamp(64px, 9vw, 104px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; border: 2px dashed rgba(110, 70, 20, .35); }
.bk-lan img { width: 92%; height: 92%; object-fit: contain; }
.bk-slot.got .bk-lan { border: 2px solid rgba(201, 140, 40, .6); background: radial-gradient(circle, rgba(255, 220, 120, .55), transparent 70%); }
.bk-slot.got .bk-lan img { filter: drop-shadow(0 0 8px rgba(255, 190, 70, .9)); }
.bk-slot.empty .bk-lan img { filter: brightness(0) opacity(.22); } /* dim silhouette until the level is beaten */
.bk-slot.new .bk-lan { animation: lanIn 1.2s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes lanIn { from { transform: scale(.2) translateY(-30px); opacity: 0; } }
.bk-slot.locked .bk-lan { border-style: solid; background: rgba(40, 25, 10, .25); }
.bk-lock { font-size: 2rem; filter: grayscale(1) opacity(.6); }
.bk-lbl { margin-top: 4px; font-size: .82rem; font-weight: bold; line-height: 1.2; }
.bk-lbl small { display: block; font-weight: normal; font-style: italic; opacity: .75; }
.bk-slot.empty .bk-lbl { opacity: .55; }
.locked-ch { background: radial-gradient(ellipse at center, #d9c9a6, #b29a6c); }
.bk-folio { position: absolute; bottom: 8px; font-size: .8rem; opacity: .6; }
.book-nav { display: flex; gap: 14px; }
.book-nav .btn:disabled { opacity: .35; }
.book-spread.flip-r .bk-page.right, .book-spread.flip-r:not(:has(.right)) .bk-page { animation: flipR .44s ease-in; transform-origin: left center; }
.book-spread.flip-l .bk-page.left { animation: flipL .44s ease-in; transform-origin: right center; }
@keyframes flipR { 50% { transform: rotateY(-90deg); filter: brightness(.7); } 100% { transform: rotateY(-90deg); } }
@keyframes flipL { 50% { transform: rotateY(90deg); filter: brightness(.7); } 100% { transform: rotateY(90deg); } }
body.reduced .book-spread .bk-page { animation: none !important; }
@media (max-width: 759px) {
  .book-spread { grid-template-columns: 1fr; } .book-spread::after { display: none; }
  .bk-page.left { border-radius: 8px; border-left: 10px solid #c9a868; }
  .bk-page { min-height: 0; padding: 14px 12px 28px; }
  .bk-grid { grid-template-columns: repeat(2, 1fr); }
  .bk-lan { width: 82px; }
}
.bk-slot.empty.own .bk-lan img { filter: none; } /* her own 'empty' art is shown as-is */
.bk-page.has-bg { background-size: cover; background-position: center; }

/* ===== v0.16 Lantern Book cover (Twyzzted's art, shown unaltered) ===== */
.book-cover { display: none; position: relative; padding: 0; border: 0; background: none; cursor: pointer; perspective: 1600px;
  height: min(88vh, 900px); max-width: 94vw; aspect-ratio: var(--cover-ar, 504 / 655); }
.book-cover img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 6px 10px 10px 6px; transform-origin: left center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .75), 0 0 50px rgba(243, 201, 107, .25); transition: transform .65s ease-in, filter .65s; }
.book-cover .bc-hint { position: absolute; left: 0; right: 0; bottom: -2.1em; text-align: center; letter-spacing: .25em; text-transform: uppercase; font-size: .9rem; color: #f3dca0; opacity: .8; animation: tapPulse 1.6s ease-in-out infinite; }
.book-wrap.closed .book-cover { display: block; }
.book-wrap.closed .book-title, .book-wrap.closed .book, .book-wrap.closed .book-nav { display: none; }
.book-wrap.closed { justify-content: center; min-height: 92vh; }
.book-wrap.opening .book-cover img { transform: rotateY(-100deg); filter: brightness(.6); }
@media (max-width: 759px) { .book-cover { height: auto; width: min(92vw, calc(86vh * 504 / 655)); } }

/* ===== v0.17 lantern pages ===== */
.bk-slot.got { cursor: pointer; } .bk-slot.got:hover .bk-lan, .bk-slot.got:focus-visible .bk-lan { transform: scale(1.06); box-shadow: 0 0 14px rgba(255, 200, 90, .7); }
.bk-slot .bk-lan { transition: transform .2s, box-shadow .2s; } .bk-slot:focus-visible { outline: 2px solid #c98c28; outline-offset: 3px; border-radius: 8px; }
.bk-slot.nope .bk-lan { animation: nope .4s; }
@keyframes nope { 20%, 60% { transform: translateX(-5px) rotate(-4deg); } 40%, 80% { transform: translateX(5px) rotate(4deg); } }
.lantern-page { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(4, 4, 16, .86); perspective: 1800px; cursor: pointer; }
.lantern-page[hidden] { display: none; }
.lp-sheet { height: min(84vh, 1000px); aspect-ratio: 1000 / 1300; max-width: 94vw; transform-origin: left center; border-radius: 4px 10px 10px 4px; overflow: hidden;
  background: radial-gradient(ellipse at center, #f6e8c4 0%, #ead3a0 70%, #d9bb7f 100%); box-shadow: inset 0 0 40px rgba(120, 80, 20, .4), 0 20px 60px rgba(0, 0, 0, .75), 0 0 0 3px #b8893a; }
.lantern-page.turn .lp-sheet { animation: lpTurn .55s cubic-bezier(.25, .8, .35, 1); }
@keyframes lpTurn { from { transform: rotateY(-95deg); filter: brightness(.55); } }
body.reduced .lantern-page.turn .lp-sheet { animation: none; }
.lp-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lp-fallback { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8%; color: #3b2410; }
.lp-fallback img { width: 55%; max-height: 50%; object-fit: contain; filter: drop-shadow(0 0 16px rgba(255, 190, 70, .9)); }
.lp-fallback h3 { margin: 4% 0 0; font-family: 'Cinzel Decorative', Georgia, serif; font-size: clamp(1.3rem, 3.4vh, 2.2rem); color: #5a3200; }
.lp-place { font-style: italic; font-size: clamp(1rem, 2.3vh, 1.4rem); opacity: .8; }
.lp-fallback p { margin-top: 6%; font-size: clamp(.95rem, 2vh, 1.2rem); opacity: .65; letter-spacing: .05em; }
@media (max-width: 759px) { .lp-sheet { height: auto; width: min(94vw, calc(80vh * 1000 / 1300)); } }
.bk-page h3 { text-align: center; line-height: 1.2; } /* v0.20: long chapter titles wrap centred */

/* v0.21: autoplay-blocked cutscene waits for a tap */
.cutscene .cs-tap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: 'Cinzel Decorative', Georgia, serif; font-size: clamp(1.4rem, 4vw, 2.6rem); color: #ffe08a; text-shadow: 0 0 12px rgba(255, 200, 90, .8), 0 2px 4px #000; letter-spacing: .1em; animation: tapPulse 1.6s ease-in-out infinite; pointer-events: none; }

/* ===== DEMO: coming soon ===== */
#ov-soon { z-index: 28; background: rgba(3, 5, 20, .85); }
.soon-panel { max-width: min(820px, 94vw); align-items: center; text-align: center; gap: 26px; padding: clamp(22px, 4vw, 44px); border-width: 3px; box-shadow: 0 0 60px rgba(185, 140, 255, .45), 0 0 30px rgba(243, 201, 107, .3); animation: bcIn .5s cubic-bezier(.2, 1.3, .4, 1); }
.soon-text { margin: 0; font-family: 'Cinzel Decorative', Georgia, serif; font-weight: 900; font-size: clamp(1.5rem, 4.6vw, 2.8rem); line-height: 1.25;
  background: linear-gradient(180deg, #fffbe6, #ffe08a 40%, #e6a93a 65%, #fff1c1); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1px #5a3200;
  filter: drop-shadow(0 0 2px #1a0c00) drop-shadow(0 0 12px rgba(255, 200, 90, .7)); }
.soon-btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* v0.22: no in-play star display */
.stars-preview { display: none !important; }
