/* SPDX-License-Identifier: LicenseRef-Proprietary */
/* Copyright (c) 2026 Griffith Software — https://griffith.software */
/* Past Bedtime: a cozy, storybook night. Gold and royal-blue buttons over the bedroom, rounded
   lettering (Fredoka, bundled; see THIRD_PARTY_NOTICES.md). */
@font-face {
  font-family: "Fredoka";
  src: url("../../assets/fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-stretch: 75% 125%;
  font-display: swap;
}

:root {
  --night: #0b1033;
  --night2: #121a4d;
  --panel: rgba(18, 26, 78, .94);
  --panel2: #1b2668;
  --line: #34449a;
  --text: #ffffff;
  --muted: #b9c3ef;
  --blue: #3b59e0;
  --blue-deep: #1f2f94;
  --blue-edge: #9db6ff;
  --gold: #ffcb3d;
  --gold-deep: #ff9f1a;
  --gold-edge: #fff1a8;
  --ink: #1a2366;
  --cream: #f4e4bd;
  --green: #4fc35a;
  --red: #ff6b6b;
  --yellow: #ffd23f;
  --cyan: #9db6ff;
  --radius: 18px;
  --font: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--text);
  font: 500 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--gold); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- The bedroom behind everything ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.backdrop-room { position: absolute; inset: 0; background: url("../../assets/ui/bg-wide.webp") center bottom / cover no-repeat, var(--night); }
@media (orientation: portrait) { .backdrop-room { background-image: url("../../assets/ui/bg-tall.webp"); } }
.backdrop-kid {
  position: absolute; left: max(1vw, 6px); bottom: 3vh; height: min(66vh, 600px); width: auto;
  filter: drop-shadow(0 18px 20px rgba(0, 0, 0, .5));
  transform-origin: bottom center;
  animation: kid-bob 1.6s ease-in-out infinite;
}
@keyframes kid-bob { 50% { transform: translateY(-1.2%) rotate(-1deg); } }
.backdrop-dim { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, rgba(11, 16, 51, .05), rgba(11, 16, 51, .35) 80%); transition: background .3s; }
/* Away from the title screen the room steps back behind the page */
body:not(.at-home) .backdrop-dim { background: rgba(9, 12, 40, .74); backdrop-filter: blur(3px); }
body:not(.at-home) .backdrop-kid { display: none; }

.app { position: relative; z-index: 1; height: 100%; }
.view {
  height: 100%; overflow-y: auto; outline: none;
  padding: calc(18px + var(--safe-t)) calc(18px + var(--safe-r)) calc(24px + var(--safe-b)) calc(18px + var(--safe-l));
}

/* ---------- Buttons ---------- */
.menu-btn, .btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: 600 18px/1 var(--font); color: #fff; text-decoration: none; cursor: pointer;
  min-height: 46px; padding: 0 22px; border-radius: 999px;
  border: 3px solid var(--blue-edge);
  background: linear-gradient(180deg, #5a78f4 0%, var(--blue) 45%, var(--blue-deep) 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 4px 0 #111a5c, 0 8px 18px rgba(0, 0, 0, .35);
  text-shadow: 0 2px 0 rgba(10, 16, 60, .55);
  transition: transform .08s, filter .15s;
}
.menu-btn:hover, .btn:hover { filter: brightness(1.12); }
.menu-btn:active, .btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 1px 0 #111a5c, 0 4px 10px rgba(0, 0, 0, .35); }
.btn.primary, .menu-btn.primary {
  color: var(--ink); text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
  border-color: var(--gold-edge);
  background: linear-gradient(180deg, #ffe680 0%, var(--gold) 40%, var(--gold-deep) 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 4px 0 #b25e00, 0 0 22px rgba(255, 190, 60, .55), 0 10px 22px rgba(0, 0, 0, .35);
}
.btn.ghost { background: rgba(255, 255, 255, .06); border-color: rgba(157, 182, 255, .55); box-shadow: none; }
.btn.small { min-height: 36px; padding: 0 16px; font-size: 15px; }
.btn.danger { background: linear-gradient(180deg, #ff8a8a, #d63b4f); border-color: #ffc2c2; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.play-ico { width: 0; height: 0; border-left: 18px solid currentColor; border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
.menu-ico { width: 34px; height: 34px; flex: none; object-fit: contain; }
.btn .menu-ico { width: 26px; height: 26px; }

/* ---------- Title screen ---------- */
.title-screen {
  position: relative; min-height: 100%;
  display: grid; justify-items: center; align-content: start; gap: 0;
  padding-bottom: 70px;
}
.title-top { position: absolute; top: 0; right: 0; display: flex; gap: 10px; align-items: center; z-index: 2; }
.token-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 999px;
  background: rgba(11, 16, 51, .78); border: 2px solid rgba(255, 203, 61, .55); color: #fff; font-weight: 600; font-size: 15px;
  text-decoration: none;
}
.token-pill img { width: 24px; height: 24px; }
.token-pill.empty { border-color: rgba(255, 107, 107, .6); }

/* The painted logo (assets/ui/logo.webp; its ribbon carries the tagline) */
.logo-art { display: block; margin: 0 0 10px; width: min(560px, 74vw); height: auto; filter: drop-shadow(0 12px 22px rgba(0, 0, 0, .45)); }
.sheet .logo-art { width: min(300px, 70%); margin: 0 auto 8px; }
.menu { display: flex; flex-direction: column; align-items: stretch; gap: 12px; width: min(400px, 88vw); }
.menu .menu-btn { min-height: 60px; font-size: 24px; }
.menu .menu-btn .menu-ico { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); }
.menu .menu-btn.primary { min-height: 74px; font-size: 32px; margin: 0 -14px 4px; border-width: 4px; }
.menu .menu-btn.primary .play-ico { border-left-width: 26px; border-top-width: 16px; border-bottom-width: 16px; margin-right: 6px; }
.menu-btn.off { opacity: .6; cursor: default; filter: saturate(.6); }
.menu-btn.off:active { transform: none; }
.menu-btn small { display: block; font-size: 13px; font-weight: 500; opacity: .85; margin-top: 3px; }
.menu-btn .label { display: flex; flex-direction: column; align-items: center; }

.corner-btn { position: absolute; left: 0; bottom: 0; min-height: 50px; font-size: 20px; padding: 0 22px 0 16px; background: rgba(11, 16, 51, .82); border-color: rgba(157, 182, 255, .7); }
.corner-btn svg { width: 26px; height: 26px; }

/* The parchment sign: the painted blank sign (assets/ui/sign.webp) with the words on it */
.parchment {
  --w: 300px;
  position: absolute; right: 0; bottom: 0; width: var(--w); height: calc(var(--w) * 780 / 700); overflow: hidden;
  padding: calc(var(--w) * .16) calc(var(--w) * .12) calc(var(--w) * .2) calc(var(--w) * .13); color: #1d2b70; transform: rotate(-3deg);
  background: url("../../assets/ui/sign.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .45));
}
.parchment h2 { margin: 0 0 8px; font: 700 22px/1.05 var(--font); text-align: center; text-transform: uppercase; color: #1d2b9a; }
.parchment ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.parchment li { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; line-height: 1.1; }
.parchment li::before {
  content: "✔"; flex: none; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%;
  color: #fff; font-size: 13px; background: radial-gradient(circle at 35% 35%, #7fe08a, #2f9a3e); box-shadow: 0 2px 0 #1d6b29;
}

.best-line { margin: 14px 0 0; color: var(--gold); font-weight: 600; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); }

/* ---------- Pages (Settings, Extras, High Scores, Account, About, the rooms) ---------- */
.page { max-width: 820px; margin: 0 auto; }
.page.wide { max-width: 1100px; }
.page-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.page-head .back { flex: none; min-height: 44px; padding: 0 18px 0 12px; font-size: 17px; }
.page-title {
  margin: 0; font: 700 clamp(28px, 4.4vw, 44px)/1 var(--font); text-transform: uppercase; letter-spacing: .02em;
  background: linear-gradient(180deg, #fff6b8 10%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 #0d1450);
}
.panel {
  background: var(--panel); border: 3px solid rgba(232, 194, 90, .75); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px;
  box-shadow: inset 0 0 0 2px rgba(29, 43, 140, .9), 0 12px 30px rgba(0, 0, 0, .4);
}
.panel h3 { margin: 0 0 10px; font-size: 22px; font-weight: 700; color: var(--gold); }
.panel p { color: #e3e8ff; }
.page-note { color: var(--muted); margin: 0 0 16px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.muted { color: var(--muted); }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid rgba(157, 182, 255, .14); }
.setting:last-child { border-bottom: 0; }
.setting .label { font-weight: 600; font-size: 18px; }
.setting small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.setting .value { text-align: right; color: #e8ecf6; }
.seg { display: inline-flex; border: 2px solid var(--blue-edge); border-radius: 999px; overflow: hidden; flex: none; background: rgba(11, 16, 51, .6); }
.seg button { border: 0; background: transparent; padding: 9px 16px; cursor: pointer; color: #dfe6ff; font-weight: 600; }
.seg button + button { border-left: 1px solid rgba(157, 182, 255, .35); }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, #ffe680, var(--gold) 50%, var(--gold-deep)); color: var(--ink); }

/* Extras: big tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; cursor: pointer; text-decoration: none; color: #fff;
  padding: 18px 18px 16px; border-radius: var(--radius); border: 3px solid var(--blue-edge);
  background: linear-gradient(180deg, rgba(74, 106, 240, .9), rgba(31, 47, 148, .95));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3), 0 5px 0 #111a5c, 0 10px 20px rgba(0, 0, 0, .35);
  font: inherit;
}
.tile:hover { filter: brightness(1.1); }
.tile b { font-size: 22px; font-weight: 700; }
.tile span { color: #dfe6ff; font-size: 15px; }
.tile img { width: 46px; height: 46px; object-fit: contain; }

/* Rooms (Level Select and the World Map, for now) */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.room-card {
  position: relative; overflow: hidden; border-radius: var(--radius); border: 3px solid rgba(232, 194, 90, .8);
  background: var(--panel); box-shadow: 0 10px 24px rgba(0, 0, 0, .4);
}
.room-card .thumb { position: relative; aspect-ratio: 16 / 10; }
.room-card canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.room-card .room-num {
  position: absolute; left: 12px; bottom: 8px; font: 700 28px/1 var(--font); text-transform: uppercase;
  background: linear-gradient(180deg, #fff6b8, var(--gold) 55%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; filter: drop-shadow(0 2px 0 #0d1450);
}
.room-card .room-body { padding: 10px 14px 12px; }
.room-card .room-body b { display: block; font-size: 18px; }
.room-card .room-body small { color: var(--muted); }
.room-card .open { position: absolute; inset: 0; z-index: 1; border: 0; background: none; cursor: pointer; }
.room-card .open:focus-visible { outline-offset: -6px; }
.room-card.locked canvas { filter: grayscale(.85) brightness(.4); }
.room-card.locked .open { cursor: default; }
.lock-ribbon { position: absolute; z-index: 2; right: 10px; top: 10px; padding: 3px 12px; border-radius: 999px; background: rgba(11, 16, 51, .88); border: 2px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }

/* High scores */
.score-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { padding: 7px 8px; text-align: left; border-bottom: 1px solid rgba(157, 182, 255, .14); }
.score-table th { color: var(--muted); font-weight: 600; font-size: 14px; }
.score-table td.num, .score-table th.num { text-align: right; }
.score-table tr.mine td { color: var(--gold); font-weight: 700; }
.score-tabs { margin: 0 0 14px; }
.score-note { color: var(--muted); margin: 0 0 10px; }
.score-boards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); text-align: left; }
.panel.score-panel { margin: 12px 0 0; padding: 12px 14px; }
.panel.score-panel h3 { font-size: 17px; }
.community-best { color: var(--blue-edge); font-weight: 700; }
.community-best:empty { display: none; }
.post-status { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.post-status:empty { display: none; }

/* Tokens */
.token-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; margin: 6px 0 12px; font-size: 15px; color: var(--muted); }
.token-bar b { color: var(--gold); }
.token-bar.empty b { color: var(--red); }
.token-ico { width: 24px; height: 24px; object-fit: contain; flex: none; }

/* Account */
.account-tabs { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 460px; margin-bottom: 14px; }
.account-tabs button { padding: 9px 6px; line-height: 1.2; text-align: center; }
.account-form { display: flex; flex-direction: column; gap: 12px; max-width: 440px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
.field-input { font: 500 17px var(--font); color: #fff; background: rgba(11, 16, 51, .7); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.field-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
select.field-input { color-scheme: dark; }
select.field-input option, select.field-input optgroup { color: #fff; background: #141b52; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--gold); }
.fine { font-size: 13px; color: var(--muted); }
.form-status { min-height: 1.2em; color: var(--red); font-weight: 600; margin: 0; }
.form-status.good { color: #7ee08a; }
.license-key { font-family: ui-monospace, Consolas, monospace; font-size: 14px; color: var(--gold); word-break: break-all; }
.panel .btn-row + h3, .panel form + h3 { margin-top: 22px; }
.share-promo { border-color: var(--gold); background: linear-gradient(135deg, rgba(255, 203, 61, .14), rgba(59, 89, 224, .2)), var(--panel); }
.install-row { display: flex; align-items: center; gap: 10px; flex: none; }
.help-btn {
  width: 38px; height: 38px; flex: none; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--blue-edge); background: rgba(11, 16, 51, .6); color: #fff; font: 700 18px/1 var(--font); display: grid; place-items: center;
}
.help-step h3 { margin: 14px 0 4px; font-size: 17px; color: var(--gold); }
.help-step p { margin: 0; color: #e3e8ff; }

/* About */
.about-name { margin-bottom: 0; }
.about-by { margin: 2px 0 6px; color: var(--muted); font-weight: 600; }
.about-stamp { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.about-stamp a { color: inherit; }

/* ---------- Game screen ---------- */
.game-screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: radial-gradient(900px 500px at 80% -10%, rgba(157, 182, 255, .18), transparent 60%), radial-gradient(800px 480px at 5% 110%, rgba(255, 159, 26, .1), transparent 60%), #070a24;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}
.game-bar {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 58px; z-index: 2;
  background: linear-gradient(180deg, #1c2a7a, #121a4d); border-bottom: 3px solid rgba(232, 194, 90, .8);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.game-title {
  margin: 0; flex: 0 1 auto; min-width: 0; white-space: nowrap; font: 700 24px/1 var(--font); text-transform: uppercase;
  background: linear-gradient(180deg, #fff6b8 10%, var(--gold) 55%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill;
}
.hud { display: flex; gap: 16px; margin-left: auto; font-variant-numeric: tabular-nums; }
.hud div { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.hud b { font-size: 19px; font-weight: 700; color: #fff; }
.hud span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.icon-btn {
  width: 46px; height: 46px; flex: none; border-radius: 50%; cursor: pointer; font-size: 18px; display: grid; place-items: center;
  border: 2px solid var(--blue-edge); background: linear-gradient(180deg, #5a78f4, var(--blue-deep)); box-shadow: 0 3px 0 #111a5c;
}
.stage { position: relative; flex: 1; min-height: 0; touch-action: none; overflow: hidden; margin: 12px; }
.game-canvas {
  position: absolute; display: block; border-radius: 16px;
  box-shadow: 0 0 0 3px rgba(232, 194, 90, .7), 0 0 0 6px rgba(29, 43, 140, .9), 0 24px 60px rgba(0, 0, 0, .65);
}
.stage.shake .game-canvas { animation: shake .28s linear; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(var(--sx), calc(var(--sx) * -.5)); }
  40% { transform: translate(calc(var(--sx) * -1), calc(var(--sx) * .4)); }
  60% { transform: translate(calc(var(--sx) * .6), var(--sx)); }
  80% { transform: translate(calc(var(--sx) * -.4), calc(var(--sx) * -.3)); }
}

/* Touch controls: shown on touch devices only */
.touch-root { display: none; }
body.touch .touch-root { display: block; flex: none; }
.touch-pad { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px 14px; min-height: 150px; user-select: none; -webkit-user-select: none; touch-action: none; }
.touch-pad.swapped { flex-direction: row-reverse; }
.touch-pad.solo { justify-content: center; }
.touch-pad.empty { display: none; }
.touch-pad > .action-btns:only-child { margin-left: auto; }
.touch-pad.swapped > .action-btns:only-child { margin-left: 0; margin-right: auto; }
.dpad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 46px); gap: 4px; }
.dpad-horizontal { grid-template-rows: 58px; grid-template-columns: 72px 72px; gap: 10px; }
.dpad-vertical { grid-template-columns: 72px; grid-template-rows: 58px 58px; gap: 10px; }
.dpad-four .d-up { grid-area: 1 / 2; }
.dpad-four .d-left { grid-area: 2 / 1; }
.dpad-four .d-right { grid-area: 2 / 3; }
.dpad-four .d-down { grid-area: 3 / 2; }
.stick {
  position: relative; flex: none; width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .04) 0 44%, rgba(157, 182, 255, .12) 45% 100%);
  border: 3px solid rgba(157, 182, 255, .45); touch-action: none; cursor: pointer; display: grid; place-items: center;
}
.stick.down { border-color: var(--gold); }
.stick-knob {
  width: 58px; height: 58px; border-radius: 50%; pointer-events: none; transition: transform .08s;
  background: radial-gradient(circle at 35% 30%, #fff1a8, var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5), 0 0 12px rgba(255, 190, 60, .45);
}
.stick.down .stick-knob { transition: none; }
.stick-horizontal { height: 84px; width: 150px; border-radius: 42px; }
.stick-vertical { width: 84px; height: 150px; border-radius: 42px; }
.touch-btn { border-radius: 16px; border: 3px solid rgba(157, 182, 255, .45); background: rgba(59, 89, 224, .25); color: #fff; font-size: 20px; touch-action: none; cursor: pointer; }
.touch-btn.down { background: rgba(255, 203, 61, .4); border-color: var(--gold); }
.action-btns { display: flex; gap: 12px; align-items: center; }
.a-btn { width: 84px; height: 84px; border-radius: 50%; font: 700 17px var(--font); text-transform: uppercase; background: rgba(255, 203, 61, .28); border-color: var(--gold); }
.a-btn.down { background: rgba(255, 203, 61, .6); }
.action-btns .a-btn:not(:last-child) { width: 64px; height: 64px; font-size: 13px; background: rgba(59, 89, 224, .3); border-color: var(--blue-edge); }

/* Sheets: in-game overlays and pop-ups */
.overlay {
  position: absolute; inset: 58px 0 0 0; z-index: 5; display: grid; place-items: center;
  background: rgba(7, 10, 36, .78); backdrop-filter: blur(3px); padding: 16px; overflow-y: auto;
}
.sheet {
  width: min(540px, 100%); text-align: center; padding: 22px 24px;
  background: linear-gradient(180deg, #1c2a7a, #121a4d); border: 3px solid rgba(232, 194, 90, .85); border-radius: 22px;
  box-shadow: inset 0 0 0 2px rgba(29, 43, 140, .9), 0 20px 60px rgba(0, 0, 0, .6);
}
.sheet h2 { margin: 0 0 6px; font-size: 32px; font-weight: 700; color: var(--gold); text-transform: uppercase; }
.sheet .sheet-logo { font: 700 40px/1 var(--font); text-transform: uppercase; margin: 4px 0 10px; background: linear-gradient(180deg, #fff6b8 10%, var(--gold) 55%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }
.sheet p { color: #e3e8ff; margin: 8px 0; }
.sheet .joke { font-size: 20px; font-weight: 600; color: var(--gold); margin: 4px 0 12px; }
.sheet .big-score { font: 700 50px/1 var(--font); color: #fff; margin: 4px 0; font-variant-numeric: tabular-nums; }
.sheet .btn-row { justify-content: center; margin-top: 14px; }
.controls-help { text-align: left; background: rgba(11, 16, 51, .6); border-radius: 12px; padding: 10px 14px; font-size: 14px; color: #e3e8ff; margin: 12px 0; }
.controls-help b { color: #fff; }
.options { text-align: left; margin: 12px 0; display: grid; gap: 10px; }
.options fieldset { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0; }
.options legend { color: var(--muted); font-size: 14px; padding: 0 4px; }
.options label { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.options input { accent-color: var(--gold); width: 18px; height: 18px; }
.practice-note { border-left: 4px solid var(--gold); padding: 4px 0 4px 12px; color: #fff3cf; text-align: left; }
.initials { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px 0; }
.initials .initials-head { margin: 0; font-weight: 700; color: #fff; }
.initials .initials-label { font-size: 13px; color: var(--muted); letter-spacing: .5px; }
.initials-row { display: flex; gap: 8px; align-items: center; justify-content: center; width: 100%; }
.initials input { width: min(100%, 300px); min-width: 0; text-align: center; font: 700 26px/1 var(--font); letter-spacing: 2px; background: rgba(11, 16, 51, .7); color: var(--gold); border: 3px solid var(--gold); border-radius: 14px; padding: 8px; }
.initials .btn.save { min-height: 50px; }
.rotate-hint { display: none; color: var(--muted); font-size: 14px; }
.share-link { width: 100%; margin: 6px 0 14px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: rgba(11, 16, 51, .7); color: var(--text); font: 15px/1.3 ui-monospace, Consolas, monospace; }

.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(7, 10, 36, .78); padding: 16px; }
.modal .sheet { text-align: left; max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal .sheet h2 { text-align: left; }
.sheet-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 4px 14px; border-radius: 999px; background: var(--gold); color: var(--ink); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.guide .guide-objective { font-size: 18px; font-weight: 600; color: #fff; }
.guide section { margin-top: 14px; }
.guide h3 { margin: 0 0 4px; font-size: 18px; color: var(--gold); }
.guide ol, .guide ul { margin: 0; padding-left: 22px; color: #e3e8ff; }
.guide li { margin: 5px 0; line-height: 1.4; }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%) translateY(20px); max-width: calc(100vw - 32px);
  background: #1c2a7a; border: 2px solid var(--gold); border-radius: 14px; padding: 10px 16px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Narrow screens and phones ---------- */
@media (max-width: 1100px) {
  .parchment { --w: 240px; }
  .parchment h2 { font-size: 17px; }
  .parchment li { font-size: 13px; gap: 6px; }
  .parchment ul { gap: 4px; }
  .parchment li::before { width: 18px; height: 18px; font-size: 11px; }
  .backdrop-kid { height: min(42vh, 380px); }
}
@media (max-width: 860px) {
  .title-screen { padding-bottom: 0; }
  .title-top { position: static; width: 100%; justify-content: space-between; margin-bottom: 4px; }
  .corner-btn { position: static; min-height: 42px; font-size: 16px; }
  .parchment { --w: min(300px, 82vw); position: relative; right: auto; bottom: auto; margin: 22px 0 8px; }
  .backdrop-kid { height: 30vh; left: -6vw; bottom: 2vh; opacity: .4; }
  .menu .menu-btn { min-height: 54px; font-size: 21px; }
  .menu .menu-btn.primary { min-height: 66px; font-size: 28px; margin: 0 0 4px; }
  .page-head .back span { display: none; }
  .page-head .back { padding: 0 14px; }
  .game-title { font-size: 18px; }
  .hud { gap: 10px; }
  .hud b { font-size: 15px; }
  .hud span { font-size: 10px; }
  .game-bar { gap: 6px; padding: 6px 8px; }
  .stage { margin: 6px; }
  .icon-btn { width: 40px; height: 40px; }
  .overlay { inset: 54px 0 0 0; }
}
@media (max-width: 860px) and (orientation: portrait) { .rotate-hint.landscape-game { display: block; } }
@media (max-width: 600px) {
  .install-setting { flex-wrap: wrap; }
  .install-setting .label { flex-basis: 100%; }
  .setting:has(.seg) { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting .seg { display: flex; width: 100%; }
  .setting .seg button { flex: 1 1 0; min-width: 0; padding: 10px 6px; }
  .game-title { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .touch-pad { position: absolute; left: 0; right: 0; bottom: 0; min-height: 0; padding: 8px 18px; pointer-events: none; }
  .touch-pad > * { pointer-events: auto; }
  .touch-btn { opacity: .75; }
  .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 40px); }
  .a-btn { width: 70px; height: 70px; }
  .stick { width: 110px; height: 110px; }
  .stick-knob { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
body.reduce-motion * { transition: none !important; animation: none !important; }
.title-logo { margin: 0; line-height: 0; }

/* ---------- Story scenes (src/ui/story.js) ---------- */
.story {
  position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px; background: #04061a;
}
.story-frame {
  position: relative; width: min(100%, calc((100dvh - 190px) * 16 / 9)); aspect-ratio: 16 / 9; cursor: pointer;
  border-radius: var(--radius); overflow: hidden; border: 3px solid rgba(232, 194, 90, .75);
  box-shadow: 0 0 0 2px rgba(29, 43, 140, .9), 0 0 60px rgba(120, 150, 255, .25);
}
.story-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.story.in .story-frame canvas, .story.in .story-text { animation: story-in .6s ease-out; }
@keyframes story-in { from { opacity: 0; } to { opacity: 1; } }
.story-title {
  position: absolute; left: 0; right: 0; top: 9%; margin: 0; text-align: center; padding: 0 12px;
  font: 700 clamp(28px, 6vw, 64px)/1.05 var(--font); text-transform: uppercase; letter-spacing: .02em;
  background: linear-gradient(180deg, #fff6b8 10%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; filter: drop-shadow(0 3px 0 #0d1450) drop-shadow(0 0 18px rgba(255, 210, 120, .5));
}
.story-title[hidden] { display: none; }
.story.in .story-title { animation: story-title 1.4s ease-out; }
@keyframes story-title { 0%, 30% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: none; } }
.story-text { margin: 0; max-width: 760px; min-height: 2.9em; text-align: center; font-size: clamp(17px, 2.4vw, 22px); font-weight: 500; color: #eef1ff; }
.story-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(100%, 760px); }
.story-bar .btn-row { margin: 0; }
.story-dots { display: flex; gap: 8px; }
.story-dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(157, 182, 255, .35); }
.story-dots span.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* ---------- World Map: Story Book Dream Land, the whole screen, walked like a world map ---------- */
body.at-map .app { position: fixed; inset: 0; }
body.at-map .view { padding: 0; overflow: hidden; }
.world-map { position: fixed; inset: 0; z-index: 5; background: #0b1033; animation: wm-open 1s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes wm-open { from { opacity: 0; transform: scale(1.12); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.wm-view { position: absolute; inset: 0; overflow: hidden; }
/* The painted world, sized to cover the screen and moved so Declan stays in view (app.js worldMap) */
.wm-stage { position: absolute; left: 0; top: 0; will-change: transform; }
.wm-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.world-map.asleep .wm-bg { filter: saturate(.7) brightness(.75); }
.wm-path { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.wm-path polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wm-path .open { stroke: #fff4c0; stroke-width: 13; stroke-dasharray: .1 28; filter: drop-shadow(0 0 2px #6a3a10) drop-shadow(0 0 6px rgba(255, 214, 120, .9)); }
.wm-path .locked { stroke: rgba(230, 230, 255, .45); stroke-width: 10; stroke-dasharray: .1 30; filter: drop-shadow(0 0 2px rgba(20, 10, 40, .8)); }
.wm-mark {
  position: absolute; left: var(--x); top: var(--y); width: 2.2%; aspect-ratio: 2 / 1; transform: translate(-50%, -50%);
  border-radius: 50%; background: radial-gradient(ellipse, #fff3b0 0 30%, #f2c14e 60%, rgba(242, 193, 78, 0) 72%); pointer-events: none;
}
.wm-mark.locked { filter: grayscale(1) brightness(.6); }
/* Declan on the map: his feet on the path, facing the way he walks */
.wm-kid {
  position: absolute; left: var(--x); top: var(--y); height: 9%; width: auto; transform: translate(-50%, -96%) scaleX(var(--face, 1));
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .5)); pointer-events: none; z-index: 3;
}
.wm-stop { z-index: 2; }
.wm-stop.here .map-label { box-shadow: 0 0 0 3px #fff6c8, 0 3px 0 #7a4a1c, 0 0 22px rgba(255, 214, 120, .9); }
.wm-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t, 0px)) 14px 10px; pointer-events: none;
}
.wm-top > * { pointer-events: auto; }
.wm-top .back { min-height: 44px; padding: 0 18px 0 12px; font-size: 17px; }
.wm-title {
  padding: .3em 1.4em .35em; border-radius: 14px; text-align: center; white-space: nowrap;
  font: 700 clamp(16px, 2.6vw, 28px)/1.1 var(--font); color: #4a2a0c;
  background: linear-gradient(180deg, #fff1c2, #e8b860); border: 3px solid #a8692c; box-shadow: 0 4px 0 #7a4a1c, 0 8px 18px rgba(0, 0, 0, .45);
}
.wm-panel {
  position: absolute; left: 50%; bottom: calc(14px + var(--safe-b, 0px)); transform: translateX(-50%); z-index: 6;
  width: min(94vw, 620px); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 14px; padding: 12px 16px;
  border-radius: var(--radius); background: var(--panel); border: 3px solid rgba(232, 194, 90, .75);
  box-shadow: inset 0 0 0 2px rgba(29, 43, 140, .9), 0 12px 30px rgba(0, 0, 0, .5);
}
.wm-where { display: flex; flex-direction: column; min-width: 0; }
.wm-name { font: 700 22px/1.1 var(--font); color: var(--gold); }
.wm-sub { color: #e3e8ff; font-size: 15px; }
.wm-go { min-height: 48px; padding: 0 22px; font-size: 18px; }
.wm-go[hidden] { display: none; }
.wm-hint { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
body.touch .wm-hint { display: none; }
@media (max-width: 560px) {
  .wm-top { flex-wrap: wrap; }
  .wm-title { order: 3; flex-basis: 100%; }
  .wm-panel { grid-template-columns: 1fr; }
  .wm-go { width: 100%; }
}

/* The pop-up books standing on the map at --x/--y (their bottom middle), --w wide, in percent of the map */
.map-book {
  position: absolute; left: var(--x); top: var(--y); width: var(--w); transform: translate(-50%, -100%);
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column; align-items: center;
}
.map-book img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .45)); }
.map-book .closed { width: 72%; margin-top: auto; }
/* Open: the pop-up; locked: the closed book; opening: the closed book gives way to the pop-up rising */
.map-book.open .closed, .map-book.soon .closed { display: none; }
.map-book.locked .popup { display: none; }
.map-book.opening { perspective: 900px; }
.map-book.opening .closed { position: absolute; left: 14%; bottom: 24%; animation: book-close-out .7s ease-in .35s both; }
.map-book.opening .popup { transform-origin: 50% 88%; animation: popup-rise 1.1s cubic-bezier(.2, 1.4, .4, 1) .75s both; }
@keyframes book-close-out { 0% { transform: none; opacity: 1; } 40% { transform: scale(1.08) rotate(-2deg); } 100% { transform: scale(1.15, .4); opacity: 0; } }
@keyframes popup-rise { 0% { transform: rotateX(82deg) scale(.7); opacity: 0; } 30% { opacity: 1; } 100% { transform: none; opacity: 1; } }
.map-book.opening::after {
  content: ""; position: absolute; left: 50%; top: 55%; width: 140%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.2);
  background: radial-gradient(circle, rgba(255, 236, 160, .85), rgba(255, 210, 120, 0) 60%); pointer-events: none;
  animation: book-burst 1.2s ease-out .7s both;
}
@keyframes book-burst { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }
.map-book.open:hover img, .map-book.open:focus-visible img { transform: translateY(-4%) scale(1.03); filter: drop-shadow(0 0 18px rgba(255, 214, 120, .8)); }
.map-book img { transition: transform .2s ease, filter .2s ease; }
.map-book.locked .closed { filter: saturate(.4) brightness(.6) drop-shadow(0 8px 10px rgba(0, 0, 0, .45)); }
.map-book.soon { cursor: default; }
.map-book.soon img { filter: drop-shadow(0 0 14px rgba(170, 120, 255, .5)); }
.map-lock {
  position: absolute; left: 50%; top: 52%; width: 13%; aspect-ratio: 30 / 24; transform: translate(-50%, -50%);
  border-radius: 18%; background: #e8c25a; box-shadow: 0 2px 0 #7a5a12, 0 4px 10px rgba(0, 0, 0, .5);
}
.map-lock::before {
  content: ""; position: absolute; left: 20%; bottom: 92%; width: 60%; height: 62%; box-sizing: border-box;
  border: max(3px, .35vw) solid #e8c25a; border-bottom: 0; border-radius: 50% 50% 0 0;
}
.map-label {
  position: relative; margin-top: -6%; padding: .25em 1em .3em; border-radius: 999px; text-align: center; white-space: nowrap;
  background: linear-gradient(180deg, #fff1c2, #f2c66a); color: #4a2a0c; border: 2px solid #a8692c; box-shadow: 0 3px 0 #7a4a1c, 0 6px 12px rgba(0, 0, 0, .4);
  font-size: clamp(11px, 1.4vw, 17px); line-height: 1.1;
}
.map-label b { display: block; font-weight: 700; font-size: 1.15em; }
.map-label small { display: block; font-size: .78em; font-weight: 600; opacity: .85; }
.map-book.soon .map-label { background: linear-gradient(180deg, #e2d2ff, #a98ce6); color: #2a1452; border-color: #6c4ab0; box-shadow: 0 3px 0 #4a2d86, 0 6px 12px rgba(0, 0, 0, .4); }
.map-book.locked .map-label { filter: saturate(.5) brightness(.85); }

/* ---------- One book of Dream Land: a glossy page of the dream ---------- */
/* The book's own world behind the page, dimmed to a starry glow (instead of the bedroom) */
body.at-book .backdrop { display: none; }
.bk-scene {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 214, 140, .28), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(120, 70, 220, .45), transparent 60%),
    linear-gradient(180deg, rgba(10, 12, 50, .38), rgba(8, 6, 30, .8)),
    var(--scene, linear-gradient(#1a2366, #0b1033)) center / cover no-repeat, #0b1033;
}
.bk-scene::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff6d8 50%, transparent 51%), radial-gradient(2px 2px at 82% 12%, #fff6d8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 64% 30%, #fff6d8 50%, transparent 51%), radial-gradient(1px 1px at 30% 40%, #fff6d8 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 58%, #ffe9a8 50%, transparent 51%), radial-gradient(1.5px 1.5px at 6% 70%, #ffe9a8 50%, transparent 51%);
  animation: bk-twinkle 4s ease-in-out infinite alternate;
}
@keyframes bk-twinkle { from { opacity: .5; } to { opacity: 1; } }
.page.bk { max-width: 1120px; position: relative; }
.bk-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 6px; }
.bk-head .back { min-height: 44px; padding: 0 18px 0 12px; font-size: 17px; }

/* The title on a ribbon banner */
.bk-title { position: relative; margin: 0 auto 22px; width: fit-content; max-width: 100%; text-align: center; padding: 14px 70px 18px; }
.bk-title::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, #8a3cc8 0%, #5a1f96 55%, #3e1270 100%);
  clip-path: polygon(0 0, 100% 0, calc(100% - 34px) 50%, 100% 100%, 0 100%, 34px 50%);
  filter: drop-shadow(0 6px 0 #2a0c52);
}
.bk-title::after {
  content: ""; position: absolute; inset: 5px 40px; z-index: -1; border-top: 2px solid rgba(255, 220, 140, .7); border-bottom: 2px solid rgba(255, 220, 140, .7);
}
.bk-title small { display: block; font: 700 13px/1 var(--font); letter-spacing: 2.5px; text-transform: uppercase; color: #ffe6a8; margin-bottom: 6px; }
.bk-title span {
  display: block; font: 700 clamp(26px, 4.4vw, 46px)/1.05 var(--font);
  background: linear-gradient(180deg, #fffbe0 0%, #ffd35a 45%, #ff9f1a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1.5px #4a1a6a; paint-order: stroke fill; filter: drop-shadow(0 3px 0 #2a0c52) drop-shadow(0 0 14px rgba(255, 200, 90, .55));
}

/* Glossy panels: a deep jewel color, a gold edge, a bright line along the top */
.bk-hero, .bk-card {
  position: relative; border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 38%),
    linear-gradient(160deg, rgba(64, 44, 150, .92), rgba(24, 20, 88, .94) 60%, rgba(40, 18, 84, .95)) padding-box,
    linear-gradient(135deg, #fff1b0, #e2a63a 30%, #8a5a1a 55%, #ffd76a 80%, #b07a24) border-box;
  border: 3px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 14px 32px rgba(0, 0, 0, .5), 0 0 30px rgba(140, 90, 255, .18);
}
.bk-book { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 22px; align-items: start; }

/* The pop-up book on a glowing stand, and what's been done in the book */
.bk-hero { padding: 18px 18px 16px; text-align: center; }
.bk-stand { position: relative; margin: -40px 0 4px; }
.bk-stand::before {
  content: ""; position: absolute; left: 10%; right: 10%; bottom: 2%; height: 26%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 220, 130, .75), rgba(255, 190, 90, .25) 45%, transparent 70%);
  animation: bk-glow 3s ease-in-out infinite alternate;
}
@keyframes bk-glow { from { opacity: .6; transform: scale(.94); } to { opacity: 1; transform: scale(1.04); } }
.bk-popup { position: relative; width: 100%; max-width: 320px; display: block; margin: 0 auto; filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .55)); animation: bk-float 5s ease-in-out infinite; }
@keyframes bk-float { 50% { transform: translateY(-6px); } }
.bk-badge {
  position: absolute; right: 4%; top: 8%; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; color: #3a2408;
  background: linear-gradient(180deg, #fff3b0, #f2c14e); border: 2px solid #a8692c; box-shadow: 0 3px 0 #7a4a1c; transform: rotate(6deg);
}
.bk-blurb { margin: 0 0 14px; font-size: 18px; line-height: 1.4; color: #f4f0ff; }
.bk-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.bk-stat {
  padding: 10px 6px; border-radius: 14px; background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(0, 0, 0, .18));
  border: 1px solid rgba(255, 214, 120, .35); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.bk-stat b { display: block; font: 700 20px/1.1 var(--font); color: var(--gold); text-shadow: 0 0 10px rgba(255, 200, 90, .5); }
.bk-stat span { display: block; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: #cfd6ff; margin-top: 3px; }
.bk-note { margin: 0; color: #c9cff5; font-size: 14px; }

/* Each chapter: its picture with a gold coin, its name, its storybook pages, a big round Play button */
.bk-chapters { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bk-card { display: grid; grid-template-columns: 148px 1fr auto; align-items: center; gap: 16px; padding: 10px 16px 10px 10px; overflow: hidden; transition: transform .2s ease, box-shadow .2s ease; }
.bk-card::after {
  /* The shine sweeping across a card you can play */
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .22), transparent); transform: skewX(-18deg);
}
.bk-card.open::after { animation: bk-shine 4.5s ease-in-out infinite; }
.bk-card.open:nth-child(2)::after { animation-delay: .6s; }
.bk-card.open:nth-child(3)::after { animation-delay: 1.2s; }
.bk-card.open:nth-child(4)::after { animation-delay: 1.8s; }
@keyframes bk-shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.bk-card.open:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 18px 36px rgba(0, 0, 0, .55), 0 0 34px rgba(255, 200, 90, .35); }
.bk-pic {
  position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: visible;
  background: linear-gradient(160deg, #3a3a9a, #1c1c5a); box-shadow: 0 0 0 2px #e8c25a, 0 0 0 4px rgba(90, 50, 10, .6), 0 6px 12px rgba(0, 0, 0, .45);
}
.bk-pic-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 30% 70%; border-radius: 14px; }
.bk-pic::after { content: ""; position: absolute; inset: 0; border-radius: 14px; background: linear-gradient(180deg, rgba(255, 255, 255, .25), transparent 35%, rgba(0, 0, 0, .25)); }
.bk-pic-fg { position: absolute; right: 6%; bottom: 6%; height: 64%; width: auto; z-index: 1; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .5)); }
.bk-coin {
  position: absolute; left: -6px; top: -6px; z-index: 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  font: 700 20px/1 var(--font); color: #4a2a0c; background: radial-gradient(circle at 35% 30%, #fff8c8, #ffd35a 45%, #d48a1a);
  border: 2px solid #8a5a1a; box-shadow: 0 3px 0 #6a400e, 0 0 12px rgba(255, 200, 90, .6);
}
.bk-text { min-width: 0; }
.bk-text small { font: 700 12px/1 var(--font); letter-spacing: 2px; text-transform: uppercase; color: #ffd35a; }
.bk-text b { display: block; margin: 4px 0 8px; font: 700 clamp(19px, 2.2vw, 24px)/1.15 var(--font); color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .6), 0 0 18px rgba(170, 140, 255, .35); }
.bk-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bk-status {
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: #e9e6ff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25);
}
.bk-card.open .bk-status { color: #3a2408; background: linear-gradient(180deg, #fff3b0, #f2c14e); border-color: #c08a2a; }
.bk-card.done .bk-status { color: #0e3a14; background: linear-gradient(180deg, #d8ffc8, #7ed870); border-color: #3e9a3a; }
.bk-pages { display: inline-flex; gap: 4px; }
.bk-pages img { width: 22px; height: auto; filter: grayscale(1) brightness(.55); opacity: .7; }
.bk-pages img.got { filter: drop-shadow(0 0 6px rgba(255, 220, 130, .9)); opacity: 1; }
.bk-play {
  position: relative; width: 64px; height: 64px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 28%, #fffbe0, #ffd35a 40%, #f09a1a 75%, #b8640e);
  border: 3px solid #fff1a8; box-shadow: 0 5px 0 #8a4a0c, 0 0 0 3px rgba(120, 60, 10, .5), 0 8px 18px rgba(0, 0, 0, .5), 0 0 22px rgba(255, 200, 90, .6);
  transition: transform .15s ease, filter .15s ease;
}
.bk-play:hover { transform: scale(1.08); filter: brightness(1.08); }
.bk-play:active { transform: translateY(3px) scale(1.02); box-shadow: 0 2px 0 #8a4a0c, 0 0 0 3px rgba(120, 60, 10, .5), 0 0 22px rgba(255, 200, 90, .6); }
.bk-tri { width: 0; height: 0; margin-left: 6px; border-left: 20px solid #5a2a06; border-top: 13px solid transparent; border-bottom: 13px solid transparent; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .6)); }
.bk-card.locked { filter: saturate(.55); }
.bk-card.locked .bk-pic-bg, .bk-card.locked .bk-pic-fg { filter: grayscale(.6) brightness(.55); }
.bk-card.locked .bk-text b { color: #c9cff5; }
.bk-lock { position: relative; width: 34px; height: 28px; margin: 14px 15px 0; border-radius: 7px; background: linear-gradient(180deg, #ffe08a, #c99a2e); box-shadow: 0 3px 0 #7a5a12; }
.bk-lock::before { content: ""; position: absolute; left: 7px; top: -14px; width: 20px; height: 16px; box-sizing: border-box; border: 4px solid #e8c25a; border-bottom: 0; border-radius: 12px 12px 0 0; }
@media (max-width: 820px) {
  .bk-book { grid-template-columns: 1fr; }
  .bk-stand { margin-top: -20px; }
  .bk-popup { max-width: 260px; }
}
@media (max-width: 520px) {
  .bk-title { padding: 12px 44px 14px; }
  .bk-card { grid-template-columns: 96px 1fr auto; gap: 10px; padding-right: 10px; }
  .bk-play { width: 52px; height: 52px; }
  .bk-tri { border-left-width: 16px; border-top-width: 10px; border-bottom-width: 10px; }
  .bk-pages img { width: 18px; }
}

/* Turning the page into a book or a chapter */
.page-turn { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(4, 6, 26, .86); animation: pt-in .25s ease-out both; }
.page-turn.out { animation: pt-out .45s ease-in both; }
.page-turn.quick.out { animation-duration: .2s; }
@keyframes pt-in { from { opacity: 0; } }
@keyframes pt-out { to { opacity: 0; } }
.pt-spread { position: relative; display: flex; width: min(92vw, 880px); aspect-ratio: 16 / 10; perspective: 1800px; filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .6)); }
.pt-page {
  position: relative; flex: 1; background: linear-gradient(90deg, #e9d6a8, #fbf0d2 12%, #f6e7c0 90%, #e3cd9b);
  border: 3px solid #a8692c; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 6%;
}
.pt-left { border-radius: 14px 4px 4px 14px; border-right: 0; background: linear-gradient(270deg, #d9c08c, #f6e7c0 10%, #fbf0d2 88%, #e9d6a8); }
.pt-right { border-radius: 4px 14px 14px 4px; border-left: 1px solid rgba(120, 80, 30, .3); color: #3a2410; }
.pt-right small { font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; font-size: clamp(11px, 1.6vw, 15px); color: #8a5a2a; }
.pt-right h2 { margin: .3em 0 .2em; font: 700 clamp(22px, 4vw, 42px)/1.1 var(--font); color: #4a2a0c; }
.pt-flourish { width: 40%; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, #c08a3a, transparent); }
.page-turn:not(.quick) .pt-right > * { animation: pt-text .5s ease-out .75s both; }
@keyframes pt-text { from { opacity: 0; transform: translateY(8px); } }
/* The page that turns: from covering the right page, over to the left */
.pt-flip { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; transform-origin: 0 50%; transform-style: preserve-3d; animation: pt-flip 1s cubic-bezier(.45, .05, .3, 1) .2s both; }
.pt-front, .pt-back { position: absolute; inset: 0; backface-visibility: hidden; border: 3px solid #a8692c; }
.pt-front { border-radius: 4px 14px 14px 4px; background: repeating-linear-gradient(180deg, transparent 0 22px, rgba(120, 80, 30, .12) 22px 24px), linear-gradient(90deg, #e3cd9b, #fbf0d2 15%, #f2e0b4); }
.pt-back { border-radius: 14px 4px 4px 14px; transform: rotateY(180deg); background: linear-gradient(270deg, #d9c08c, #f6e7c0 12%, #fbf0d2); }
@keyframes pt-flip { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
.page-turn.quick .pt-flip { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


/* Extras: Scenes */
.scene-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.scene-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(157, 182, 255, .14); }

