/* style.css — رحلة يارا · الرياضيات — «خلية يارا» (Yara's Honey Hive).
   1) tokens and base (design-samples/tokens.css, verbatim)   2) the shell and every non-play screen
   3) the engine's play / mechanic / stimulus rules (legacy skin; play.css, loaded after this file, re-skins them).
   No web fonts, no url() outside the project, no external requests. See DESIGN.md. */

:root {
  color-scheme: light;

  /* ---------- ink and paper (reading surfaces) ---------- */
  --paper:        #FFFCF3;  /* cards, bubbles, keypad face            ink on it 16.1:1 */
  --paper-2:      #FBF2DC;  /* second surface, mat, pressed key        ink 14.8:1       */
  --paper-3:      #F4E7C6;  /* key lip, quiet dividers by tone                           */
  --ink:          #2A1C0C;  /* all reading text                                         */
  --ink-2:        #5B4426;  /* secondary text (8.9:1 on paper) — never lighter           */
  --ink-on-dark:  #FFF8E6;  /* text on --action                                         */

  /* ---------- honey and wax (the world's material; frames and rewards, never under text) ---------- */
  --honey:        #F5B120;
  --honey-deep:   #E39410;
  --honey-light:  #FFD36B;
  --honey-shine:  #FFE9A8;
  --wax:          #F0CE74;  /* cell wall                                                 */
  --wax-rim:      #C99637;  /* outer rim of a comb                                       */
  --wax-rim-dark: #A87A26;
  --wax-empty:    #FFF4D4;  /* inside of an empty (current) cell                         */
  --wax-raw:      #F6EEDB;  /* unbuilt cell: locked / not yet                            */
  --wax-raw-rim:  #DCCB9F;

  /* ---------- actions ---------- */
  --action:       #7A4600;  /* primary button (العبي، تحقّق، التالي) — cream text 7.3:1   */
  --action-press: #5F3600;
  --action-lip:   #4A2A00;

  /* ---------- feedback (never colour alone: always ✓/✗ shape + a word) ---------- */
  --right:        #255E22;  /* ✓ badge, right border (7.6:1 on paper)                    */
  --right-tint:   #E6F2D9;
  --notyet:       #6E6250;  /* ✗ badge (warm grey, never red)                            */
  --notyet-tint:  #EFEAE0;  /* tried card fill                                           */
  --notyet-line:  #8A6A4A;  /* dashed outline of a tried card / answer slot              */
  --hint:         #FFF1C4;  /* hint bubble wash behind the bulb                           */

  /* ---------- stars ---------- */
  --star:         #F5B120;
  --star-line:    #A86A00;
  --star-empty:   #F6EAD0;
  --star-empty-line: #C9A86A;

  /* ---------- the garden (scenery only, art.js paints these) ---------- */
  --sky:          #D4EBF2;
  --cloud:        #F8FCFD;
  --haze:         #C9DEC4;
  --hill:         #ADCF8C;
  --meadow:       #7DB353;
  --meadow-deep:  #62983C;
  --stone:        #EFE3C8;
  --stone-shade:  #D9C8A2;
  --olive-leaf:   #93A77F;
  --olive-silver: #C8D3BA;
  --bark:         #6E5034;

  /* ---------- the book's base-ten blocks (p009 blue) ---------- */
  --blk-face:     #45A3E5;
  --blk-top:      #A3D4F6;
  --blk-side:     #2B7CC1;
  --blk-line:     #1E5F9C;
  --blk:          96px;     /* height of a hundred flat AND a ten rod; a one = --blk * 18/108 */

  /* ---------- the five units: strong / dark (text on tint ≥ 7:1) / tint ---------- */
  --u1: #EFA81E;  --u1-dark: #6E4100;  --u1-tint: #FFF0C7;  /* الأعداد — sunflower honey      */
  --u2: #E2694C;  --u2-dark: #7F270F;  --u2-tint: #FCE3DA;  /* مقارنة الأعداد — anemone coral */
  --u3: #6FA33B;  --u3-dark: #265210;  --u3-tint: #E3F1D1;  /* الجمع — olive leaf (dark 7.7:1 on tint) */
  --u4: #CC4D88;  --u4-dark: #7A1D4D;  --u4-tint: #F9DCE9;  /* الطرح — bougainvillea         */
  --u5: #2E97AB;  --u5-dark: #0F4C58;  --u5-tint: #D6EEF2;  /* معالجة البيانات — Aqaba sea   */
  --unit: var(--u1); --unit-dark: var(--u1-dark); --unit-tint: var(--u1-tint);

  /* ---------- type (system fonts only) ---------- */
  --font: "SF Arabic Rounded", ui-rounded, system-ui, "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
  --fs-label:    18px;                                   /* floor for any word               */
  --fs-body:     20px;
  --fs-title:    clamp(22px, 1.2vmin + 13px, 26px);      /* cell titles, card titles         */
  --fs-heading:  clamp(26px, 1.6vmin + 14px, 32px);      /* screen titles                    */
  --fs-question: clamp(28px, 2.6vmin + 10px, 38px);      /* the question, never under 28     */
  --fs-numeral:  clamp(30px, 3vmin + 8px, 40px);         /* keypad digits, option numbers    */
  --fs-answer:   clamp(40px, 4.6vmin + 6px, 56px);       /* the answer slot, win score       */
  --lh-tight: 1.2;  --lh-body: 1.5;
  --fw-regular: 500; --fw-bold: 700; --fw-heavy: 800;

  /* ---------- space (4-pt), radius, depth ---------- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --gutter: 24px;           /* outer margin on tablets; 16px on phones                       */
  --tap: 64px;              /* tablet touch target; 48px is the hard floor                   */
  --r-sm: 12px; --r-md: 20px; --r-lg: 28px; --r-pill: 999px;
  --lip: 4px;               /* pressable keys/buttons sit on a darker wax lip of this height */
  --lift-1: 0 1px 0 rgba(122, 82, 20, .14), 0 6px 16px -8px rgba(90, 60, 10, .32);   /* cards at rest  */
  --lift-2: 0 2px 0 rgba(122, 82, 20, .16), 0 14px 32px -12px rgba(90, 60, 10, .40); /* bubble, dialog */
  --focus: 0 0 0 3px var(--paper), 0 0 0 7px var(--ink);                              /* focus-visible  */

  /* ---------- motion ---------- */
  --t-fast: 150ms; --t-med: 220ms; --t-slow: 300ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);          /* everything that arrives               */
  --ease-honey: cubic-bezier(.33, 0, .2, 1);         /* liquid filling, drips                 */
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);     /* the ✓ pop, once                       */

  --z-scene: 0; --z-ui: 10; --z-mascot: 20; --z-toast: 30; --z-dialog: 40;

  /* honeycomb geometry: pointy-top hexagon, height = width × 1.1547 */
  --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.u1 { --unit: var(--u1); --unit-dark: var(--u1-dark); --unit-tint: var(--u1-tint); }
.u2 { --unit: var(--u2); --unit-dark: var(--u2-dark); --unit-tint: var(--u2-tint); }
.u3 { --unit: var(--u3); --unit-dark: var(--u3-dark); --unit-tint: var(--u3-tint); }
.u4 { --unit: var(--u4); --unit-dark: var(--u4-dark); --unit-tint: var(--u4-tint); }
.u5 { --unit: var(--u5); --unit-dark: var(--u5-dark); --unit-tint: var(--u5-tint); }

@media (max-width: 600px) {
  :root { --gutter: 16px; --tap: 56px; --fs-body: 18px; --blk: 72px; }
}
@media (min-width: 1000px) and (min-height: 700px) {
  :root { --blk: 112px; }
}

/* ============================== base ============================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%; height: 100%;
  font-family: var(--font); font-size: var(--fs-body); font-weight: var(--fw-regular);
  line-height: var(--lh-body); color: var(--ink); background: var(--sky);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; touch-action: manipulation;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: var(--lh-tight); font-weight: var(--fw-heavy); text-wrap: balance; }
img, svg { display: block; max-width: 100%; }
svg.art { overflow: visible; }

/* Western digits stay LTR inside RTL text; always tabular so numbers don't jiggle */
bdi.n, .n, .num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums lining-nums; }

button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; -webkit-user-select: none; user-select: none;
  min-width: 48px; min-height: 48px; border-radius: var(--r-md);
}
button:disabled { cursor: default; }

/* the one focus ring: keyboard only, never left behind by a tap */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }

::selection { background: var(--honey-light); color: var(--ink); }
input, textarea { font: inherit; color: var(--ink); caret-color: var(--action); }
* { scrollbar-width: thin; scrollbar-color: var(--wax-rim) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--wax); border-radius: 10px; border: 2px solid var(--paper-2); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============================== shared surfaces ============================== */
.card   { background: var(--paper); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--lift-1); }
.plaque { background: var(--paper); color: var(--ink); border-radius: var(--r-sm); box-shadow: var(--lift-1); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s6); border-radius: var(--r-pill);
  background: var(--action); color: var(--ink-on-dark);
  font-size: var(--fs-title); font-weight: var(--fw-heavy);
  border-bottom: var(--lip) solid var(--action-lip);
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.btn-primary:active { transform: translateY(2px); border-bottom-width: 2px; background: var(--action-press); }

/* ============================== art hooks (classes emitted by art.js) ============================== */
.art-honey-surface { animation: art-slosh 5.5s ease-in-out infinite alternate; transform-box: fill-box; }
.art-drip          { animation: art-drip 3.6s var(--ease-honey) infinite; transform-box: fill-box; transform-origin: 50% 0; }
.art-pulse         { animation: art-pulse 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
.art-cloud         { animation: art-drift 60s linear infinite alternate; }
.art-twinkle       { animation: art-twinkle 3s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
.art-sway          { animation: art-sway 7s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.art-bee-hover     { animation: art-hover 3.2s ease-in-out infinite; }

@keyframes art-slosh   { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes art-drip    { 0%, 55% { transform: scaleY(.55); } 80% { transform: scaleY(1.08); } 100% { transform: scaleY(.55); } }
@keyframes art-pulse   { 0%, 100% { opacity: .45; transform: scale(.97); } 50% { opacity: 1; transform: scale(1.015); } }
@keyframes art-drift   { from { transform: translateX(-18px); } to { transform: translateX(18px); } }
@keyframes art-twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes art-sway    { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@keyframes art-hover   { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* the signature move: a honey drop falls into the progress cell and fills it (see DESIGN.md) */
@keyframes honey-fall  { 0% { transform: translateY(-120%) scale(.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes honey-fill  { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop-in      { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes lift        { 0% { transform: translateY(0); } 40% { transform: translateY(-8px); } 100% { transform: translateY(0); } }
@keyframes nudge       { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes settle      { 0% { transform: translateY(0); } 30% { transform: translateY(3px); } 100% { transform: translateY(0); } }
@keyframes gate-ring   { from { stroke-dashoffset: var(--ring-len, 151); } to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
  .art-honey-surface, .art-drip, .art-pulse, .art-cloud, .art-twinkle, .art-sway, .art-bee-hover { animation: none !important; }
}

/* =====================================================================================
   THE SHELL — «خلية يارا»: app frame, top bar, hive home, learn, win, album, parent corner,
   dialogs. Play / mechanics / stimuli live in the legacy block below and in play.css.
   ===================================================================================== */

[hidden] { display: none !important; }
.app {
  min-height: 100dvh; position: relative;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.screen { position: relative; min-height: 100dvh; isolation: isolate; display: flow-root; }
.eqn { white-space: nowrap; }

/* the garden behind a screen: fixed, full bleed, never under words */
.scene-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: var(--sky); }
.scene-bg > svg { width: 100%; height: 100%; max-width: none; }

/* ---------- buttons ---------- */
.btn, .btn-icon, .tb-chip, .unit-tab, .cell, .lrow, .sticker, .switch {
  cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding-inline: 24px; border-radius: var(--r-pill);
  background: var(--paper-2); color: var(--ink); border-bottom: var(--lip) solid var(--paper-3);
  font-size: var(--fs-title); font-weight: var(--fw-heavy); line-height: 1.2; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out), border-bottom-width var(--t-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; background: var(--paper-3); }
.btn.btn-primary, .btn-primary { background: var(--action); color: var(--ink-on-dark); border-bottom: var(--lip) solid var(--action-lip); }
.btn.btn-primary:active:not(:disabled) { background: var(--action-press); }
.btn:disabled { opacity: .55; border-bottom-width: 0; cursor: default; }
.btn .art-icon, .btn-primary .art-icon { width: 24px; height: 24px; flex: none; }
.btn-glyph { display: inline-grid; place-items: center; line-height: 1; }
.btn-glyph svg { width: 24px; height: 24px; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: #F8EBCB; }
  .btn.btn-primary:hover:not(:disabled) { background: #6C3E00; }
  .tb-chip:hover { background: var(--paper-2); }
  .btn.btn-danger.is-armed:hover:not(:disabled) { background: #6C3E00; }
}

/* round paper chip (close, help, back on play) */
.btn-icon {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 56px; height: 56px; border-radius: 50%; background: var(--paper); color: var(--ink-2);
  box-shadow: var(--lift-1); font-size: 24px; font-weight: var(--fw-heavy);
}
.btn-icon .art-icon { width: 28px; height: 28px; }
.btn-icon:active { transform: translateY(2px); background: var(--paper-2); }

/* ---------- the top bar ---------- */
.topbar {
  position: relative; z-index: var(--z-ui);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  height: 64px; margin: 16px var(--gutter) 0;
}
.tb-start, .tb-end { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.tb-start { flex: 1 1 auto; }
.tb-end { flex: none; }
.brand {
  display: flex; align-items: center; gap: var(--s3); height: 64px; min-width: 0;
  padding-inline: 14px 26px; border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--lift-1);
}
.brand-logo { width: 40px; height: 46px; flex: none; }
.brand-logo svg { width: 100%; height: 100%; }
.brand h1, .tb-title h1 { font-size: var(--fs-heading); line-height: 1.5; padding-block: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-dot { color: var(--honey-deep); padding-inline: 4px; }
.tb-title {
  display: flex; align-items: center; gap: var(--s3); height: 64px; min-width: 0;
  padding-inline: 12px 24px; border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--lift-1);
}
.tb-title .art-hex-num, .tb-title .art-unit-badge { width: 40px; height: 46px; flex: none; }
.tb-title .tb-icon { display: grid; place-items: center; width: 40px; height: 46px; flex: none; color: var(--honey-deep); }
.tb-title .tb-icon svg { width: 32px; height: 32px; }
.tb-chip {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); flex: none;
  height: 56px; min-width: 56px; padding-inline: 16px; border-radius: var(--r-pill);
  background: var(--paper); color: var(--ink); box-shadow: var(--lift-1);
  font-size: var(--fs-title); font-weight: var(--fw-heavy); white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
button.tb-chip:active { transform: translateY(2px); background: var(--paper-2); }
.tb-chip:focus-visible, button.tb-chip:active:focus-visible, .btn-icon:focus-visible, .btn-danger:focus-visible { box-shadow: var(--focus); }
.tb-chip.round { width: 56px; padding: 0; }
.tb-chip .art-star { width: 28px; height: 28px; }
.tb-chip .art-icon { width: 28px; height: 28px; color: var(--ink-2); }
.tb-chip .tb-label { font-size: var(--fs-body); font-weight: var(--fw-bold); }
.tb-chip.page-chip .art-icon { color: var(--u3-dark); width: 26px; height: 26px; }

/* the parent gate: hold the gear 1.5 s; JS drives the ring so reduced motion cannot skip it */
.gear .art-ring { position: absolute; inset: -4px; width: 64px; height: 64px; opacity: 0; transition: opacity var(--t-fast) var(--ease-out); pointer-events: none; }
.gear.is-holding .art-ring, .gear.is-rewinding .art-ring { opacity: 1; }
.gear.is-holding { box-shadow: var(--lift-2); }
.gear-tip {
  position: absolute; z-index: var(--z-toast); top: 92px; inset-inline-end: var(--gutter);
  max-width: min(360px, calc(100vw - 32px)); padding: 10px 18px; border-radius: var(--r-md);
  background: var(--paper); box-shadow: var(--lift-2); font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2);
  animation: pop-in var(--t-slow) var(--ease-out);
}
.gear-tip::before { content: ""; position: absolute; top: -10px; inset-inline-end: 22px; width: 20px; height: 12px; background: var(--paper); clip-path: polygon(50% 0, 100% 100%, 0 100%); }

/* page badge (a chip with the book glyph) */
.page-badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
  height: 40px; padding-inline: 12px 14px; border-radius: var(--r-pill);
  background: var(--paper); box-shadow: inset 0 0 0 2px var(--paper-3);
  font-size: var(--fs-label); font-weight: var(--fw-heavy); color: var(--ink);
}
.page-badge::before {
  content: ""; width: 22px; height: 22px; flex: none; background: var(--u3-dark);
  -webkit-mask: var(--book-mask) center / contain no-repeat; mask: var(--book-mask) center / contain no-repeat;
}
:root {
  --book-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6.6C10 5.1 7.2 4.7 3.6 5v13.2c3.6-.3 6.4.1 8.4 1.6 2-1.5 4.8-1.9 8.4-1.6V5c-3.6-.3-6.4.1-8.4 1.6z'/%3E%3Cpath d='M12 6.6v13.2'/%3E%3C/svg%3E");
}

/* stars */
.stars { display: inline-flex; gap: 4px; direction: rtl; align-items: center; } /* earned stars fill from the start (right), like the progress cells */
.stars svg { width: 26px; height: 26px; }
.lock svg, .art-lock { width: 22px; height: 22px; }

/* motion helpers (engine classes) */
.is-shake { animation: nudge var(--t-fast) var(--ease-out) 2; }
.is-pop { animation: pop-in var(--t-slow) var(--ease-spring); }

/* =============================== HIVE (home + unit) =============================== */
.screen-hive { overflow: hidden; height: 100dvh; }
.screen-hive.is-ribbon { overflow: visible; height: auto; padding-bottom: 32px; }

/* unit strip: one paper card, five tabs */
.unit-strip {
  position: relative; z-index: calc(var(--z-ui) + 1);  /* its tab tip floats over the comb / ribbon head */
  display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 8px;
  height: 104px; margin: 16px var(--gutter) 0; padding: 8px;
  border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-1);
}
.unit-tab {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding-inline: 12px 8px; border-radius: var(--r-md); text-align: start;
  transition: background-color var(--t-med) var(--ease-out);
}
.unit-tab .art-unit-badge { width: 52px; height: 60px; flex: none; }
.ut-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ut-name { font-size: var(--fs-label); font-weight: var(--fw-heavy); line-height: 1.4; color: var(--ink); text-wrap: balance; }
.ut-meta { display: flex; align-items: center; gap: 6px; font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2); line-height: 1.2; }
.ut-meta .art-star, .ut-meta .art-lock { width: 22px; height: 22px; flex: none; }
.unit-tab.is-active { background: var(--unit-tint); }
.unit-tab.is-active .ut-name, .unit-tab.is-active .ut-meta { color: var(--unit-dark); }
.unit-tab.is-active::after {
  content: ""; position: absolute; bottom: -14px; inset-inline-start: 50%; translate: 50% 0;
  width: 20px; height: 12px; background: var(--paper); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.unit-tab.is-later .ut-name { color: var(--ink-2); font-weight: var(--fw-bold); }
.unit-tab:focus-visible { box-shadow: var(--focus); }
@media (hover: hover) { .unit-tab:not(.is-active):not(.is-later):hover { background: var(--paper-2); } }
.unit-tab:not(.is-active):not(.is-later):active { background: var(--paper-2); }

/* landscape: the star counts share one baseline across the strip, whether a name takes one line or two */
.is-landscape .ut-text { display: grid; grid-template-rows: minmax(0, 1fr) auto; align-self: stretch; padding-block: 6px; }
.is-landscape .ut-name { align-self: end; }
.unit-tab.is-3l .ut-name { line-height: 1.2; }
.is-landscape .unit-tab.is-3l .ut-text { padding-block: 3px; gap: 0; }
.is-portrait .unit-strip { height: 150px; gap: 8px; padding: 8px 6px; }
.is-portrait .unit-tab { flex-direction: column; justify-content: center; gap: 4px; padding: 6px 4px; text-align: center; }
.is-portrait .ut-text { align-items: center; }

/* a tab that is not open yet says once what opens it */
.tab-tip {
  position: absolute; z-index: var(--z-toast); top: calc(100% + 14px); left: 0;
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: min(420px, calc(100vw - 48px));
  padding: 10px 18px; border-radius: var(--r-md); background: var(--paper); box-shadow: var(--lift-2);
  font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2); line-height: 1.3;
  animation: pop-in var(--t-slow) var(--ease-out);
}
.tab-tip .art-lock { width: 22px; height: 22px; flex: none; }
.tab-tip::before { content: ""; position: absolute; top: -10px; left: calc(var(--px, 50%) - 10px); width: 20px; height: 12px; background: var(--paper); clip-path: polygon(50% 0, 100% 100%, 0 100%); }

/* the comb */
.comb { position: absolute; z-index: var(--z-ui); }
.cell {
  position: absolute; width: var(--cw); height: calc(var(--cw) * 1.1547);
  min-width: 0; min-height: 0; border-radius: 0; pointer-events: none;
  transition: transform var(--t-med) var(--ease-out);
}
.cell > .art-cell { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; pointer-events: none; }
.cell > .art-cell path { pointer-events: visiblePainted; }
.cell-face {
  position: absolute; inset: 17% 12% 22%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.cell .plaque {
  width: 100%; max-width: calc(var(--cw) * .76); display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 10px 10px; border-radius: 16px; text-align: center; pointer-events: auto;
  background: var(--paper); box-shadow: var(--lift-1);
}
.plaque .t { font-size: var(--fs-cell, 21px); font-weight: var(--fw-heavy); line-height: 1.4; text-wrap: balance; color: var(--ink); }
.plaque .stars .art-star { width: 26px; height: 26px; }
.go {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding-inline: 22px 18px;
  border-radius: var(--r-pill); background: var(--action); color: var(--ink-on-dark);
  border-bottom: var(--lip) solid var(--action-lip); font-weight: var(--fw-heavy); font-size: var(--fs-title); line-height: 1;
}
.go .art-icon { width: 20px; height: 20px; }
.cell.is-locked .plaque { background: #FBF6E8; box-shadow: none; }
.cell.is-locked .t { color: var(--ink-2); font-weight: var(--fw-bold); }
.why { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: var(--fs-label); font-weight: var(--fw-regular); color: var(--ink-2); line-height: 1.2; text-wrap: balance; }
.why .art-lock { width: 22px; height: 22px; flex: none; }
.cell.is-current { z-index: 3; transform: scale(1.05); }
.cell.is-current .plaque { box-shadow: var(--lift-2); }
.cell.is-current .cell-face { justify-content: flex-end; }
.cell.is-full { z-index: 2; }
.cell:active:not(.is-locked) .plaque { transform: translateY(2px); }
.comb.is-small .cell-face { inset: 16% 7% 21%; }
.comb.is-small .cell .plaque { max-width: calc(var(--cw) * .86); padding: 8px 6px 10px; gap: 4px; }
.comb.is-small .plaque .t { line-height: 1.36; }
.comb.is-small .go { height: 48px; padding-inline: 18px 14px; }
.cell .plaque { transition: transform var(--t-fast) var(--ease-out); }
.cell:focus-visible { box-shadow: none; }
.cell:focus-visible .plaque { box-shadow: var(--focus); }
/* the current cell of a lesson already played: its stars sit small between the title and «العبي» */
.plaque .cell-stars { gap: 2px; }
.plaque .cell-stars .art-star, .plaque .cell-stars svg { width: 18px; height: 18px; }
.cell.is-replay .plaque { padding: 8px 10px 10px; gap: 4px; }
.cell.is-replay .plaque .t { font-size: 18px; line-height: 1.3; }
.cell.is-replay .go { height: 44px; }  /* the whole cell is the tap target; the pill is its label */
.comb.is-small .cell.is-long .plaque .t { font-size: 18px; }
/* a title that wraps to three lines (set by renderHive): smaller, tighter, so the plaque keeps clear of the number badge */
.cell.is-long .plaque { padding: 8px 10px 10px; gap: 4px; }
.cell.is-long .plaque .t { font-size: 19px; line-height: 1.3; text-wrap: pretty; }
.cell.is-long .plaque .stars .art-star { width: 22px; height: 22px; }
/* still too tall on this device's font (set by fitPlaques): a wider plaque, the 18px floor, balanced lines */
.cell.is-xlong .plaque { max-width: calc(var(--cw) * .9); padding: 6px 6px 8px; gap: 3px; }
.cell.is-xlong .plaque .t { font-size: 18px; line-height: 1.28; text-wrap: balance; }
.cell.is-xlong .go { height: 44px; }
/* the current cell's plaque ends at 72% of the cell, above the next row's number badges */
.comb .cell.is-current .cell-face { inset: 17% 12% 28%; justify-content: center; }
.comb.is-small .cell.is-current .cell-face { inset: 16% 7% 27%; }
/* number badges: one layer above every cell, so the scaled current cell never covers a neighbour's number */
.cell-num { position: absolute; z-index: 5; pointer-events: none; }
.cell-num > svg { width: 100%; height: 100%; max-width: none; }
.cell-bee { position: absolute; z-index: 4; left: 9%; top: 0; width: calc(var(--cw) * .3); height: calc(var(--cw) * .31); pointer-events: none; }
.cell-bee .art-mascot, .rbee .art-mascot { width: 100%; height: 100%; }
.cell-bee, .rbee { animation: art-hover 3.2s ease-in-out infinite; }

/* the honey run: on the first visit the honey rises cell by cell, in order */
.art-cell-honey { transform-box: view-box; transform-origin: 50% 100%; }
.is-reveal .cell.is-done .art-cell-honey, .lrow.is-reveal .art-cell-honey {
  animation: honey-fill var(--t-slow) var(--ease-honey) both; animation-delay: calc(var(--i, 0) * 90ms);
}
.comb .cell.is-rise .art-cell-honey, .ribbon .lrow.is-rise .art-cell-honey, .win-cell.is-rise .art-cell-honey { animation: honey-fill calc(var(--lv, 1) * 300ms) var(--ease-honey) both; animation-delay: 200ms; }

/* the drip waits until its cell is full */
.is-reveal .cell.is-full g:has(> .art-drip) { animation: fade-in var(--t-med) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 90ms + 300ms); }
.comb .cell.is-rise g:has(> .art-drip), .win-cell.is-rise g:has(> .art-drip) { animation: fade-in var(--t-med) var(--ease-out) both; animation-delay: calc(var(--lv, 1) * 300ms + 200ms); }

/* phone (and short screens): the comb becomes a ribbon of rows */
.is-ribbon .topbar { height: 56px; }
.is-ribbon .brand { height: 56px; padding-inline: 8px 16px; }
.is-ribbon .brand h1 { font-size: 22px; }
.is-ribbon .brand-logo { width: 32px; height: 37px; }
.is-ribbon .unit-strip { height: 92px; padding: 6px; margin-top: 16px; }
.is-ribbon .unit-tab { flex-direction: column; justify-content: center; padding: 4px 2px; gap: 2px; }
.is-ribbon .unit-tab .art-unit-badge { width: 40px; height: 46px; }
.is-ribbon .ut-text { display: none; }
.ribbon-head { position: relative; z-index: var(--z-ui); display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px var(--gutter) 0; }
.ribbon-head .tb-chip.tb-album { width: auto; flex: none; padding-inline: 14px 18px; }
.ribbon-head .tb-album .tb-label { display: inline; }
.ribbon-head .rh-end { display: flex; gap: var(--s3); flex: none; }
/* narrow phones: the album chip drops its word so the sound chip always has room (she can mute it herself) */
@media (max-width: 420px) {
  .ribbon-head .tb-chip.tb-album { width: 52px; padding: 0; }
  .ribbon-head .tb-album .tb-label { display: none; }
  .screen-album .tb-title .tb-icon { display: none; }  /* room for the word «ألبومي» next to the sound chip */
  .screen-album .tb-title { padding-inline: 16px; }
}
.unit-pill {
  position: relative; z-index: var(--z-ui); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-width: 0; padding: 6px 18px;
  border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-1);
  font-size: var(--fs-heading); font-weight: var(--fw-heavy); line-height: 1.25;
}
.unit-pill .meta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-label); color: var(--unit-dark); }
.unit-pill .meta .art-star { width: 20px; height: 20px; }
.ribbon { position: relative; z-index: var(--z-ui); list-style: none; margin: 20px 0 0; padding: 0 var(--gutter); display: flex; flex-direction: column; gap: 10px; }
.lrow {
  position: relative; width: 100%; display: flex; align-items: center; gap: 12px; min-height: 92px;
  padding: 8px 14px 8px 10px; border-radius: var(--r-md); background: var(--paper); box-shadow: var(--lift-1); text-align: start;
}
.lrow > .art-cell { width: 66px; height: 76px; flex: none; }
.lrow .lt { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.lrow .t { font-size: var(--fs-body); font-weight: var(--fw-heavy); line-height: 1.4; }
.lrow .stars { align-self: flex-start; }
.lrow .stars .art-star { width: 22px; height: 22px; }
.lrow .why { justify-content: flex-start; text-wrap: wrap; }
.lrow.is-locked { background: #FBF6E8; box-shadow: none; }
.lrow.is-locked .t { color: var(--ink-2); font-weight: var(--fw-bold); }
.lrow.is-current { box-shadow: 0 0 0 3px var(--honey), var(--lift-2); margin-top: 18px; }
.lrow .go { flex: none; height: 48px; padding-inline: 18px 14px; }
.lrow .go .art-icon { width: 18px; height: 18px; }
.rbee { position: absolute; width: 58px; height: 60px; top: -30px; inset-inline-end: 110px; pointer-events: none; }
.lrow:focus-visible { box-shadow: var(--focus); }

/* =============================== LEARN =============================== */
.screen-learn { padding-bottom: 24px; }
.learn-layout {
  position: relative; z-index: var(--z-ui);
  display: grid; gap: var(--s5); margin: 24px var(--gutter) 0; align-items: start;
}
.learn-layout.has-media { grid-template-columns: minmax(0, 55fr) minmax(0, 45fr); }
.learn-layout.no-media { max-width: 720px; margin-inline: auto; }
.learn-shelf { padding: 12px; border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-1); display: grid; gap: 12px; }
.learn-media {
  position: relative; margin: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px;
  min-height: 120px; padding: 20px 16px 16px; border-radius: var(--r-md); background: var(--paper-2);
  --blk: 92px; --flat: 92px;
}
.learn-media .art-hex-num { position: absolute; top: 8px; inset-inline-start: 8px; width: 32px; height: 37px; }
.learn-figure { margin: 0; display: grid; place-items: center; }
.learn-figure.is-missing { display: none; }
.learn-img { max-height: min(280px, 32vh); width: auto; max-width: 100%; object-fit: contain; border-radius: var(--r-sm); }
/* the apple crop is a small source picture: shown near its own size, never blown up into blocks */
.learn-img[src$="u5-apple.webp"] { max-height: 140px; }
.learn-shelf, .learn-facts { min-width: 0; }
.learn-media { min-width: 0; overflow-x: auto; overflow-y: hidden; }
.learn-media .stim { max-width: 100%; }
.learn-facts { padding: 28px 32px 32px; display: flex; flex-direction: column; gap: 20px; }
.learn-heading { display: flex; align-items: center; gap: 12px; font-size: var(--fs-heading); }
.learn-heading .art-unit-badge { width: 44px; height: 50px; flex: none; }
.learn-heading .page-badge { display: none; margin-inline-start: auto; }
.learn-goal { font-size: var(--fs-body); font-weight: var(--fw-bold); color: var(--ink-2); margin-top: -10px; }
.learn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.learn-card { display: flex; gap: 14px; align-items: flex-start; }
.learn-card .art-hex-num { width: 32px; height: 37px; flex: none; margin-top: 2px; }
.learn-text { font-size: var(--fs-body); font-weight: var(--fw-regular); line-height: 1.6; color: var(--ink); }
.learn-card .page-badge { margin-top: 6px; }
.terms { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.terms-label { font-size: var(--fs-label); font-weight: var(--fw-heavy); color: var(--ink-2); }
.term { padding: 4px 14px; border-radius: var(--r-pill); background: var(--unit-tint); color: var(--unit-dark); font-size: var(--fs-label); font-weight: var(--fw-heavy); }
.learn-actions { display: flex; justify-content: stretch; margin-top: 4px; }
.btn-play { width: 100%; min-height: 76px; font-size: 28px; gap: 12px; }
.btn-play .art-icon { width: 26px; height: 26px; }
/* two columns that spill a few pixels past the screen (fitLearn): tighter spacing, so the page does not scroll a sliver */
.screen-learn.is-snug { padding-bottom: 16px; }
.screen-learn.is-snug .learn-layout { margin-top: 12px; }
.screen-learn.is-snug .learn-shelf { padding: 8px; gap: 8px; }
.screen-learn.is-snug .learn-media { padding: 12px 12px 10px; }
.screen-learn.is-snug .learn-facts { padding: 22px 28px 24px; gap: 16px; }

@media not ((min-aspect-ratio: 5/4) and (min-width: 900px)) {
  .learn-layout.has-media { grid-template-columns: minmax(0, 1fr); }
  .learn-img { max-height: min(280px, 24vh); }
}
/* two columns: when the facts run past the fold, «العبي» stays in view at the bottom of its card (paper pad = card colour) */
.learn-facts > .learn-actions { position: sticky; bottom: 12px; z-index: 2; border-radius: var(--r-pill); background: var(--paper); box-shadow: 0 0 0 10px var(--paper); }
/* one column: each fact carries its own example right under it (placeLearnPlay moves the figures in) */
.learn-pair { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.learn-layout.is-paired .learn-list { gap: 24px; }
.learn-layout.is-paired .learn-card + .learn-card { padding-top: 24px; border-top: 0; margin-top: 8px; } /* facts are separated by tone (the paper-2 panels), never by a hairline */
.learn-pair > .learn-media { min-height: 0; padding: 16px 12px 12px; }
.learn-pair > .learn-media > .art-hex-num { display: none; }  /* the fact's own hex already numbers it */
/* one column: «العبي» rides a paper strip pinned to the bottom edge of the screen (nothing shows beneath it),
   and settles under the facts at the end of the page */
.screen-learn:has(.learn-actions.is-pinned) { padding-bottom: 0; }
.learn-actions.is-pinned {
  position: sticky; bottom: 0; z-index: 3; grid-column: 1 / -1; margin: 0 calc(-1 * var(--gutter));
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0; background: var(--paper);
  box-shadow: 0 -1px 0 rgba(122,82,20,.14), 0 -10px 24px -12px rgba(90,60,10,.30);
}
.learn-actions.is-pinned .btn-play { min-height: 72px; }
/* a worked example on learn: the answer is written in, in ink on paper, never the empty dashed slot of play */
.learn-media .colboard.is-solved .cb-ans { background: var(--paper); border: 0; color: var(--ink); }
.learn-media .colboard.is-solved .cb-carry, .learn-media .colboard.is-solved .cb-new { box-shadow: 0 0 0 2px var(--honey-light); }

/* =============================== WIN =============================== */
.screen-win { min-height: 100dvh; display: grid; place-items: center; padding: 140px var(--gutter) 32px; }
.win-card {
  position: relative; z-index: var(--z-ui); width: min(640px, 100%);
  padding: 0 40px 32px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-2);
}
.win-cell { width: 200px; height: 231px; margin-top: -120px; margin-bottom: 22px; position: relative; }  /* room for the 3★ drip */
.win-cell svg { width: 100%; height: 100%; }
.win-mascot { position: absolute; width: 150px; height: 155px; inset-inline-end: 24px; top: -70px; pointer-events: none; }
.win-mascot .art-mascot { width: 100%; height: 100%; }
.win-title { font-size: 40px; font-weight: var(--fw-heavy); line-height: 1.2; text-wrap: balance; }
.win-stars { gap: 12px; }
.win-stars svg { width: 64px; height: 64px; }
.win-stars .star { display: block; }
.win-stars .star.is-earned { animation: pop-in var(--t-slow) var(--ease-out) both; }
.win-stars .star:nth-child(1) { animation-delay: 350ms; }
.win-stars .star:nth-child(2) { animation-delay: 600ms; }
.win-stars .star:nth-child(3) { animation-delay: 850ms; }
.win-score { font-size: var(--fs-title); font-weight: var(--fw-bold); color: var(--ink-2); }
.win-score .score { color: var(--ink); font-weight: var(--fw-heavy); }
.win-stickers { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: pop-in var(--t-slow) var(--ease-out) 1.1s both; }
.win-stickers-title { font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2); }
.sticker-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.sticker-row .sticker { width: 104px; height: 104px; padding: 4px; }
.win-note { font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2); }
.win-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 6px; }
@media (max-height: 800px) and (min-width: 601px) {
  .screen-win { padding-top: 112px; padding-bottom: 20px; }
  .win-card { padding-bottom: 26px; gap: 10px; }
  .win-cell { width: 170px; height: 196px; margin-top: -100px; margin-bottom: 18px; }
  .win-mascot { width: 130px; height: 134px; top: -62px; }
  .win-stars svg { width: 54px; height: 54px; }
}

/* =============================== ALBUM =============================== */
.screen-album { padding-bottom: 40px; }
.album-hint {
  position: relative; z-index: var(--z-ui); display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 2 * var(--gutter));
  margin: 24px var(--gutter) 0; padding: 10px 24px 10px 12px; border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--lift-1);
  font-size: var(--fs-body); font-weight: var(--fw-heavy);
}
.album-hint .art-mascot { width: 52px; height: 54px; flex: none; }
.album-unit {
  position: relative; z-index: var(--z-ui); margin: 20px var(--gutter) 0; padding: 20px 24px 24px;
  border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-1);
}
.album-unit h2 { display: flex; align-items: center; gap: 12px; font-size: var(--fs-title); margin-bottom: 16px; }
.album-unit h2 .art-unit-badge { width: 40px; height: 46px; flex: none; }
.album-unit h2 .count { margin-inline-start: auto; font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.album-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px 14px; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); justify-items: center; align-items: start; } /* six 140px stickers fit one row from 1024 up */
.album-grid > li { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.sticker {
  position: relative; width: 140px; height: 140px; max-width: 100%; display: grid; place-items: center; overflow: hidden; padding: 12px;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  border-radius: var(--r-md); background: var(--paper-2);
}
.sticker::after { content: ""; position: absolute; inset: 0; z-index: 1; border: 3px solid var(--wax); border-radius: inherit; pointer-events: none; }
button.sticker:active { transform: translateY(2px); }
.sticker:focus-visible { box-shadow: var(--focus); }
.sticker-fallback { grid-area: 1 / 1; visibility: hidden; }
.sticker.is-missing .sticker-fallback { visibility: visible; }  /* the star shows only when the picture is missing */
.sticker-fallback svg { width: 56px; height: 56px; opacity: .5; }
.sticker-img { grid-area: 1 / 1; width: 100%; height: 100%; min-width: 0; min-height: 0; max-width: 100%; object-fit: contain; position: relative; border-radius: 8px; mix-blend-mode: multiply; }
.sticker-name { font-size: var(--fs-label); font-weight: var(--fw-bold); line-height: 1.25; text-align: center; color: var(--ink); text-wrap: balance;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 160px; }
.sticker-slot { width: 140px; height: 140px; max-width: 100%; display: grid; place-items: center; }
.sticker-slot .art-hex-slot { width: 108px; height: 125px; }
.sticker-big { width: min(360px, 70vw); height: auto; aspect-ratio: 1; padding: 16px; }

/* =============================== PARENT CORNER =============================== */
.screen-parents { background: var(--paper-2); padding-bottom: 48px; }
.screen-parents .topbar { margin-bottom: 8px; }
.screen-parents.is-gated { display: grid; grid-template-rows: auto 1fr; }
.screen-parents.is-gated .gate { align-self: center; margin-block: 0 48px; }
.gate {
  position: relative; z-index: var(--z-ui); width: min(520px, calc(100% - 2 * var(--gutter))); margin: 48px auto 0;
  display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px 32px;
  border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-1); text-align: center;
}
.gate-text { font-size: var(--fs-title); font-weight: var(--fw-heavy); }
.gate .gear { width: 96px; height: 96px; }
.gate .gear .art-icon { width: 44px; height: 44px; }
.gate .gear .art-ring { inset: -8px; width: 112px; height: 112px; }
.gate-note, .p-note { color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-regular); line-height: 1.5; }
.p-body { display: flex; flex-direction: column; gap: 16px; max-width: 980px; margin: 16px auto 0; padding-inline: var(--gutter); -webkit-user-select: text; user-select: text; }
.p-section { background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--lift-1); padding: 22px 26px; display: flex; flex-direction: column; gap: 12px; }
.p-section h2 { font-size: var(--fs-title); }
.p-section h3 { font-size: var(--fs-label); margin-bottom: 4px; }
.p-warn { background: var(--hint); border-radius: var(--r-sm); padding: 12px 16px; font-weight: var(--fw-bold); font-size: var(--fs-label); }
.p-done { color: var(--right); font-weight: var(--fw-bold); }
.p-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.switch {
  display: inline-flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 16px 6px 8px;
  border-radius: var(--r-pill); background: var(--paper-2); font-size: var(--fs-label); font-weight: var(--fw-bold); text-align: start;
}
.switch-track { width: 56px; height: 32px; border-radius: 999px; background: var(--wax-raw-rim); position: relative; flex: none; transition: background-color var(--t-med) var(--ease-out); }
.switch-thumb { position: absolute; top: 3px; inset-inline-start: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px rgba(90,60,10,.35); transition: inset-inline-start var(--t-med) var(--ease-out); }
.switch[aria-checked="true"] .switch-track { background: var(--right); }
.switch[aria-checked="true"] .switch-thumb { inset-inline-start: 27px; }
.switch:focus-visible { box-shadow: var(--focus); }
.btn-danger { background: var(--paper-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--notyet-line); }
.btn-danger.is-armed { background: var(--action); color: var(--ink-on-dark); border-bottom-color: var(--action-lip); box-shadow: none; }
.p-table-wrap { overflow-x: auto; }
.p-table { width: 100%; border-collapse: collapse; font-size: var(--fs-label); }
.p-table th, .p-table td { padding: 10px 8px; text-align: start; vertical-align: middle; }
.p-table thead th { color: var(--ink-2); font-weight: var(--fw-bold); }
.p-table tbody tr:nth-child(odd) { background: var(--paper-2); }
.p-table tbody th { font-weight: var(--fw-bold); }
.p-table .stars svg { width: 20px; height: 20px; }
.p-flag { display: inline-block; font-size: 16px; padding: 2px 10px; border-radius: 999px; background: var(--hint); color: var(--ink); font-weight: var(--fw-bold); }
.p-missed-list, .p-inf-list, .p-ev-list, .p-word-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.p-missed-item, .p-inf { padding: 10px 14px; border-radius: var(--r-sm); background: var(--paper-2); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: var(--fs-label); }
.p-lesson, .p-times { color: var(--ink-2); font-size: 16px; }
.p-inf-q { font-weight: var(--fw-bold); width: 100%; }
.p-inf .switch { background: var(--paper); }
.p-ev-list ul { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 4px; }
.p-ev { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: var(--fs-label); }
.ev-glyph { width: 1.2em; text-align: center; color: var(--ink-2); }
.ev-state { color: var(--ink-2); font-size: var(--fs-label); }
.p-word-list { flex-direction: row; flex-wrap: wrap; }
.p-word-list li { padding: 4px 12px; border-radius: 999px; background: var(--paper-2); font-size: var(--fs-label); }
.p-section code { font-size: 15px; }

/* =============================== DIALOGS =============================== */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-dialog); display: grid; place-items: center; padding: 24px;
  background: rgba(42, 28, 12, .38); animation: fade-in var(--t-med) var(--ease-out);
}
.dialog {
  position: relative; width: min(520px, 100%); max-height: calc(100dvh - 48px); overflow: auto;
  padding: 32px 32px 28px; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center;
  border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-2);
  animation: pop-in var(--t-slow) var(--ease-out);
}
.dialog-mascot { width: 120px; height: 124px; margin-top: -8px; }
.dialog-mascot .art-mascot { width: 100%; height: 100%; }
.dialog-title { font-size: var(--fs-heading); font-weight: var(--fw-heavy); line-height: 1.25; }
.dialog-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; width: 100%; }
.dialog-actions .btn { min-width: 140px; }
.howto { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: start; align-self: stretch; }
.howto-step { display: flex; gap: 14px; align-items: center; font-size: var(--fs-body); font-weight: var(--fw-bold); padding: 8px 12px; border-radius: var(--r-md); background: var(--paper-2); }
.howto-n { width: 40px; height: 46px; flex: none; display: grid; place-items: center; background: var(--honey-light); clip-path: var(--hex); font-weight: var(--fw-heavy); color: var(--ink); }
.overlay-sticker .dialog-title { font-size: var(--fs-title); }
.overlay-sticker .sticker-from { font-size: var(--fs-label); font-weight: var(--fw-bold); color: var(--ink-2); text-align: center; text-wrap: balance; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* =============================== EMPTY =============================== */
.empty { position: relative; z-index: var(--z-ui); width: min(520px, calc(100% - 48px)); margin: 48px auto 0; padding: 32px; border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--lift-1); text-align: center; font-size: var(--fs-body); font-weight: var(--fw-bold); }
.empty-mascot { width: 120px; height: 124px; margin: 0 auto 12px; }

/* =============================== PHONE =============================== */
@media (max-width: 600px) {
  .topbar { margin-top: 16px; height: 56px; }
  .tb-chip { height: 52px; min-width: 52px; }
  .tb-chip.round { width: 52px; }
  .tb-title { height: 56px; padding-inline: 8px 16px; }
  .topbar { height: auto; min-height: 56px; }
  .tb-title { height: auto; min-height: 56px; padding-block: 6px; }
  .tb-title h1 { font-size: 20px; white-space: normal; line-height: 1.4; padding-block: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .tb-count .art-icon, .tb-end .page-chip { display: none; }  /* the sound chip stays: she can always mute it herself */
  .learn-heading .page-badge { display: inline-flex; }
  .tb-title .art-hex-num, .tb-title .art-unit-badge { width: 32px; height: 37px; }
  .tb-chip .tb-label { display: none; }
  .tb-chip:has(.tb-label) { width: 52px; padding: 0; }
  .learn-facts { padding: 20px 20px 24px; }
  .screen-win { padding-top: 110px; }
  .win-card { padding: 0 20px 24px; gap: 10px; }
  .win-cell { width: 140px; height: 162px; margin-top: -84px; margin-bottom: 14px; }
  .win-mascot { width: 96px; height: 99px; top: -50px; inset-inline-end: 4px; }
  .win-title { font-size: 30px; }
  .win-stars svg { width: 52px; height: 52px; }
  .win-actions { flex-direction: column; align-self: stretch; }
  .win-actions .btn { width: 100%; }
  .album-unit { padding: 16px; }
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticker, .sticker-slot { width: 100%; height: auto; aspect-ratio: 1; }
  .p-section { padding: 16px; }
  .dialog { padding: 24px 20px; }
}

/* =====================================================================================
   PLAY — the engine's own rules for the play screen, mechanics and stimuli.
   Kept so play works on its own; play.css (loaded after style.css) owns the play look.
   The aliases map the old placeholder names onto the hive tokens.
   ===================================================================================== */
:root {
  --bg: var(--paper-2); --card: var(--paper); --line: var(--wax-raw-rim); --ink-soft: var(--ink-2);
  --accent: var(--action); --accent-ink: var(--ink-on-dark); --ok: var(--right); --miss: var(--notyet); --glow: var(--honey);
  --radius: var(--r-md); --radius-sm: var(--r-sm); --shadow: var(--lift-1); --font-num: var(--font);
  --tap-min: 48px; --gap: 12px; --pad: clamp(12px, 2.2vmin, 24px); --q-size: clamp(24px, 3.6vmin, 36px);
  --unit-color: var(--unit); --dur: 200ms;
}
.screen-play { display: grid; }
/* ---------- stimuli (shared) ---------- */
.stim { max-inline-size: 100%; }
.stim-title { font-weight: 800; margin-block-end: 6px; text-align: center; }
.stim-blocks { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: center; }
.sb-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end; max-inline-size: 100%; }
.sb-h .art-hundred { inline-size: var(--flat, 72px); block-size: var(--flat, 72px); }
.sb-t .art-ten { inline-size: calc(var(--flat, 72px) * 18 / 108); block-size: var(--flat, 72px); }
.sb-o { max-inline-size: calc(var(--flat, 72px) * .6); }
.sb-o .art-one { inline-size: calc(var(--flat, 72px) * 18 / 108); block-size: calc(var(--flat, 72px) * 18 / 108); }
.stim.is-small { --flat: 40px; }

.stim-placevalue { border-collapse: separate; border-spacing: 0; background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius-sm); overflow: hidden; font-size: 1em; margin-inline: auto; }
.stim-placevalue th, .stim-placevalue td { padding: 6px 18px; text-align: center; border-inline-start: 2px solid var(--line); }
.stim-placevalue th { font-size: .8em; background: var(--bg); }
.stim-placevalue td { font-size: 1.5em; font-weight: 800; }
.pv-h { box-shadow: inset 0 -4px 0 #9a62c9; }
.pv-t { box-shadow: inset 0 -4px 0 #d9824f; }
.pv-o { box-shadow: inset 0 -4px 0 #4fa673; }

.nl-svg { inline-size: 100%; block-size: auto; overflow: visible; }
.nl-axis { stroke: var(--ink); stroke-width: 3; }
.nl-end { fill: var(--ink); }
.nl-tick { stroke: var(--ink); stroke-width: 2; }
.nl-tick.is-major { stroke-width: 3; }
.nl-label { font: 700 20px var(--font-num); fill: var(--ink); }
.nl-mark { fill: var(--accent); }
.nl-mark-label { font: 800 22px var(--font-num); fill: var(--accent); }

.colboard {
  --cb-cell: clamp(40px, 7.5vmin, 68px);
  display: grid; grid-template-columns: repeat(var(--cols), var(--cb-cell)); grid-template-rows: calc(var(--cb-cell) * .55) repeat(3, var(--cb-cell)); justify-content: center;
  font-family: var(--font-num); font-size: calc(var(--cb-cell) * .62); font-weight: 800; line-height: 1;
}
.cb { block-size: 100%; display: grid; place-items: center; position: relative; }
.cb-mark { align-items: end; font-size: .55em; color: var(--accent); }
.cb-rule { border-block-start: 4px solid var(--ink); }
.cb-ans { margin: 4px 3px 0; border-radius: 10px; background: var(--bg); border: 2px dashed var(--line); block-size: calc(var(--cb-cell) - 4px); }
.cb-op.cb-rule { margin: 0; }
.cb.is-active { background: rgba(47, 98, 201, .08); }
.cb-ans.is-active { border: 3px solid var(--accent); background: var(--card); }
.cb-ans.is-filled { border-style: solid; border-color: var(--ok); background: var(--card); }
.cb-ans.is-miss { color: var(--miss); border-color: var(--miss); }
.cb-ans.is-answer { box-shadow: 0 0 0 4px var(--glow); }
.cb-top.is-struck .cb-d { text-decoration: line-through; text-decoration-thickness: 3px; color: var(--ink-soft); }
.cb-pre, .cb-new, .cb-carry { font-size: .9em; color: var(--accent); }
.cb-pre { font-size: .5em; align-self: start; margin-inline-end: 1px; }
.cb-top:has(.cb-pre) { display: flex; justify-content: center; align-items: center; }

.stim-pictograph .picto, .stim-tally .tally { border-collapse: collapse; background: var(--card); margin-inline: auto; }
.picto th, .tally th { padding: 6px 12px; text-align: start; font-size: .85em; border-block-end: 1px solid var(--line); white-space: nowrap; }
.picto td, .tally td { padding: 6px 10px; border-block-end: 1px solid var(--line); border-inline-start: 2px solid var(--line); }
.picto-icons { display: flex; gap: 4px; align-items: center; min-block-size: 40px; }
.ico { display: inline-block; font-size: 1.4em; line-height: 1; inline-size: 1.15em; text-align: center; }
img.ico { inline-size: 32px; block-size: 32px; object-fit: contain; }
.ico-dot::before { content: ""; display: inline-block; inline-size: .7em; block-size: .7em; border-radius: 50%; background: var(--ink-soft); }
.ico-half { display: inline-block; inline-size: .6em; overflow: hidden; direction: ltr; }
.picto-key { margin-block-start: 6px; text-align: center; font-weight: 700; font-size: max(18px, .85em); }
.tally-svg { block-size: 1.8em; inline-size: calc(var(--tally-w) * .045em); stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.tally-cell { direction: ltr; }

.stim-table { border-collapse: collapse; background: var(--card); margin-inline: auto; font-size: 1em; }
.stim-table th, .stim-table td { border: 2px solid var(--line); padding: 6px 16px; text-align: center; }
.stim-table th { background: var(--bg); }

.stim-eq { text-align: center; font-size: clamp(32px, 6vmin, 56px); font-weight: 800; }
.stim-eq .hl { color: #1e8fd0; }          /* ones / tens that change: blue, as on p22 */
.stim-eq .hl-h { color: #d2343a; }        /* hundreds that change: red */
.stim-target { text-align: center; font-size: clamp(40px, 8vmin, 72px); font-weight: 800; }
.stim-objects { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.obj-group { display: grid; grid-template-columns: repeat(5, auto); gap: 4px; padding: 6px; border: 2px dashed var(--line); border-radius: var(--radius-sm); }

.q-figure { margin: 0; }
.q-figure.is-missing { display: none; }
.q-img { max-block-size: 100%; max-inline-size: 100%; object-fit: contain; border-radius: var(--radius-sm); }

/* ---------- PLAY (must never scroll) ---------- */
.screen-play {
  block-size: 100dvh; min-block-size: 0; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px;
  padding: clamp(8px, 1.6vmin, 18px);
}
.play-bar { display: flex; align-items: center; gap: 12px; }
.play-bar .btn-icon { --tap: 56px; font-size: 24px; }
.btn-howto.is-new { box-shadow: 0 0 0 4px var(--glow), var(--shadow); }
.dots { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; justify-content: center; gap: 8px; }
.dot { inline-size: 16px; block-size: 16px; border-radius: 50%; border: 3px solid var(--line); background: var(--card); }
.dot.is-done { background: var(--unit-color); border-color: var(--unit-color); }
.dot.is-current { inline-size: 22px; block-size: 22px; border-color: var(--unit-color); }

.play-stage { min-block-size: 0; display: flex; flex-direction: column; gap: 12px; }
.play-ask {
  flex: 1 1 auto; min-block-size: 0; display: flex; flex-direction: column; gap: 10px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(10px, 1.8vmin, 20px);
}
.q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.q-text { font-size: var(--q-size); line-height: 1.3; font-weight: 800; }
.ord-dir { font-weight: 700; color: var(--ink-soft); }
.q-stim {
  flex: 1 1 auto; min-block-size: 0; overflow: hidden; container-type: size;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px;
}
.q-stim .stim-blocks { --flat: min(30cqh, 96px); }
.q-stim .nl-svg { inline-size: min(100cqw, 640px); max-block-size: 100cqh; }
.q-stim .q-img { max-block-size: min(100cqh, 260px); }
.q-stim .colboard { --cb-cell: min(22cqh, 68px, 16cqw); }
.play-answer { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; justify-content: center; min-block-size: 0; padding-block-start: 12px; padding-inline: 4px; }

/* landscape split: question on the start side, answers on the end side */
@media (min-aspect-ratio: 5/4), (max-height: 500px) {
  .play-stage { flex-direction: row; }
  .play-ask { flex: 1 1 52%; }
  .play-answer { flex: 1 1 48%; }
  .play-stage.no-stim .play-ask { flex: 0 1 34%; justify-content: center; }
  .play-stage.no-stim .play-answer { flex: 1 1 66%; }
}

/* options */
.opts { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opts-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opts-2.opts-tf, .opts-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt {
  position: relative; min-block-size: clamp(64px, 11vmin, 104px); padding: 8px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: clamp(24px, 4vmin, 36px); font-weight: 800;
  transition: transform var(--dur) ease-out, opacity var(--dur) ease-out, filter var(--dur) ease-out;
}
.opt-text { line-height: 1.2; }
.opt-stim { display: block; }
.opt-img { max-block-size: 90px; object-fit: contain; }
.opt-figure.is-missing { display: none; }
.opt-sym .sym { font-family: var(--font-num); font-size: 1.4em; line-height: 1; }
.tf-glyph { font-size: .8em; }
.opt.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
.opt.is-right, .opt.is-answer, .opt.is-matched { border-color: var(--ok); border-style: solid; }
.opt.is-answer { box-shadow: 0 0 0 5px var(--glow); }
.opt.is-miss, .nl-tick-btn.is-miss { filter: grayscale(1); opacity: .5; transform: scale(.96); border-style: dashed; }
.opt.is-folded { opacity: .2; transform: scale(.92); }
.opt.is-placed { opacity: .3; }
.opt.is-matched { opacity: .75; }
.is-glow { animation: glow 1.1s ease-in-out infinite; }
.opt:disabled { cursor: default; }
.stamp {
  position: absolute; inset-block-start: -10px; inset-inline-end: -10px; z-index: 2;
  inline-size: 32px; block-size: 32px; display: grid; place-items: center; border-radius: 50%;
  font-size: 20px; font-weight: 900; color: #fff; line-height: 1;
}
.stamp-ok { background: var(--ok); }
.stamp-miss { background: var(--miss); }
.pair-n { position: absolute; inset-block-start: 6px; inset-inline-start: 10px; font-size: 16px; font-family: var(--font-num); color: var(--ok); }

/* compare */
.cmp { display: flex; align-items: center; justify-content: center; gap: 16px; inline-size: 100%; }
.cmp-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cmp-value { font: 800 clamp(32px, 6vmin, 56px) var(--font-num); }
.cmp-slot { inline-size: 72px; block-size: 72px; display: grid; place-items: center; font: 800 44px var(--font-num); }
.cmp-slot .blank { min-inline-size: 64px; min-block-size: 64px; display: grid; place-items: center; }
.cmp-slot.is-filled { border: 3px solid var(--ok); border-radius: var(--radius-sm); }

/* numpad and keypad */
.np { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.np-display {
  position: relative; min-block-size: clamp(56px, 9vmin, 80px); display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); font: 800 clamp(32px, 6vmin, 52px) var(--font-num);
}
.np-display.is-empty .np-caret { inline-size: 3px; block-size: 1em; background: var(--ink-soft); animation: blink 1s steps(2) infinite; }
.np-display.is-right { border-color: var(--ok); }
.np-display.is-miss { border-style: dashed; color: var(--miss); }
.np-display.is-answer { box-shadow: 0 0 0 5px var(--glow); border-color: var(--ok); }
.np-unit { text-align: center; font-weight: 700; color: var(--ink-soft); margin-block-start: -6px; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.key {
  min-block-size: var(--tap-min); block-size: clamp(48px, 8vh, 72px);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  font: 800 clamp(24px, 4vmin, 34px) var(--font-num);
}
.key-clear, .key-check { font-family: var(--font); font-size: 20px; }
.key-check { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.key-label { font-size: 16px; }
.key:active { transform: translateY(2px); }

/* blocks builder */
.bb { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.bb-col { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); padding: 8px; }
.bb-col.is-locked { border-color: var(--ok); }
.bb-col.is-answer { box-shadow: 0 0 0 4px var(--glow); }
.bb-head { text-align: center; font-weight: 800; font-size: 18px; }
.bb-area { block-size: clamp(80px, 18vh, 170px); display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center; gap: 3px; overflow: hidden; }
.bb-area-h .art-hundred { inline-size: clamp(26px, 5vh, 50px); block-size: clamp(26px, 5vh, 50px); }
.bb-area-t .art-ten { inline-size: clamp(7px, 1.2vh, 11px); block-size: clamp(60px, 13vh, 110px); }
.bb-area-o { max-inline-size: 90px; margin-inline: auto; }
.bb-area-o .art-one { inline-size: clamp(14px, 2.4vh, 22px); block-size: clamp(14px, 2.4vh, 22px); }
.bb-count { text-align: center; font: 800 28px var(--font-num); }
.bb-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bb-btn { min-block-size: var(--tap-min); block-size: clamp(48px, 7vh, 64px); border-radius: var(--radius-sm); background: var(--bg); border: 2px solid var(--line); font: 800 30px var(--font-num); }
.bb-btn:disabled { opacity: .35; }
.bb-check, .btn-check { align-self: center; min-inline-size: 200px; }

/* order */
.ord-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.slot { position: relative; min-block-size: clamp(64px, 10vmin, 92px); display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid var(--line); border-radius: var(--radius); background: var(--card); }
.slot.is-filled { border-style: solid; border-color: var(--ok); }
.slot-n { font-size: 15px; color: var(--ink-soft); }
.slot-v { font-size: clamp(22px, 3.6vmin, 32px); font-weight: 800; }
.ord-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.chip { min-inline-size: 96px; min-block-size: 64px; padding-inline: 16px; }

/* sort */
.sort-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.sort-bins { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; }
.bin {
  position: relative; min-block-size: clamp(110px, 20vh, 180px); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px;
  background: var(--card); border: 3px solid var(--unit-color); border-radius: var(--radius); box-shadow: var(--shadow);
}
.bin-label { font-size: 24px; font-weight: 800; }
.bin-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.bin-chip { position: relative; padding: 4px 14px; border-radius: 999px; background: var(--bg); font-weight: 800; font-size: 22px; }
.bin-chip .stamp { inline-size: 22px; block-size: 22px; font-size: 13px; inset-block-start: -8px; inset-inline-end: -8px; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(16px, 4vw, 48px); }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match .opt { min-block-size: clamp(56px, 9vh, 92px); }

/* number line: place */
.nl-place { inline-size: 100%; }
.nl-place-inner { position: relative; inline-size: 100%; }
.nl-ticks { position: absolute; inset: 0; }
.nl-tick-btn {
  position: absolute; inset-block-start: 26%; --bw: clamp(30px, var(--tw, 8%), 64px); margin-inline-start: calc(var(--bw) * -.5);
  inline-size: var(--bw); block-size: clamp(48px, 34%, 64px);
  display: grid; place-items: center; border-radius: 12px; background: transparent;
}
.tick-dot { inline-size: 18px; block-size: 18px; border-radius: 50%; background: var(--card); border: 3px solid var(--ink); }
.nl-tick-btn.is-right .tick-dot, .nl-tick-btn.is-answer .tick-dot { background: var(--accent); border-color: var(--accent); }
.nl-tick-btn.is-answer { box-shadow: 0 0 0 4px var(--glow); }
.tick-label { position: absolute; inset-block-end: 100%; font: 800 22px var(--font-num); color: var(--accent); }
.nl-tick-btn .stamp { inset-block-start: auto; inset-block-end: -18px; inline-size: 24px; block-size: 24px; font-size: 14px; }

/* steps */
.steps-panel { display: flex; flex-direction: column; gap: 10px; }
.steps-col { text-align: center; font-weight: 800; font-size: 22px; min-block-size: 1.5em; }
.keypad-digits { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.key-spacer { display: block; }

/* feedback row: mascot, bubble, next */
.play-feedback {
  min-block-size: clamp(80px, 12vh, 112px);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
}
.fb-mascot svg { inline-size: clamp(52px, 8vh, 80px); block-size: clamp(52px, 8vh, 80px); }
.bubble { min-block-size: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: clamp(18px, 2.6vmin, 24px); }
.bubble:empty { visibility: hidden; }
.bubble.is-hint, .bubble.is-reveal, .bubble.is-praise { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px; }
.bubble-line { font-weight: 800; inline-size: 100%; }
.bubble-praise { font-weight: 800; font-size: 1.2em; }
.bubble-answer { font-weight: 800; font-size: 1.15em; }
.bubble-why, .bubble-hint { color: var(--ink-soft); }
.btn-next { min-block-size: 64px; min-inline-size: 160px; font-size: 26px; }

@keyframes shake { 0%, 100% { translate: 0; } 25% { translate: -6px; } 50% { translate: 5px; } 75% { translate: -3px; } }
@keyframes pop { 0% { scale: 1; } 50% { scale: 1.08; } 100% { scale: 1; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 3px var(--glow); } 50% { box-shadow: 0 0 0 8px var(--glow); } }
@keyframes blink { 50% { opacity: 0; } }
/* small phones */
@media (max-width: 420px) {
  .btn-next { min-inline-size: 120px; }
}

/* stimuli grow with the space the play screen gives them */
.q-stim > .stim { font-size: clamp(18px, min(5.2cqh, 3.6cqw), 34px); }
.q-stim > .stim-eq { font-size: clamp(24px, min(16cqh, 9cqw, calc(150cqw / var(--len, 12))), 80px); max-inline-size: 100%; }
.stim-eq .eq-line { display: inline; }
.q-stim > .stim-target { font-size: clamp(40px, min(26cqh, 14cqw), 120px); }
.stim.is-small { font-size: 16px; }

/* portrait: a question without a picture keeps a small card, the answers get the room */
@media (max-aspect-ratio: 5/4) and (min-height: 501px) {
  .play-stage.no-stim .play-ask { flex: 0 0 auto; }
  .play-stage.no-stim .play-answer { flex: 1 1 auto; }
}

/* compare sides: two block pictures must share the card */
.q-stim .cmp .stim-blocks { --flat: min(18cqh, 15cqw, 72px); }
.q-stim .cmp-value { font-size: clamp(28px, min(12cqh, 10cqw), 56px); }
/* small ✓ on column-sum answer cells so the digit stays readable */
.cb-ans .stamp { inline-size: 18px; block-size: 18px; font-size: 11px; inset-block-start: -9px; inset-inline-end: -7px; }

/* phones: keep the feedback row one line high */
@media (max-width: 520px) {
  .play-feedback { gap: 8px; }
  .fb-mascot svg { inline-size: 40px; block-size: 40px; }
  .btn-next { min-inline-size: 96px; padding-inline: 14px; font-size: 22px; }
  .bubble { font-size: 16px; }
  .bubble.is-hint, .bubble.is-reveal, .bubble.is-praise { padding: 6px 10px; }
  .bubble .page-badge { font-size: 13px; }
}
.cmp .stim-placevalue th, .cmp .stim-placevalue td { padding: 4px 8px; }
.cmp { gap: clamp(8px, 2vw, 16px); }
.opt-text, .slot-v, .bin-chip { overflow-wrap: anywhere; max-inline-size: 100%; }
