/* MathFun styles - design tokens + light/dark, mobile-first (SPEC R9, R10). */

/* ---------- Design tokens ---------- */
:root {
  --brand: #6d5efc;
  --brand-2: #ff8fab;
  --accent: #ffb703;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;

  --bg: #f5f3ff;
  --surface: #ffffff;
  --surface-2: #f1eefe;
  --text: #1f2340;
  --text-soft: #5b5f7a;
  --border: #e5e1f7;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 20px rgba(76, 60, 180, 0.12);
  --shadow-sm: 0 2px 8px rgba(76, 60, 180, 0.10);

  --space: 16px;
  --space-lg: 24px;
  --tap: 52px;                 /* min tap target for young children */
  --fs-question: clamp(2.4rem, 10vw, 4rem);
  --transition: 160ms ease-out;

  /* mastery states */
  --m-solid: #16a34a;
  --m-okay: #f59e0b;
  --m-needs: #ef4444;
  --m-new: #cbd5e1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14162b;
    --surface: #1e2140;
    --surface-2: #262a4d;
    --text: #f0f1fb;
    --text-soft: #a6abcf;
    --border: #333863;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --good-bg: #143a24;
    --bad-bg: #401b1b;
    --m-new: #475069;
  }
}
:root[data-theme="dark"] {
  --bg: #14162b; --surface: #1e2140; --surface-2: #262a4d;
  --text: #f0f1fb; --text-soft: #a6abcf; --border: #333863;
  --shadow: 0 6px 20px rgba(0,0,0,.4); --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --good-bg: #143a24; --bad-bg: #401b1b; --m-new: #475069;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, 'Comic Sans MS', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--space);
}
/* .brand is a <button> (tap = reload home) - strip the native button chrome so no box shows. */
.brand {
  display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.3rem;
  background: none; border: none; padding: 0; margin: 0; cursor: pointer; color: inherit; font: inherit;
}
.brand:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
/* The mark is the SVG logo itself - no gradient box behind it (that was the old text monogram). */
.brand-mark { display: block; width: 34px; height: 34px; }
.brand-name { background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Layout ---------- */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space) var(--space) var(--space-lg);
}
.screen { display: none; animation: fade var(--transition); }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h1, h2 { outline: none; }
h2 { font-size: 1.5rem; margin: 4px 0 var(--space); text-align: center; }

/* ---------- Buttons (WealthOrah-style emboss + shrink) ---------- */
:root {
  /* layered shadow for a raised, embossed feel; inset highlight up top, soft drop below */
  --emboss: inset 0 1px 0 rgba(255,255,255,0.35), 0 3px 0 rgba(76,60,180,0.28), 0 6px 14px rgba(76,60,180,0.22);
  --emboss-hover: inset 0 1px 0 rgba(255,255,255,0.45), 0 5px 0 rgba(76,60,180,0.30), 0 10px 20px rgba(76,60,180,0.28);
  --emboss-press: inset 0 2px 5px rgba(0,0,0,0.28);
}
.btn {
  position: relative;
  font: inherit; font-weight: 800;
  border: none; border-radius: var(--radius-sm);
  min-height: var(--tap); padding: 0 18px;
  cursor: pointer; color: #fff;
  box-shadow: var(--emboss);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), filter var(--transition);
}
@media (hover: hover) {
  .btn:hover { transform: translateY(-2px); box-shadow: var(--emboss-hover); filter: brightness(1.03); }
}
.btn:active { transform: translateY(1px) scale(0.97); box-shadow: var(--emboss-press); filter: brightness(0.98); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn-play {
  display: block; width: 100%; margin: var(--space) 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: 1.35rem; min-height: 62px;
}
.btn-secondary { background: linear-gradient(135deg, var(--brand), #8a7dfd); }
.btn-ghost {
  background: var(--surface); color: var(--text); border: 2px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 6px rgba(76,60,180,0.12);
}
@media (hover: hover) {
  .btn-ghost:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 5px 12px rgba(76,60,180,0.18); }
}
.btn-back { min-width: var(--tap); padding: 0; font-size: 1.3rem; }

.home-hint { text-align: center; margin-top: 4px; }
.home-msg { text-align: center; color: var(--bad); font-weight: 800; margin: 8px 0 0; min-height: 1.2em; }

/* ---------- Home ---------- */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface); border: 3px solid var(--border);
  border-radius: var(--radius); padding: 18px 10px; min-height: 96px;
  cursor: pointer; color: var(--text); font: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 0 var(--border), 0 6px 12px rgba(76,60,180,0.12);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
/* Hover/press are transient only (revert when pointer leaves); disabled on touch via @media hover. */
@media (hover: hover) {
  .mode-card:hover {
    transform: translateY(-2px); border-color: var(--brand);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 5px 0 var(--border), 0 10px 18px rgba(76,60,180,0.18);
  }
}
.mode-card:active { transform: translateY(1px) scale(0.97); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.mode-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Selected = flat highlight (brand border + tint), NOT a raised lift, so it never looks "stuck" hovered. */
.mode-card.selected {
  border-color: var(--brand); background: var(--surface-2);
  box-shadow: inset 0 0 0 2px rgba(109,94,252,0.25);
  transform: none;
}
.mode-emoji { font-size: 2rem; }
.mode-name { font-weight: 800; font-size: 0.95rem; }

.toggles { display: flex; flex-direction: column; gap: 10px; margin: var(--space) 0; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; min-height: var(--tap);
}
.toggle-label { font-weight: 800; }

/* Three toggles side by side (Timer / Sound / Music) */
.toggles-row { flex-direction: row; gap: 10px; }
.toggles-row .toggle-row {
  flex: 1; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 6px; text-align: center;
}
.toggles-row .toggle-label { font-size: 0.9rem; }
.toggles-row .switch { flex-direction: column; gap: 6px; }
.toggles-row .switch-state { min-width: 0; text-align: center; }

/* On/Off switch */
.switch {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; font: inherit; font-weight: 800;
  padding: 4px; color: var(--text-soft);
}
.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 999px; }
.switch-track {
  position: relative; width: 52px; height: 30px; border-radius: 999px;
  background: var(--border); transition: background var(--transition);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.18);
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  transition: transform var(--transition);
}
.switch.on .switch-track { background: var(--good); }
.switch.on .switch-thumb { transform: translateX(22px); }
.switch.on { color: var(--good); }
.switch-state { min-width: 2.2em; text-align: left; }

/* Modal / dialog */
#modalHost:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(20, 22, 43, 0.55); padding: var(--space);
  animation: fade var(--transition);
}
.modal {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--space-lg); width: 100%; max-width: 460px;
  max-height: 92vh; overflow-y: auto;
}
/* Theme picker needs more room for all themes - widen the modal on bigger screens so
   the whole set fits without scrolling (v1.3 round 6). */
.modal.modal-wide { max-width: 560px; }
@media (min-width: 700px) { .modal.modal-wide { max-width: 760px; } }
@media (min-width: 1000px) { .modal.modal-wide { max-width: 900px; } }
.modal h2 { text-align: center; }
/* 1-20 number tiles: 5-up on phones (4 rows), more columns on wider screens so the whole
   set stays compact and never needs scrolling. Pair with .modal-wide on the dialog. */
.table-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: var(--space) 0; }
@media (min-width: 560px) { .table-grid { grid-template-columns: repeat(7, 1fr); } }
@media (min-width: 820px) { .table-grid { grid-template-columns: repeat(10, 1fr); } }
.table-tile {
  aspect-ratio: 1; font: inherit; font-weight: 900; font-size: 1.2rem; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 3px solid var(--border); border-radius: var(--radius-sm);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 0 var(--border), 0 5px 10px rgba(76,60,180,0.12);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) { .table-tile:hover { transform: translateY(-2px); border-color: var(--brand); } }
.table-tile:active { transform: translateY(1px) scale(0.95); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.table-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.table-tile.selected { border-color: var(--brand); background: var(--surface-2); transform: none; box-shadow: inset 0 0 0 2px rgba(109,94,252,0.25); }

.home-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.home-nav .btn { flex: 1; }

/* ---------- Play ---------- */
.play-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.mode-tag { font-weight: 800; color: var(--text-soft); }

/* ---------- v1.4: hopscotch "board" of 10 numbered boxes + theme runner ----------
   A row of 10 numbered boxes replaces the old progress line. The theme character sits inside
   the current box and HOPS to the next box as the round advances. Completed boxes remember how
   it went (green tick = correct, soft amber marker = wrong). The runner is absolutely
   positioned; its `left` is set in px by JS (positionRunnerToBox, measured from the DOM) with
   translateX(-50%) centring it on the box, and a left-transition makes the hop glide. */
.qboard {
  position: relative;
  padding-top: 38px;        /* headroom above the boxes for the character + its hop */
  margin-bottom: 4px;
}
/* The whole row is framed as one "wagon": a chunky outer border wraps all 10 boxes, which
   sit inside as compartments divided by shared inner walls. Fully-rounded (pill) ends so the
   first/last compartment reads as a soft rounded edge; internal boxes are squared so the
   dividers read as walls, not gaps. */
.qbox-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0;                                   /* compartments share walls (no gap) */
  border: 3px solid var(--brand);
  border-radius: 999px;                     /* soft, fully-rounded ends on the first/last box */
  background: var(--surface-2);
  overflow: hidden;                         /* clip the compartments to the rounded frame */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 4px 10px rgba(76,60,180,0.16);
}
.qbox {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 0;                         /* square inside the wagon */
  background: var(--surface-2);
  border: 0;
  border-right: 2px solid var(--border);    /* the dividing wall between compartments */
  display: grid; place-items: center;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.qbox:last-child { border-right: 0; }       /* no wall after the final compartment */
.qbox-num { font-weight: 900; font-size: 0.8rem; color: var(--text-soft); line-height: 1; }
.qbox-mark { position: absolute; top: 1px; right: 2px; font-size: 0.6rem; line-height: 1; }

/* Current compartment: brand-tinted fill + an inset ring so it reads as "you are here"
   without lifting out of the wagon frame (the frame uses overflow:hidden, so no translate). */
.qbox.current {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--brand);
}
.qbox.current .qbox-num { color: var(--brand); }

/* Done compartments: tinted fill + a small corner marker. Correct = green tick, wrong = amber
   dot. We tint the compartment and recolour its dividing wall (no outer border to set). */
.qbox.done-correct { background: var(--good-bg); border-right-color: var(--good); }
.qbox.done-correct .qbox-num { color: var(--good); }
.qbox.done-correct .qbox-mark::before { content: '\2713'; color: var(--good); font-weight: 900; } /* tick */
.qbox.done-wrong { background: var(--bad-bg); border-right-color: var(--bad); }
.qbox.done-wrong .qbox-num { color: var(--bad); }
.qbox.done-wrong .qbox-mark::before { content: '\2022'; color: var(--accent); font-weight: 900; }   /* dot */

.progress-text { text-align: center; color: var(--text-soft); font-weight: 700; margin: 8px 0; }

.runner {
  position: absolute;
  left: 0; top: 0;                 /* sits above the boxes; `left` set in px by JS */
  width: 34px; height: 34px;
  transform: translateX(-50%);
  transition: left 440ms cubic-bezier(.34,1.3,.5,1); /* glide/hop to the next box with overshoot */
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.18));
  z-index: 2;
  /* v1.4: the character is interactive (hover/tap to greet). It sits in the headroom ABOVE
     the boxes, clear of the answer buttons, so enabling pointer events here is safe. */
  pointer-events: auto; cursor: pointer; touch-action: manipulation;
  transform-origin: 50% 100%;
}
.runner svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.runner:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

/* v1.4: full-screen confetti overlay (positioning is also set inline by confetti.js
   as a safety net). Non-interactive; sits above content but below modals. */
.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* On small screens the 10 compartments get tight - thin the frame/walls + shrink the number
   so the wagon still fits one row. */
@media (max-width: 560px) {
  .qbox-row { border-width: 2.5px; border-radius: 999px; }
  .qbox { border-right-width: 1.5px; }
  .qbox-num { font-size: 0.66rem; }
  .runner { width: 30px; height: 30px; }
}
@media (max-width: 380px) {
  .qbox-num { font-size: 0.58rem; }
}

/* A lively idle: a gentle bob with a slight side-to-side sway so the character feels alive. */
.runner[data-mood="idle"] { animation: runnerBob 2s ease-in-out infinite; }

/* One-shot reactions, added via the .react class. data-mood picks which keyframes run. */
.runner.react[data-mood="happy"] { animation: runnerHop 1000ms cubic-bezier(.28,.9,.35,1) 1; }
.runner.react[data-mood="sad"]   { animation: runnerStumble 950ms ease-in-out 1; }

/* Idle: a soft bob + tiny sway + micro-rotate (keeps translateX for centring). */
@keyframes runnerBob {
  0%, 100% { transform: translateX(-50%) translateY(0)    rotate(0deg); }
  25%      { transform: translateX(-53%) translateY(-2px) rotate(-3deg); }
  50%      { transform: translateX(-50%) translateY(-4px) rotate(0deg); }
  75%      { transform: translateX(-47%) translateY(-2px) rotate(3deg); }
}
/* Happy: a big, joyful double-hop - squash to launch, a tall spinning first hop, a second
   smaller bounce, then a squashy landing. */
@keyframes runnerHop {
  0%   { transform: translateX(-50%) translateY(0)     scale(1,1)        rotate(0deg); }
  10%  { transform: translateX(-50%) translateY(4px)   scale(1.18,0.82)  rotate(0deg); }   /* deep squash */
  32%  { transform: translateX(-50%) translateY(-34px) scale(0.86,1.16)  rotate(-18deg); } /* big launch + spin */
  46%  { transform: translateX(-50%) translateY(-30px) scale(1,1)        rotate(14deg); }  /* hang + counter-spin */
  58%  { transform: translateX(-50%) translateY(3px)   scale(1.14,0.86)  rotate(0deg); }   /* first landing squash */
  72%  { transform: translateX(-50%) translateY(-16px) scale(0.94,1.08)  rotate(-6deg); }  /* second, smaller hop */
  86%  { transform: translateX(-50%) translateY(2px)   scale(1.08,0.92)  rotate(0deg); }   /* land */
  100% { transform: translateX(-50%) translateY(0)     scale(1,1)        rotate(0deg); }
}
/* Sad: a more characterful trip - lurch forward, arms-out wobble both ways, a little hop to
   recover balance, then settle upright. Still dips toward the line but never leaves it. */
@keyframes runnerStumble {
  0%   { transform: translateX(-50%) translateY(0)    rotate(0deg)  scale(1,1); }
  15%  { transform: translateX(-46%) translateY(4px)  rotate(-20deg) scale(1.06,0.94); } /* trip forward */
  32%  { transform: translateX(-54%) translateY(6px)  rotate(14deg)  scale(1.08,0.92); } /* overbalance back */
  50%  { transform: translateX(-49%) translateY(2px)  rotate(-10deg) scale(1,1); }
  64%  { transform: translateX(-51%) translateY(-5px) rotate(4deg)   scale(0.96,1.04); } /* little recovery hop */
  80%  { transform: translateX(-50%) translateY(2px)  rotate(-3deg)  scale(1.02,0.98); }
  100% { transform: translateX(-50%) translateY(0)    rotate(0deg)   scale(1,1); }
}

/* v1.4: hover/tap "hello wave" - the character enlarges and rocks side to side like it's
   waving hello. Only fires when idle (the hop/stumble reactions take priority). On desktop it
   plays while hovered; on touch, JS adds .greet for one play on tap. */
@media (hover: hover) {
  .runner[data-mood="idle"]:not(.react):hover { animation: runnerGreet 900ms ease-in-out infinite; }
}
.runner[data-mood="idle"].greet:not(.react) { animation: runnerGreet 900ms ease-in-out 1; }
@keyframes runnerGreet {
  0%   { transform: translateX(-50%) translateY(0)    scale(1)    rotate(0deg); }
  20%  { transform: translateX(-50%) translateY(-5px) scale(1.35) rotate(-10deg); } /* zoom up + lean */
  40%  { transform: translateX(-50%) translateY(-5px) scale(1.35) rotate(9deg); }   /* wave over */
  60%  { transform: translateX(-50%) translateY(-5px) scale(1.35) rotate(-7deg); }  /* wave back */
  80%  { transform: translateX(-50%) translateY(-4px) scale(1.3)  rotate(5deg); }
  100% { transform: translateX(-50%) translateY(0)    scale(1)    rotate(0deg); }
}
/* Reduced motion: no wave animation, but still give a subtle static enlarge on hover so the
   character clearly reads as interactive. */
@media (prefers-reduced-motion: reduce) and (hover: hover) {
  .runner:hover { transform: translateX(-50%) scale(1.2); }
}

.timer-wrap { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.timer-wrap.hidden { display: none; }
.timer-bar { height: 100%; width: 100%; background: var(--accent); }

.question {
  text-align: center; font-size: var(--fs-question); font-weight: 900;
  margin: var(--space-lg) 0; color: var(--text);
}
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.option {
  font: inherit; font-weight: 900; font-size: 1.8rem;
  background: var(--surface); color: var(--text);
  border: 3px solid var(--border); border-radius: var(--radius);
  min-height: 84px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 0 var(--border), 0 6px 12px rgba(76,60,180,0.12);
  transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
@media (hover: hover) {
  .option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--brand);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 5px 0 var(--border), 0 10px 18px rgba(76,60,180,0.18); }
}
.option:active:not(:disabled) { transform: translateY(1px) scale(0.96); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.option:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.option:disabled { cursor: default; }
.option.is-correct { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

/* ---------- v1.2: Need a Hint? (untimed mode, after a pause) ---------- */
.hint-zone { min-height: 0; margin-top: var(--space); text-align: center; }
.hint-zone:empty { display: none; }
.hint-btn {
  font: inherit; font-weight: 900; font-size: 1.05rem; cursor: pointer;
  color: #4a2c00; background: linear-gradient(135deg, var(--accent), #ffd166);
  border: none; border-radius: 999px; padding: 12px 22px; min-height: var(--tap);
  box-shadow: 0 4px 0 rgba(180,120,0,0.35), 0 8px 16px rgba(255,183,3,0.35);
  animation: hintpop 300ms ease-out, hintpulse 1.6s ease-in-out 300ms infinite;
}
.hint-btn:hover { filter: brightness(1.04); }
.hint-btn:active { transform: translateY(1px) scale(0.97); }
.hint-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
@keyframes hintpop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes hintpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.hint-text {
  display: inline-block; text-align: left; font-weight: 700; line-height: 1.5;
  background: var(--surface-2); border: 2px solid var(--accent); border-radius: var(--radius);
  padding: 12px 16px; color: var(--text); animation: hintpop 300ms ease-out;
}

.feedback { text-align: center; font-weight: 900; font-size: 1.3rem; min-height: 1.8em; margin-top: var(--space); }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* ---------- Results ---------- */
#screen-results { text-align: center; }
.score-big { font-size: 3.2rem; font-weight: 900; color: var(--brand); margin: 8px 0; }
.stars { font-size: 2.4rem; letter-spacing: 6px; }
.star { filter: grayscale(1) opacity(0.35); transition: transform var(--transition); }
.star.on { filter: none; animation: pop 300ms ease-out; }
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.new-best { color: var(--accent); font-weight: 900; margin: 10px 0; }
.streak-note { color: var(--text-soft); font-weight: 700; }
.new-badges { margin: var(--space) 0; }
.badge-chip { display: inline-block; background: var(--surface-2); border: 2px solid var(--brand);
  border-radius: 999px; padding: 8px 16px; font-weight: 800; margin: 6px; }
.results-actions { margin-top: var(--space-lg); display: flex; flex-direction: column; gap: 10px; }

/* ---------- Mastery grid ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; font-size: 0.85rem; font-weight: 700; }
.legend .dot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }
.dot.solid { background: var(--m-solid); } .dot.okay { background: var(--m-okay); }
.dot.needs { background: var(--m-needs); } .dot.new { background: var(--m-new); }

.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.grid { display: flex; flex-direction: column; gap: 5px; min-width: 560px; }
.grid-row { display: grid; grid-template-columns: 34px repeat(20, 1fr); gap: 4px; align-items: center; }
.grid-header-row { position: sticky; top: 0; }
.grid-head { text-align: center; font-size: 0.62rem; font-weight: 800; color: var(--text-soft); }
.grid-label { font-weight: 900; color: var(--text-soft); font-size: 0.78rem; }
.cell {
  aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center;
  font-size: 0.6rem; font-weight: 800; color: #fff; min-width: 18px;
}
.cell-txt { opacity: 0.85; }
.cell.solid { background: var(--m-solid); }
.cell.okay { background: var(--m-okay); }
.cell.needs { background: var(--m-needs); }
.cell.new { background: var(--m-new); color: var(--text-soft); }

/* ---------- Rewards ---------- */
.bests { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: var(--space-lg); }
.best-item { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center; font-weight: 700; color: var(--text-soft); }
.best-num { display: block; font-size: 1.8rem; font-weight: 900; color: var(--brand); }
.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.badge-card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; }
.badge-card.locked { opacity: 0.55; }
.badge-card.earned { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.badge-icon { font-size: 2rem; }
.badge-name { font-weight: 900; margin-top: 4px; }
.badge-desc { font-size: 0.8rem; color: var(--text-soft); margin-top: 2px; }

/* ---------- Help ---------- */
.help-body { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: var(--space); line-height: 1.6; }
.help-body ol { padding-left: 1.2em; }
.help-body li { margin: 6px 0; }
.muted { color: var(--text-soft); font-size: 0.85rem; }

/* ---------- Larger screens: comfortable, centred, bigger options ---------- */
@media (min-width: 700px) {
  .options { gap: 18px; }
  .option { min-height: 96px; font-size: 2rem; }
}

/* ---------- Header right + profile chip ---------- */
/* nowrap keeps theme | Home | chip on ONE line; on small screens the buttons go icon-only. */
.header-right { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; min-width: 0; }
/* Compact header buttons so theme | Home | chip line up neatly. */
.header-right .btn-ghost { min-height: 44px; padding: 0 12px; font-size: 0.9rem; }
.header-right .btn-ghost .hdr-ico { font-size: 1.05rem; }
.header-right .btn-ghost .hdr-txt { margin-left: 6px; }
.home-btn.hidden { display: none; }

/* Mobile: single line, icon-only Theme/Home, tighter chip - avoids the header wrapping. */
@media (max-width: 560px) {
  .app-header { padding: 10px 12px; gap: 8px; }
  .brand-name { display: none; } /* keep the logo mark; drop the wordmark to save width */
  .header-right { gap: 6px; }
  .header-right .btn-ghost { padding: 0; width: 44px; min-width: 44px; }
  .header-right .btn-ghost .hdr-txt { display: none; } /* icon-only Theme + Home */
  .header-right .btn-ghost .hdr-ico { font-size: 1.2rem; margin: 0; }
  .chip-name { max-width: 5ch; }
  .chip-btn { padding: 4px 8px 4px 5px; }
}
.profile-chip { position: relative; }
.profile-chip.hidden { display: none; }
.chip-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 999px; padding: 4px 10px 4px 6px; min-height: 44px;
  font: inherit; font-weight: 800; color: var(--text); cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chip-btn:hover { border-color: var(--brand); }
.chip-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.chip-av { font-size: 1.3rem; }
.chip-name { max-width: 8ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-caret { color: var(--text-soft); font-size: 0.8rem; }
.chip-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 190px;
  /* Clip to rounded corners, but if the menu is ever taller than the viewport (very short
     screens) let it scroll INSIDE rather than clipping items off-screen. */
  overflow: hidden auto; max-height: min(80vh, 460px);
}
.chip-menu > button {
  display: block; width: 100%; text-align: left; font: inherit; font-weight: 700;
  background: none; border: none; color: var(--text); padding: 12px 16px; min-height: 48px; cursor: pointer;
}
.chip-menu > button:hover, .chip-menu > button:focus-visible { background: var(--surface-2); outline: none; }

/* v1.2: Timer / Sound / Music toggles inside the player menu - compact single row,
   each an icon with its On/Off switch stacked below (v1.2 round 3). */
.chip-menu-section {
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px 12px;
}
.menu-toggle {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 4px 2px;
}
.menu-toggle-icon { font-size: 1.35rem; line-height: 1; }
.chip-menu-section .switch { flex-direction: column; gap: 4px; padding: 0; }
.chip-menu-section .switch-state { min-width: 0; text-align: center; font-size: 0.8rem; }

/* ---------- Setup screen ---------- */
.setup { display: flex; flex-direction: column; gap: var(--space); }
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 800; }
.field input[type="text"] {
  font: inherit; padding: 12px 14px; min-height: var(--tap);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field input[type="text"]:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.field input[type="range"] { accent-color: var(--brand); height: 32px; }
/* Responsive: more columns on wider screens so every avatar shows without scrolling
   (min ~54px tile, auto-fitting as many columns as fit). (v1.3 round 6) */
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
@media (min-width: 600px) { .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 10px; } }
.avatar-opt {
  aspect-ratio: 1; font-size: 1.8rem; cursor: pointer;
  background: var(--surface); border: 3px solid var(--border); border-radius: var(--radius-sm);
  display: grid; place-items: center;
  transition: transform var(--transition), border-color var(--transition);
}
@media (hover: hover) {
  .avatar-opt:hover { transform: translateY(-2px); border-color: var(--brand); }
}
.avatar-opt:active { transform: translateY(1px) scale(0.94); }
.avatar-opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.avatar-opt.selected { border-color: var(--brand); background: var(--surface-2); transform: none; box-shadow: inset 0 0 0 2px rgba(109,94,252,0.25); }
.btn.danger { color: var(--bad); border-color: var(--bad); }

/* Gender picker tiles */
.gender-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gender-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: inherit; font-weight: 800; cursor: pointer; color: var(--text);
  background: var(--surface); border: 3px solid var(--border); border-radius: var(--radius);
  padding: 20px 10px; min-height: 110px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 0 var(--border), 0 5px 10px rgba(76,60,180,0.12);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) { .gender-opt:hover { transform: translateY(-2px); border-color: var(--brand); } }
.gender-opt:active { transform: translateY(1px) scale(0.96); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.gender-opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gender-opt.selected { border-color: var(--brand); background: var(--surface-2); transform: none; box-shadow: inset 0 0 0 2px rgba(109,94,252,0.25); }
.gender-emoji { font-size: 2.6rem; }

/* Profile summary card (edit view) */
.profile-card {
  display: flex; align-items: center; gap: var(--space); flex-wrap: wrap;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: var(--space); box-shadow: var(--shadow-sm); margin-bottom: var(--space);
}
.profile-avatar-big {
  font-size: 3.4rem; width: 84px; height: 84px; display: grid; place-items: center;
  background: var(--surface-2); border-radius: 20px; flex: none;
}
.profile-details { flex: 1; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.profile-details > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--border); padding-bottom: 6px; }
.profile-details dt { color: var(--text-soft); font-weight: 700; }
.profile-details dd { margin: 0; font-weight: 900; }
.play-top h2 { flex: 1; }

/* Age picker tiles */
.age-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.age-opt {
  aspect-ratio: 1; font: inherit; font-weight: 900; font-size: 1.2rem; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 3px solid var(--border); border-radius: var(--radius-sm);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 0 var(--border), 0 5px 10px rgba(76,60,180,0.12);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) {
  .age-opt:hover { transform: translateY(-2px); border-color: var(--brand); }
}
.age-opt:active { transform: translateY(1px) scale(0.95); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.age-opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.age-opt.selected {
  border-color: var(--brand); background: var(--surface-2); transform: none;
  box-shadow: inset 0 0 0 2px rgba(109,94,252,0.25);
}

/* Age stepper (v1.2): a single colourful editable box with - / + on each side */
.age-stepper {
  display: flex; align-items: stretch; justify-content: center; gap: 12px;
  margin-top: 4px;
}
.age-step-btn {
  flex: none; width: 64px; min-height: 64px; font: inherit; font-weight: 900; font-size: 2rem;
  color: #fff; border: none; border-radius: var(--radius); cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--emboss);
  display: grid; place-items: center; line-height: 1;
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}
@media (hover: hover) { .age-step-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--emboss-hover); filter: brightness(1.05); } }
.age-step-btn:active:not(:disabled) { transform: translateY(1px) scale(0.95); box-shadow: var(--emboss-press); }
.age-step-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.age-step-btn:disabled { opacity: 0.4; cursor: default; }
.age-input {
  flex: 1; max-width: 130px; text-align: center;
  font: inherit; font-weight: 900; font-size: 2.6rem; color: var(--brand);
  background: var(--surface-2); border: 3px solid var(--brand); border-radius: var(--radius);
  padding: 6px 4px; min-height: 64px;
  box-shadow: inset 0 2px 6px rgba(76,60,180,0.12);
}
.age-input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Hide the native number spinner - the +/- buttons are the control. */
.age-input::-webkit-outer-spin-button, .age-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.age-input { -moz-appearance: textfield; appearance: textfield; }

/* Setup wizard */
.wiz-dots { display: flex; justify-content: center; gap: 8px; margin: 4px 0 var(--space); }
.wiz-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--border); transition: background var(--transition), transform var(--transition); }
.wiz-dot.on { background: var(--brand); transform: scale(1.3); }
.wiz-dot.done { background: var(--brand-2); }
.wiz-step { min-height: 220px; }
.wiz-hint { color: var(--bad); font-weight: 700; text-align: center; margin: 8px 0 0; }
.wiz-actions { display: flex; gap: 10px; margin-top: var(--space); }
.wiz-actions .btn { flex: 1; }
.wiz-actions .btn-play { margin: 0; }

/* ---------- Who's playing ---------- */
.profile-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface); border: 3px solid var(--border); border-radius: var(--radius);
  padding: 18px 10px; min-height: 120px; cursor: pointer; color: var(--text); font: inherit;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.profile-pick:active { transform: scale(0.97); }
.profile-pick:hover { border-color: var(--brand); }
.profile-pick:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.profile-pick.add { border-style: dashed; color: var(--text-soft); }
.profile-pick-av { font-size: 2.6rem; }
.profile-pick-name { font-weight: 900; }
.profile-pick-age { font-size: 0.8rem; color: var(--text-soft); }

/* ---------- v1.1: Operations picker (fun, aligned tiles) ---------- */
.ops-hint { text-align: center; margin: 0 0 var(--space); }
/* Fixed 2 columns x 3 rows on every screen. Columns are capped in width and the grid is
   centred + width-limited so tiles stay squarish and don't stretch wide on a laptop. */
.op-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 150px));
  gap: 14px; justify-content: center;
  max-width: 340px; margin: 0 auto;
}
.op-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); border: 3px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; min-height: 81px; /* ~25% shorter (was 108px square) */
  cursor: pointer; color: var(--text); font: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 4px 0 var(--border), 0 8px 16px rgba(76,60,180,0.14);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) {
  .op-card:not(.coming-soon):hover {
    transform: translateY(-4px); border-color: var(--brand);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 7px 0 var(--border), 0 14px 26px rgba(76,60,180,0.22);
  }
  .op-card:not(.coming-soon):hover .op-symbol { transform: rotate(-6deg) scale(1.06); }
}
.op-card:not(.coming-soon):active { transform: translateY(1px) scale(0.97); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.op-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Emoji chip - a chunky rounded "squircle" with a soft per-op tint behind the emoji,
   echoing the MathFun app icon. The emoji keeps its own colour. */
.op-symbol {
  font-size: 1.8rem; line-height: 1;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -3px 6px rgba(0,0,0,0.10), 0 5px 12px rgba(76,60,180,0.18);
  transition: transform var(--transition), background var(--transition);
}
.op-name { font-weight: 900; font-size: 0.98rem; text-align: center; line-height: 1.15; }

/* Per-operation playful tints behind the emoji (bright, MathFun-family). */
.op-add .op-symbol { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }   /* green */
.op-sub .op-symbol { background: linear-gradient(135deg, #ffedd5, #fed7aa); }   /* orange */
.op-mul .op-symbol { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }   /* purple */
.op-div .op-symbol { background: linear-gradient(135deg, #fce7f3, #fbcfe8); }   /* pink */
.op-facts .op-symbol { background: linear-gradient(135deg, #fef9c3, #fde68a); } /* sunny yellow */
.op-daily .op-symbol { background: linear-gradient(135deg, #cffafe, #a5f3fc); } /* bright cyan */
@media (hover: hover) {
  .op-add:not(.coming-soon):hover { border-color: #22c55e; }
  .op-sub:not(.coming-soon):hover { border-color: #f97316; }
  .op-mul:not(.coming-soon):hover { border-color: #6d5efc; }
  .op-div:not(.coming-soon):hover { border-color: #ec4899; }
  .op-facts:hover { border-color: #eab308; }
  .op-daily:hover { border-color: #06b6d4; }
}

/* ---------- v1.2: Fun Facts screen ---------- */
.funfact-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 3px solid var(--border); border-radius: var(--radius);
  padding: var(--space-lg); text-align: center; min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  box-shadow: var(--shadow);
}
.funfact-emoji { font-size: 3.4rem; line-height: 1; }
.funfact-text { font-size: 1.25rem; font-weight: 800; margin: 0; line-height: 1.5; }
.funfact-card.pop { animation: factpop 320ms ease-out; }
@keyframes factpop {
  0% { transform: scale(0.94); opacity: 0.4; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

.op-card.coming-soon { cursor: not-allowed; opacity: 0.72; }
.op-card.coming-soon .op-symbol { filter: grayscale(0.55); }
.op-soon {
  position: absolute; top: 10px; right: 10px;
  background: var(--accent); color: #4a2c00; font-weight: 900; font-size: 0.62rem;
  padding: 3px 8px; border-radius: 999px; letter-spacing: 0.02em;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

/* Difficulty grid variants: keep a tidy 2-up on phones for both 3+table and 4-level sets. */
.mode-grid-4 { grid-template-columns: 1fr 1fr; }

/* ---------- v1.2: All-operations progress overview ---------- */
.op-progress-grid { display: flex; flex-direction: column; gap: 12px; }
.op-progress-card {
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; color: var(--text); font: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) { .op-progress-card:hover { transform: translateY(-2px); border-color: var(--brand); } }
.op-progress-card:active { transform: translateY(1px) scale(0.99); }
.op-progress-card:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.opc-head { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.1rem; }
.opc-symbol { font-size: 1.4rem; }
.opc-stats { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-soft); font-weight: 700; font-size: 0.9rem; }
.opc-stats b { color: var(--brand); font-size: 1.05rem; }

/* ---------- v1.1: Operation progress summary (add/sub/div) ---------- */
.op-summary { display: flex; flex-direction: column; gap: var(--space); }
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.summary-stats .stat {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px 8px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num { display: block; font-size: 1.9rem; font-weight: 900; color: var(--brand); }
.stat-lbl { font-size: 0.75rem; font-weight: 700; color: var(--text-soft); }
.summary-sub { text-align: center; font-size: 1.05rem; margin: 4px 0 0; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==================================================================================
   v1.3: Character themes (skins) - a parallel axis to Light/Dark.
   Applied via data-skin="<key>" on <html>. Each skin re-points the core palette
   tokens (--brand, --brand-2, --accent, --bg, --surface, --surface-2, --border) and
   sets a page background via --skin-bg. Because these only change token VALUES, the
   existing data-theme="light|dark" blocks still layer on top: dark mode re-darkens
   --bg/--surface after the skin has set the accent colours, so every skin has a
   light and a dark form.

   Trademark-safe: palettes + emoji + vibe only, no copyrighted assets.
   ================================================================================== */

/* The page background uses --skin-bg (a gradient/pattern per skin); defaults to --bg
   so the plain Math World / no-skin case is unchanged. Fixed so it doesn't scroll. */
body {
  background: var(--skin-bg, var(--bg));
  background-attachment: fixed;
  position: relative;
}

/* A themed decorative layer sits behind everything: a large, faint, tiled pattern of the
   skin's emoji (an inline SVG data-URI in --skin-pattern - fully offline, no image files).
   Fixed + non-interactive so it never scrolls or blocks taps. Math World / no-skin = none. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--skin-pattern, none);
  background-repeat: repeat;
  background-size: var(--skin-pattern-size, 260px 260px);
  opacity: var(--skin-pattern-opacity, 0.10);
  transition: opacity var(--transition);
}
/* Keep real content above the decorative layer. The HEADER must sit above .app-main so its
   dropdown menu (the player chip menu) is clickable where it overlaps the page content -
   otherwise .app-main (same z-index, later in the DOM) paints over the menu and swallows taps
   (v1.3.1 fix). #modalHost stays highest for full-screen dialogs. */
.app-main, .app-footer { position: relative; z-index: 1; }
.app-header { position: relative; z-index: 30; }
#modalHost { position: relative; z-index: 50; }
/* In dark mode the emoji pattern is dialled down so it doesn't fight the dark surfaces. */
:root[data-theme="dark"] body::before { opacity: 0.06; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before { opacity: 0.06; }
}
@media (prefers-reduced-motion: reduce) { body::before { transition: none; } }

/* ---- Math World (default): clean maths-symbol palette, scattered symbol pattern ---- */
:root[data-skin="math"] {
  --brand: #6d5efc; --brand-2: #ff8fab; --accent: #ffb703;
  --bg: #f5f3ff; --surface: #ffffff; --surface-2: #f1eefe; --border: #e5e1f7;
  --skin-bg:
    radial-gradient(circle at 12% 18%, rgba(109,94,252,0.10), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(255,143,171,0.10), transparent 44%),
    #f5f3ff;
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Ctext x='30' y='60' font-size='44'%3E%E2%9E%95%3C/text%3E%3Ctext x='150' y='110' font-size='44'%3E%E2%9C%96%EF%B8%8F%3C/text%3E%3Ctext x='60' y='180' font-size='44'%3E%E2%9E%97%3C/text%3E%3Ctext x='175' y='210' font-size='44'%3E%E2%9E%96%3C/text%3E%3Ctext x='110' y='150' font-size='40'%3E%F0%9F%94%A2%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.09;
}

/* ---- Plumber World: bright red/blue/coin-gold, sky + brick feel ---- */
:root[data-skin="plumber"] {
  --brand: #e5322f; --brand-2: #2a7de1; --accent: #f7c331;
  --bg: #eaf4ff; --surface: #ffffff; --surface-2: #e2f0ff; --border: #cfe3fb;
  --skin-bg: linear-gradient(180deg, #8ecbff 0%, #cfeaff 44%, #eaf4ff 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='30' y='60' font-size='46'%3E%F0%9F%8D%84%3C/text%3E%3Ctext x='160' y='110' font-size='42'%3E%E2%AD%90%3C/text%3E%3Ctext x='70' y='180' font-size='46'%3E%F0%9F%AA%99%3C/text%3E%3Ctext x='185' y='215' font-size='44'%3E%F0%9F%8F%B0%3C/text%3E%3Ctext x='120' y='150' font-size='42'%3E%F0%9F%8C%BC%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.12;
}

/* ---- Dino Valley: leafy greens + earthy amber, jungle canopy ---- */
:root[data-skin="dino"] {
  --brand: #3f9d4e; --brand-2: #b06a2c; --accent: #e0b23a;
  --bg: #eef7e9; --surface: #ffffff; --surface-2: #e4f1dc; --border: #cfe6c4;
  --skin-bg: linear-gradient(180deg, #cdeab6 0%, #e6f4dc 55%, #eef7e9 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='28' y='62' font-size='48'%3E%F0%9F%A6%96%3C/text%3E%3Ctext x='155' y='115' font-size='46'%3E%F0%9F%A6%95%3C/text%3E%3Ctext x='65' y='185' font-size='44'%3E%F0%9F%8C%8B%3C/text%3E%3Ctext x='185' y='215' font-size='44'%3E%F0%9F%8C%B4%3C/text%3E%3Ctext x='120' y='150' font-size='40'%3E%F0%9F%A5%9A%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.13;
}

/* ---- Speedy Hedgehog: electric blue + gold ring, fast + zingy ---- */
:root[data-skin="hedgehog"] {
  --brand: #1f6feb; --brand-2: #16a34a; --accent: #f5c518;
  --bg: #e9f1ff; --surface: #ffffff; --surface-2: #dfeafe; --border: #c7dbfb;
  --skin-bg: linear-gradient(135deg, #bfe0ff 0%, #dceeff 50%, #e9f1ff 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='44'%3E%E2%9A%A1%3C/text%3E%3Ctext x='155' y='108' font-size='44'%3E%F0%9F%92%8D%3C/text%3E%3Ctext x='65' y='180' font-size='42'%3E%F0%9F%8F%8E%EF%B8%8F%3C/text%3E%3Ctext x='180' y='210' font-size='44'%3E%E2%9C%A8%3C/text%3E%3Ctext x='115' y='150' font-size='40'%3E%F0%9F%94%B5%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.11;
}

/* ---- Magic Kingdom: royal purple + pink sparkle + gold ---- */
:root[data-skin="magic"] {
  --brand: #8b5cf6; --brand-2: #ec4899; --accent: #fbbf24;
  --bg: #f6effe; --surface: #ffffff; --surface-2: #efe4fd; --border: #e4d3fb;
  --skin-bg:
    radial-gradient(circle at 20% 12%, rgba(251,191,36,0.14), transparent 38%),
    radial-gradient(circle at 84% 20%, rgba(236,72,153,0.12), transparent 40%),
    linear-gradient(180deg, #efe0ff 0%, #f6effe 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='44'%3E%E2%9C%A8%3C/text%3E%3Ctext x='155' y='108' font-size='46'%3E%F0%9F%8F%B0%3C/text%3E%3Ctext x='65' y='180' font-size='44'%3E%F0%9F%A6%84%3C/text%3E%3Ctext x='180' y='212' font-size='42'%3E%F0%9F%8C%88%3C/text%3E%3Ctext x='115' y='148' font-size='40'%3E%F0%9F%8C%9F%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.12;
}

/* ---- Space Blast: deep indigo/violet, starry night (dark-leaning) ---- */
:root[data-skin="space"] {
  --brand: #7c6cff; --brand-2: #22d3ee; --accent: #f5c518;
  --bg: #eef0ff; --surface: #ffffff; --surface-2: #e6e8fe; --border: #d3d6fb;
  --skin-bg:
    radial-gradient(circle at 15% 20%, rgba(124,108,255,0.10), transparent 40%),
    radial-gradient(circle at 80% 75%, rgba(34,211,238,0.10), transparent 42%),
    linear-gradient(180deg, #e3e6ff 0%, #eef0ff 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='46'%3E%F0%9F%9A%80%3C/text%3E%3Ctext x='155' y='108' font-size='42'%3E%E2%AD%90%3C/text%3E%3Ctext x='65' y='180' font-size='44'%3E%F0%9F%AA%90%3C/text%3E%3Ctext x='182' y='212' font-size='42'%3E%F0%9F%91%BD%3C/text%3E%3Ctext x='112' y='148' font-size='40'%3E%E2%98%84%EF%B8%8F%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.12;
}

/* ---- Ocean Deep: aqua/teal, watery depths ---- */
:root[data-skin="ocean"] {
  --brand: #0891b2; --brand-2: #2563eb; --accent: #f59e0b;
  --bg: #e7f7fb; --surface: #ffffff; --surface-2: #d9f1f7; --border: #c0e6ef;
  --skin-bg: linear-gradient(180deg, #a9e6f2 0%, #cdeef5 50%, #e7f7fb 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='28' y='60' font-size='46'%3E%F0%9F%90%9F%3C/text%3E%3Ctext x='158' y='112' font-size='46'%3E%F0%9F%90%99%3C/text%3E%3Ctext x='62' y='185' font-size='46'%3E%F0%9F%90%B3%3C/text%3E%3Ctext x='185' y='215' font-size='44'%3E%F0%9F%90%A0%3C/text%3E%3Ctext x='118' y='150' font-size='42'%3E%F0%9F%8C%8A%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.13;
}

/* ---- Jungle Safari: warm leaf-green + safari tan ---- */
:root[data-skin="jungle"] {
  --brand: #2f9e44; --brand-2: #d97706; --accent: #eab308;
  --bg: #f0f7e8; --surface: #ffffff; --surface-2: #e7f2d9; --border: #d3e6bf;
  --skin-bg: linear-gradient(180deg, #d8ecb8 0%, #e9f4d8 55%, #f0f7e8 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='28' y='62' font-size='46'%3E%F0%9F%A6%81%3C/text%3E%3Ctext x='158' y='112' font-size='46'%3E%F0%9F%90%92%3C/text%3E%3Ctext x='62' y='185' font-size='46'%3E%F0%9F%90%98%3C/text%3E%3Ctext x='185' y='215' font-size='44'%3E%F0%9F%A6%92%3C/text%3E%3Ctext x='118' y='150' font-size='42'%3E%F0%9F%8C%B4%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.12;
}

/* ---- Candy Land: bubblegum pink + mint + sunny yellow ---- */
:root[data-skin="candy"] {
  --brand: #ec4899; --brand-2: #22c55e; --accent: #fbbf24;
  --bg: #fff0f7; --surface: #ffffff; --surface-2: #ffe3f0; --border: #fccbe1;
  --skin-bg:
    radial-gradient(circle at 18% 16%, rgba(34,197,94,0.10), transparent 36%),
    radial-gradient(circle at 82% 78%, rgba(251,191,36,0.12), transparent 40%),
    linear-gradient(180deg, #ffe0ef 0%, #fff0f7 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='44'%3E%F0%9F%8D%AD%3C/text%3E%3Ctext x='155' y='110' font-size='44'%3E%F0%9F%A7%81%3C/text%3E%3Ctext x='65' y='182' font-size='44'%3E%F0%9F%8D%A9%3C/text%3E%3Ctext x='182' y='212' font-size='44'%3E%F0%9F%8D%AC%3C/text%3E%3Ctext x='115' y='150' font-size='42'%3E%F0%9F%8D%A6%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.13;
}

/* ---- Robot Lab: steel slate + cyan circuit + amber ---- */
:root[data-skin="robot"] {
  --brand: #3b82f6; --brand-2: #14b8a6; --accent: #f59e0b;
  --bg: #eef2f7; --surface: #ffffff; --surface-2: #e3e9f1; --border: #cdd6e3;
  --skin-bg:
    linear-gradient(135deg, rgba(59,130,246,0.06), transparent 45%),
    linear-gradient(180deg, #e2e8f2 0%, #eef2f7 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='44'%3E%F0%9F%A4%96%3C/text%3E%3Ctext x='155' y='110' font-size='42'%3E%E2%9A%99%EF%B8%8F%3C/text%3E%3Ctext x='65' y='182' font-size='44'%3E%F0%9F%92%A1%3C/text%3E%3Ctext x='182' y='212' font-size='42'%3E%F0%9F%94%8B%3C/text%3E%3Ctext x='113' y='150' font-size='40'%3E%F0%9F%9B%B0%EF%B8%8F%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.11;
}

/* ==== v1.4 NEW skins (original, trademark-safe vibe-alikes) ==== */

/* ---- Honey Woods: warm honey-gold + soft red, cosy woodland ---- */
:root[data-skin="honey"] {
  --brand: #e0982f; --brand-2: #d9643a; --accent: #f4c430;
  --bg: #fdf5e3; --surface: #ffffff; --surface-2: #fbeccb; --border: #f0dca8;
  --skin-bg: linear-gradient(180deg, #ffe9b8 0%, #fdf1d6 55%, #fdf5e3 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='28' y='62' font-size='46'%3E%F0%9F%90%BB%3C/text%3E%3Ctext x='158' y='112' font-size='42'%3E%F0%9F%90%9D%3C/text%3E%3Ctext x='62' y='185' font-size='46'%3E%F0%9F%8D%AF%3C/text%3E%3Ctext x='185' y='215' font-size='44'%3E%F0%9F%8E%88%3C/text%3E%3Ctext x='118' y='150' font-size='42'%3E%F0%9F%8D%82%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.13;
}

/* ---- Kart Racers: racing red + track blue + checkered-flag energy ---- */
:root[data-skin="kart"] {
  --brand: #e11d48; --brand-2: #2563eb; --accent: #f5c518;
  --bg: #fdeef0; --surface: #ffffff; --surface-2: #fbe0e5; --border: #f6c4cd;
  --skin-bg: linear-gradient(135deg, #ffd9df 0%, #ffe9ec 50%, #fdeef0 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='28' y='60' font-size='44'%3E%F0%9F%8F%8E%EF%B8%8F%3C/text%3E%3Ctext x='158' y='110' font-size='44'%3E%F0%9F%8F%81%3C/text%3E%3Ctext x='62' y='182' font-size='44'%3E%F0%9F%8F%86%3C/text%3E%3Ctext x='185' y='214' font-size='42'%3E%E2%AD%90%3C/text%3E%3Ctext x='116' y='150' font-size='40'%3E%F0%9F%9B%9E%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.11;
}

/* ---- Piggy Puddles: bubblegum pink + puddle blue, rainy-day fun ---- */
:root[data-skin="piggy"] {
  --brand: #ec4b8a; --brand-2: #3b82f6; --accent: #fbbf24;
  --bg: #fff0f6; --surface: #ffffff; --surface-2: #ffe1ee; --border: #fcc7dd;
  --skin-bg: linear-gradient(180deg, #ffd6e8 0%, #ffe6f0 55%, #fff0f6 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Ctext x='28' y='62' font-size='46'%3E%F0%9F%90%B7%3C/text%3E%3Ctext x='158' y='112' font-size='42'%3E%E2%98%82%EF%B8%8F%3C/text%3E%3Ctext x='62' y='185' font-size='44'%3E%F0%9F%8C%88%3C/text%3E%3Ctext x='185' y='215' font-size='44'%3E%F0%9F%8C%BC%3C/text%3E%3Ctext x='118' y='150' font-size='42'%3E%F0%9F%92%A7%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.12;
}

/* ---- Robo Cat: bright sky-blue + white + red collar, futuristic + friendly ---- */
:root[data-skin="robocat"] {
  --brand: #2aa5e0; --brand-2: #e5322f; --accent: #f5c518;
  --bg: #e8f6fe; --surface: #ffffff; --surface-2: #dcf0fd; --border: #bfe3f7;
  --skin-bg: linear-gradient(135deg, #bfe6fb 0%, #ddf2fe 50%, #e8f6fe 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='44'%3E%F0%9F%90%B1%3C/text%3E%3Ctext x='155' y='110' font-size='42'%3E%F0%9F%94%94%3C/text%3E%3Ctext x='65' y='182' font-size='44'%3E%F0%9F%9A%80%3C/text%3E%3Ctext x='182' y='212' font-size='42'%3E%F0%9F%94%AE%3C/text%3E%3Ctext x='114' y='150' font-size='40'%3E%E2%AD%90%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.11;
}

/* ---- Little Explorer: sunny yellow + sky blue, bright + cheerful ---- */
:root[data-skin="explorer"] {
  --brand: #f5a623; --brand-2: #2a7de1; --accent: #ec4899;
  --bg: #fff8e9; --surface: #ffffff; --surface-2: #fdefcf; --border: #f6e0a8;
  --skin-bg:
    radial-gradient(circle at 18% 16%, rgba(42,125,225,0.10), transparent 38%),
    radial-gradient(circle at 82% 80%, rgba(236,72,153,0.10), transparent 40%),
    linear-gradient(180deg, #fff1cc 0%, #fff8e9 100%);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Ctext x='30' y='60' font-size='44'%3E%F0%9F%A7%92%3C/text%3E%3Ctext x='155' y='110' font-size='42'%3E%F0%9F%90%A5%3C/text%3E%3Ctext x='65' y='182' font-size='44'%3E%F0%9F%90%B6%3C/text%3E%3Ctext x='182' y='212' font-size='42'%3E%F0%9F%8E%88%3C/text%3E%3Ctext x='114' y='150' font-size='40'%3E%E2%9A%BD%3C/text%3E%3C/svg%3E");
  --skin-pattern-opacity: 0.12;
}

/* ---- Dark form of each skin: keep the skin's accents (--brand/--brand-2/--accent
   set above), but re-darken the surfaces so dark mode reads consistently across skins.
   These fire only when the user also has dark selected (manual or, for no explicit
   choice, OS-dark). ---- */
:root[data-theme="dark"] {
  --bg: #14162b; --surface: #1e2140; --surface-2: #262a4d;
  --text: #f0f1fb; --text-soft: #a6abcf; --border: #333863;
  --skin-bg:
    radial-gradient(circle at 15% 18%, rgba(255,255,255,0.03), transparent 40%),
    #14162b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --skin-bg:
      radial-gradient(circle at 15% 18%, rgba(255,255,255,0.03), transparent 40%),
      #14162b;
  }
}

/* ---- Skin picker (wizard step + menu) - reuses the tile look ---- */
/* Responsive columns so all themes fit WITHOUT a scrollbar: 2-up on phones, 3-up on
   tablets, 4-up on laptops (paired with the .modal-wide widths). No height cap. (v1.3 r6) */
.theme-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 2px;
}
@media (min-width: 560px) { .theme-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .theme-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
/* Tile: compact padding/gap (v1.3 r6) so all fit comfortably on one screen. */
.theme-opt {
  display: flex; align-items: center; gap: 8px; text-align: left;
  background: var(--surface); border: 3px solid var(--border); border-radius: var(--radius);
  padding: 10px; cursor: pointer; color: var(--text); font: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 0 var(--border), 0 5px 10px rgba(76,60,180,0.12);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
@media (hover: hover) { .theme-opt:hover { transform: translateY(-2px); border-color: var(--brand); } }
.theme-opt:active { transform: translateY(1px) scale(0.97); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.theme-opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.theme-opt.selected { border-color: var(--brand); background: var(--surface-2); transform: none; box-shadow: inset 0 0 0 2px rgba(109,94,252,0.28); }
.theme-opt-emoji {
  font-size: 1.5rem; line-height: 1; flex: none;
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 0 4px 10px rgba(0,0,0,0.12);
}
.theme-opt-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.theme-opt-name { font-weight: 900; font-size: 0.98rem; }
.theme-opt-tag { font-size: 0.74rem; color: var(--text-soft); font-weight: 700; line-height: 1.2; }

/* In the player menu: a compact "Theme" launcher row that opens the picker dialog. */
.chip-menu .menu-theme-current { color: var(--text-soft); font-weight: 700; font-size: 0.8rem; }

/* ---- Footer (v1.3): shown on every screen ---- */
.app-footer {
  flex: none; text-align: center; padding: 12px var(--space) 16px;
  color: var(--text-soft); line-height: 1.5;
}
.app-footer .footer-brand { font-weight: 800; font-size: 0.82rem; }
/* No extra opacity here: it would compound with the already-soft colour + small size and
   risk dipping below the 4.5:1 contrast minimum on the lighter themed backgrounds (a11y). */
.app-footer .footer-copy { font-size: 0.72rem; }
.app-footer .footer-brand .accent { color: var(--brand); }
@media (max-width: 560px) {
  .app-footer { padding: 10px 12px 14px; }
  .app-footer .footer-brand { font-size: 0.78rem; }
  .app-footer .footer-copy { font-size: 0.68rem; }
}

/* ==================================================================================
   v1.3 round 4: fill the empty space - centre short screens vertically and scale content
   up on larger viewports so the layout doesn't look sparse (mobile, tablet or laptop).
   ================================================================================== */

/* Let the main area grow to fill the viewport between header and footer, so its screens
   have room to centre into rather than hugging the top. */
.app-main { display: flex; flex-direction: column; }
.screen.is-active { flex: 1; }

/* The "short" screens (few controls) centre their content vertically + horizontally so
   they use the whole space instead of clinging to the top. Content-heavy/scrolling screens
   (play, progress grid, rewards, help, setup wizard) stay top-aligned so nothing is cut off. */
#screen-ops.is-active,
#screen-who.is-active,
#screen-funfacts.is-active,
#screen-results.is-active {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 8px; min-height: 100%;
}
#screen-ops.is-active > *,
#screen-who.is-active > *,
#screen-funfacts.is-active > *,
#screen-results.is-active > * { width: 100%; }

/* Bigger, more generous tiles/headings once there's room (tablet + laptop). Fills the
   width nicely without stretching tiles absurdly wide. */
@media (min-width: 600px) {
  .op-grid { grid-template-columns: repeat(2, minmax(0, 200px)); max-width: 440px; gap: 20px; }
  .op-card { min-height: 120px; }
  .op-symbol { width: 58px; height: 58px; font-size: 2.3rem; border-radius: 18px; }
  .op-name { font-size: 1.15rem; }
  .profile-picks { max-width: 460px; margin: 0 auto; }
  h2 { font-size: 1.8rem; }
}

/* Wide laptop/desktop: allow three across so the row of six option tiles reads as 3x2 and
   fills the width instead of leaving big side gutters. */
@media (min-width: 900px) {
  .op-grid { grid-template-columns: repeat(3, minmax(0, 200px)); max-width: 680px; }
}

/* On phones, give the short screens a little breathing room and let the tiles grow a bit
   so the 2x3 grid fills more of the tall screen. */
@media (max-width: 560px) {
  .op-grid { max-width: 92vw; gap: 14px; }
  .op-card { min-height: 96px; }
  .op-symbol { width: 50px; height: 50px; font-size: 2rem; }
}

/* ==================================================================================
   v1.4: "update available" toast - a small bottom banner shown when a new service-worker
   version is waiting. Tap Update to activate it (page reloads into the new version); Later
   hides it for this session. Theme-tinted; reduced-motion-safe (the global block disables
   the slide transition, and the JS removes it via a timeout).
   ================================================================================== */
.update-toast {
  position: fixed;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%) translateY(140%);   /* start off-screen below */
  z-index: 70;                                     /* above confetti (60) + content */
  width: min(440px, calc(100vw - 24px));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--surface); color: var(--text);
  border: 2px solid var(--brand); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  transition: transform 320ms cubic-bezier(.2,.8,.3,1);
}
.update-toast.show { transform: translateX(-50%) translateY(0); }
.update-toast-text { font-weight: 800; font-size: 0.95rem; text-align: center; }
.update-toast-actions { display: flex; align-items: center; justify-content: center; gap: 10px; }
.update-toast .update-toast-update { width: auto; margin: 0; min-height: 44px; font-size: 1rem; padding: 0 18px; }
.update-toast-dismiss {
  font: inherit; font-weight: 800; cursor: pointer;
  background: none; border: none; color: var(--text-soft);
  min-height: 44px; padding: 0 10px; border-radius: var(--radius-sm);
}
.update-toast-dismiss:hover { color: var(--text); }
.update-toast-dismiss:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 560px) {
  .update-toast { gap: 8px; padding: 10px 12px; }
  .update-toast-text { font-size: 0.88rem; }
}
