/* Fizz's Fraction Factory — fractions (build / name / compare) for ages 7–8.
   Art direction: a warm, sunny pizza kitchen — cream tiles, kraft-paper order
   tickets, a conveyor belt, cheese-and-dough shapes. Deliberately NOT the dark
   space look of the other 7–8 game, but the same structure and quality bar.
   Type is Mulish (var(--gk-sans)) — older kids find Comic Sans insulting. */

:root{
    --ff-ink:#4A2A18;  --ff-dim:#8B6749;
    --ff-card:#FFFDF6; --ff-edge:#EBD2A9; --ff-edge-2:#D6AC72;
    --ff-tomato:#E04E2A; --ff-cheese:#F0A32E; --ff-cheese-lt:#FFD070;
    --ff-crust:#DFA85E; --ff-dough:#FDEDCE; --ff-pep:#CE382C;
    --ff-basil:#33864A; --ff-jam:#C4406F; --ff-plum:#7B4A8F;
    --ff-sans:"Mulish", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --ff-shadow:0 10px 24px rgba(120,70,30,.16);
}

body{
    font-family:var(--ff-sans);
    color:var(--ff-ink);
    background:radial-gradient(135% 95% at 50% -14%, #FFF9EC 0%, #FFEBCD 46%, #F4D5A6 100%);
    overflow:hidden;
    -webkit-font-smoothing:antialiased;
}
.screen{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }
#screen-play{ flex-direction:column; justify-content:flex-start; }
/* scroll-safe centring (same trick as the order board): margin-block:auto
   centres the panel when it fits and lets a short screen scroll instead of
   pushing the play button off the bottom edge */
#screen-start{ align-items:flex-start; overflow-y:auto; }
.start-inner{ margin-block:auto; }

/* kitchen tiles + drifting snacks (background only) */
.tile-bg{
    position:absolute; inset:0; z-index:0; pointer-events:none; opacity:.5;
    background-image:
        repeating-linear-gradient(90deg, rgba(255,255,255,.85) 0 2px, transparent 2px 48px),
        repeating-linear-gradient(0deg,  rgba(255,255,255,.85) 0 2px, transparent 2px 48px);
    -webkit-mask-image:linear-gradient(180deg, rgba(0,0,0,.95), rgba(0,0,0,.08));
    mask-image:linear-gradient(180deg, rgba(0,0,0,.95), rgba(0,0,0,.08));
}
.floaties{ position:absolute; inset:0; z-index:0; pointer-events:none; overflow:hidden; }
.floaties span{ position:absolute; font-size:2.1rem; opacity:.15; animation:drift 17s linear infinite; }
.floaties span:nth-child(1){ left:6%;  top:78%; animation-delay:0s }
.floaties span:nth-child(2){ left:26%; top:88%; animation-delay:-4s }
.floaties span:nth-child(3){ left:52%; top:82%; animation-delay:-8s }
.floaties span:nth-child(4){ left:74%; top:90%; animation-delay:-12s }
.floaties span:nth-child(5){ left:90%; top:76%; animation-delay:-15s }
@keyframes drift{
    0%{ transform:translateY(0) rotate(0) }
    100%{ transform:translateY(-118vh) rotate(38deg) }
}

/* ── START ─────────────────────────────────────────────────────────────── */
.start-inner{ position:relative; z-index:1; text-align:center; padding:24px; max-width:540px; }
#start-pizza{
    font-size:5.2rem; line-height:1; filter:drop-shadow(0 12px 18px rgba(150,90,30,.32));
    animation:spin-slice 9s linear infinite;
}
@keyframes spin-slice{ from{transform:rotate(-8deg)} 50%{transform:rotate(8deg) translateY(-8px)} to{transform:rotate(-8deg)} }
.game-title{
    font-weight:900; font-size:clamp(2rem,7vw,3.3rem); line-height:1.02; letter-spacing:-.015em;
    margin:.12em 0 .1em; color:var(--ff-ink); text-shadow:0 2px 0 rgba(255,255,255,.6);
}
.ff-accent{ color:var(--ff-tomato); }
.tagline{ color:var(--ff-dim); font-size:clamp(1rem,3vw,1.2rem); font-weight:800; margin:.25em 0 1em; }
.star-chip{
    display:inline-block; background:rgba(240,163,46,.16); border:2px solid rgba(224,78,42,.35);
    color:#A9541A; font-weight:900; border-radius:999px; padding:6px 16px; margin-bottom:20px;
}
/* keep the chip and the play button on their own lines (both are inline-block) */
#screen-start .gk-btn{ display:block; margin:0 auto; }
.gk-btn.gk-go{
    background:linear-gradient(135deg,#F4692F,#F7B93B); color:#48200A;
    box-shadow:0 6px 18px rgba(200,110,40,.42);
}
.info-btn{
    position:fixed; right:12px; bottom:12px; z-index:6; width:52px; height:52px; border-radius:50%;
    border:2px solid var(--ff-edge); background:rgba(255,253,246,.94); font-size:1.4rem; cursor:pointer;
    box-shadow:0 5px 14px rgba(120,70,30,.22);
}
.info-btn:active{ transform:scale(.94); }
.corner-btn{
    position:fixed; top:12px; left:12px; z-index:6; border:2px solid var(--ff-edge-2);
    background:rgba(255,253,246,.92); color:var(--ff-ink); font-family:inherit; font-weight:900;
    border-radius:14px; padding:9px 15px; cursor:pointer; box-shadow:0 4px 12px rgba(120,70,30,.18);
}
.corner-btn:active{ transform:scale(.95); }

/* ── ORDER BOARD ───────────────────────────────────────────────────────── */
/* scroll-safe centering: margin-block:auto centres the board when it fits and
   still lets a short screen scroll instead of clipping the bottom row */
#screen-levels{ align-items:flex-start; overflow-y:auto; }
.levels-inner{ position:relative; z-index:1; width:100%; max-width:800px; padding:70px 18px 84px;
    text-align:center; margin-block:auto; }
.levels-heading{ font-weight:900; font-size:clamp(1.45rem,5vw,2.1rem); margin:0; }
.levels-sub{ color:var(--ff-dim); font-weight:700; margin:6px 0 18px; font-size:clamp(.9rem,2.6vw,1.05rem); }
#level-cards{ display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:13px; }
.station-card{
    position:relative; background:linear-gradient(180deg,#FFFDF6,#FFF3DC);
    border:2.5px solid var(--ff-edge-2); border-radius:20px; padding:14px 10px 12px; cursor:pointer;
    color:var(--ff-ink); font-family:inherit; text-align:center;
    box-shadow:0 7px 0 rgba(214,172,114,.45), var(--ff-shadow);
    transition:transform .12s ease, box-shadow .12s ease, border-color .12s;
}
.station-card:hover{ transform:translateY(-3px); border-color:var(--ff-tomato); }
.station-card:active{ transform:translateY(2px); box-shadow:0 2px 0 rgba(214,172,114,.45); }
.station-card .st-shape{ display:flex; align-items:center; justify-content:center; gap:7px; height:104px; }
.station-card .st-shape .frac-svg{ max-height:100%; }
.station-card .st-frac{ font-weight:900; font-size:1.05rem; color:var(--ff-tomato); }
.station-card .st-name{ display:block; font-weight:900; font-size:1rem; margin-top:6px; line-height:1.15;
    min-height:2.3em; }
.station-card .st-sub{ display:block; font-size:.72rem; color:var(--ff-dim); font-weight:800; letter-spacing:.03em; text-transform:uppercase; margin-top:2px; }
.station-card .st-stars{ display:block; margin-top:7px; font-size:.9rem; letter-spacing:2px; color:#D98A18; min-height:1.1em; }
.station-card .st-best{ display:block; font-size:.7rem; color:var(--ff-dim); font-weight:800; min-height:1em; }
.station-card.hot{ border-color:var(--ff-tomato); background:linear-gradient(180deg,#FFF6E6,#FFE6C9); }

/* ── PLAY ──────────────────────────────────────────────────────────────── */
/* a soft pool of kitchen light on the play wall (no objects — nothing can
   ever collide with the shapes) */
#screen-play .tile-bg{
    background-image:
        radial-gradient(72% 38% at 50% 0%, rgba(255,255,255,.5), rgba(255,255,255,0) 72%),
        repeating-linear-gradient(90deg, rgba(255,255,255,.85) 0 2px, transparent 2px 48px),
        repeating-linear-gradient(0deg,  rgba(255,255,255,.85) 0 2px, transparent 2px 48px);
}
/* margin-top is the HUD clearance token, not the 76px that used to sit here — and
   not the 70px the phone rule below had drifted to for the same job. Both cleared
   the HUD by a couple of pixels on the one screen they were measured on and knew
   nothing about a fourth pill or a notch. */
#play-top{
    position:relative; z-index:2; width:100%; max-width:780px;
    display:flex; align-items:center; justify-content:space-between; gap:8px;
    padding:0 14px 4px; margin-top:var(--gk-hud-clear-top); flex-wrap:wrap;
}
.pill{
    background:rgba(255,253,246,.94); border:2px solid var(--ff-edge-2); border-radius:999px;
    padding:5px 13px; font-weight:900; font-size:.9rem; color:var(--ff-ink); white-space:nowrap;
    box-shadow:0 3px 8px rgba(120,70,30,.12);
}
.score-pill{ border-color:rgba(51,134,74,.5); color:#2C6E3F; }
.streak-pill{ border-color:rgba(224,78,42,.5); color:#C0451F; }
#progress-dots{ display:flex; gap:5px; flex-wrap:wrap; justify-content:center; flex:1; min-width:96px; }
#progress-dots span{
    width:11px; height:11px; border-radius:50%; background:rgba(140,100,60,.22);
    border:1.5px solid rgba(140,100,60,.18); transition:background .2s, transform .2s;
}
#progress-dots span.done{ background:var(--ff-basil); border-color:var(--ff-basil); }
#progress-dots span.miss{ background:var(--ff-cheese); border-color:#C98716; }
#progress-dots span.now{ background:var(--ff-tomato); border-color:#A93A18; transform:scale(1.35); }

#play-stage{
    position:relative; z-index:1; width:100%; max-width:700px; flex:1; min-height:0;
    display:flex; flex-direction:column; gap:8px; padding:6px 14px 14px;
}

/* order ticket */
#ticket{
    display:flex; align-items:center; gap:10px; flex:none;
    background:
        linear-gradient(180deg,#FFFEFA,#FFF6E4);
    border:2px solid var(--ff-edge); border-left:7px solid var(--ff-tomato);
    border-radius:6px 16px 16px 6px; padding:9px 12px; box-shadow:var(--ff-shadow);
}
#ticket-side{ font-size:1.6rem; line-height:1; flex:none; }
#ticket-body{ flex:1; min-width:0; text-align:left; }
#ticket-text{ font-weight:900; font-size:clamp(1rem,3.6vw,1.22rem); line-height:1.15; }
#ticket-sub{ font-weight:700; font-size:.8rem; color:var(--ff-dim); margin-top:2px; }

/* the fraction "stacked" display */
.frac{ display:inline-flex; flex-direction:column; align-items:center; line-height:1; font-weight:900; color:var(--ff-tomato); }
.frac .fbar{ display:block; height:4px; width:1.5em; background:currentColor; border-radius:3px; margin:3px 0; }
.frac.big{ font-size:clamp(1.5rem,6vw,2.1rem); flex:none; }
.frac.big .fnum, .frac.big .fden{ font-variant-numeric:tabular-nums; }

/* shapes */
/* overflow:hidden keeps the "ride in from the belt" slide and the win pulse
   from ever poking outside the viewport (no stray horizontal scroll). */
#shape-area{ position:relative; flex:4 1 0; min-height:112px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
/* shapes sit ON the belt (bottom-aligned), so spare height is calm air under
   the order ticket instead of an odd gap above the conveyor */
#shape-main, #reveal{ width:100%; height:100%; display:flex; align-items:flex-end; justify-content:center; gap:10px; }
#shape-main.arrive{ animation:ride-in .42s cubic-bezier(.2,.9,.3,1.1); }
@keyframes ride-in{ from{ transform:translateX(38px); opacity:0 } to{ transform:translateX(0); opacity:1 } }

/* 96% leaves headroom for the win pulse so it never clips */
.frac-svg{ max-width:96%; max-height:96%; width:auto; height:auto; display:block;
    filter:drop-shadow(0 6px 10px rgba(120,70,30,.2)); }
.frac-svg .crust{ fill:var(--ff-crust); }
.frac-svg .dough, .frac-svg .seg{ fill:var(--ff-dough); }
.frac-svg .tray{ fill:var(--ff-crust); }
.frac-svg .cell{ fill:var(--ff-dough); }
.frac-svg .rim{ fill:none; stroke:rgba(150,95,40,.55); stroke-width:1.4; }
.frac-svg .cuts{ stroke:rgba(160,105,50,.5); stroke-width:1.1; pointer-events:none; }
.frac-svg .pep{ fill:var(--ff-pep); opacity:0; pointer-events:none; }
.frac-svg .slice .seg{ transition:fill .2s ease; }
.frac-svg .slice.on .seg{ fill:var(--ff-cheese); }
.frac-svg .slice.on .pep{ opacity:1; }
.frac-svg.bar .slice.on .cell{ fill:var(--ff-jam); }
/* shading animates in — staggered, from the slice outward */
.frac-svg.pizza .slice.on{ animation:slice-in .34s cubic-bezier(.2,1.5,.4,1) backwards;
    transform-box:view-box; transform-origin:50px 50px; }
@keyframes slice-in{ 0%{ opacity:0; transform:scale(.45) } 100%{ opacity:1; transform:scale(1) } }
.frac-svg.bar .slice.on{ animation:cell-in .3s ease backwards; transform-box:fill-box; transform-origin:left center; }
@keyframes cell-in{ 0%{ opacity:.2; transform:scaleX(.05) } 100%{ opacity:1; transform:scaleX(1) } }

/* tappable (BUILD) */
.frac-svg.tappable .slice{ cursor:pointer; }
.frac-svg.tappable .slice:hover .seg{ fill:var(--ff-cheese-lt); }
.frac-svg.tappable .slice.on:hover .seg{ fill:#E5931F; }
.frac-svg.tappable.bar .slice:hover .cell{ fill:#F0BBD0; }
.frac-svg.tappable.bar .slice.on:hover .cell{ fill:#B03761; }
.frac-svg.good{ animation:shape-yay .5s ease; }
@keyframes shape-yay{ 0%,100%{ transform:scale(1) } 45%{ transform:scale(1.04) } }

/* compare pair */
.pair{ display:flex; gap:10px; width:100%; height:100%; align-items:stretch; justify-content:center; }
.cmp-card{
    flex:1 1 0; min-width:0; max-height:100%;
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
    background:rgba(255,253,246,.95); border:2.5px solid var(--ff-edge); border-radius:18px;
    padding:8px 6px; cursor:pointer; font-family:inherit; color:var(--ff-ink);
    transition:border-color .15s, transform .12s, background .15s;
}
.cmp-card:hover{ border-color:var(--ff-tomato); transform:translateY(-2px); }
.cmp-card .cmp-cap{ font-weight:900; font-size:.72rem; letter-spacing:.08em; text-transform:uppercase; color:var(--ff-dim); }
.cmp-card .cmp-label{ font-weight:900; font-size:.95rem; color:var(--ff-tomato); min-height:1.2em; }
.cmp-card.picked{ background:rgba(240,163,46,.16); }
.cmp-card.more{ border-color:var(--ff-basil); background:rgba(51,134,74,.12); }
.cmp-card.tie{ border-color:var(--ff-plum); background:rgba(123,74,143,.1); }
.cmp-card .cmp-badge{ font-size:.72rem; font-weight:900; color:var(--ff-basil); min-height:1em; }
.cmp-card.tie .cmp-badge{ color:var(--ff-plum); }
#shape-main.locked .cmp-card{ cursor:default; }
#shape-main.locked .cmp-card:hover{ transform:none; }

/* miss reveal — child's amount beside the correct amount */
#reveal{ gap:8px; }
.rv-card{
    flex:1 1 0; min-width:0; max-height:100%;
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
    background:rgba(255,253,246,.95); border:2.5px dashed var(--ff-edge-2); border-radius:18px; padding:8px 6px;
}
.rv-card.ok{ border-style:solid; border-color:var(--ff-basil); background:rgba(51,134,74,.1); }
.rv-cap{ font-weight:900; font-size:.72rem; letter-spacing:.06em; text-transform:uppercase; color:var(--ff-dim); }
.rv-frac{ font-weight:900; font-size:1.05rem; color:var(--ff-tomato); }
.rv-card.ok .rv-frac{ color:#25703B; }
.rv-vs{ flex:none; align-self:center; font-weight:900; color:var(--ff-dim); font-size:.85rem; }
/* inside a card the shape must be the part that gives way, so captions and
   fraction labels are never clipped on short screens */
.cmp-card .frac-svg, .rv-card .frac-svg{ min-height:0; }

/* conveyor belt */
#belt{
    position:relative; flex:none; height:20px; border-radius:8px; overflow:hidden;
    background:linear-gradient(180deg,#6C5340,#4A382A); border:2px solid #3A2B20;
    box-shadow:inset 0 2px 4px rgba(0,0,0,.3);
}
#belt .belt-move{
    position:absolute; inset:0;
    background:repeating-linear-gradient(115deg, rgba(255,255,255,.16) 0 8px, rgba(255,255,255,0) 8px 18px);
    animation:belt-roll 1.1s linear infinite;
}
@keyframes belt-roll{ from{ transform:translateX(0) } to{ transform:translateX(-18px) } }
#belt-box{ position:absolute; top:-4px; left:-14%; font-size:1.1rem; opacity:0; }
#belt.shipping #belt-box{ animation:ship 1s ease-in forwards; }
@keyframes ship{ 0%{ left:-14%; opacity:1 } 100%{ left:104%; opacity:1 } }

/* feedback */
/* the feedback band shares the leftover height with the shapes, so spare room
   never piles up as one dead gap */
#feedback{ flex:1 1 auto; min-height:2.5em; display:flex; flex-direction:column; align-items:center;
    justify-content:center; text-align:center; font-weight:900; font-size:clamp(.92rem,3.2vw,1.05rem); line-height:1.25; }
#feedback.good{ color:#25703B; }
#feedback.bad{ color:#B25C0C; }
#feedback .fb-sub{ display:block; font-weight:800; font-size:.86em; color:var(--ff-dim); margin-top:1px; }

/* controls */
#controls{ flex:none; transition:opacity .2s; }
#controls.hushed{ pointer-events:none; opacity:.45; }
.panel{ display:flex; flex-direction:column; gap:8px; }
.count-chip{
    align-self:center; background:rgba(255,253,246,.94); border:2px solid var(--ff-edge-2);
    border-radius:999px; padding:5px 15px; font-weight:900; font-size:.92rem;
}
.count-chip.exact{ border-color:var(--ff-basil); color:#25703B; background:rgba(51,134,74,.1); }
.btn-row{ display:flex; gap:10px; align-items:stretch; justify-content:center; }
.mini-btn{
    flex:none; font-family:inherit; font-weight:900; font-size:.95rem; color:var(--ff-ink);
    background:#FFFDF6; border:2.5px solid var(--ff-edge-2); border-radius:16px; padding:0 16px;
    min-height:56px; cursor:pointer; box-shadow:0 4px 0 rgba(214,172,114,.6);
}
.mini-btn:active{ transform:translateY(3px); box-shadow:0 1px 0 rgba(214,172,114,.6); }
.gk-btn.send-btn{ flex:1; min-height:56px; padding:12px 18px; font-size:clamp(1rem,3.6vw,1.2rem); border-radius:16px; }
#panel-next .gk-btn{ width:100%; min-height:56px; padding:12px 18px; font-size:clamp(1rem,3.6vw,1.2rem); border-radius:16px; }

/* NAME panel */
/* grid keeps the fraction slots dead-centre with the hint beside them */
.name-row{ display:grid; grid-template-columns:1fr auto 1fr; align-items:center; }
.name-row .frac.input{ grid-column:2; }
.name-row .hint{ grid-column:3; justify-self:start; padding-left:12px; }
.frac.input{ color:var(--ff-tomato); }
.frac.input .slot{
    font-family:inherit; font-weight:900; font-size:1.7rem; line-height:1; color:var(--ff-tomato);
    width:2.05em; height:1.5em; min-width:56px; min-height:50px; border-radius:12px; cursor:pointer;
    background:rgba(255,253,246,.95); border:2.5px dashed var(--ff-edge-2);
    display:flex; align-items:center; justify-content:center; font-variant-numeric:tabular-nums;
}
.frac.input .slot.filled{ border-style:solid; border-color:var(--ff-tomato); }
.frac.input .slot.active{ box-shadow:0 0 0 4px rgba(224,78,42,.2); border-color:var(--ff-tomato); }
.frac.input .fbar{ width:2.25em; height:5px; }
.hint{ font-weight:800; font-size:.8rem; color:var(--ff-dim); text-align:left; line-height:1.3; }
#num-keys{ display:grid; grid-template-columns:repeat(4,1fr); gap:7px; }
.key{
    font-family:inherit; font-weight:900; font-size:1.35rem; color:var(--ff-ink);
    background:linear-gradient(180deg,#FFFDF6,#FFF1D9); border:2.5px solid var(--ff-edge-2);
    border-radius:14px; min-height:52px; cursor:pointer; box-shadow:0 4px 0 rgba(214,172,114,.6);
    font-variant-numeric:tabular-nums; transition:background .1s;
}
.key:active{ transform:translateY(3px); box-shadow:0 1px 0 rgba(214,172,114,.6); }
.key.flash{ background:var(--ff-cheese-lt); }
.key.key-del{ font-size:1.2rem; color:var(--ff-dim); }
.key.key-go{
    grid-column:span 3; background:linear-gradient(135deg,#F4692F,#F7B93B); color:#48200A;
    border-color:#C9591F; font-size:1.05rem;
}

/* COMPARE panel */
.cmp-grid{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.cmp-btn{
    font-family:inherit; font-weight:900; font-size:clamp(.86rem,3vw,1rem); color:var(--ff-ink);
    background:linear-gradient(180deg,#FFFDF6,#FFF1D9); border:2.5px solid var(--ff-edge-2);
    border-radius:16px; min-height:56px; padding:8px 6px; cursor:pointer;
    box-shadow:0 4px 0 rgba(214,172,114,.6);
}
.cmp-btn:hover{ border-color:var(--ff-tomato); }
.cmp-btn:active{ transform:translateY(3px); box-shadow:0 1px 0 rgba(214,172,114,.6); }
.cmp-btn.cmp-same{ grid-column:span 2; background:linear-gradient(180deg,#FBF4FF,#F1E4FA); border-color:#C6A6D8; }
.cmp-btn.flash{ background:var(--ff-cheese-lt); }

/* ── celebration: reuse the gamekit overlay, tinted to the kitchen palette ── */
/* on a sideways phone the shared card is taller than the screen; trim its own
   padding and star row here (never in shared/) so nothing is cut off */
@media (max-height:430px){
    .gk-celebrate .gk-celebrate-card{ padding:16px 22px; border-radius:22px; }
    .gk-celebrate .gk-stars{ font-size:1.9rem; margin:2px 0 8px; }
    .gk-celebrate .gk-celebrate-card p{ margin:6px 0; }
}
.gk-celebrate .gk-btn.gk-celebrate-next{
    background:linear-gradient(135deg,#F4692F,#F7B93B); color:#48200A;
    box-shadow:0 6px 18px rgba(200,110,40,.42);
}
.gk-celebrate .gk-btn.gk-secondary{
    background:linear-gradient(135deg,#7B4A8F,#A868BE);
    box-shadow:0 6px 18px rgba(123,74,143,.4);
}

/* ── FOR GROWN-UPS ─────────────────────────────────────────────────────── */
/* align-items:flex-start + margin-block:auto — a flex-CENTRED card taller than
   the overlay overflows in BOTH directions, and the half above the top edge can
   never be scrolled to, which stranded the ✕ off-screen on short viewports. */
#grownups{
    position:fixed; inset:0; z-index:920; display:flex; align-items:flex-start; justify-content:center;
    background:rgba(74,42,24,.5); padding:16px; overflow:auto;
}
.grownups-card{ position:relative; max-width:520px; width:100%; text-align:left; background:var(--ff-card);
    margin-block:auto; }
.grownups-card h3{ font-size:1.3rem; margin-bottom:8px; }
.grownups-card p{ font-size:.95rem; line-height:1.5; margin-bottom:8px; }
.teach-list{ margin:0 0 8px 18px; padding:0; }
.teach-list li{ font-size:.92rem; line-height:1.45; margin-bottom:5px; }
.tip-row{ display:flex; gap:10px; align-items:flex-start; background:rgba(240,163,46,.13); border-radius:16px; padding:10px 12px; }
.tip-row .tip-icons{ font-size:1.5rem; line-height:1; flex:none; }
.tip-row p{ margin:0; font-size:.9rem; }
.close-btn{
    position:absolute; top:8px; right:8px; width:38px; height:38px; border-radius:50%;
    border:2px solid var(--ff-edge); background:#FFF6E4; font-size:1rem; font-weight:900;
    color:var(--ff-ink); cursor:pointer;
}

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width:430px){
    #play-top{ margin-top:var(--gk-hud-clear-top); padding:0 10px 4px; gap:6px; }
    .pill{ font-size:.78rem; padding:4px 10px; }
    #progress-dots{ gap:4px; min-width:0; }
    #progress-dots span{ width:9px; height:9px; }
    #play-stage{ padding:6px 10px 12px; gap:7px; }
    #ticket{ padding:8px 10px; gap:8px; }
    #ticket-side{ font-size:1.35rem; }
    .key{ min-height:48px; font-size:1.25rem; }
    .name-row{ gap:10px; }
    .hint{ font-size:.74rem; }
}
/* short screens: shrink the order board so both card rows always fit */
@media (max-height:770px){
    .levels-inner{ padding:56px 14px 68px; }
    .station-card .st-shape{ height:80px; }
    .station-card{ padding:11px 8px 9px; }
    .levels-sub{ margin-bottom:14px; }
}
@media (max-height:640px){
    /* clear the fixed HUD (bottom edge at 68px): any less and the score/streak
       pills and the progress dots tuck in behind its buttons. --gk-hud-clear-top
       replaces a hand-rolled 72px; it is computed from the HUD's own inset and
       button height in gamekit.css, so it cannot drift out of step again. */
    #play-top{ margin-top:var(--gk-hud-clear-top); }
    #feedback{ min-height:2em; }
    .key{ min-height:46px; }
}
@media (min-width:760px){
    #play-stage{ gap:12px; padding-bottom:20px; }
    #num-keys{ grid-template-columns:repeat(8,1fr); }
    .key.key-go{ grid-column:span 6; }
    .key.key-del{ grid-column:span 2; }
}

/* ── a phone or small tablet held SIDEWAYS ──────────────────────────────────
   The single stacked column needs ~520px of height. Below that the controls
   (Send order / the keypad / the compare buttons) slid off the bottom, and
   because body is overflow:hidden there was no way to scroll down to them —
   the order could be built but never sent. Wide-and-short has width to spare,
   so lay the stage out in two columns: shape on the left, controls on the
   right, ticket across the top. */
@media (min-width:560px) and (max-height:640px){
    /* the fixed HUD owns the top-right corner — keep the pills clear of it.
       --gk-hud-clear-right happens to equal the 208px that was here; the point of
       the token is that it keeps equalling the right number (see gamekit.css). */
    #play-top{ margin-top:7px; padding:0 var(--gk-hud-clear-right) 2px 12px; }
    #progress-dots{ justify-content:flex-start; flex:none; }
    #play-stage{
        display:grid; max-width:1040px; gap:6px 16px; padding:2px 12px 8px;
        grid-template-columns:1fr 1.06fr; grid-template-rows:auto minmax(0,1fr) auto;
    }
    /* the ticket now shares its line with the fixed HUD — stop the kraft card
       (and the big fraction on its right edge) short of those buttons */
    #ticket{ grid-area:1 / 1 / 2 / 3; margin-right:var(--gk-hud-clear-right); }
    #ticket-sub{ display:none; }
    #shape-area{ grid-area:2 / 1; min-height:52px; }
    #controls{ grid-area:2 / 2; align-self:center; }
    #belt{ grid-area:3 / 1; align-self:end; }
    #feedback{ grid-area:3 / 2; flex:none; min-height:2.1em; font-size:.86rem; }
    .key{ min-height:42px; font-size:1.15rem; }
    .frac.input .slot{ min-height:42px; height:1.3em; font-size:1.45rem; }
    .gk-btn.send-btn, .mini-btn, #panel-next .gk-btn, .cmp-btn{ min-height:46px; font-size:.95rem; }
}
/* one row of digits keeps the keypad two rows tall once there is width for it */
@media (min-width:740px) and (max-height:640px){
    #num-keys{ grid-template-columns:repeat(8,1fr); }
    .key.key-del{ grid-column:span 2; }
    .key.key-go{ grid-column:span 6; }
}
/* the floor: a small phone sideways (568×320). Trim the chrome, never the
   tappable targets. */
@media (min-width:560px) and (max-height:430px){
    #play-top{ margin-top:5px; }
    #ticket{ padding:6px 10px; }
    #ticket-side{ display:none; }
    #ticket-text{ font-size:1rem; }
    .frac.big{ font-size:1.3rem; }
    #belt{ height:12px; }
    #feedback{ min-height:1.8em; font-size:.8rem; }
    .panel{ gap:6px; }
    #num-keys{ gap:5px; }
    .key{ min-height:36px; font-size:1.02rem; border-radius:11px; }
    .frac.input .slot{ min-height:36px; min-width:46px; height:1.2em; font-size:1.2rem; }
    .frac.input .fbar{ height:4px; }
    .hint{ font-size:.7rem; }
    .count-chip{ padding:3px 12px; font-size:.84rem; }
    .gk-btn.send-btn, .mini-btn, #panel-next .gk-btn, .cmp-btn{ min-height:40px; font-size:.92rem; }
    .cmp-grid{ gap:6px; }
}
/* narrow AND short (a small phone in portrait with a browser bar eating the
   screen): no second column to move to, so flatten the stack instead */
@media (max-width:559px) and (max-height:600px){
    #play-stage{ gap:5px; }
    #ticket-sub{ display:none; }
    #shape-area{ min-height:64px; }
    #belt{ height:14px; }
    #feedback{ flex:0 1 auto; min-height:1.8em; font-size:.85rem; }
    .key{ min-height:40px; }
    .gk-btn.send-btn, .mini-btn, #panel-next .gk-btn, .cmp-btn{ min-height:48px; }
}
@media (max-width:559px) and (max-height:520px){
    #ticket{ padding:6px 10px; }
    #ticket-side{ display:none; }
    .frac.big{ font-size:1.3rem; }
    #belt{ display:none; }
    #feedback{ min-height:1.5em; font-size:.78rem; }
    .key{ min-height:34px; font-size:1.05rem; }
    .frac.input .slot{ min-height:34px; min-width:46px; height:1.2em; font-size:1.2rem; }
    .count-chip{ padding:3px 11px; font-size:.82rem; }
    .gk-btn.send-btn, .mini-btn, #panel-next .gk-btn, .cmp-btn{ min-height:42px; font-size:.92rem; }
}
/* the start screen has to survive a sideways phone too */
@media (max-height:520px){
    #start-pizza{ font-size:3.2rem; }
    .game-title{ font-size:clamp(1.5rem,5.4vw,2.3rem); }
    .tagline{ margin:.2em 0 .6em; }
    .star-chip{ margin-bottom:12px; padding:4px 14px; }
    .start-inner{ padding:14px 20px; }
}

@media (prefers-reduced-motion:reduce){
    *{ animation:none !important; }
    .floaties{ display:none; }
    #belt .belt-move{ animation:none !important; }
    .frac-svg.pizza .slice.on, .frac-svg.bar .slice.on{ animation:none !important; }
    #belt-box{ opacity:0 !important; }
}
