@font-face { font-family: Fredoka; src: url(../fonts/fredoka-latin-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
:root { --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --ink: #2b2350; --gold: #ffc93c; --blue: #3f7fe0; --wood: #c98d4b; --wood2: #e9b877; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3c98b; color: var(--ink); font-family: Fredoka, ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif; font-weight: 700;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; pointer-events: none; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; position: relative; }
button:disabled { cursor: default; }
button:focus { outline: none; }
button:focus-visible, .kbd button:focus { outline: 5px solid #fff; outline-offset: 1px; box-shadow: 0 0 0 9px var(--ink), 0 0 0 12px var(--gold); z-index: 6; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: var(--st) var(--sr) var(--sb) var(--sl); display: none; }
.screen.on { display: grid; }

/* ---------- hub: the castle playroom ---------- */
.hub { grid-template-rows: auto 1fr; gap: 6px; padding: 8px 12px 12px; }
body[data-screen="hub"] { background: #f1d2a4 url(../art/bg_playroom.webp) center / cover no-repeat; }
@media (orientation: portrait) {
  body[data-screen="hub"] { background-image: url(../art/bg_playroom_tall.webp); }
  body[data-screen="connect4"], body[data-screen="ttt"], body[data-screen="memory"], body[data-screen="kitchen"] { background-image: linear-gradient(rgba(255,246,223,.42), rgba(255,240,205,.3)), url(../art/bg_playroom_tall.webp) !important; }
  body[data-screen="maze"] { background-image: url(../art/bg_garden_tall.webp) !important; }
}
.hub-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.title { margin: 0; min-width: 0; line-height: 0; }
.title img { height: clamp(58px, 15vmin, 132px); width: auto; max-width: 100%; object-fit: contain; object-position: 0 50%; filter: drop-shadow(0 4px 3px rgba(43,35,80,.35)); }
.hub-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: clamp(8px, 2.2vmin, 24px); min-height: 0; }
@media (orientation: portrait) { .hub-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); } }
.hub-hello { position: relative; min-height: 0; min-width: 0; }
.hub-grid[data-n="4"] .hub-hello { grid-column: span 2; }
.hub-grid[data-n="4"] .hello-elise { left: 12%; width: 46%; } .hub-grid[data-n="4"] .hello-nay { right: 14%; width: 30%; height: 44%; }
.hello-elise { position: absolute; bottom: 0; left: 4%; height: 100%; width: 62%; object-fit: contain; object-position: 50% 100%; filter: drop-shadow(0 6px 5px rgba(60,30,0,.3)); animation: sway 3.2s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.hello-nay { position: absolute; bottom: 0; right: 0; height: 48%; width: 44%; object-fit: contain; object-position: 50% 100%; filter: drop-shadow(0 5px 4px rgba(60,30,0,.3)); }
.station { display: grid; grid-template-rows: 1fr auto; min-height: 0; min-width: 0; padding: clamp(6px, 1.4vmin, 14px); border-radius: clamp(20px, 5vmin, 40px); border: clamp(20px, 4.6vmin, 38px) solid transparent; border-image: url(../art/ui_panel.webp) 96 fill / clamp(20px, 4.6vmin, 38px) stretch;
  padding: 0 0 clamp(0px, .6vmin, 6px); filter: drop-shadow(0 8px 7px rgba(60,30,0,.35)); transition: transform .12s; }
.station:hover { transform: translateY(-3px); }
.station:active { transform: translateY(4px) scale(.98); }
.st-pic { position: relative; min-height: 0; }
.st-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 5px 4px rgba(60,30,0,.28)); }
.st-name { padding: 2px 0 0; margin: 0 -8px; font-size: clamp(15px, 3.6vmin, 32px); line-height: 1.05; text-align: center; }

/* ---------- station screen ---------- */
.game { grid-template-rows: auto auto 1fr; gap: 4px; padding: 6px 8px 8px; }
body[data-screen="connect4"], body[data-screen="ttt"], body[data-screen="memory"], body[data-screen="kitchen"] { background: linear-gradient(rgba(255,246,223,.42), rgba(255,240,205,.3)), #f1d2a4 url(../art/bg_playroom.webp) center / cover no-repeat; }
body[data-screen="maze"] { background: #7cc25a url(../art/bg_garden.webp) center / cover no-repeat; }
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; min-width: 0; }
.tb-left, .tb-right { display: flex; gap: clamp(6px, 1.5vmin, 12px); }
.ib { width: clamp(48px, 9.5vmin, 76px); height: clamp(48px, 9.5vmin, 76px); border-radius: 50%; flex: none; transition: transform .1s; }
.ib:active { transform: scale(.92); }
.ib img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.allgames img { object-fit: contain; } .allgames.holding { transform: scale(1.15); }
.sound .off, .sound.muted .on { display: none; } .sound.muted .off { display: block; }
.status { --sh: clamp(60px, 11.5vmin, 92px); justify-self: center; display: flex; align-items: center; gap: clamp(6px, 1.6vmin, 14px); min-width: 0; max-width: 100%; height: var(--sh); padding: 0 calc(var(--sh) * .13); border-radius: 999px;
  border-image: url(../art/ui_plaque.webp) 0 69 fill / 0 calc(var(--sh) * .497) stretch; filter: drop-shadow(0 3px 3px rgba(60,30,0,.3)); }
.status:has(.who.right[hidden]) { padding-right: calc(var(--sh) * .42); }
.who { position: relative; flex: none; width: calc(var(--sh) * .74); height: calc(var(--sh) * .74); border-radius: 50%; background: #fff; border: 4px solid #d8cfe8; opacity: .62; transition: transform .2s, opacity .2s, border-color .2s; }
.who .face { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 12%; }
.who.on { opacity: 1; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255,201,60,.45); transform: scale(1.12); animation: nudge 1.4s ease-in-out infinite; }
.who.think .face { animation: think .9s ease-in-out infinite; }
.chip { position: absolute; right: -9px; bottom: -6px; width: 48%; height: 48%; } .chip img { width: 100%; height: 100%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); } .chip:empty { display: none; }
.mid { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.label { max-width: 100%; font-size: clamp(15px, 3.2vmin, 26px); line-height: 1.05; text-align: center; white-space: nowrap; }
.extra { display: flex; align-items: center; gap: clamp(3px, .8vmin, 6px); } .extra:empty { display: none; }
.slot { position: relative; width: clamp(19px, 3.9vmin, 32px); height: clamp(19px, 3.9vmin, 32px); opacity: .3; filter: grayscale(1); transition: transform .25s, opacity .25s; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.slot.on { opacity: 1; filter: none; transform: scale(1.15); }
.gate-slot .open, .extra.open .gate-slot .closed { display: none; } .extra.open .gate-slot .open { display: block; } .extra.open .gate-slot { opacity: 1; filter: none; }
@media (max-width: 640px) { .topbar { grid-template-columns: auto auto; grid-template-areas: "l r" "s s"; justify-content: space-between; row-gap: 4px; } .tb-left { grid-area: l; } .tb-right { grid-area: r; } .status { grid-area: s; } }
/* a phone on its side: controls move to a side panel so the board gets the full height */
@media (orientation: landscape) and (max-height: 520px) {
  .game { grid-template-columns: minmax(176px, 30%) 1fr; grid-template-rows: auto 1fr; column-gap: 8px; }
  .topbar { grid-column: 1; grid-row: 1; grid-template-columns: auto auto; grid-template-areas: "l r" "s s"; justify-content: space-between; row-gap: 4px; } .tb-left { grid-area: l; } .tb-right { grid-area: r; } .status { grid-area: s; }
  .game .opts { grid-column: 1; grid-row: 2; align-content: start; } .opt-group { flex-wrap: wrap; justify-content: center; border-radius: 24px; }
  .field { grid-column: 2; grid-row: 1 / span 2; }
  .label { white-space: normal; font-size: 13px; }
  .opt-tools { flex-wrap: wrap; justify-content: center; } .lvl-badge { order: 0; font-size: 14px; } #lvl-prev { order: 1; } #lvl-next { order: 2; }
}
.opts { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px 12px; min-height: 0; }
.opts:empty { display: none; }
.opt-group { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
@media (max-width: 360px) { .opt { padding: 0 calc(var(--oh) * .26) !important; font-size: 11px !important; } .opt-pic { height: 50% !important; } }
.opt { --oh: clamp(44px, 7.8vmin, 60px); display: flex; align-items: center; gap: 4px; height: var(--oh); padding: 0 calc(var(--oh) * .36); border-radius: 999px; font-size: clamp(12px, 2.5vmin, 20px); white-space: nowrap;
  border-image: url(../art/ui_pill_off.webp) 0 92 fill / 0 calc(var(--oh) * .5) stretch; filter: drop-shadow(0 2px 2px rgba(60,30,0,.3)) saturate(.85); opacity: .9; }
.opt.sel { opacity: 1; color: #fff; text-shadow: 0 2px 0 #7a1f6e, 0 0 3px #7a1f6e; border-image-source: url(../art/ui_pill_on.webp); border-image-slice: 0 95 fill; filter: drop-shadow(0 3px 3px rgba(60,30,0,.4)); transform: scale(1.04); }
.opt-pic { height: 60%; width: auto; aspect-ratio: 1; object-fit: cover; object-position: 50% 12%; border-radius: 50%; }
.opt-pic[src*="star"], .opt-pic[src*="card_back"] { border-radius: 0; object-fit: contain; aspect-ratio: auto; width: auto; }
.opt-tools { display: flex; } .opt-tools:empty { display: none; }
.field { position: relative; min-height: 0; min-width: 0; display: grid; place-items: center; overflow: hidden; }

/* ---------- Connect 4 ---------- */
/* The painted frame is 7.881 cells wide and 6.998 tall; its first hole centre sits 0.936 / 0.932 of a cell in.
   Discs sit under the frame and show through its holes. The top cell-high strip is where a disc waits to drop. */
.c4 { --u: 60px; position: relative; width: calc(var(--u) * 7.881); height: calc(var(--u) * 8); }
.c4-board { position: absolute; left: calc(var(--u) * .436); top: calc(var(--u) * 1.432); width: calc(var(--u) * 7); height: calc(var(--u) * 6); display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr); }
.c4-frame { position: absolute; left: 0; top: var(--u); width: 100%; height: calc(var(--u) * 6.998); z-index: 2; filter: drop-shadow(0 calc(var(--u) * .1) calc(var(--u) * .08) rgba(20,30,90,.4)); }
.c4-cell { position: relative; }
.hole { position: absolute; inset: 11%; border-radius: 50%; background: rgba(18,40,120,.3); box-shadow: inset 0 3px 5px rgba(0,0,40,.35); }
.disc { position: absolute; left: 6%; top: 6%; width: 88%; height: 88%; object-fit: contain; z-index: 1; animation: fall .3s cubic-bezier(.45,0,.9,.55) both; }
@keyframes fall { from { transform: translateY(calc(var(--fall) * -113.6% - 30%)); } to { transform: none; } }
.c4-cell.win .disc { animation: winpulse .6s ease-in-out infinite alternate; }
.c4-cell.win::after { content: ""; position: absolute; inset: 4%; z-index: 3; border-radius: 50%; border: calc(var(--u) * .09) solid #fff; box-shadow: 0 0 calc(var(--u) * .25) calc(var(--u) * .08) #fff3a8, inset 0 0 calc(var(--u) * .12) #fff3a8; }
.c4-cols { position: absolute; left: calc(var(--u) * .436); top: 0; width: calc(var(--u) * 7); height: 100%; z-index: 4; display: grid; grid-template-columns: repeat(7, 1fr); }
.c4-col { border-radius: calc(var(--u) * .4); }
.c4-col:not(:disabled):hover { background: rgba(255,255,255,.22); }
.drop-mark { position: absolute; left: 50%; top: calc(var(--u) * .14); width: calc(var(--u) * .7); height: calc(var(--u) * .7); margin-left: calc(var(--u) * -.35); opacity: .55; animation: bob 1.1s ease-in-out infinite alternate; }
.drop-mark img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.c4[data-turn="heart"] .pm.star, .c4[data-turn="star"] .pm.heart { display: none; }
.c4-col:hover .drop-mark, .c4-col:focus .drop-mark { opacity: 1; }
.c4.busy .drop-mark { opacity: .18; animation: none; }
.c4-col.full { background: rgba(43,35,80,.22); }
.c4-col.full .drop-mark { display: none; }
.c4-col.full::after { content: ""; position: absolute; left: 50%; top: calc(var(--u) * .1); width: calc(var(--u) * .8); height: calc(var(--u) * .8); margin-left: calc(var(--u) * -.4); background: url(../art/lock.webp) center / contain no-repeat; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }

/* ---------- Tic-Tac-Toe ---------- */
/* the painted wooden tray: nine pockets, each 24.6% of the tray, starting 8% in, 28.6% apart */
.t3 { --u: 120px; position: relative; width: calc(var(--u) * 3.36); height: calc(var(--u) * 3.36); background: url(../art/t3_tray.webp) center / 100% 100% no-repeat; filter: drop-shadow(0 calc(var(--u) * .08) calc(var(--u) * .07) rgba(60,30,0,.4)); }
.t3-sq { position: absolute; left: calc(8% + var(--c) * 28.6%); top: calc(8.1% + var(--r) * 28.75%); width: 24.6%; height: 24.6%; display: grid; place-items: center; border-radius: 12%; }
.t3-sq:not(:disabled):hover { background: rgba(255,255,255,.28); }
.piece { width: 84%; height: 84%; object-fit: contain; animation: pop .25s ease-out; filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.t3-sq.win { background: rgba(255,255,255,.35); box-shadow: 0 0 0 calc(var(--u) * .05) #fff, 0 0 calc(var(--u) * .22) calc(var(--u) * .07) #fff3a8; z-index: 1; }
.t3-sq.win .piece { animation: winpulse .6s ease-in-out infinite alternate; }

/* ---------- Memory Match ---------- */
.mm { --u: 100px; --cols: 4; display: grid; grid-template-columns: repeat(var(--cols), var(--u)); gap: calc(var(--u) * .09); }
.mcard { width: var(--u); height: calc(var(--u) * 1.3); perspective: 700px; border-radius: calc(var(--u) * .13); }
.flipper { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .34s ease; }
.mcard.up .flipper { transform: rotateY(180deg); }
.side { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; border-radius: calc(var(--u) * .13); -webkit-backface-visibility: hidden; backface-visibility: hidden; box-shadow: 0 4px 0 rgba(43,35,80,.25); }
.side.back { box-shadow: none; filter: drop-shadow(0 4px 2px rgba(43,35,80,.3)); } .side.back img { width: 100%; height: 100%; object-fit: fill; }
.side.front { transform: rotateY(180deg); background: url(../art/card_front.webp) center / 100% 100% no-repeat; box-shadow: none; filter: drop-shadow(0 4px 2px rgba(43,35,80,.3)); }
.side.front img { width: 70%; height: 70%; object-fit: contain; }
.mcard.matched .side.front { filter: drop-shadow(0 0 calc(var(--u) * .08) #fff3a8) drop-shadow(0 0 calc(var(--u) * .05) #ffd45e); }
.pawpop { position: absolute; right: -7%; top: -6%; width: 40%; z-index: 2; animation: pop .4s ease-out; filter: drop-shadow(0 2px 1px rgba(0,0,0,.3)); }

.tally { font-size: clamp(14px, 3vmin, 22px); white-space: nowrap; }
.opt-tools { align-items: center; gap: clamp(6px, 1.6vmin, 12px); }
.lvl-arrow { width: clamp(44px, 8vmin, 62px); height: clamp(44px, 8vmin, 62px); } .lvl-arrow:disabled { opacity: .3; filter: grayscale(1); }
.lvl-badge { --oh: clamp(46px, 8.4vmin, 64px); display: flex; align-items: center; gap: clamp(6px, 1.6vmin, 12px); height: var(--oh); padding: 0 calc(var(--oh) * .42); white-space: nowrap; color: #fff; text-shadow: 0 2px 0 #7a1f6e, 0 0 3px #7a1f6e;
  font-size: clamp(15px, 3.2vmin, 25px); border-image: url(../art/ui_pill_on.webp) 0 95 fill / 0 calc(var(--oh) * .5) stretch; filter: drop-shadow(0 3px 3px rgba(60,30,0,.4)); }
.lvl-cards { display: flex; align-items: center; gap: 3px; } .lvl-cards img { height: calc(var(--oh) * .52); width: auto; }

/* ---------- Garden Maze ---------- */
.gm { --u: 80px; position: relative; margin-top: calc(var(--u) * .45); display: grid; grid-template-columns: repeat(var(--cols), var(--u)); grid-template-rows: repeat(var(--rows), var(--u)); border-radius: calc(var(--u) * .2); background: rgba(46,120,40,.55); box-shadow: 0 0 0 calc(var(--u) * .1) rgba(46,120,40,.55), 0 calc(var(--u) * .16) calc(var(--u) * .22) rgba(20,60,10,.4); }
.gt { position: relative; width: var(--u); height: var(--u); }
.gt.hedge img { position: absolute; inset: -5%; width: 110%; height: 110%; object-fit: fill; z-index: 1; filter: drop-shadow(0 3px 2px rgba(20,60,10,.4)); }
.gt.path::before { content: ""; position: absolute; inset: 3%; background: url(../art/stone.webp) center / 100% 100% no-repeat; filter: drop-shadow(0 2px 1px rgba(90,70,20,.45)); }
.gt.path:hover::before { filter: drop-shadow(0 2px 1px rgba(90,70,20,.45)) brightness(1.07); }
.gstar { position: absolute; left: 15%; top: 15%; width: 70%; height: 70%; object-fit: contain; z-index: 1; animation: bob 1s ease-in-out infinite alternate; filter: drop-shadow(0 2px 2px rgba(120,80,0,.4)); }
.gstar.taken { animation: take .5s ease-in forwards; }
.gimg { position: absolute; left: -12%; top: -22%; width: 124%; height: 124%; object-fit: contain; z-index: 2; filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.gate .open, .gm.open .gate .closed { display: none; } .gm.open .gate .open { display: block; animation: pop .4s ease-out; }
.gt.hint::after { content: ""; position: absolute; inset: 5%; z-index: 2; border-radius: 26%; border: calc(var(--u) * .08) solid #fff; box-shadow: 0 0 calc(var(--u) * .22) calc(var(--u) * .08) var(--gold); animation: winpulse .5s ease-in-out infinite alternate; }
.hero { position: absolute; left: 0; top: 0; width: var(--u); height: var(--u); z-index: 4; pointer-events: none; transition: transform .16s linear; }
.hero-img { position: absolute; left: 50%; bottom: 10%; height: 138%; width: auto; max-width: none; margin: 0; transform: translateX(-50%); filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.hero.yay .hero-img { animation: hop .4s ease-out 2; }
.hero.bump .hero-img { animation: shake .25s; }

/* ---------- Royal Kitchen ---------- */
/* The kitchen painting is anchored bottom centre. Its counter (back edge --ct, depth --dp) is drawn a second time on top
   of the guest and Elise, so they stand behind it. Sizes come from layout() in kitchen.js. */
.kt { --tb: clamp(54px, 11vmin, 92px); width: min(100%, 940px); height: 100%; display: grid; grid-template-rows: 1fr auto; gap: clamp(6px, 1.4vmin, 12px); padding: 7px 7px 2px; }
.kt-scene, .kt-counter { background: #f3d6ae url(../art/bg_kitchen.webp) var(--bp, 50% 100%) / var(--bs, cover) no-repeat; }
.kt-scene { position: relative; min-height: 0; overflow: hidden; border-radius: 20px; box-shadow: 0 0 0 3px #fff3c4, 0 0 0 7px #e2a52c, 0 8px 14px rgba(60,30,0,.35); }
.kt-counter { position: absolute; inset: 0; z-index: 3; clip-path: inset(var(--ct) 0 0 0); pointer-events: none; }
.kt-elise { position: absolute; left: 2%; top: calc(var(--ct) - var(--eh) * .58); height: var(--eh); width: auto; max-width: none; z-index: 2; filter: drop-shadow(0 3px 3px rgba(60,30,0,.3)); }
.kt-guest { position: absolute; right: 3%; top: calc(var(--ct) - var(--gh) * .93); height: var(--gh); width: auto; max-width: none; z-index: 2; transform-origin: 50% 100%; filter: drop-shadow(0 3px 3px rgba(60,30,0,.3)); }
.kt-guest.in { animation: ktin .5s ease-out; } .kt-guest.munch { animation: ktmunch .3s ease-in-out infinite; } .kt-guest.react { animation: ktreact .5s ease-out; }
.kt-bubble { position: absolute; z-index: 2; right: calc(3% + var(--gh) * .78); top: 2%; width: min(calc(var(--gh) * .86), 34%); aspect-ratio: 465 / 399; opacity: 0; transform: scale(.4); transform-origin: 100% 100%; transition: opacity .25s, transform .25s; }
.kt-bubble.on { opacity: 1; transform: none; }
.kt-bubble .bub { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); filter: drop-shadow(0 3px 3px rgba(60,30,0,.3)); }
.kt-want { position: absolute; left: 12%; right: 14%; top: 10%; height: 56%; display: flex; align-items: center; justify-content: center; gap: 4%; }
.kt-want .w-dish { height: 100%; width: 56%; object-fit: contain; } .kt-want .w-top { height: 70%; width: 36%; object-fit: contain; }
.kt-dish { position: absolute; z-index: 4; left: calc(50% - var(--dw) / 2); top: calc(var(--ct) + var(--dp) * .78 - var(--dw)); width: var(--dw); height: var(--dw); transition: transform .6s ease-in, opacity .6s ease-in; filter: drop-shadow(0 calc(var(--dw) * .04) calc(var(--dw) * .03) rgba(60,30,0,.4)); }
.kt-dish.pop { animation: pop .3s ease-out; } .kt-dish.serving { opacity: .2; }
.kt-dish-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; }
.kt-tops { position: absolute; inset: 0; }
.kt-top { position: absolute; object-fit: contain; transform: rotate(var(--rot)); animation: ktdrop .3s ease-out; filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); }
.kt-dish[data-on="cupcake"] .kt-tops, .kt-dish[data-on="sundae"] .kt-tops, .kt-dish[data-on="soup"] .kt-tops { left: 9%; right: 9%; }
.kt-tool { position: absolute; z-index: 5; left: calc(50% - var(--dw) * .8); top: calc(var(--ct) + var(--dp) * .85 - var(--dw) * 1.75); width: calc(var(--dw) * 1.6); height: calc(var(--dw) * 1.75); object-fit: contain; object-position: 50% 100%; opacity: 0; transform: scale(.3); transform-origin: 50% 100%; transition: opacity .2s, transform .25s; pointer-events: none; filter: drop-shadow(0 6px 5px rgba(60,30,0,.4)); }
.kt-tool.on { opacity: 1; transform: none; animation: ktcook .28s ease-in-out .25s infinite; }
.kt-fx { position: absolute; z-index: 6; pointer-events: none; }
.kt-p { position: absolute; width: 26%; height: auto; animation: ktfloat 1.5s ease-out both; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.kt-tray { display: grid; grid-template-columns: repeat(5, var(--tb)); grid-auto-rows: var(--tb); gap: clamp(4px, 1vmin, 8px); justify-self: center; width: max-content; }
.kt-tray[data-phase="pick"] { grid-template-columns: repeat(4, calc(var(--tb) * 1.3)); grid-auto-rows: calc(var(--tb) * 2 + clamp(4px, 1vmin, 8px)); }
.kt-btn { --bw: calc(var(--tb) * .16); border: var(--bw) solid transparent; border-image: url(../art/ui_panel.webp) 96 fill / var(--bw) stretch; border-radius: calc(var(--tb) * .2); filter: drop-shadow(0 3px 3px rgba(60,30,0,.35)); transition: transform .1s; min-width: 0; min-height: 0; }
.kt-btn img { position: absolute; inset: 2%; width: 96%; height: 96%; object-fit: contain; }
.kt-btn:active { transform: scale(.92); } .kt-btn:disabled { opacity: .45; filter: grayscale(.6); }
.kt-btn.want::after, .kt-btn.pulse::after { content: ""; position: absolute; inset: calc(var(--bw) * -1.1); border-radius: calc(var(--tb) * .26); border: 4px solid #fff; box-shadow: 0 0 calc(var(--tb) * .22) calc(var(--tb) * .05) var(--gold); animation: winpulse .6s ease-in-out infinite alternate; pointer-events: none; }
.kt-bookbtn { display: flex; align-items: center; gap: 6px; height: clamp(46px, 8.4vmin, 64px); padding: 0 calc(clamp(46px, 8.4vmin, 64px) * .4) 0 calc(clamp(46px, 8.4vmin, 64px) * .2); white-space: nowrap; color: #fff; text-shadow: 0 2px 0 #7a1f6e, 0 0 3px #7a1f6e; font-size: clamp(15px, 3.2vmin, 24px);
  border-image: url(../art/ui_pill_on.webp) 0 95 fill / 0 calc(clamp(46px, 8.4vmin, 64px) * .5) stretch; filter: drop-shadow(0 3px 3px rgba(60,30,0,.4)); }
.kt-bookbtn img { height: 84%; width: auto; } .kt-bookbtn.new { animation: ktnew .5s ease-in-out 2; }
.overlay.kt-book { position: fixed; z-index: 30; }
.kt-book .card { width: min(96%, 620px); max-height: 96%; }
.kt-book h2 { font-size: clamp(18px, 4vmin, 30px); }
.kt-stickers { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(3px, 1vmin, 8px); width: min(100%, calc((100vh - 250px) * 1.4)); min-width: 200px; }
@media (orientation: landscape) and (max-height: 520px) { .kt-stickers { grid-template-columns: repeat(12, minmax(0, 1fr)); width: min(100%, calc((100vh - 190px) * 4)); } }
.kt-sticker { aspect-ratio: 1; border-radius: 22%; background: rgba(120,80,20,.1); box-shadow: inset 0 0 0 2px rgba(180,130,40,.35); display: grid; place-items: center; }
.kt-sticker img { width: 84%; height: 84%; object-fit: contain; filter: brightness(0); opacity: .16; }
.kt-sticker.got { background: #fff; box-shadow: inset 0 0 0 2px var(--gold), 0 2px 3px rgba(60,30,0,.25); } .kt-sticker.got img { filter: none; opacity: 1; }
@keyframes ktin { from { transform: translateX(120%); } to { transform: none; } }
@keyframes ktmunch { 50% { transform: scale(1.05, .95); } }
@keyframes ktreact { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: none; } }
@keyframes ktdrop { from { transform: translateY(-60%) rotate(var(--rot)) scale(1.3); opacity: 0; } to { transform: rotate(var(--rot)); opacity: 1; } }
@keyframes ktcook { 50% { transform: rotate(-3deg) scale(1.03); } }
@keyframes ktfloat { 0% { transform: translate(0, 40%) scale(.4); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(var(--dx), -150%) scale(1.1); opacity: 0; } }
@keyframes ktnew { 50% { transform: scale(1.18) rotate(-4deg); } }
.rm .kt-p { opacity: 1; }

.demo-stage .kt { --tb: clamp(34px, 6.4vmin, 46px); padding: 5px; }

/* ---------- overlays: end card and demo ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 10px; background: rgba(43,35,80,.55); }
.card { --bw: clamp(30px, 6.4vmin, 50px); position: relative; display: grid; justify-items: center; gap: clamp(4px, 1.2vmin, 10px); max-width: min(96%, 600px); max-height: 100%; padding: clamp(2px, 1vmin, 8px) clamp(2px, 1.4vmin, 14px); border-radius: var(--bw);
  border: var(--bw) solid transparent; border-image: url(../art/ui_panel.webp) 96 fill / var(--bw) stretch; filter: drop-shadow(0 10px 14px rgba(0,0,0,.4)); animation: pop .3s ease-out; }
.card::before { content: ""; position: absolute; left: 50%; top: calc(var(--bw) * -1.62); width: calc(var(--bw) * 2.6); height: calc(var(--bw) * 1.2); transform: translateX(-50%); background: url(../art/ui_crown.webp) center bottom / contain no-repeat; pointer-events: none; }
.overlay .card { margin-top: calc(var(--bw) * .6); }
.card .pose { height: clamp(96px, 30vh, 250px); width: auto; filter: drop-shadow(0 5px 4px rgba(60,30,0,.3)); }
.card h2 { margin: 0; font-size: clamp(22px, 5.2vmin, 42px); line-height: 1.1; text-align: center; }
.icons { display: flex; gap: 6px; } .icons img { width: clamp(26px, 6vmin, 46px); height: clamp(26px, 6vmin, 46px); }
.row { display: flex; gap: clamp(14px, 4.5vmin, 40px); }
.big { display: grid; justify-items: center; gap: 2px; padding: 4px; border-radius: 22px; font-size: clamp(14px, 2.8vmin, 21px); transition: transform .1s; }
.big:active { transform: scale(.93); }
.big img { width: clamp(70px, 16vmin, 116px); height: clamp(70px, 16vmin, 116px); object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0,0,0,.3)); }
.confetti { position: absolute; inset: calc(var(--bw) * -.6); overflow: hidden; border-radius: inherit; pointer-events: none; }
.confetti i { position: absolute; top: -14px; width: 10px; height: 15px; border-radius: 3px; animation: conf 1.5s ease-in forwards; }
.demo-card { width: min(96%, 560px); }
.demo-wrap { position: relative; width: 100%; }
.demo-stage { width: 100%; height: min(48vh, 360px); border-radius: 20px; pointer-events: none; background: #f1d2a4 url(../art/bg_playroom.webp) center / cover; }
.g-maze .demo-stage { background: #8fcf6a url(../art/bg_garden.webp) center / cover; }
.demo-hand { position: absolute; left: 0; top: 0; z-index: 8; width: clamp(40px, 9vmin, 64px); height: auto; translate: -42% -4%; opacity: 0; transition: transform .6s ease, opacity .25s, scale .12s; filter: drop-shadow(0 4px 3px rgba(0,0,0,.4)); }
.demo-hand.press { scale: .82; }

@keyframes pop { from { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.08); } to { transform: none; opacity: 1; } }
@keyframes winpulse { from { transform: scale(.94); } to { transform: scale(1.06); } }
@keyframes bob { from { transform: translateY(-6%); } to { transform: translateY(8%); } }
@keyframes take { to { transform: translateY(-120%) scale(.2); opacity: 0; } }
@keyframes hop { 50% { transform: translateY(-14%); } }
@keyframes shake { 25% { transform: translateX(-5%); } 75% { transform: translateX(5%); } }
@keyframes nudge { 50% { transform: scale(1.2); } }
@keyframes think { 50% { transform: rotate(-9deg); } }
@keyframes sway { from { transform: rotate(-1.5deg); } to { transform: rotate(1.5deg); } }
@keyframes conf { to { transform: translate(var(--dx), 460px) rotate(var(--rot)); opacity: 0; } }
.hero.yay .hero-img, .hero.bump .hero-img { --tx: -50%; }
@keyframes hophero { 50% { transform: translate(-50%, -14%); } }
@keyframes shakehero { 25% { transform: translateX(-58%); } 75% { transform: translateX(-42%); } }
.hero.yay .hero-img { animation-name: hophero; } .hero.bump .hero-img { animation-name: shakehero; }

/* reduced motion: no looping or travelling animation; state changes are still shown (rings, glows, pictures) */
.rm *, .rm *::before, .rm *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
