:root {
  --bg1: #fff3e0; --bg2: #ffe0b2;
  --paper: #fffdf7; --ink: #3e2723; --muted: #8d6e63;
  --accent: #ff7043; --accent2: #29b6f6; --good: #66bb6a;
  --hero: #e53935; --friend: #1e88e5; --place: #43a047; --thing: #8e24aa; --food: #fb8c00; --color: #ec407a; --sound: #f9a825; --name: #d81b60;
  --radius: 22px; --shadow: 0 6px 0 rgba(0,0,0,.12), 0 10px 24px rgba(0,0,0,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', 'Arial Rounded MT Bold', 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg1), var(--bg2)) fixed;
  font-size: 18px; line-height: 1.4;
  user-select: none; -webkit-user-select: none;
}
#app { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { opacity: .3; cursor: default; }

/* ---------- home ---------- */
.logo { text-align: center; font-size: clamp(2.4rem, 9vw, 4rem); font-weight: 700; margin: 12px 0 0; line-height: 1.05; letter-spacing: -.5px; }
.logo span:nth-child(1) { color: var(--hero); } .logo span:nth-child(2) { color: var(--friend); }
.logo span:nth-child(3) { color: var(--place); } .logo span:nth-child(4) { color: var(--thing); }
.tagline { text-align: center; color: var(--muted); margin: 6px 0 20px; font-weight: 600; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid.stories { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.names, .grid.choices { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.card {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform .12s ease, box-shadow .12s ease; position: relative; overflow: hidden;
}
.card:active { transform: scale(.95); }
.card .emoji { font-size: 48px; line-height: 1; }
.story-card .emoji { font-size: 60px; }
.card .label { font-weight: 600; text-align: center; font-size: 1.05rem; line-height: 1.15; }
.card .sub { font-size: .8rem; color: var(--muted); }
.card.picked { transform: scale(1.08); box-shadow: 0 0 0 5px var(--good), var(--shadow); animation: pop .4s ease; z-index: 2; }
.choice-card::before { content: ''; position: absolute; inset: 0; background: var(--tint); opacity: .14; pointer-events: none; }
@keyframes pop { 0% { transform: scale(.9); } 50% { transform: scale(1.15); } 100% { transform: scale(1.08); } }
.big {
  display: block; width: 100%; margin: 16px auto 0; padding: 16px 20px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 1.25rem;
  border-radius: var(--radius); box-shadow: 0 6px 0 #c6451f; transition: transform .1s;
}
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #c6451f; }
.surprise { max-width: 360px; background: var(--accent2); box-shadow: 0 6px 0 #0288d1; }
.surprise:active { box-shadow: 0 2px 0 #0288d1; }
.shelf { margin-top: 30px; }
.shelf h2 { font-size: 1.4rem; margin: 0 0 10px; }
.tiny { display: inline-block; margin-top: 12px; color: var(--muted); font-weight: 600; font-size: .95rem; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.5); }
.foot { text-align: center; margin-top: 24px; }

/* ---------- picker ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.round {
  width: 54px; height: 54px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow);
  font-size: 1.4rem; display: grid; place-items: center; transition: transform .1s;
}
.round:active { transform: scale(.92); }
.dots { display: flex; gap: 7px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(0,0,0,.14); }
.dot.done { background: var(--good); } .dot.now { background: var(--accent); transform: scale(1.3); }
.question { text-align: center; font-size: clamp(1.5rem, 5.5vw, 2.1rem); margin: 10px 0 18px; }
.name-form { display: flex; gap: 10px; margin-top: 16px; }
.name-form input {
  flex: 1; font: inherit; font-size: 1.2rem; padding: 12px 16px; border-radius: var(--radius);
  border: 3px solid rgba(0,0,0,.1); background: var(--paper); color: var(--ink); min-width: 0;
}
.name-form input:focus { outline: none; border-color: var(--accent2); }
.name-form .big { width: auto; margin: 0; padding: 12px 20px; }

/* ---------- book ---------- */
.book-title { font-weight: 700; font-size: 1.15rem; text-align: center; flex: 1; }
.page {
  background: var(--paper); border-radius: 26px; box-shadow: var(--shadow); overflow: hidden;
  animation: pagein .35s ease;
}
@keyframes pagein { from { transform: translateX(18px); } to { transform: none; } }
.text {
  margin: 0; padding: 20px 26px 8px; font-family: 'Andika', 'Fredoka', sans-serif; font-size: clamp(1.35rem, 4.6vw, 1.8rem); line-height: 1.6; font-weight: 400;
  background: #fffdf5; color: #3b2a22;
}
.text .w { font-family: inherit; }
.book-title { font-family: 'Baloo 2', sans-serif; }
.find-line { background: #fffdf5; }
.pager { background: #fffdf5; }
/* cover + end pages */
.text.cover, .text.end { text-align: center; padding: 22px 22px 26px; }
.cover-kicker { font-family: 'Baloo 2', sans-serif; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-size: .85rem; }
.cover-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(2rem, 8vw, 3rem); line-height: 1.05; margin: 4px 0 10px; color: var(--accent); text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(0,0,0,.08); }
.cover-star { font-size: clamp(1.15rem, 4vw, 1.5rem); }
.cover-studio { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.cover-studio img { height: 56px; width: auto; }
.end-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(2.4rem, 10vw, 3.6rem); margin: 0 0 6px; color: var(--good); text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(0,0,0,.08); }
.end-sub { font-size: clamp(1.1rem, 3.8vw, 1.4rem); color: #3b2a22; }
.end-finds { margin-top: 10px; color: var(--muted); font-weight: 700; }
.text .w { border-radius: 8px; padding: 0 2px; transition: background .12s; cursor: pointer; }
.text .w:active { background: #ffe082; }
.text .w.hot { background: #ffe082; box-shadow: 0 0 0 3px #ffe082; }
.text .slot { font-weight: 700; }
.slot-hero { color: var(--hero); } .slot-friend { color: var(--friend); } .slot-place { color: var(--place); }
.slot-thing { color: var(--thing); } .slot-food { color: var(--food); } .slot-color { color: var(--color); }
.slot-sound { color: var(--sound); } .slot-name { color: var(--name); }
.pager { text-align: right; color: var(--muted); font-weight: 600; padding: 0 20px 12px; font-size: .95rem; }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.controls .big { flex: 1; margin: 0; }
.nav { width: 64px; height: 64px; font-size: 1.6rem; }
.the-end { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-top: 14px; }
.the-end .big { margin: 0; background: var(--good); box-shadow: 0 6px 0 #388e3c; font-size: 1.1rem; }
.the-end .big:active { box-shadow: 0 2px 0 #388e3c; }

/* ---------- scene (illustration library) ---------- */
.scene {
  position: relative; aspect-ratio: 4 / 3; width: 100%; overflow: hidden;
  background: #cfe8ff center / cover no-repeat;
}
.scene img, .scene .emoji-fallback { position: absolute; display: block; width: auto; pointer-events: auto; user-select: none; -webkit-user-drag: none; }
.scene .emoji-fallback { font-size: min(20vw, 110px); line-height: 1; height: auto !important; }
.scene .centered { translate: -50% 0; }
.scene .flip { scale: -1 1; }
/* figures: wrapper positions, shadow sits at the feet, the image animates */
.scene .fig { position: absolute; z-index: 2; }
.scene .fig .fig-img { position: relative; height: 100%; width: auto; display: block; filter: drop-shadow(0 2px 2px rgba(60,30,10,.18)) saturate(.96); }
.scene .fig .emoji-fallback { position: relative; height: 100% !important; font-size: min(22vw, 120px) !important; }
.scene .fig .shadow { position: absolute; left: 6%; right: 6%; bottom: -3%; height: 7%; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(40,20,10,.32) 0%, rgba(40,20,10,.14) 45%, transparent 70%); z-index: -1; }
.scene .fig.creature { z-index: 3; }
.scene .prop { filter: drop-shadow(0 4px 3px rgba(0,0,0,.15)); z-index: 1; }
.scene .thing { z-index: 2; }
.scene .glow { position: absolute; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, var(--glow) 0%, transparent 70%); opacity: .5; animation: glow 2s ease-in-out infinite; }
/* painted-in feel: color wash, vignette, frame (paper grain lives on .page.paper) */
.scene .wash { position: absolute; inset: 0; background: var(--wash); mix-blend-mode: soft-light; opacity: .45; pointer-events: none; z-index: 4; }
.scene .vignette { position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(62,39,35,.22) 100%); }
.scene .frame { position: absolute; inset: 0; pointer-events: none; z-index: 6; box-shadow: inset 0 0 0 5px #fffaf0, inset 0 0 0 6px rgba(93,64,55,.28); }
.scene .night-sky {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: .72;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 60%, transparent 61%), radial-gradient(1.5px 1.5px at 28% 8%, #fff 60%, transparent 61%),
    radial-gradient(2px 2px at 45% 22%, #fff 60%, transparent 61%), radial-gradient(1.5px 1.5px at 60% 10%, #fff 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 72% 26%, #fff 60%, transparent 61%), radial-gradient(2px 2px at 88% 14%, #fff 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 35% 34%, #fff 60%, transparent 61%), radial-gradient(1.5px 1.5px at 80% 38%, #fff 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 8% 40%, #fff 60%, transparent 61%), radial-gradient(1.5px 1.5px at 52% 42%, #fff 60%, transparent 61%),
    linear-gradient(#0b1a3a 0%, rgba(11,26,58,.75) 55%, rgba(11,26,58,.35) 100%);
}
.scene.night .fig .fig-img, .scene.night .prop { filter: drop-shadow(0 2px 2px rgba(0,0,20,.35)) brightness(.82) saturate(.85); }
.scene .moon { position: absolute; right: 7%; top: 8%; width: 11%; aspect-ratio: 1; border-radius: 50%; box-shadow: 0 0 24px 6px rgba(255,249,196,.5); z-index: 1; }
.scene .moon.big { width: 20%; top: 6%; box-shadow: 0 0 40px 12px rgba(255,249,196,.45); }
.scene .burst {
  position: absolute; right: 4%; top: 6%; width: 32%; aspect-ratio: 1; display: grid; place-items: center; z-index: 5;
  background: #ffeb3b; clip-path: polygon(50% 0%, 61% 20%, 82% 10%, 78% 32%, 100% 40%, 82% 55%, 94% 76%, 72% 74%, 68% 98%, 50% 82%, 32% 98%, 28% 74%, 6% 76%, 18% 55%, 0% 40%, 22% 32%, 18% 10%, 39% 20%);
  animation: burst .6s cubic-bezier(.2,1.6,.4,1) both; cursor: pointer;
}
.scene .burst span { font-family: 'Baloo 2', 'Fredoka', sans-serif; font-weight: 800; color: #bf360c; font-size: clamp(.9rem, 3.6vw, 1.5rem); text-align: center; line-height: 1; padding: 0 12%; }
.scene .burst.long span { font-size: clamp(.7rem, 2.6vw, 1.05rem); }
.scene .wiggle, .scene .wiggle .fig-img { animation: wiggle .5s ease !important; }

/* paper grain over the whole page card */
.page.paper { position: relative; }
.page.paper::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 7; opacity: .16; mix-blend-mode: multiply; border-radius: inherit;
  background-image: 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='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

/* scene animations (transform only; position uses translate/scale properties) */
.bob { animation: bob 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
.bob2 { animation: bob 2.6s ease-in-out infinite .8s; transform-origin: 50% 100%; }
.bob3 { animation: bob 2.2s ease-in-out infinite .4s; transform-origin: 50% 100%; }
.jumpy { animation-name: jump; }
.breathe { animation: breathe 3s ease-in-out infinite; transform-origin: 50% 100%; }
.float { animation: floaty 3s ease-in-out infinite; }
.float2 { animation: floaty 3.4s ease-in-out infinite .9s; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-4%) scaleX(1.02) } }
@keyframes jump { 0%,100% { transform: translateY(0) } 40% { transform: translateY(-12%) } 60% { transform: translateY(-10%) } }
@keyframes breathe { 0%,100% { transform: scale(1) } 50% { transform: scale(1.03) } }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-3deg) } 50% { transform: translateY(-8%) rotate(3deg) } }
@keyframes glow { 0%,100% { transform: scale(1); opacity: .5 } 50% { transform: scale(1.18); opacity: .7 } }
@keyframes burst { from { transform: scale(0) rotate(-20deg) } to { transform: scale(1) rotate(0) } }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-8deg) scale(1.08) } 75% { transform: rotate(8deg) scale(1.08) } }
@media (prefers-reduced-motion: reduce) { .bob, .bob2, .bob3, .breathe, .float, .float2, .glow, .burst, .page { animation: none !important; } }

/* picture cards */
.card .thumb { height: 72px; width: auto; max-width: 100%; object-fit: contain; }
.card .thumb.wide { height: 72px; width: 100%; object-fit: cover; border-radius: 12px; }
.grid.choices.places { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.book-card .thumb { height: 64px; }
.foot { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 420px) {
  #app { padding: 12px 12px 24px; }
  .card .emoji { font-size: 42px; }
  .nav { width: 56px; height: 56px; }
}

/* ---------- find-it ---------- */
.scene .find-spot { position: absolute; height: 13%; aspect-ratio: 1; translate: -50% 0; cursor: pointer; z-index: 4; }
.scene .find-spot img, .scene .find-spot .emoji-fallback { position: static; height: 100% !important; width: auto; font-size: 200% !important; }
.scene .find-spot .emoji-fallback { display: grid; place-items: center; }
.scene .find-spot.hint { animation: hint 1.1s ease-in-out infinite; }
.scene .find-spot.found img, .scene .find-spot.found .emoji-fallback { animation: foundpop .7s ease forwards; }
.scene .find-spot .sparkle { position: absolute; inset: -60%; pointer-events: none; opacity: 0;
  background:
    radial-gradient(circle at 20% 30%, #fff176 0 10%, transparent 11%), radial-gradient(circle at 80% 25%, #ffd54f 0 8%, transparent 9%),
    radial-gradient(circle at 70% 80%, #fff176 0 9%, transparent 10%), radial-gradient(circle at 25% 78%, #ffd54f 0 7%, transparent 8%),
    radial-gradient(circle at 50% 10%, #fff 0 6%, transparent 7%), radial-gradient(circle at 92% 55%, #fff 0 6%, transparent 7%); }
.scene .find-spot.found .sparkle { animation: sparkle .9s ease-out forwards; }
@keyframes hint { 0%,100% { transform: rotate(0) scale(1) } 25% { transform: rotate(-12deg) scale(1.15) } 75% { transform: rotate(12deg) scale(1.15) } }
@keyframes foundpop { 0% { transform: scale(1) } 40% { transform: scale(1.7) rotate(10deg) } 100% { transform: scale(1.25) rotate(0) } }
@keyframes sparkle { 0% { opacity: 0; transform: scale(.3) } 30% { opacity: 1 } 100% { opacity: 0; transform: scale(1.6) rotate(40deg) } }
.find-line { margin: 0; padding: 0 22px 6px; font-size: 1.15rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.find-line.done { color: var(--good); }

/* ---------- stickers ---------- */
.stickers-btn { max-width: 360px; background: #ffca28; color: var(--ink); box-shadow: 0 6px 0 #f9a825; }
.stickers-btn:active { box-shadow: 0 2px 0 #f9a825; }
.round.ghost { visibility: hidden; }
.sticker-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); padding: 8px 0; }
.sticker { position: relative; background: var(--paper); border-radius: 50% 50% 45% 45% / 55% 55% 45% 45%; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 0 0 4px #fff, var(--shadow); rotate: var(--rot); animation: stickerin .4s ease both; }
.sticker img, .sticker .emoji-fallback { height: 58%; width: auto; }
.sticker .emoji-fallback { font-size: 48px; }
.sticker .label { font-size: .85rem; font-weight: 600; text-align: center; padding: 0 8px; }
.sticker .count { position: absolute; top: 6px; right: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: .8rem; padding: 2px 7px; border-radius: 10px; }
@keyframes stickerin { from { transform: scale(.4); opacity: 0 } to { transform: none; opacity: 1 } }
.empty { text-align: center; color: var(--muted); font-weight: 600; font-size: 1.15rem; padding: 40px 0; }
.empty .emoji { font-size: 72px; margin-bottom: 8px; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; top: 14px; translate: -50% -140%; z-index: 50; display: flex; align-items: center; gap: 12px;
  background: var(--paper); border-radius: 18px; padding: 10px 18px 10px 12px; box-shadow: 0 0 0 4px #ffca28, var(--shadow);
  font-weight: 600; line-height: 1.2; transition: translate .35s cubic-bezier(.2,1.4,.4,1); pointer-events: none; }
#toast.on { translate: -50% 0; }
#toast img, #toast .emoji-fallback { height: 52px; width: auto; }
#toast .emoji-fallback { font-size: 40px; }

/* ---------- confetti, parent gate, grown-ups ---------- */
canvas.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
#gate { position: fixed; inset: 0; background: rgba(62,39,35,.55); z-index: 70; display: grid; place-items: center; padding: 16px; }
.gate-card { background: var(--paper); border-radius: 26px; padding: 22px 20px 16px; width: min(340px, 100%); text-align: center; box-shadow: var(--shadow); }
.gate-card.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0) } 20%,60% { transform: translateX(-10px) } 40%,80% { transform: translateX(10px) } }
.gate-title { font-weight: 700; font-size: 1.2rem; }
.gate-q { color: var(--muted); font-weight: 600; margin: 6px 0 10px; font-size: 1.1rem; }
.gate-answer { font-size: 2rem; font-weight: 700; min-height: 2.6rem; background: #fff3e0; border-radius: 14px; margin-bottom: 12px; }
.gate-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gate-key { background: #fff3e0; border-radius: 14px; font-size: 1.4rem; font-weight: 700; padding: 12px 0; box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.gate-key:active { transform: translateY(2px); box-shadow: none; }
.gate-key.ok { background: var(--good); color: #fff; box-shadow: 0 3px 0 #388e3c; }
.panel { background: var(--paper); border-radius: 26px; padding: 10px 18px 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 16px 0 8px; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.panel .row { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 14px 4px; border-bottom: 2px solid #fff3e0; font-weight: 600; font-size: 1.1rem; text-align: left; }
.pill { background: #fff3e0; border-radius: 12px; padding: 4px 12px; font-weight: 700; color: var(--accent); min-width: 44px; text-align: center; }
.panel .about { margin: 0; color: var(--muted); font-weight: 500; line-height: 1.5; }
.foot { flex-direction: column; align-items: center; gap: 14px; }
.studio { color: var(--muted); font-weight: 600; font-size: .9rem; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.studio-logo { height: 120px; width: auto; filter: drop-shadow(0 6px 10px rgba(74,20,140,.18)); }
.about-logo { display: block; height: 110px; width: auto; margin: 4px auto 10px; }

/* narrator voice picker */
.voice-row { display: flex; gap: 10px; align-items: center; margin: 4px 0 8px; }
.voice-row select { flex: 1; min-width: 0; font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 14px; border: 3px solid #fff3e0; background: #fff; color: var(--ink); }
.voice-row .tiny { margin: 0; white-space: nowrap; }
.about.small { font-size: .95rem; }

/* ---------- picker preview strip ---------- */
.strip { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.chip { width: 42px; height: 42px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); display: grid; place-items: center; overflow: hidden; padding: 0; }
.chip img, .chip .emoji-fallback { height: 34px; width: auto; max-width: 34px; object-fit: contain; }
.chip .emoji-fallback { font-size: 22px; }
.chip-emoji { font-size: 20px; line-height: 1; }
.chip-text { font-size: .62rem; font-weight: 700; color: var(--name); line-height: 1; padding: 0 2px; }
.chip.now { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.chip.todo { opacity: .45; box-shadow: none; background: rgba(255,255,255,.5); color: var(--muted); }
.chip:disabled { cursor: default; opacity: .9; }
.chip.todo:disabled { opacity: .45; }

/* ---------- story cards ---------- */
.grid.stories { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.story-card { position: relative; padding-bottom: 14px; }
.story-card .thumb { height: 84px; }
.story-card .label { font-family: 'Baloo 2', sans-serif; font-size: 1.2rem; }
.story-card .blurb { font-size: .9rem; color: var(--muted); font-weight: 500; text-align: center; line-height: 1.25; padding: 0 6px; }
.story-card .listen { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; background: #fff3e0; display: grid; place-items: center; font-size: 1rem; }

/* ---------- participation + forks ---------- */
.ask-line { margin: 0; padding: 4px 22px 8px; background: #fffdf5; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 600; color: var(--thing); font-size: 1.1rem; }
.ask-line .ask-text { cursor: pointer; }
.ask-line .ask-done { margin: 0; background: #fff3e0; color: var(--ink); }
.text.fork { text-align: center; padding: 18px 20px 22px; }
.fork-q { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(1.3rem, 5vw, 1.8rem); color: var(--ink); margin-bottom: 14px; }
.fork-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fork-btn { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px; font-size: 1.1rem; background: var(--accent2); box-shadow: 0 6px 0 #0288d1; }
.fork-btn:active { box-shadow: 0 2px 0 #0288d1; }
.fork-btn .emoji { font-size: 2rem; line-height: 1; }
.fork-btn.chosen { background: var(--good); box-shadow: 0 6px 0 #388e3c; }

/* ---------- reading levels ---------- */
.text.level-1 { font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.7; word-spacing: .25em; }
.text.level-3 { font-size: clamp(1.2rem, 3.8vw, 1.5rem); line-height: 1.6; }
.text.one-at-a-time .w.dim { opacity: .18; }
.text .w.sight { text-decoration: underline dotted rgba(141,110,99,.7); text-underline-offset: .22em; text-decoration-thickness: 2px; }
.text .w.chunking { background: #ffe082; box-shadow: 0 0 0 3px #ffe082; letter-spacing: .08em; }
.text .w.echo { background: #e8f5e9; box-shadow: 0 0 0 3px #e8f5e9; }
.sentence-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 22px 10px; background: #fffdf5; }
.sentence-dots i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: rgba(0,0,0,.14); margin-right: 6px; }
.sentence-dots i.on { background: var(--accent); }
.sentence-nav .tiny { margin: 0; background: var(--accent); color: #fff; }
.echo-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 22px 12px; background: #e8f5e9; font-weight: 700; color: #2e7d32; }
.echo-nav .tiny { margin: 0; background: var(--good); color: #fff; }
.level-pick { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.level-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 14px; border-radius: 16px; background: #fff3e0; color: var(--ink); min-width: 92px; box-shadow: 0 3px 0 rgba(0,0,0,.08); }
.level-chip b { font-family: 'Baloo 2', sans-serif; font-size: 1.3rem; line-height: 1; }
.level-chip span { font-size: .72rem; font-weight: 700; color: var(--muted); }
.level-chip small { font-size: .7rem; color: var(--muted); font-weight: 500; max-width: 150px; text-align: center; line-height: 1.2; }
.level-chip.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 #c6451f; }
.level-chip.on span, .level-chip.on small { color: #fff; }
.level-pick.wide .level-chip { flex: 1; }
.big-idea, .talk { margin-top: 14px; text-align: left; background: #fff3e0; border-radius: 16px; padding: 12px 16px; font-size: 1rem; }
.big-idea .label, .talk .label { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.big-idea { font-weight: 700; color: var(--ink); }
.talk ul { margin: 0; padding-left: 20px; color: #3b2a22; }
.talk li { margin: 2px 0; }
.i-read { margin-top: 14px; background: var(--thing); box-shadow: 0 6px 0 #5e1a7a; }
.i-read:active { box-shadow: 0 2px 0 #5e1a7a; }
.i-read:disabled { opacity: 1; background: var(--good); box-shadow: 0 6px 0 #388e3c; }
.practice { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.practice div { background: #fff3e0; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.practice b { font-family: 'Baloo 2', sans-serif; font-size: 1.6rem; color: var(--accent); line-height: 1; }
.practice span { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: 4px; }
.panel .row small { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; }

/* ---------- the book fills the screen ---------- */
body[data-screen="book"] { overflow: hidden; }
body[data-screen="book"] #app { max-width: none; height: 100dvh; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); box-sizing: border-box; }
.screen.book { height: 100%; display: flex; flex-direction: column; gap: 8px; }
.screen.book .topbar { margin: 0; flex: none; }
.screen.book .topbar .round { width: 44px; height: 44px; font-size: 1.15rem; }
.screen.book .controls { margin: 0; flex: none; }
.screen.book .controls .nav { width: 56px; height: 56px; }
.screen.book .controls .big { padding: 12px 20px; font-size: 1.15rem; }
/* portrait: picture on top takes whatever height is left; text panel below */
.page { flex: 1; min-height: 0; display: grid; grid-template-rows: var(--scene-h, 55%) minmax(0, 1fr); grid-template-columns: 100%; grid-template-areas: "scene" "text"; }
.page .scene { grid-area: scene; aspect-ratio: auto; width: 100%; height: 100%; }
.page .text { grid-area: text; min-height: 0; overflow: auto; display: flex; flex-direction: column; justify-content: center; }
.page .text > * { flex: none; }
.page .text:not(.cover):not(.end):not(.fork) { display: block; }
.page .text:not(.cover):not(.end):not(.fork)::before { content: ''; display: block; height: var(--text-pad, 0px); }
.page .ask-line, .page .find-line, .page .sentence-nav, .page .echo-nav { grid-area: text; align-self: end; justify-self: stretch; position: relative; z-index: 8; margin: 0; }
.page .find-line { z-index: 9; }
.page:has(.ask-line):has(.find-line) .ask-line { translate: 0 -40px; }
.page .pager { position: absolute; right: 12px; bottom: 6px; padding: 0; font-size: .8rem; z-index: 8; }
/* when there is a helper line, the text panel reserves room for it */
.page:has(.ask-line) .text, .page:has(.find-line) .text, .page:has(.sentence-nav) .text, .page:has(.echo-nav) .text { padding-bottom: 54px; }
.page:has(.ask-line):has(.find-line) .text { padding-bottom: 96px; }
.page { position: relative; }
.page .text.end .the-end { margin-top: 12px; }
.page .meaning { position: absolute; left: 12px; right: 12px; bottom: 8px; z-index: 9; display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 10px 12px; box-shadow: 0 0 0 3px var(--thing), var(--shadow); font-size: 1rem; line-height: 1.3; translate: 0 140%; opacity: 0; transition: translate .3s cubic-bezier(.2,1.4,.4,1), opacity .2s; pointer-events: none; }
.page .meaning.on { translate: 0 0; opacity: 1; pointer-events: auto; }
.page .meaning .m-emoji { font-size: 2rem; }
.page .meaning div { flex: 1; }
.page .meaning .tiny { margin: 0; }
.text .w.vocab { text-decoration: underline dotted var(--thing); text-decoration-thickness: 2px; text-underline-offset: .22em; }
/* landscape (tablet sideways, laptop): open-book spread */
@media (orientation: landscape) and (min-width: 700px) {
  .page { grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); grid-template-rows: 100%; grid-template-areas: "scene text"; }
  .page .scene { height: 100%; }
  .page .text { max-height: none; height: 100%; padding: 24px 28px; font-size: clamp(1.3rem, 2.4vh + .6vw, 2rem); }
  .page .text.cover, .page .text.end, .page .text.fork { display: flex; }
  .page .text.level-1 { font-size: clamp(1.7rem, 3.4vh + .8vw, 3rem); }
  .page .text.cover, .page .text.end, .page .text.fork { overflow: auto; justify-content: center; }
  .page .meaning { left: auto; width: 38%; right: 12px; }
}
/* tall phones in portrait: a little more room for the picture */
@media (orientation: portrait) {
  .page .text { font-size: clamp(1.25rem, 2.6vh, 1.8rem); padding: 14px 18px 8px; }
  .page .text.level-1 { font-size: clamp(1.6rem, 3.6vh, 2.4rem); }
}

/* ---------- spelling tiles + retell ---------- */
.spell { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.spell-hint { font-size: .8rem; color: var(--muted); font-weight: 700; margin-right: 4px; }
.tile { width: 40px; height: 44px; border-radius: 10px; background: #fff3e0; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 1.4rem; color: var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.tile.said { background: #ffe082; }
.tile.inorder { background: var(--good); color: #fff; box-shadow: 0 3px 0 #388e3c; }
.retell-q { text-align: center; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(1.3rem, 5vw, 1.8rem); margin: 10px 0 14px; }
.retell-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.retell-card { position: relative; background: var(--paper); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); padding: 0 0 10px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.retell-card .scene { aspect-ratio: 4 / 3; height: auto; pointer-events: none; }
.retell-card .scene .find-spot, .retell-card .scene .burst { display: none; }
.retell-card .cap { font-family: 'Andika', sans-serif; font-size: .95rem; padding: 0 12px; color: #3b2a22; }
.retell-card .badge { position: absolute; top: 8px; left: 8px; background: var(--good); color: #fff; font-weight: 800; border-radius: 12px; padding: 4px 10px; font-family: 'Baloo 2', sans-serif; opacity: 0; }
.retell-card.done { outline: 4px solid var(--good); }
.retell-card.done .badge { opacity: 1; }
.retell-card.shake { animation: shake .4s ease; }
.retell .big { margin-top: 16px; }
.retell-btn { margin-top: 10px; background: var(--accent2); box-shadow: 0 6px 0 #0288d1; }
.retell-btn:active { box-shadow: 0 2px 0 #0288d1; }

@media (max-width: 480px) {
  .level-chip { min-width: 0; padding: 6px 10px; }
  .level-chip span { font-size: .62rem; }
  .text.cover .cover-studio img { height: 44px; }
}

/* ---------- scene effects + held items + trouble ---------- */
.scene .fig .held { position: absolute; translate: -50% 0; z-index: 3; pointer-events: none; }
.scene .fig .held .held-img, .scene .fig .held .emoji-fallback { position: relative; height: 100%; width: auto; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); animation: heldbob 2.6s ease-in-out infinite; }
.scene .fig .held .emoji-fallback { font-size: min(10vw, 56px) !important; height: auto !important; }
.scene .fig.flip .held .held-img { scale: -1 1; }
@keyframes heldbob { 0%,100% { transform: rotate(-4deg) } 50% { transform: rotate(4deg) translateY(-3%) } }
.scene .trouble-wrap { position: absolute; z-index: 2; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); }
.scene .trouble-wrap .trouble, .scene .trouble-wrap .emoji-fallback { position: relative; height: 100%; width: auto; display: block; animation: wobbleslow 2.2s ease-in-out infinite; transform-origin: 50% 100%; }
.scene .trouble-wrap .emoji-fallback { font-size: min(26vw, 150px) !important; height: auto !important; }
.scene .trouble-wrap.solved { opacity: .35; filter: grayscale(.4); }
.scene .trouble-wrap.solved .trouble { animation: none; }
@keyframes wobbleslow { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(2deg) } }
.scene .burst.left { right: auto; left: 4%; }
/* figure-level effects */
.scene .figfx { position: absolute; pointer-events: none; z-index: 1; }
.scene .figfx-speed { left: -38%; top: 35%; width: 36%; height: 30%; background: repeating-linear-gradient(to bottom, rgba(255,255,255,.85) 0 4px, transparent 4px 13px); mask-image: linear-gradient(to right, transparent, #000); animation: speedlines .35s linear infinite; }
@keyframes speedlines { from { background-position: 0 0 } to { background-position: 0 13px } }
.scene .figfx-dirt, .scene .figfx-flour { left: 10%; right: 10%; bottom: -2%; height: 22%; background: radial-gradient(circle at 20% 80%, rgba(141,110,99,.9) 0 18%, transparent 20%), radial-gradient(circle at 55% 90%, rgba(141,110,99,.85) 0 14%, transparent 16%), radial-gradient(circle at 85% 75%, rgba(141,110,99,.8) 0 16%, transparent 18%); animation: puffs .9s ease-in-out infinite alternate; }
.scene .figfx-flour { background: radial-gradient(circle at 20% 60%, rgba(255,255,255,.95) 0 18%, transparent 20%), radial-gradient(circle at 55% 30%, rgba(255,255,255,.9) 0 16%, transparent 18%), radial-gradient(circle at 85% 65%, rgba(255,255,255,.9) 0 18%, transparent 20%); bottom: 20%; height: 60%; animation-duration: 1.3s; }
@keyframes puffs { from { transform: scale(.9) translateY(0); opacity: .9 } to { transform: scale(1.08) translateY(-6%); opacity: .6 } }
.scene .figfx-zzz { left: 60%; top: -18%; width: 40%; height: 40%; }
.scene .figfx-zzz::before { content: 'z z z'; position: absolute; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(14px, 3.5vw, 26px); color: #5c6bc0; animation: zzz 2.4s ease-in-out infinite; }
@keyframes zzz { 0% { transform: translateY(0) rotate(-8deg); opacity: 0 } 30% { opacity: 1 } 100% { transform: translateY(-50%) rotate(8deg); opacity: 0 } }
.scene .figfx-sparkle { inset: -10%; background: radial-gradient(circle at 15% 25%, #fff176 0 4%, transparent 5%), radial-gradient(circle at 85% 20%, #ffd54f 0 4%, transparent 5%), radial-gradient(circle at 75% 85%, #fff176 0 4%, transparent 5%), radial-gradient(circle at 20% 80%, #ffd54f 0 3%, transparent 4%); animation: twinkle 1.2s ease-in-out infinite alternate; z-index: 4; }
/* scene-level effects */
.scene .fx { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.scene .fx-sunset { background: linear-gradient(to bottom, rgba(255,112,67,.45), rgba(255,167,38,.3) 45%, rgba(123,31,162,.25) 75%, transparent); mix-blend-mode: multiply; }
.scene .fx-sun { position: absolute; left: 14%; bottom: 34%; width: 14%; aspect-ratio: 1; border-radius: 50%; background: #ffb74d; box-shadow: 0 0 40px 14px rgba(255,183,77,.6); z-index: 0; }
.scene .fx-dusk { background: linear-gradient(to bottom, rgba(74,20,140,.45), rgba(74,20,140,.15)); }
.scene .fx-dark { background: rgba(5,10,30,.5); z-index: 3; }
.scene .fx-rain { background: repeating-linear-gradient(100deg, transparent 0 7px, rgba(255,255,255,.45) 7px 9px); background-size: 80px 80px; animation: rainfall .45s linear infinite; opacity: .7; z-index: 3; }
@keyframes rainfall { from { background-position: 0 0 } to { background-position: -14px 80px } }
.scene .fx-raintint { background: rgba(60,80,120,.28); mix-blend-mode: multiply; }
.scene .fx-snow { background-image: radial-gradient(3px 3px at 10% 10%, #fff 60%, transparent 61%), radial-gradient(2px 2px at 30% 40%, #fff 60%, transparent 61%), radial-gradient(3px 3px at 55% 20%, #fff 60%, transparent 61%), radial-gradient(2px 2px at 75% 60%, #fff 60%, transparent 61%), radial-gradient(3px 3px at 90% 30%, #fff 60%, transparent 61%), radial-gradient(2px 2px at 45% 75%, #fff 60%, transparent 61%); background-size: 100% 100%; animation: snowfall 6s linear infinite; z-index: 3; }
@keyframes snowfall { from { background-position: 0 -100% } to { background-position: 0 100% } }
.scene .fx-sparkles { z-index: 4; }
.scene .fx-sparkles span { position: absolute; color: #fff176; font-size: clamp(14px, 4vw, 30px); text-shadow: 0 0 8px #ffd54f; animation: twinkle 1.1s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .2; transform: scale(.6) rotate(0) } to { opacity: 1; transform: scale(1.2) rotate(30deg) } }
.scene .fx-bubble { position: absolute; inset: auto; z-index: 5; background: #fff; border-radius: 50%; display: grid; place-items: center; font-family: 'Baloo 2', sans-serif; font-weight: 800; box-shadow: 0 0 0 3px #3b2a22; animation: bubblein .5s cubic-bezier(.2,1.6,.4,1) both; }
.scene .fx-shh { left: 50%; top: 8%; translate: -50% 0; padding: 4% 6%; border-radius: 40px; font-size: clamp(1rem, 4.5vw, 2rem); color: var(--thing); }
.scene .fx-mark { left: 42%; top: 6%; width: 13%; aspect-ratio: 1; font-size: clamp(1.4rem, 7vw, 3rem); color: var(--accent); }
@keyframes bubblein { from { transform: scale(0) } to { transform: scale(1) } }
.scene .fx-stars3 { z-index: 2; }
.scene .fx-stars3 span { position: absolute; color: #fff59d; font-size: clamp(22px, 7vw, 48px); text-shadow: 0 0 12px #fff176; animation: twinkle 1.4s ease-in-out infinite alternate; }
.scene .fx-wind i { position: absolute; left: -20%; width: 25%; height: 3px; border-radius: 3px; background: rgba(255,255,255,.75); animation: gust 1.8s linear infinite; }
@keyframes gust { from { left: -25%; opacity: 0 } 20% { opacity: 1 } to { left: 105%; opacity: 0 } }
.scene .fx-hearts span { position: absolute; bottom: 30%; color: #ec407a; font-size: clamp(18px, 6vw, 40px); animation: floatup 2.4s ease-in infinite; }
@keyframes floatup { from { transform: translateY(0) scale(.6); opacity: 0 } 30% { opacity: 1 } to { transform: translateY(-120px) scale(1.1); opacity: 0 } }
.scene .fx-confetti i { position: absolute; top: -6%; width: 8px; height: 12px; border-radius: 2px; animation: drop 2.2s linear infinite; }
@keyframes drop { from { transform: translateY(0) rotate(0) } to { transform: translateY(110vh) rotate(540deg) } }
.scene.dark .fx-sparkles span, .scene.night .fx-sparkles span { color: #fff; }

/* ---------- storyteller voice ---------- */
.narrator-status { position: absolute; left: 12px; bottom: 10px; z-index: 9; background: #fff; border-radius: 14px; padding: 8px 12px; font-size: .85rem; font-weight: 600; color: var(--muted); box-shadow: var(--shadow); }
.narrator-status b { color: var(--accent); }

.scene .prop.under { z-index: 0; }

/* fix-page actions, landmarks, costumes, Halloween */
.scene .fig .held.wear { z-index: 4; }
.scene .fig .held.wear .held-img { animation: none; }
.scene .landmark { position: absolute; z-index: 1; filter: drop-shadow(0 6px 6px rgba(0,0,0,.2)); }
.scene .landmark.front { z-index: 3; }
.scene .landmark .landmark-img, .scene .landmark .emoji-fallback { position: relative; height: 100%; width: auto; display: block; }
.scene .landmark .emoji-fallback { font-size: min(22vw, 120px) !important; height: auto !important; }
.scene .fx-beam { position: absolute; bottom: 28%; width: 62%; height: 40%; translate: 0 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to right, rgba(255,245,140,.95), rgba(255,235,80,.6) 55%, rgba(255,235,80,0)); clip-path: polygon(0 46%, 100% 0, 100% 100%, 0 54%); animation: beam 1.6s ease-in-out infinite alternate; }
@keyframes beam { from { opacity: .55 } to { opacity: .95 } }
.scene .fx-notes span { position: absolute; bottom: 40%; font-size: clamp(20px, 6vw, 40px); color: #5c6bc0; text-shadow: 0 2px 0 #fff; animation: floatup 2.2s ease-in infinite; }
.scene .fx-glow { background: radial-gradient(circle at var(--gx) 55%, rgba(255,241,118,.55) 0%, rgba(255,241,118,.25) 25%, transparent 55%); mix-blend-mode: screen; animation: glow 2s ease-in-out infinite; }
.scene .fx-sparkles2 span { color: #ff80ab; text-shadow: 0 0 8px #f06292; animation-duration: .8s; }
.scene .fx-bats span { position: absolute; font-size: clamp(18px, 5vw, 34px); animation: batfly 3s ease-in-out infinite; }
@keyframes batfly { 0%,100% { transform: translate(0,0) scaleX(1) } 50% { transform: translate(40px, -14px) scaleX(-1) } }
