/*
 * Pizza party: pizzas on the table, children waiting, one question. Colour carries meaning only:
 *   lemon = how many pizzas (the amount), teal = one child's serving, purple = a part serving,
 *   green = correct, soft amber = a wrong guess. Red is never used for "wrong" (children read it as failure).
 */

/* ================= Tokens ================= */
:root {
  --ink: #0f2a4a;
  --ink-70: rgba(15, 42, 74, .72);
  --ink-50: rgba(15, 42, 74, .5);
  --bg: #effcfb;
  --card: #fff;
  --line: #d5e7ea;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-bg: #ccfbf1;
  --lemon: #facc15;
  --lemon-l: #fde047;
  --lemon-bg: #fef9c3;
  --good: #16a34a; --good-bg: #dcfce7;
  --wrong: #d97706; --wrong-bg: #fef3c7;
  --part: #7c3aed; --part-bg: #ede9fe;
  --wood: #b7793f; --wood-dark: #8a5528;
  --radius: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; color: var(--ink); background: var(--bg);
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
  user-select: none; touch-action: manipulation; -webkit-text-size-adjust: 100%;
}
h1, h2, p, ol { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #0ea5e9; outline-offset: 3px; }

.fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: .72em; line-height: 1.02; margin: 0 .06em; }
.fr-n { padding: 0 .14em .04em; border-bottom: .09em solid currentColor; }
.fr-d { padding: .04em .14em 0; }
.mx { margin-right: .06em; }
.dc { white-space: nowrap; font-variant-numeric: tabular-nums; }

.screen { position: fixed; inset: 0; transition: opacity .35s ease, visibility .35s ease; }
.screen.off { opacity: 0; visibility: hidden; pointer-events: none; }

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; display: grid; place-items: center;
  background: var(--card); color: var(--ink); border: 1px solid rgba(15, 42, 74, .06);
  box-shadow: 0 1px 0 var(--line), 0 2px 8px rgba(15, 42, 74, .08); transition: transform .15s;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.ghost { background: rgba(255, 255, 255, .7); }
.icon-btn.is-off { opacity: .55; }

.btn {
  min-height: 52px; padding: 12px 20px; border-radius: 16px; width: 100%;
  font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 18px;
  background: #f1f5f9; color: var(--ink); transition: transform .15s;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--teal); color: #fff; box-shadow: 0 4px 0 var(--teal-dark); }
.btn.ghost { background: none; color: var(--ink-70); }

/* ================= Start: a sunny stand under a striped awning ================= */
.start {
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 22%, rgba(250, 204, 21, .35), transparent 22%),
    radial-gradient(ellipse 70% 40% at 50% 100%, rgba(13, 148, 136, .14), transparent 70%),
    linear-gradient(180deg, #bae6fd 0%, #e0f7fa 45%, #f0fdfa 100%);
}
.awning {
  position: absolute; z-index: 4; left: 0; right: 0; top: 0; height: calc(var(--safe-t) + 34px);
  background: repeating-linear-gradient(90deg, var(--teal) 0 36px, #fff 36px 72px);
  -webkit-mask: radial-gradient(18px 12px at 18px 100%, transparent 98%, #000) 0 0 / 36px 100%;
          mask: radial-gradient(18px 12px at 18px 100%, transparent 98%, #000) 0 0 / 36px 100%;
  filter: drop-shadow(0 4px 4px rgba(15, 42, 74, .12));
}
.start-bar {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(var(--safe-t) + 36px); display: flex; justify-content: space-between; align-items: center;
  padding: 8px calc(var(--safe-r) + 12px) 8px calc(var(--safe-l) + 12px);
}
.sound-group { display: flex; gap: 6px; }
.lang-switch { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .7); }
.lang-btn { min-width: 42px; height: 38px; padding: 0 8px; border-radius: 999px; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 14px; color: var(--ink-70); }
.lang-btn[aria-pressed="true"] { background: var(--teal); color: #fff; }
.start-scroll { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.start-col {
  width: min(560px, 100%); min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 16px;
  padding: calc(var(--safe-t) + 100px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 18px);
}
.start-head { text-align: center; }
.hero svg { width: min(220px, 60vw); height: auto; }
.brand { margin-top: 2px; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-dark); }
.title { margin-top: 4px; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: clamp(36px, 8.5vw, 54px); line-height: 1.05; color: var(--ink); text-wrap: balance; }
.title::after { content: ''; display: block; width: 72px; height: 5px; margin: 10px auto 0; border-radius: 3px; background: linear-gradient(90deg, var(--lemon), var(--teal)); }
.tagline { margin-top: 8px; font-size: 16px; line-height: 1.4; color: var(--ink-70); text-wrap: balance; }

.play-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.play-btn {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 18px; text-align: left; color: var(--ink-70);
  background: rgba(255, 255, 255, .55); border: 2px solid rgba(15, 118, 110, .15); transition: background-color .2s, border-color .2s, transform .15s;
}
.play-btn:active { transform: scale(.98); }
.play-btn svg { flex-shrink: 0; }
.play-btn span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.play-btn b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 17px; color: var(--ink); }
.play-btn small { font-size: 12.5px; line-height: 1.3; }
.play-btn[aria-checked="true"] { background: #fff; border-color: var(--teal); box-shadow: 0 6px 16px rgba(13, 148, 136, .18); }
.rotate-note { display: none; margin-top: -6px; padding: 8px 12px; border-radius: 12px; background: var(--lemon-bg); color: #713f12; font-size: 13.5px; line-height: 1.4; text-align: center; }
@media (max-width: 700px) and (orientation: portrait) { .start.teams-picked .rotate-note { display: block; } }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 18px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(15, 118, 110, .12); }
.mode-btn { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 14px; text-align: left; color: var(--ink-70); transition: background-color .2s; }
.mode-btn b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 17px; color: var(--ink); }
.mode-btn small { font-size: 12.5px; line-height: 1.3; }
.mode-btn[aria-checked="true"] { background: #fff; box-shadow: 0 4px 12px rgba(15, 42, 74, .1), inset 0 -3px 0 var(--lemon); }

.list-title { margin-top: 2px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--teal-dark); }
.shifts { list-style: none; padding: 0; display: grid; gap: 8px; }
.shift {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 16px; background: #fff; color: var(--ink); text-align: left;
  border-left: 5px solid var(--c); box-shadow: 0 4px 0 rgba(15, 42, 74, .08), 0 6px 16px rgba(15, 42, 74, .06); transition: transform .15s, box-shadow .2s;
}
@media (hover: hover) { .shift:hover { box-shadow: 0 0 0 3px var(--c); } }
.shift:active { transform: scale(.98); }
.shift-n { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--c); color: #fff; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 19px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.shift-txt { display: flex; flex-direction: column; min-width: 0; }
.shift-name { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 18px; line-height: 1.2; }
.shift-desc { font-size: 13.5px; color: var(--ink-70); }
.shift-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.stars { display: flex; gap: 1px; }
.stars svg { width: 17px; height: 17px; }
.stars path { fill: #e2e8f0; stroke: #cbd5e1; }
.stars .on path { fill: #facc15; stroke: #eab308; }
.shift-best { font-size: 11.5px; color: var(--ink-50); }
.start-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.link-btn { min-height: 44px; padding: 8px 4px; color: var(--teal-dark); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }

/* ================= Game layout ================= */
.play {
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: radial-gradient(ellipse 80% 50% at 50% 0%, #e0f2fe, transparent 70%), linear-gradient(180deg, #f0fdfa, #e6f6f4);
}
.hud { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 12px) 6px calc(var(--safe-l) + 12px); }
.hud-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.line-name { max-width: 100%; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 14px; color: var(--ink-70); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip { display: flex; gap: 4px; }
.trip i { width: 18px; height: 6px; border-radius: 3px; background: #cfe3e1; }
.trip i.now { background: var(--teal); box-shadow: 0 0 0 2px rgba(13, 148, 136, .25); }
.trip i.ok { background: var(--good); }
.trip i.no { background: var(--wrong); }
@media (max-width: 380px) { .trip i { width: 13px; } }
.score { display: flex; align-items: center; gap: 5px; padding: 6px 12px 6px 8px; border-radius: 999px; background: #fff; box-shadow: 0 1px 0 var(--line), 0 2px 8px rgba(15, 42, 74, .08); font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.score.bump { animation: bump .35s ease; }
.menu-wrap { position: relative; }
.menu { position: absolute; z-index: 50; right: 0; top: calc(100% + 8px); min-width: 230px; padding: 6px; border-radius: 16px; background: #fff; box-shadow: 0 12px 34px rgba(15, 42, 74, .2); display: none; }
.menu.show { display: grid; }
.menu-item { min-height: 46px; padding: 0 12px; border-radius: 10px; text-align: left; font-size: 15.5px; display: flex; align-items: center; gap: 10px; }
.menu-item svg { flex-shrink: 0; }
@media (hover: hover) { .menu-item:hover { background: #f1f5f9; } }
.menu-item.is-off { color: var(--ink-50); }

.stage {
  min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px;
  width: min(820px, 100%); margin: 0 auto;
  padding: 4px calc(var(--safe-r) + 14px) calc(var(--safe-b) + 14px) calc(var(--safe-l) + 14px);
}
.stand { min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 10px; }

/* the party's sign: a chalkboard under a little awning */
.sign-wrap { position: relative; display: flex; flex-direction: column; gap: 6px; }
.sign-awning { height: 16px; margin: 0 6px -6px; border-radius: 8px 8px 0 0; background: repeating-linear-gradient(90deg, var(--teal) 0 22px, #fff 22px 44px); box-shadow: 0 3px 0 rgba(15, 42, 74, .08); }
.sign {
  container-type: inline-size; min-height: clamp(58px, 11vh, 88px); display: grid; place-items: center; border-radius: 16px;
  background: radial-gradient(ellipse at 50% 20%, #1f5f58, #12403b 75%); border: 5px solid var(--wood); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .06), 0 4px 0 var(--wood-dark);
}
.op { display: inline-flex; align-items: center; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; line-height: 1; white-space: nowrap; color: #fff; font-size: min(clamp(32px, 6.6vh, 54px), 9cqi); }
.op .op-a { color: var(--lemon-l); }
.op .op-b { color: #5eead4; }
.op .sign-x, .op .eqs { margin: 0 .18em; color: #fff; }
.op .op-q { color: rgba(255, 255, 255, .55); }
.op .op-r { color: #bbf7d0; display: inline-flex; animation: resIn .45s cubic-bezier(.34, 1.56, .64, 1); }
.sign.flip .op { animation: flip .4s ease; }

/* countdown (team mode) */
.timer { display: none; position: relative; height: 14px; border-radius: 999px; background: rgba(15, 42, 74, .14); overflow: hidden; }
.play.teams .timer { display: block; }
.timer i { position: absolute; inset: 0; transform-origin: left center; border-radius: inherit; background: linear-gradient(90deg, var(--lemon), var(--lemon-l)); }
.play.teams[data-turn="blue"] .timer i { background: linear-gradient(90deg, #60a5fa, #bfdbfe); }
.play.teams[data-turn="red"] .timer i { background: linear-gradient(90deg, #fb7185, #fecdd3); }
.timer.low i { animation: blink .5s steps(2) infinite; }
.timer.up i { transform: scaleX(0) !important; }
.timer span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 12px; color: var(--ink); }

/* ================= The scene: children above, the table with pizzas below ================= */
.scene { position: relative; container-type: inline-size; height: clamp(250px, 46vh, 440px); display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; --pz: 120px; --kw: 48px; }
.kids-area { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: calc(var(--kw) * 1.55 + 40px); }
.kids { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 0 4px; min-height: calc(var(--kw) * 1.5); width: 100%; }
.kid { position: relative; width: var(--kw); display: flex; flex-direction: column; align-items: center; }
.kid-svg { width: 100%; height: auto; display: block; }
.kid-svg .shirt { fill: #0d9488; }
.kid:nth-child(3n+2) .kid-svg .shirt { fill: #8b5cf6; }
.kid:nth-child(3n) .kid-svg .shirt { fill: #f59e0b; }
.kid-svg .k-eyes circle { fill: var(--ink); }
.kid-svg .k-happy { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; opacity: 0; }
.kid-svg .k-mouth { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; opacity: 0; transition: opacity .2s; }
.kid-svg .k-o { fill: #7c2d12; stroke: none; opacity: 1; }
.kid.fed .k-o { opacity: 0; }
.kid.fed:not(.part) .k-smile { opacity: 1; fill: #fda4af; }
.kid.fed:not(.part) .k-eyes { opacity: 0; }
.kid.fed:not(.part) .k-happy { opacity: 1; }
.kid.part.fed .k-soft { opacity: 1; }
.kid.arrive { animation: popIn .35s cubic-bezier(.34, 1.56, .64, 1); }
.kid.fed:not(.part) .kid-svg { animation: hop .5s cubic-bezier(.3, 1.6, .5, 1); }
.kid .plate { position: absolute; left: 50%; bottom: 2px; width: 62%; aspect-ratio: 1; transform: translateX(-50%) scale(0); border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(15, 42, 74, .2); transition: transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.kid.fed .plate { transform: translateX(-50%) scale(1); }
.pie { width: 100%; height: 100%; display: block; }
.pie-bg { fill: #fff; stroke: #e2e8f0; stroke-width: .8; }
.pie-on { fill: #fcd34d; stroke: #e3a35a; stroke-width: .9; }
.pie-off { fill: none; stroke: #cbd5e1; stroke-width: .7; stroke-dasharray: 1.4 1.2; }
.kid-n { margin-top: 2px; min-width: 20px; padding: 0 5px; border-radius: 8px; background: #fff; color: var(--teal-dark); font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-size: 13px; line-height: 1.3; text-align: center; box-shadow: 0 1px 0 var(--line); }
.kid.part .kid-n { color: var(--part); background: var(--part-bg); font-size: 14px; }
.flying { position: fixed; left: 0; top: 0; z-index: 41; width: calc(var(--kw, 48px) * .62); aspect-ratio: 1; border-radius: 50%; background: #fff; box-shadow: 0 6px 14px rgba(15, 42, 74, .25); pointer-events: none; }
.flying .pie { width: 100%; height: 100%; }

/* the waiting crowd: how many children are there? nobody knows yet */
.crowd { display: flex; align-items: flex-end; gap: 2px; height: calc(var(--kw) * 1.1); transition: opacity .3s, transform .3s; }
.crowd span { width: calc(var(--kw) * .62); height: calc(var(--kw) * .9); border-radius: 50% 50% 8px 8px; background: radial-gradient(circle at 50% 30%, #94a3b8 0 26%, transparent 27%), linear-gradient(180deg, transparent 52%, #94a3b8 52%); opacity: .55; }
.crowd span:nth-child(2) { height: calc(var(--kw) * 1.05); opacity: .7; }
.crowd b { align-self: center; margin-left: 4px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--teal-dark); font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-size: 20px; box-shadow: 0 2px 6px rgba(15, 42, 74, .12); }
.crowd.gone { position: absolute; opacity: 0; transform: translateY(-8px); pointer-events: none; }
.kids:empty { display: none; }

.table {
  position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 10px 18px; border-radius: 18px;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .55) 0 14px, rgba(204, 251, 241, .55) 14px 28px);
  box-shadow: inset 0 0 0 2px rgba(13, 148, 136, .14);
}
.table::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; border-radius: 0 0 18px 18px; background: linear-gradient(180deg, #d4955a, var(--wood) 50%, var(--wood-dark)); }
.pizzas { flex: 1; min-height: 0; width: 100%; display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: 14px; }
.pizza { position: relative; width: var(--pz); height: var(--pz); flex-shrink: 0; border-radius: 50%; transition: transform .15s; }
.pizza-svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 4px 4px rgba(120, 72, 30, .2)); }
.pizza-svg .plate { fill: #fff; stroke: #e2e8f0; stroke-width: 1; }
.pizza-svg .sl { transition: transform .35s cubic-bezier(.3, 1.4, .5, 1), opacity .35s; }
.pizza-svg .cheese { fill: #fcd34d; stroke: #fcd34d; stroke-width: .6; }
.pizza-svg .crust { fill: none; stroke: #e3a35a; stroke-width: 7; stroke-linecap: butt; }
.pizza-svg .olive { fill: none; stroke: #334155; stroke-width: 1.8; }
.pizza-svg .pep { fill: #16a34a; }
.pizza-svg .sl-n { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 12px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.pizza-svg .cutline { stroke: #fffbeb; stroke-width: 2; stroke-dasharray: 50; stroke-dashoffset: 50; opacity: 0; }
.pizza.cutting .cutline { opacity: 1; animation: cutIn .14s linear forwards; animation-delay: calc(var(--d) * 90ms); }
.pizza.cut .cutline { opacity: 0; }
.pizza.cut .sl { transform: translate(var(--dx), var(--dy)); }
.pizza.cut .cheese { stroke: #fffbeb; stroke-width: 1.4; }
.pizza .sl.pick { transform: translate(calc(var(--dx) * 3), calc(var(--dy) * 3)) scale(1.04); }
.pizza .sl.taken { opacity: .1; }
/* hint: each child's portion in its own colour, numbered */
.scene.grouped .sl .cheese { fill: #fde68a; }
.scene.grouped .sl.g-odd .cheese { fill: #99f6e4; stroke: #99f6e4; }
.scene.grouped .sl.g-left .cheese { fill: #ddd6fe; stroke: #ddd6fe; }
.pizza.cut.boxed .lid, .pizza:not(.boxed) .lid { display: none; }
.lid {
  position: absolute; inset: 4%; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #f8fafc, #e2e8f0); border: 3px solid #cbd5e1; box-shadow: 0 6px 12px rgba(15, 42, 74, .15);
}
.lid b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-size: calc(var(--pz) * .16); letter-spacing: .08em; color: #94a3b8; }
.pizza.boxed .pizza-svg { visibility: hidden; }
.play.cutting .pizza:not(.cut):not(.cutting) { cursor: pointer; animation: nudge 1.6s ease-in-out infinite; }
.play.cutting .pizza:not(.cut):not(.cutting)::after { /* a little knife */
  content: ''; position: absolute; right: -4px; top: -4px; width: 30px; height: 30px; border-radius: 50%; background: #fff center / 20px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20L17 7l2 2L6 22z' fill='%2394a3b8'/%3E%3Cpath d='M17 7l3-3 2 2-3 3z' fill='%230f2a4a'/%3E%3C/svg%3E");
  box-shadow: 0 2px 6px rgba(15, 42, 74, .2);
}
@media (hover: hover) { .play.cutting .pizza:not(.cut):hover { transform: scale(1.04); } }
.pizza:disabled { cursor: default; }

/* tags: the numbers ride on the things they belong to */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border-radius: 12px; white-space: nowrap;
  font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: clamp(16px, 2.8vh, 22px); line-height: 1.1;
}
.tag .fr { font-size: .78em; }
.a-tag { background: var(--lemon-bg); border: 2.5px solid #ca8a04; color: #713f12; }
.b-tag { background: var(--teal-bg); border: 2.5px solid var(--teal); color: #134e4a; }
.op .op-w { font-size: .42em; font-weight: 600; margin-left: .18em; opacity: .75; align-self: flex-end; margin-bottom: .2em; }
.op.words { font-size: min(clamp(28px, 5.6vh, 46px), 7.5cqi); }

.step-cap {
  position: absolute; z-index: 5; left: 50%; top: calc(var(--kw) * 1.55 + 46px); transform: translate(-50%, -6px); opacity: 0; pointer-events: none;
  padding: 4px 12px; border-radius: 999px; background: var(--ink); color: #fff; font-size: clamp(13px, 2.1vh, 16px); white-space: nowrap;
  transition: opacity .25s, transform .3s;
}
.step-cap.show { opacity: 1; transform: translate(-50%, 0); }
.step-cap .fr { font-size: .8em; }

@keyframes cutIn { to { stroke-dashoffset: 0; } }
@keyframes nudge { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }

/* ================= Answers / feedback ================= */
.controls, .fb { width: 100%; }
.ask-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.prompt { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 17px; color: var(--ink-70); }
.hint-btn { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 6px 12px; border-radius: 999px; background: var(--lemon-bg); color: #92400e; font-size: 14.5px; box-shadow: 0 2px 0 var(--lemon-l); }
.hint-btn small { font-size: 12px; opacity: .75; }
.hint-btn:disabled { opacity: .45; cursor: default; }
.answers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ans {
  min-height: 74px; padding: 8px 6px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  background: #fff; color: var(--ink); border: 3px solid #99e6dc;
  font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; line-height: 1.05;
  box-shadow: 0 4px 0 #7dd3c8, 0 8px 16px rgba(13, 148, 136, .12); transition: transform .12s, box-shadow .12s, opacity .2s, background-color .2s;
}
.ans-v { font-size: clamp(24px, 4vh, 32px); display: inline-flex; align-items: center; }
.ans small { font-size: 12.5px; font-weight: 600; color: var(--ink-50); margin-top: 2px; }
@media (hover: hover) { .ans:not(:disabled):hover { background: #f0fdfa; } }
.ans:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 #7dd3c8; }
.ans:disabled { cursor: default; opacity: .5; }
.ans.picked { opacity: 1; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink); }
.ans.right { opacity: 1; background: var(--good-bg); border-color: var(--good); box-shadow: 0 4px 0 #15803d; }
.ans.picked:not(.right) { background: var(--wrong-bg); border-color: var(--wrong); }

.fb { display: none; padding: 14px 16px; border-radius: var(--radius); background: #fff; border-left: 6px solid var(--c, var(--good)); box-shadow: 0 2px 10px rgba(15, 42, 74, .08); }
.fb.show { display: block; animation: rise .3s ease; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 7%, #fff), #fff 60%); }
.fb.good { --c: var(--good); }
.fb.bad { --c: var(--wrong); }
.play.answered .controls { display: none; }
.fb-head { display: flex; align-items: center; gap: 10px; }
.fb-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; flex-shrink: 0; }
.fb-icon svg { width: 20px; height: 20px; }
.fb-title { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 21px; color: var(--c); }
.fb-pts { margin-left: auto; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 17px; color: #a16207; }
.fb-pts.blue { color: #1d4ed8; } .fb-pts.red { color: #be123c; }
.fb-why { margin-top: 6px; font-size: 15.5px; line-height: 1.45; }
.fb-why b { color: var(--teal-dark); }
.fb-diag { margin-top: 8px; padding: 8px 10px; border-radius: 12px; background: var(--wrong-bg); color: #78350f; font-size: 15px; line-height: 1.4; }
.fb-diag:empty { display: none; }
.fb-why .fr, .fb-diag .fr { font-size: .8em; }
.fb-next { position: relative; overflow: hidden; width: 100%; margin-top: 12px; min-height: 50px; border-radius: 14px; background: linear-gradient(180deg, #1e3a5f, var(--ink)); color: #fff; box-shadow: 0 3px 0 #020617; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 600; font-size: 18px; }
.fb-next:active { transform: translateY(2px); }
.fb-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .2); }
.fb-bar span { display: block; height: 100%; width: 0; background: rgba(255, 255, 255, .8); }

/* ================= Team mode ================= */
.team { display: none; }
.play.teams .team {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 118px; padding: 5px 14px 6px; border-radius: 16px;
  color: #fff; line-height: 1.05; opacity: .62; transform: scale(.94); transition: opacity .3s, transform .3s, box-shadow .3s;
}
.team.blue { background: linear-gradient(180deg, #3b82f6, #1d4ed8); box-shadow: 0 3px 0 #1e3a8a; }
.team.red { background: linear-gradient(180deg, #f43f5e, #be123c); box-shadow: 0 3px 0 #881337; }
.team-name { font-size: 13px; opacity: .9; white-space: nowrap; }
.team b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 28px; font-variant-numeric: tabular-nums; }
.play.teams .team.active { opacity: 1; transform: scale(1); }
.play.teams .team.blue.active { box-shadow: 0 3px 0 #1e3a8a, 0 0 0 4px #bfdbfe, 0 0 24px rgba(37, 99, 235, .55); }
.play.teams .team.red.active { box-shadow: 0 3px 0 #881337, 0 0 0 4px #fecdd3, 0 0 24px rgba(225, 29, 72, .5); }
.team.bump b { animation: bump .45s ease; }
.play.teams .score { display: none; }
.play.teams .hud { gap: 14px; }
.play.teams .trip i.t-blue:not(.ok):not(.no):not(.now) { background: #bfdbfe; }
.play.teams .trip i.t-red:not(.ok):not(.no):not(.now) { background: #fecdd3; }
.play.teams .trip i.now.t-blue { background: #2563eb; }
.play.teams .trip i.now.t-red { background: #e11d48; }
.turn-glow { position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: 0; transition: opacity .4s, box-shadow .4s; }
.play.teams[data-turn="blue"] .turn-glow { opacity: 1; box-shadow: inset 0 0 0 6px #3b82f6, inset 0 0 70px rgba(59, 130, 246, .35); }
.play.teams[data-turn="red"] .turn-glow { opacity: 1; box-shadow: inset 0 0 0 6px #f43f5e, inset 0 0 70px rgba(244, 63, 94, .32); }
.turn-banner {
  position: fixed; z-index: 45; left: 50%; top: calc(var(--safe-t) + 74px); display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 28px 12px; border-radius: 22px; color: #fff; text-align: center; pointer-events: none;
  opacity: 0; transform: translate(-50%, -16px) scale(.9); transition: opacity .3s, transform .35s cubic-bezier(.3, 1.4, .5, 1); box-shadow: 0 14px 34px rgba(15, 42, 74, .3);
}
.turn-banner.blue { background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.turn-banner.red { background: linear-gradient(180deg, #f43f5e, #be123c); }
.turn-banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.turn-banner b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: clamp(24px, 4.4vh, 38px); white-space: nowrap; }
.turn-banner small { font-size: clamp(14px, 2.2vh, 18px); opacity: .92; }

/* ================= Overlays ================= */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow-y: auto;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); background: rgba(15, 42, 74, .55);
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
.overlay.show { opacity: 1; visibility: visible; }
.modal { width: min(460px, 100%); padding: 22px 20px 18px; border-radius: 24px; background: #fff; text-align: center; box-shadow: 0 20px 50px rgba(15, 42, 74, .3); border-top: 6px solid var(--teal); }
.modal-title { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 26px; }
.help-steps { margin: 14px 0 10px; padding-left: 22px; display: grid; gap: 8px; text-align: left; font-size: 15.5px; line-height: 1.45; }
.help-steps b { color: var(--teal-dark); }
.help-teams { display: none; margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; background: #eff6ff; font-size: 14.5px; line-height: 1.45; text-align: left; }
#help.teams .help-teams { display: block; }
.help-tip { padding: 10px 12px; border-radius: 12px; background: #12403b; color: var(--lemon-l); font-size: 15px; }
.help-tip b { color: #fff; }
.help-keys { margin: 10px 0 14px; font-size: 13px; color: var(--ink-50); }
@media (pointer: coarse) { .help-keys { display: none; } .help-tip { margin-bottom: 14px; } }
.res-stars { display: flex; justify-content: center; gap: 6px; }
.res-stars svg { width: 52px; height: 52px; }
.res-stars path { fill: #e2e8f0; stroke: #cbd5e1; stroke-width: 1.4; }
.res-stars .on path { fill: #facc15; stroke: #eab308; }
.res-stars .on { animation: starIn .5s cubic-bezier(.34, 1.56, .64, 1) both; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; }
.res-stats div { display: flex; flex-direction: column; padding: 8px 4px; border-radius: 14px; background: #f1f5f9; }
.res-stats b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-size: 24px; }
.res-stats span { font-size: 12px; color: var(--ink-50); }
.res-new { display: none; margin-bottom: 10px; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; color: #b45309; }
.res-new.show { display: block; }
.res-tip { margin-bottom: 14px; padding: 10px 12px; border-radius: 12px; background: #f0fdfa; font-size: 15px; line-height: 1.4; text-align: left; }
.res-tip b { color: var(--teal-dark); }
.res-actions { display: grid; gap: 8px; }
.res-teams, .res-trophy { display: none; }
#results.teams .res-stars, #results.teams .res-stats, #results.teams .res-new { display: none; }
#results.teams .res-trophy { display: block; }
#results.teams .res-trophy svg { animation: starIn .6s cubic-bezier(.34, 1.56, .64, 1) both; }
#results.teams .res-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.rt { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border-radius: 16px; color: #fff; opacity: .8; transition: transform .3s; }
.rt.blue { background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.rt.red { background: linear-gradient(180deg, #f43f5e, #be123c); }
.rt span { font-size: 14px; }
.rt b { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-size: 38px; line-height: 1.1; }
.rt small { font-size: 13px; opacity: .9; }
.rt.win { opacity: 1; transform: scale(1.05); box-shadow: 0 0 0 4px #facc15, 0 10px 24px rgba(0, 0, 0, .2); }
.gate { z-index: 70; }
.gate-icon { color: var(--ink); margin-bottom: 6px; }
.gate-body { margin: 8px 0 16px; font-size: 15.5px; line-height: 1.45; color: var(--ink-70); }

/* ================= Effects ================= */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.particle { position: absolute; left: 0; top: 0; border-radius: 2px; }
.fly { position: absolute; left: 0; top: 0; padding: 3px 12px; border-radius: 999px; background: #facc15; color: #713f12; font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 24px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.fly.blue { background: #2563eb; color: #fff; }
.fly.red { background: #e11d48; color: #fff; }

@keyframes blink { 50% { filter: brightness(1.6); } }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes bump { 40% { transform: scale(1.2); } }
@keyframes starIn { from { transform: scale(0) rotate(-60deg); } }
@keyframes resIn { from { transform: scale(.4); opacity: 0; } }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } }
@keyframes hop { 40% { transform: translateY(-7px) rotate(-3deg); } 70% { transform: translateY(0) rotate(2deg); } }

/* ================= Smart board ================= */
@media (min-width: 1200px) and (min-height: 760px) {
  .stage { width: min(1040px, 100%); }
  .play.teams .team { min-width: 170px; padding: 8px 20px; }
  .play.teams .team b { font-size: 38px; }
  .team-name { font-size: 16px; }
  .ans { min-height: 94px; }
  .ans-v { font-size: 38px; }
  .timer { height: 18px; }
}

/* ================= Landscape phones: stand left, answers right ================= */
@media (orientation: landscape) and (max-height: 540px) {
  .hud { padding-top: calc(var(--safe-t) + 6px); padding-bottom: 2px; }
  .stage { width: 100%; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) minmax(210px, 32%); gap: 14px; align-items: center; }
  .stand { gap: 6px; }
  .sign { min-height: 46px; border-width: 4px; }
  .sign-awning { height: 10px; }
  .op { font-size: min(30px, 9cqi); }
  .scene { height: calc(100dvh - 150px); min-height: 170px; }
  .controls, .fb { grid-column: 2; grid-row: 1; }
  .ask-row { flex-wrap: wrap; justify-content: center; text-align: center; }
  .prompt { font-size: 15px; }
  .answers { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ans { min-height: 56px; }
  .ans-v { font-size: 22px; }
  .fb { padding: 10px 12px; max-height: calc(100dvh - 70px); overflow-y: auto; }
  .fb-why, .fb-diag { font-size: 14px; }
  .play.teams .team { min-width: 84px; padding: 3px 8px; border-radius: 12px; }
  .play.teams .team b { font-size: 19px; }
  .team-name { font-size: 10.5px; }
  .play.teams .hud-mid .line-name { display: none; }
  .turn-banner { top: calc(var(--safe-t) + 52px); padding: 6px 18px 8px; }
  .turn-banner b { font-size: 20px; }
  .turn-banner small { font-size: 12.5px; }
  .timer { height: 10px; }
  .timer span { font-size: 9.5px; }
}
@media (max-width: 560px) {
  .answers { grid-template-columns: 1fr 1fr; }
  .play.teams .team { min-width: 0; padding: 4px 9px; }
  .play.teams .team b { font-size: 20px; }
  .team-name { font-size: 11px; }
  .play-btn { padding: 10px; gap: 8px; }
  .play-btn small { font-size: 11.5px; }
}
@media (max-height: 700px) and (orientation: portrait) {
  .scene { height: clamp(190px, 36vh, 300px); }
  .ans { min-height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .1s !important; }
}

/* the step caption sits low on the table, clear of the pizza count tag */
.step-cap { top: auto; bottom: 20px; }
/* room for the children's numbers under them */
.kids-area { min-height: calc(var(--kw) * 1.07 + 62px); }
.kids { min-height: calc(var(--kw) * 1.07 + 22px); }
.kid-n { position: relative; z-index: 1; }
/* never wider than the screen: long signs shrink instead of pushing the page sideways */
.stage { grid-template-columns: minmax(0, 1fr); }
.stand, .sign-wrap, .sign, .scene, .table, .pizzas, .controls, .fb { min-width: 0; }
.sign { overflow: hidden; }
@media (orientation: landscape) and (max-height: 540px) { .stage { grid-template-columns: minmax(0, 1fr) minmax(210px, 32%); } }
.play { grid-template-columns: minmax(0, 1fr); }
.trip { max-width: 100%; }
.trip i { flex: 0 1 18px; min-width: 7px; }
.pizzas { flex-wrap: wrap; align-content: center; gap: 12px; }
/* children: room reserved for the biggest size (--kh); each child is drawn at --kk once served */
.kids-area { min-height: calc(var(--kh, 48px) * 1.07 + 62px); }
.kids { min-height: calc(var(--kh, 48px) * 1.07 + 22px); }
.kid { width: var(--kk, var(--kw)); }


/* points still on offer for this question: slides from 1000 to 500 */
.pts-live {
  display: none; align-items: center; gap: 4px; margin-left: auto; padding: 4px 10px; border-radius: 999px;
  background: var(--ink); color: var(--lemon-l); font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums;
}
.pts-live.on { display: inline-flex; }
.pts-live b { min-width: 3.2ch; text-align: right; }
.ask-row .hint-btn { margin-left: 0; }
/* hint: toppings step aside so the portion numbers read clearly */
.scene.grouped .pizza-svg .olive, .scene.grouped .pizza-svg .pep { opacity: 0; }
.pizza-svg .sl-n { font-size: 15px; }
