@font-face { font-family: Fredoka; src: url(/fonts/fredoka.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: Lexend; src: url(/fonts/lexend.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #1b1a2e; --cream: #fff6e3; --paper: #fffdf6; --kaya: #ffc72e; --chilli: #e8352e;
  --pandan: #128a57; --sky: #1f6cf0; --ube: #6d3fd6; --orange: #ff8a3d; --line: #dfe7f2;
  --bg: #fff6e3; --bg-tile: #f7e3bb; --on-bg: #1b1a2e;
  --r1: 22px 16px 24px 14px; --r2: 14px 24px 16px 26px;
  --shadow: 4px 5px 0 var(--ink);
}
body[data-theme="night"] { --bg: #231a4f; --bg-tile: #2f2466; --on-bg: #fff6e3; }
body[data-theme="gardens"] { --bg: #0d5b52; --bg-tile: #12695f; --on-bg: #fff6e3; }
body[data-theme="sentosa"] { --bg: #bfeaf5; --bg-tile: #a9e0ee; --on-bg: #1b1a2e; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Lexend, system-ui, sans-serif; color: var(--on-bg); background-color: var(--bg);
  background-image: var(--tile);
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.045' stroke-width='3'%3E%3Cpath d='M48 8c11 13 11 27 0 40-11-13-11-27 0-40zM48 88c11-13 11-27 0-40-11 13-11 27 0 40zM8 48c13-11 27-11 40 0-13 11-27 11-40 0zM88 48c-13-11-27-11-40 0 13 11 27 11 40 0z'/%3E%3Ccircle cx='48' cy='48' r='7'/%3E%3Cpath d='M0 20 20 0M76 0l20 20M0 76l20 20M96 76 76 96'/%3E%3C/g%3E%3C/svg%3E");
  transition: background-color .4s;
  overflow-x: hidden;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
body[data-theme="night"], body[data-theme="gardens"] {
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.05' stroke-width='3'%3E%3Cpath d='M48 8c11 13 11 27 0 40-11-13-11-27 0-40zM48 88c11-13 11-27 0-40-11 13-11 27 0 40zM8 48c13-11 27-11 40 0-13 11-27 11-40 0zM88 48c-13-11-27-11-40 0 13 11 27 11 40 0z'/%3E%3Ccircle cx='48' cy='48' r='7'/%3E%3Cpath d='M0 20 20 0M76 0l20 20M0 76l20 20M96 76 76 96'/%3E%3C/g%3E%3C/svg%3E");
}
body[data-heat="1"] { box-shadow: inset 0 0 0 5px var(--kaya); }
body[data-heat="2"] { box-shadow: inset 0 0 0 7px var(--orange); }
body[data-heat="3"] { box-shadow: inset 0 0 0 9px var(--chilli); }

h1, h2, h3, .prompt b, .btn, .key, .choice { font-family: Fredoka, Lexend, sans-serif; }
h1 { font-weight: 700; line-height: 1.05; margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, [tabindex]:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
svg { display: block; }

#app { min-height: 100dvh; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
#fxlayer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 58px; padding: 10px 26px;
  font-size: 21px; font-weight: 600; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: var(--r1); box-shadow: var(--shadow);
  transition: transform .07s, box-shadow .07s;
}
.btn:active { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--kaya); }
.btn.quiet-btn { box-shadow: none; background: transparent; color: var(--on-bg); border-color: currentColor; font-size: 18px; }
.btn.armed { background: var(--chilli); color: #fff; border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; }
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 15px 12px 16px 11px; flex: none;
}
.icon-btn svg { width: 24px; height: 24px; }
.text-btn { height: 48px; padding: 0 14px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 13px 16px 12px 15px; font-weight: 600; font-size: 15px; }
.text-btn.on { background: var(--pandan); color: #fff; }

/* ---------- Level picker ---------- */
.pick { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; text-align: center; }
.pick .logo { width: 150px; color: var(--chilli); }
.pick h1 { font-size: clamp(30px, 7vw, 46px); }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; width: min(640px, 100%); }
.level-btn {
  aspect-ratio: 3 / 4; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
  border: 3px solid var(--ink); border-radius: var(--r2); box-shadow: var(--shadow); font-family: Fredoka; transition: transform .1s;
}
.level-btn:hover { transform: translateY(-4px) rotate(-1.5deg); }
.level-btn small { font-size: clamp(12px, 3vw, 16px); font-weight: 500; }
.level-btn b { font-size: clamp(46px, 13vw, 84px); line-height: 1; }
.l3 { background: var(--sky); } .l4 { background: var(--pandan); } .l5 { background: var(--ube); } .l6 { background: var(--chilli); }
@media (max-width: 420px) { .levels { grid-template-columns: repeat(2, 1fr); } .level-btn { aspect-ratio: 5 / 4; } }

/* ---------- Home ---------- */
.home { width: min(860px, 100%); margin: 0 auto; padding: 16px 16px 30px; display: flex; flex-direction: column; gap: 16px; }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.home-top .logo { width: 84px; color: var(--chilli); }
.home-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lv { display: flex; border: 3px solid var(--ink); border-radius: 15px; overflow: hidden; background: var(--paper); }
.lv-btn { height: 42px; min-width: 44px; padding: 0 6px; font-weight: 700; font-size: 15px; color: var(--ink); font-family: Fredoka; }
.lv-btn + .lv-btn { border-left: 2px solid var(--ink); }
.lv-btn.on { background: var(--ink); color: var(--kaya); }

.rank { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r2); padding: 11px 15px; }
.rank-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; font-family: Fredoka; font-size: 19px; }
.rank-row small { font-family: Lexend; font-size: 13px; color: #55536b; }
.rank-bar { margin-top: 7px; height: 13px; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: #efe6cf; }
.rank-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pandan), var(--kaya)); transition: width .5s; }

.gift { background: var(--chilli); color: #fff; font-weight: 600; font-size: 16px; padding: 13px 16px; border: 3px solid var(--ink); border-radius: var(--r1); animation: nudge 2.4s infinite; }

.go-big {
  position: relative; display: flex; align-items: baseline; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 20px 24px; color: var(--ink); background: var(--kaya);
  border: 4px solid var(--ink); border-radius: 30px 18px 34px 20px; box-shadow: 7px 8px 0 var(--ink);
  transition: transform .08s, box-shadow .08s; font-family: Fredoka;
}
.go-big span { font-size: clamp(64px, 17vw, 112px); font-weight: 700; line-height: .95; letter-spacing: -2px; }
.go-big small { font-size: 22px; font-weight: 500; }
.go-big:hover { transform: translate(-1px, -2px) rotate(-.6deg); }
.go-big:active { transform: translate(5px, 6px); box-shadow: 2px 2px 0 var(--ink); }

.modes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.mode-card {
  grid-column: span 2; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-align: left;
  padding: 12px; color: #fff; border: 3px solid var(--ink); border-radius: var(--r1); box-shadow: 3px 4px 0 var(--ink); min-height: 96px;
  transition: transform .1s;
}
.mode-card:hover { transform: translateY(-3px) rotate(.7deg); }
.mode-card:nth-child(even) { border-radius: var(--r2); }
.mode-card.m-chop { grid-column: span 3; }
.mode-card.m-rush { grid-column: span 3; }
.mode-card.m-boss { grid-column: span 6; min-height: 76px; }
.mode-art { width: 38px; height: 38px; grid-row: span 2; }
.mode-card b { font-family: Fredoka; font-size: 20px; line-height: 1.1; }
.mode-card small { font-size: 13px; line-height: 1.25; }
.c-sky { background: var(--sky); } .c-chilli { background: var(--chilli); } .c-pandan { background: var(--pandan); }
.c-ube { background: var(--ube); } .c-kaya { background: var(--kaya); color: var(--ink); } .c-boss { background: var(--ink); color: var(--kaya); }
@media (max-width: 640px) { .modes { grid-template-columns: 1fr 1fr; } .mode-card, .mode-card.m-chop, .mode-card.m-rush, .mode-card.m-boss { grid-column: span 1; grid-template-columns: 1fr; row-gap: 3px; } .mode-art { grid-row: auto; } }

.home-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.stamp-link { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r2); font-weight: 600; padding: 13px 18px; font-size: 17px; }
.stamp-link b { color: var(--chilli); }
.grown-link { font-size: 15px; text-decoration: underline; text-underline-offset: 3px; padding: 12px 6px; color: var(--on-bg); }

/* ---------- Intro card ---------- */
.intro { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; cursor: pointer; animation: slamin .32s cubic-bezier(.2,1.5,.5,1); }
.intro-art { width: 92px; height: 92px; animation: wig 1.2s infinite; }
.intro h1 { font-size: clamp(50px, 13vw, 92px); }
.intro-tag { font-size: clamp(18px, 4vw, 23px); margin: 0; max-width: 28em; }
.twist { display: flex; flex-direction: column; gap: 2px; padding: 12px 20px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r2); transform: rotate(-1.5deg); margin-top: 8px; }
.twist span { font-size: 13px; color: #55536b; }
.twist b { font-family: Fredoka; font-size: 25px; }
.twist small { font-size: 15px; }
.mnemonic { background: var(--paper); color: var(--ink); padding: 14px 20px; border: 3px solid var(--ink); border-radius: var(--r1); margin-top: 8px; }
.mnemonic p { margin: 0; }
.mn-line { font-family: Fredoka; font-size: clamp(22px, 5.5vw, 32px); margin: 5px 0 !important; }
.mn-line b { color: var(--chilli); }
.mn-small { font-size: 15px; }
.intro-go { font-size: 15px; opacity: .85; margin: 6px 0 0; }

/* ---------- Play layout ---------- */
.play { height: 100dvh; display: flex; flex-direction: column; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px; max-width: 1100px; margin: 0 auto; }
.hud { display: flex; align-items: center; gap: 10px; flex: none; }
.hud .exit { width: 42px; height: 42px; }
.hud .exit svg { width: 18px; height: 18px; }
.pips { display: flex; gap: 6px; flex: 1; min-width: 0; }
.pips i { flex: 1; max-width: 62px; height: 14px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 7px; }
.pips i.done { background: var(--pandan); }
.heat { display: flex; align-items: center; gap: 4px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 13px; padding: 4px 9px 4px 6px; }
.heat-icon { width: 20px; height: 20px; color: var(--chilli); }
.heat-bar { width: 52px; height: 10px; background: #efe6cf; border-radius: 5px; overflow: hidden; }
.heat-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--kaya), var(--chilli)); transition: width .18s; }
.heat-n { font-family: Fredoka; font-weight: 700; min-width: 15px; text-align: right; }
.hud-xp { display: flex; align-items: baseline; gap: 3px; background: var(--ink); color: var(--kaya); border-radius: 13px 10px 14px 9px; padding: 6px 11px; font-family: Fredoka; }
.hud-xp b { font-size: 21px; }
.hud-xp small { font-size: 12px; }
.hud-xp.bump { animation: bump .22s; }
@media (max-width: 400px) { .heat-bar { width: 26px; } }

.stage { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 8px; }
@media (min-width: 820px) and (orientation: landscape) {
  .stage:not(.rush-stage):not(.story-stage):not(.share-stage):not(.bug-stage) { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto minmax(0, 1fr); column-gap: 14px; }
  .stage > .board-area { grid-column: 1; grid-row: 1 / span 2; }
  .stage > .say { grid-column: 2; grid-row: 1; }
  .stage > .pad { grid-column: 2; grid-row: 2; align-self: end; }
  .stage > .pad .key { min-height: 66px; }
}

/* ---------- Board (exercise-book squares) ---------- */
.board-area {
  min-height: 0; overflow: auto; background: var(--paper); color: var(--ink); border: 3px solid var(--ink);
  border-radius: var(--r2); padding: 8px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  position: relative;
}
.board-label { margin: 0 0 4px; font-weight: 600; font-size: 15px; color: var(--ube); }
.board {
  --c: 44px; display: grid; flex: none;
  grid-template-columns: repeat(var(--cols), var(--c)); grid-template-rows: repeat(var(--rows), var(--c));
  background-image: linear-gradient(var(--line) 1.5px, transparent 1.5px), linear-gradient(90deg, var(--line) 1.5px, transparent 1.5px);
  background-size: var(--c) var(--c); position: relative;
  font-family: Fredoka; font-size: calc(var(--c) * .72); font-weight: 600; line-height: 1;
}
.cell, .slot, .minus { display: grid; place-items: center; width: var(--c); height: var(--c); position: relative; }
.board.focusing .cell { opacity: .34; transition: opacity .12s; }
.board.focusing .cell.focus, .board.focusing .cell.glow { opacity: 1; }
.cell.focus { background: rgba(255, 199, 46, .34); }
.cell.quotient { color: var(--sky); }
.cell.product { color: var(--ube); }
.cell.rem { color: #c9301f; }
.cell.brought { color: var(--pandan); }
.cell.divisor { color: var(--ink); font-weight: 700; }
.bracket { border-right: 4px solid var(--ink); border-radius: 0 0 16px 0; pointer-events: none; }
.overline { border-top: 4px solid var(--ink); pointer-events: none; height: 0; align-self: start; }
.rule { border-bottom: 3.5px solid var(--ink); align-self: end; height: 0; pointer-events: none; }
.minus { color: var(--ink); font-weight: 700; opacity: .75; }
.rem-tag { display: grid; place-items: center; font-size: calc(var(--c) * .58); color: #c9301f; white-space: nowrap; }
.dot { justify-self: start; align-self: end; width: calc(var(--c) * .19); height: calc(var(--c) * .19); background: var(--ink); border-radius: 50%; transform: translate(-50%, -30%); z-index: 2; margin-bottom: 3px; }
.slot { border: 3px dashed #a9a6c4; border-radius: 9px; color: var(--ink); background: #fff; z-index: 2; }
.slot.now { border: 3.5px solid var(--sky); animation: pulsebox 1s infinite; }
.slot.gold { border-color: #d59a00; background: #fff0b3; }
.slot.wrong { border-color: var(--orange); background: #ffe7d6; animation: nope .25s; }
.cell.glow { color: #fff; background: var(--pandan); border-radius: 10px; cursor: pointer; animation: pulsepop .8s infinite; z-index: 3; }
.dot.glow { background: var(--pandan); box-shadow: 0 0 0 7px rgba(18, 138, 87, .3); animation: pulsedot .8s infinite; cursor: pointer; }
.cell.tappable { cursor: pointer; border-radius: 8px; }
.cell.tappable:hover { background: rgba(31, 108, 240, .12); }
.cell.checked { background: rgba(18, 138, 87, .16); }
.cell.caught { background: var(--chilli); color: #fff !important; border-radius: 50%; animation: slamin .3s; }
.cell.fixed { background: #cdf3df; color: var(--pandan) !important; }
.cell.glow-soft { background: rgba(255, 199, 46, .55); }

.pop-divide { animation: stampin .22s cubic-bezier(.2,1.6,.5,1); }
.pop-multiply { animation: slidein .2s cubic-bezier(.2,1.3,.5,1); }
.pop-subtract { animation: chopin .24s; }
.pop-bring { animation: dropin .22s cubic-bezier(.2,1.8,.5,1); }
.pop-point { animation: stampin .3s; }

/* ---------- Prompt bar ---------- */
.say { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r1); padding: 8px 12px 10px; --tone: var(--sky); border-bottom: 7px solid var(--tone); }
.say[data-step="multiply"] { --tone: var(--ube); }
.say[data-step="subtract"] { --tone: #c9301f; }
.say[data-step="bring"], .say[data-step="point"], .say[data-step="done"] { --tone: var(--pandan); }
.say[data-step="bug"] { --tone: var(--chilli); }
.say.golden { background: #fff0b3; --tone: #d59a00; }
.wheel { display: flex; gap: 4px; align-items: center; margin-bottom: 5px; }
.wheel span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 9px; font-size: 13px; color: #6d6b85; }
.wheel span b { font-family: Fredoka; font-size: 16px; }
.wheel span em { display: none; font-style: normal; font-weight: 600; }
.wheel span.on { background: var(--tone); color: #fff; }
.wheel span.on em { display: inline; }
.hint-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; height: 34px; padding: 0 9px; font-size: 14px; font-weight: 600; color: var(--ink); background: #fff0b3; border: 2px solid var(--ink); border-radius: 10px; }
.hint-btn svg { width: 16px; height: 16px; }
.prompt { margin: 0; font-size: clamp(22px, 5.6vw, 30px); line-height: 1.22; }
.prompt b { font-weight: 700; color: var(--tone); }
.helper { margin-top: 6px; font-size: 16px; line-height: 1.35; }
.helper p { margin: 0; }
.multiples { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.multiples span { display: flex; flex-direction: column; align-items: center; background: #fff0b3; border-radius: 7px; padding: 2px 0; font-family: Fredoka; font-weight: 600; font-size: 15px; }
.multiples small { font-size: 10px; color: #55536b; font-weight: 500; font-family: Lexend; }

/* ---------- Keypad ---------- */
.pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; transition: opacity .15s; }
.pad.sleep { opacity: .42; }
.key {
  min-height: 56px; font-size: 27px; font-weight: 700; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 13px 11px 14px 10px; box-shadow: 2px 3px 0 var(--ink); transition: transform .05s, box-shadow .05s;
  display: grid; place-items: center;
}
.key:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); background: var(--kaya); }
.key.del { background: #ffe0cf; }
.key.del svg { width: 30px; height: 24px; }
.key.send { background: var(--pandan); color: #fff; font-size: 21px; grid-column: 1 / -1; }
@media (orientation: landscape) and (min-width: 820px) {
  .stage:not(.rush-stage):not(.story-stage):not(.share-stage):not(.bug-stage) .pad { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 640px) { .key { min-height: 46px; font-size: 23px; } }

/* ---------- Hawker Rush ---------- */
.clock { flex: none; height: 16px; background: var(--paper); border: 3px solid var(--ink); border-radius: 9px; overflow: hidden; }
.clock-fill { display: block; height: 100%; width: 100%; background: var(--pandan); transition: width .25s linear, background .3s; }
.clock-fill.low { background: var(--orange); }
.rush-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.ticket-wrap { width: min(560px, 100%); position: relative; }
.ticket {
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); padding: 18px 22px 22px; text-align: center; transform: rotate(var(--tilt));
  border-radius: 6px 6px 16px 18px; box-shadow: var(--shadow); animation: slidedown .18s cubic-bezier(.2,1.4,.5,1);
}
.ticket small { display: block; font-size: 14px; color: #55536b; border-bottom: 2px dashed #bbb6a2; padding-bottom: 6px; margin-bottom: 10px; }
.ticket p { margin: 0; font-size: clamp(28px, 7vw, 44px); line-height: 1.15; font-family: Fredoka; font-weight: 500; }
.ticket b { color: var(--chilli); font-weight: 700; }
.choices { width: min(560px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { position: relative; min-height: 88px; font-size: 44px; font-weight: 700; color: #fff; border: 3px solid var(--ink); border-radius: var(--r1); box-shadow: var(--shadow); transition: transform .06s, box-shadow .06s; }
.choice:nth-child(even) { border-radius: var(--r2); }
.choice small { position: absolute; left: 10px; top: 6px; font-size: 13px; font-weight: 500; opacity: .85; }
.choice:active { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.c0 { background: var(--sky); } .c1 { background: var(--chilli); } .c2 { background: var(--pandan); } .c3 { background: var(--ube); }
.choice.nope, .choice:disabled { background: #cfccd8; color: #55536b; box-shadow: none; }
.rush-count { margin: 0; font-size: 18px; color: var(--on-bg); }
.rush-count b { font-family: Fredoka; font-size: 28px; }
.rush-count small { margin-left: 8px; font-size: 14px; }

/* ---------- Bug Hunt ---------- */
.bug-stage { grid-template-rows: minmax(0, 1fr) auto auto; }
.bug-next { display: flex; justify-content: center; min-height: 0; }
.bug-next:empty { display: none; }

/* ---------- Story Stall ---------- */
.story-stage { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; width: min(680px, 100%); margin: 0 auto; }
.story-card { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r2); box-shadow: var(--shadow); padding: 16px 18px; flex: none; }
.story-card p { margin: 0; font-size: clamp(19px, 4.3vw, 25px); line-height: 1.38; user-select: text; -webkit-user-select: text; }
.story-answer { display: flex; justify-content: center; flex: none; }
.story-input { display: grid; place-items: center; min-width: 170px; height: 62px; padding: 0 16px; font-family: Fredoka; font-size: 36px; font-weight: 700; color: var(--ink); background: #fff; border: 3.5px solid var(--sky); border-radius: 15px; }
.story-input.empty::before { content: "Your answer"; font-size: 18px; font-weight: 400; color: #6d6b85; }
.story-input.right { background: #cdf3df; border-color: var(--pandan); }
.story-help { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r1); padding: 10px 14px; flex: none; margin: 0; }
.story-help .btn { margin-top: 10px; width: 100%; }
.story-stage .pad { margin-top: auto; flex: none; }
.pad-send { grid-template-columns: repeat(6, 1fr); }

/* ---------- Share Plates ---------- */
.share-stage { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; width: min(760px, 100%); margin: 0 auto; }
.share-q { margin: 0; text-align: center; font-size: 21px; color: var(--on-bg); flex: none; }
.share-q b { font-family: Fredoka; font-size: 28px; }
.piles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; flex: none; }
.pile { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r1); padding: 6px 8px; min-height: 92px; opacity: .55; transition: opacity .15s; }
.pile.active { opacity: 1; border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky); }
.pile h3 { margin: 0 0 4px; display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 500; }
.pile h3 b { font-size: 22px; font-weight: 700; }
.pile-chips { display: flex; flex-wrap: wrap; gap: 2px; }
.chip { display: grid; place-items: center; font: 700 9px/1 Fredoka; font-style: normal; border: 1.5px solid var(--ink); }
.chip.h { width: 28px; height: 28px; background: var(--kaya); color: var(--ink); border-radius: 6px; }
.chip.t { width: 21px; height: 21px; background: var(--pandan); color: #fff; border-radius: 5px; }
.chip.o { width: 15px; height: 15px; background: var(--sky); color: #fff; border-radius: 50%; font-size: 8px; }
.more { font: 600 13px Fredoka; align-self: center; margin-left: 3px; }
.plates { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; flex: 1 0 auto; align-content: center; }
.plate { flex: 1 1 96px; max-width: 170px; min-height: 86px; display: flex; flex-wrap: wrap; gap: 2px; align-content: center; justify-content: center; padding: 10px; background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 50% / 44%; box-shadow: inset 0 0 0 5px #e6eefb; }
.plate.thump { animation: bump .18s; }
.share-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: none; }
.share-btns .btn { font-size: 17px; padding: 8px; min-height: 62px; }
.deal-btn { background: var(--kaya) !important; }
.break-btn { background: #ffd7c2 !important; }

/* ---------- Boss ---------- */
.boss-bar { flex: none; display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--cream); border-radius: var(--r1); padding: 5px 12px; }
.boss-pic { width: 78px; flex: none; }
.boss-pic.wobble { animation: hitshake .22s; }
.durian { width: 100%; }
.spike { fill: #77861c; stroke: #1b1a2e; stroke-width: 4; transition: transform .25s, opacity .25s; transform-box: fill-box; transform-origin: center; }
.spike.gone { opacity: 0; transform: scale(.2) rotate(50deg) translateY(-10px); }
.boss-pic.defeated { animation: spinout 1.2s forwards; }
.boss-info { flex: 1; min-width: 0; }
.boss-say { margin: 0 0 4px; font-family: Fredoka; font-size: 17px; font-weight: 500; }
.hp { height: 14px; border: 2px solid var(--cream); border-radius: 8px; overflow: hidden; }
.hp-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--chilli), var(--orange)); transition: width .2s; }

/* ---------- Results, break ---------- */
.results, .wiggle { min-height: 100dvh; width: min(640px, 100%); margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 24px 16px; text-align: center; }
.results h1 { font-size: clamp(38px, 10vw, 64px); animation: slamin .35s cubic-bezier(.2,1.5,.5,1); }
.result-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.r-card { display: flex; flex-direction: column; padding: 14px 6px; border: 3px solid var(--ink); box-shadow: var(--shadow); color: #fff; animation: stampin .35s backwards; }
.r-card b { font: 700 clamp(30px, 8vw, 46px)/1 Fredoka; }
.r-card span { font-size: 13px; margin-top: 3px; }
.r-a { background: var(--sky); border-radius: var(--r1); transform: rotate(-1.5deg); }
.r-b { background: var(--chilli); border-radius: var(--r2); animation-delay: .1s; }
.r-c { background: var(--pandan); border-radius: var(--r1); transform: rotate(1.5deg); animation-delay: .2s; }
.rank-up { background: var(--ink); color: var(--kaya); padding: 12px; border-radius: var(--r2); animation: slamin .4s; }
.rank-up span { display: block; font-size: 14px; }
.rank-up b { font: 700 30px Fredoka; }
.stop-card { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r2); padding: 14px 18px; }
.stop-card h2 { margin: 0 0 5px; font-size: 25px; }
.stop-card p { margin: 0; }
.wiggle { align-items: center; }
.eyebrow { margin: 0; font-weight: 600; }
.wiggle h1 { font-size: clamp(42px, 11vw, 70px); }
.wiggle-text { margin: 0; font-size: 21px; max-width: 24em; }
.wiggle-clock { width: 112px; height: 112px; display: grid; place-items: center; background: var(--kaya); color: var(--ink); border: 4px solid var(--ink); border-radius: 50%; font: 700 48px Fredoka; animation: wig 1s infinite; }

/* ---------- Tiffin + stamps ---------- */
#modal:empty { display: none; }
.modal-back { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; background: rgba(27, 26, 46, .88); color: var(--cream); animation: fadein .15s; }
.modal-back h2 { margin: 0; font-size: clamp(30px, 8vw, 46px); }
.tiffin-btn { width: min(240px, 58vw); }
.tiffin { width: 100%; overflow: visible; }
.tier { transition: transform .32s cubic-bezier(.3,1.3,.5,1), opacity .32s; transform-box: fill-box; }
.tier.off { opacity: 0; }
.tier.t1.off { transform: translate(-90px, -70px) rotate(-30deg); }
.tier.t2.off { transform: translate(100px, -40px) rotate(25deg); }
.tier.t3.off { transform: translateY(90px) scale(.8); }
.tiffin-tip { margin: 0; font-size: 18px; min-height: 1.4em; }
.rarity { margin: 0; text-transform: uppercase; letter-spacing: 3px; font-weight: 700; font-size: 15px; }
.revealed.rare .rarity { color: #9fc1ff; }
.revealed.legendary .rarity { color: var(--kaya); }
.big-next { min-width: 170px; margin-top: 6px; }

.stamp {
  --stamp-bg: var(--paper); --ink-c: #c43a30;
  width: 92px; height: 92px; padding: 15px; border-radius: 50%; color: var(--ink-c); background: var(--paper);
  border: 3.5px solid var(--ink-c); outline: 1.5px solid var(--ink-c); outline-offset: -8px; transform: rotate(var(--tilt));
}
.stamp.rare { --ink-c: #1f55c9; }
.stamp.legendary { --ink-c: #5a2fc0; background: #fff0b3; --stamp-bg: #fff0b3; box-shadow: 0 0 0 4px var(--kaya); }
.stamp.locked { --ink-c: #a39fb8; background: #ece8dc; box-shadow: none; display: grid; place-items: center; }
.stamp.big { width: min(220px, 54vw); height: min(220px, 54vw); padding: 36px; animation: slamin .38s cubic-bezier(.2,1.6,.5,1); }
.stamp .q { font: 700 34px Fredoka; }
.book, .grown { width: min(820px, 100%); margin: 0 auto; padding: 14px 16px 32px; }
.sub-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.sub-top h1 { font-size: 32px; flex: 1; }
.count { font: 700 24px Fredoka; }
.book-note { margin: 0 0 14px; }
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.stamp-slot { display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; padding: 11px 6px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r2); }
.stamp-slot:nth-child(3n) { border-radius: var(--r1); }
.stamp-slot p { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.2; }
.stamp-slot small { color: #55536b; }

/* ---------- Grown-ups ---------- */
.grown { -webkit-user-select: text; user-select: text; }
.grown section { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r1); padding: 13px 17px; margin-bottom: 12px; font-size: 16px; line-height: 1.45; }
.grown h2 { margin: 0 0 7px; font-size: 22px; }
.grown ul { margin: 7px 0; padding-left: 20px; }
.grown p { margin: 7px 0; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.stat-table th, .stat-table td { text-align: left; padding: 6px 5px; border-bottom: 1.5px solid #e0dcc9; }
.grown .quiet-btn { color: var(--ink); }

/* ---------- Text effects ---------- */
.floater { position: absolute; transform: translateX(-50%); font-family: Fredoka; font-weight: 700; white-space: nowrap; animation: floatup 1s forwards; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.floater.pts { color: var(--kaya); font-size: 25px; }
.floater.say { color: #fff; font-size: 31px; }
.floater.loud { color: var(--kaya); font-size: clamp(30px, 8vw, 42px); }
.flyer { position: absolute; display: grid; place-items: center; font-family: Fredoka; font-weight: 700; color: var(--pandan); }
.otter-dash { position: absolute; bottom: 12%; left: -210px; width: 200px; animation: dash 1.5s linear forwards; }
.stamp-slam { position: absolute; inset: 0; display: grid; place-items: center; }
.stamp-slam span { font: 700 clamp(70px, 22vw, 170px) Fredoka; color: var(--chilli); border: 10px solid var(--chilli); border-radius: 26px; padding: 0 26px; background: rgba(255, 246, 227, .86); animation: slamfade .95s forwards; }
.slash { position: absolute; left: -10%; right: -10%; top: 48%; height: 15px; background: #fff; box-shadow: 0 0 0 4px var(--ink); transform: rotate(-16deg) scaleX(0); animation: slash .5s forwards; }

.wobble { animation: wobble .3s !important; }

@keyframes wobble { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes hitshake { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-12deg) scale(.92); } 70% { transform: rotate(9deg); } }
@keyframes spinout { to { transform: rotate(720deg) scale(0); opacity: 0; } }
@keyframes stampin { from { transform: scale(2.1) rotate(-10deg); opacity: 0; } }
@keyframes slidein { from { transform: translateX(-16px); opacity: 0; } }
@keyframes chopin { 0% { transform: scale(.6) skewX(-22deg); opacity: 0; } 60% { transform: scale(1.2) skewX(6deg); } }
@keyframes dropin { from { transform: translateY(-20px) scale(1.3); } }
@keyframes pulsebox { 50% { box-shadow: 0 0 0 5px rgba(31, 108, 240, .22); } }
@keyframes pulsepop { 50% { transform: scale(1.14); } }
@keyframes pulsedot { 50% { box-shadow: 0 0 0 13px rgba(18, 138, 87, .16); } }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.7); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 100% { opacity: 0; transform: translate(-50%, -62px) scale(1); } }
@keyframes dash { to { left: calc(100% + 20px); } 25% { transform: translateY(-16px) rotate(-3deg); } 50% { transform: translateY(0); } 75% { transform: translateY(-14px) rotate(3deg); } }
@keyframes slamfade { 0% { transform: scale(2.6) rotate(-14deg); opacity: 0; } 22% { transform: scale(1) rotate(-8deg); opacity: 1; } 78% { transform: scale(1) rotate(-8deg); opacity: 1; } 100% { transform: scale(1.04) rotate(-8deg); opacity: 0; } }
@keyframes slash { 40% { transform: rotate(-16deg) scaleX(1); opacity: 1; } 100% { transform: rotate(-16deg) scaleX(1); opacity: 0; } }
@keyframes slamin { from { transform: scale(1.5); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.14); } }
@keyframes wig { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes nudge { 50% { transform: scale(1.015); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes slidedown { from { transform: translateY(-34px) rotate(var(--tilt)); opacity: 0; } }

body.calm *, body.calm *::before, body.calm *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
body.calm[data-heat] { box-shadow: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
