/* play.css — the play screen of رحلة يارا · الرياضيات, in the «خلية يارا» world (see DESIGN.md › Play).
   Loads after style.css and owns: the play top bar (✕ · honey progress cells with the bee · page chip),
   the question card (start side) and the answer card (end side), the miss / hint / reveal / right states,
   the keypad, every mechanic and every stimulus. Tokens come from style.css (tokens.css); the layer below
   only fills in if a token is missing, and never wins over style.css. No url(), no web fonts. */

@layer play-fallback {
  :root {
    --paper: #FFFCF3; --paper-2: #FBF2DC; --paper-3: #F4E7C6; --ink: #2A1C0C; --ink-2: #5B4426; --ink-on-dark: #FFF8E6;
    --honey: #F5B120; --honey-deep: #E39410; --honey-light: #FFD36B; --honey-shine: #FFE9A8;
    --wax: #F0CE74; --wax-rim: #C99637; --wax-empty: #FFF4D4; --wax-raw: #F6EEDB; --wax-raw-rim: #DCCB9F;
    --action: #7A4600; --action-press: #5F3600; --action-lip: #4A2A00;
    --right: #255E22; --right-tint: #E6F2D9; --notyet: #6E6250; --notyet-tint: #EFEAE0; --notyet-line: #8A6A4A; --hint: #FFF1C4;
    --sky: #D4EBF2; --blk-face: #45A3E5; --blk-side: #2B7CC1; --blk-line: #1E5F9C; --blk: 96px;
    --u1: #EFA81E; --u1-dark: #6E4100; --u1-tint: #FFF0C7; --u2: #E2694C; --u2-dark: #7F270F; --u2-tint: #FCE3DA;
    --u3: #6FA33B; --u3-dark: #2E5F14; --u3-tint: #E3F1D1; --u4: #CC4D88; --u4-dark: #7A1D4D; --u4-tint: #F9DCE9;
    --u5: #2E97AB; --u5-dark: #0F4C58; --u5-tint: #D6EEF2;
    --font: "SF Arabic Rounded", ui-rounded, system-ui, "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
    --fs-label: 18px; --fs-body: 20px; --fs-title: clamp(22px, 1.2vmin + 13px, 26px);
    --fs-question: clamp(28px, 2.6vmin + 10px, 38px); --fs-numeral: clamp(30px, 3vmin + 8px, 40px); --fs-answer: clamp(40px, 4.6vmin + 6px, 56px);
    --gutter: 24px; --r-sm: 12px; --r-md: 20px; --r-lg: 28px; --r-pill: 999px; --lip: 4px;
    --lift-1: 0 1px 0 rgba(122, 82, 20, .14), 0 6px 16px -8px rgba(90, 60, 10, .32);
    --lift-2: 0 2px 0 rgba(122, 82, 20, .16), 0 14px 32px -12px rgba(90, 60, 10, .40);
    --focus: 0 0 0 3px var(--paper), 0 0 0 7px var(--ink);
    --t-fast: 150ms; --t-med: 220ms; --t-slow: 300ms;
    --ease-out: cubic-bezier(.22, 1, .36, 1); --ease-honey: cubic-bezier(.33, 0, .2, 1); --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
    --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); }
  @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 nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
}

/* ============================== the screen ============================== */
.screen-play {
  position: fixed; inset: 0; block-size: 100dvh; min-block-size: 0; overflow: hidden;
  display: block; padding: 0; gap: 0;
  background: var(--sky); color: var(--ink); font-family: var(--font);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --stage-top: 92px; --stage-bottom: 20px;
  --wax-lip: #E6D3A3;            /* the lip under a pressable paper card: one tone below paper-3 */
  --hint-bee-w: 128px;
}
.screen-play .scene-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.screen-play .scene-bg > svg { inline-size: 100%; block-size: 100%; max-inline-size: none; }
.screen-play button { font-family: var(--font); color: var(--ink); -webkit-tap-highlight-color: transparent; }
.screen-play button:focus-visible { outline: none; box-shadow: var(--focus); }
.screen-play bdi.n { font-family: var(--font); font-variant-numeric: tabular-nums lining-nums; }
.screen-play svg.art { overflow: visible; }

/* ============================== top bar ============================== */
.screen-play .play-bar {
  position: absolute; z-index: 10; inset-block-start: calc(12px + var(--safe-t)); inset-inline: var(--gutter);
  block-size: 64px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px;
}
.screen-play .btn-exit, .screen-play .btn-howto {
  inline-size: 56px; block-size: 56px; min-inline-size: 56px; min-block-size: 56px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; background: var(--paper); box-shadow: var(--lift-1);
  font-size: 24px; color: var(--ink); transition: transform var(--t-fast) var(--ease-out);
}
.screen-play .play-bar-start { justify-self: start; display: flex; align-items: center; gap: 12px; }
.screen-play .btn-exit svg { inline-size: 28px; block-size: 28px; }
.screen-play .btn-howto { position: relative; color: var(--ink-2); }
.screen-play .btn-howto svg { inline-size: 30px; block-size: 30px; }
.screen-play .btn-howto.is-new::after {
  content: ""; position: absolute; inset-block-start: 3px; inset-inline-end: 3px; inline-size: 12px; block-size: 12px;
  border-radius: 50%; background: var(--honey); box-shadow: 0 0 0 2px var(--paper);
}
.screen-play .btn-exit:active, .screen-play .btn-howto:active { transform: translateY(2px); }
.screen-play .play-bar-end { justify-self: end; display: flex; align-items: center; gap: 12px; min-inline-size: 0; }

/* the progress pill: one wax cell per question; the bee flies just before the current one */
.screen-play .progress {
  block-size: 64px; padding-inline: 18px; display: flex; align-items: center;
  border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--lift-1);
}
.screen-play .dots { list-style: none; margin: 0; padding: 0; flex: none; display: flex; align-items: center; gap: 10px; direction: rtl; }
.screen-play .dot {
  position: relative; display: flex; align-items: center; gap: 0;
  inline-size: auto; block-size: auto; border: 0; border-radius: 0; background: none; padding: 0;
}
.screen-play .dot-hex { display: block; inline-size: 34px; block-size: 39px; }
.screen-play .dot-hex svg { inline-size: 100%; block-size: 100%; }
/* an extra practice cell (added after a taught answer) arrives visibly, so the end of the round never moves in silence */
.screen-play .dot.is-added .dot-hex { animation: pop-in var(--t-slow) var(--ease-out) 400ms both; }
.screen-play .dot-fallback { display: block; inline-size: 100%; block-size: 100%; clip-path: var(--hex); background: var(--wax-rim); }
.screen-play .dot.is-done .dot-fallback, .screen-play .dot.is-helped .dot-fallback { background: var(--honey); }
.screen-play .dot-bee { display: block; inline-size: 40px; block-size: 42px; margin-inline-end: 2px; flex: none; }
.screen-play .dot-bee svg { inline-size: 100%; block-size: 100%; }
.screen-play .dot-bee.is-hopping { transition: transform var(--t-med) var(--ease-out); }
.screen-play .dot.is-filling .art-dot-honey { animation: honey-fill 250ms var(--ease-honey) both; transform-box: fill-box; transform-origin: 50% 100%; }
.screen-play .honey-fly {
  position: absolute; z-index: 2; inset-inline-end: 6px; inset-block-start: 6px; inline-size: 22px; block-size: 28px; pointer-events: none;
  animation: honey-fall var(--t-slow) var(--ease-honey) 120ms both;
}
.screen-play .honey-fly svg { inline-size: 100%; block-size: 100%; }

/* the page of the book */
.screen-play .page-chip {
  display: inline-flex; align-items: center; gap: 8px; block-size: 56px; padding-inline: 16px 20px;
  border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--lift-1);
  font-size: var(--fs-title); font-weight: 800; color: var(--ink); white-space: nowrap;
}
.screen-play .page-chip svg { inline-size: 26px; block-size: 26px; color: var(--u3-dark); flex: none; }
.screen-play .page-chip.is-hint { box-shadow: 0 0 0 4px var(--honey), var(--lift-1); animation: nudge var(--t-fast) var(--ease-out) 2; }

/* ============================== stage ============================== */
.screen-play .play-stage {
  position: absolute; z-index: 10;
  inset-block: calc(var(--stage-top) + var(--safe-t)) calc(var(--stage-bottom) + var(--safe-b)); inset-inline: var(--gutter);
  display: grid; gap: 24px; min-block-size: 0;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
}
/* landscape: question on the start side, answers on the end side */
@media (min-aspect-ratio: 5/4) and (min-width: 900px), (max-height: 500px) {
  .screen-play .play-stage { grid-template-columns: minmax(0, 1fr) clamp(360px, 37vw, 440px); grid-template-rows: minmax(0, 1fr); }
  /* building a number beside a picture: the three place columns need the room, so the board gets the wider side
     and every − / + stays a full finger-size target */
  .screen-play .play-stage:not(.ask-light):has(.play-answer .bb) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  .screen-play .play-stage:not(.ask-light) .bb-btn { min-inline-size: 56px; }
}
/* ---------- «light» items (no picture, or only the number to build): one full-width stage.
   Row 1 is a compact question band (question top-start, the hint beside it in landscape, under it in portrait);
   row 2 is the answer card, which takes all the rest. The question starts at the same place on every item. */
.screen-play .play-stage.ask-light { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-content: stretch; }
.screen-play .ask-light .play-ask {
  display: grid; align-items: center; column-gap: 24px; row-gap: 4px; padding: 16px 28px;
  grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head stim" "fb fb";
}
.screen-play .ask-light .q-head { grid-area: head; }
.screen-play .ask-light .q-stim { grid-area: stim; container-type: normal; overflow: visible; flex: none; align-self: center; }
.screen-play .ask-light .play-feedback { grid-area: fb; min-block-size: 64px; align-items: center; --hint-bee-w: 84px; }
.screen-play .ask-light .fb-mascot { inset-block-end: 2px; inset-inline-end: 12px; }
.screen-play .ask-light .stim-target .target-n { font-size: clamp(40px, 3vmin + 18px, 56px); border-width: 3px; }
@media (min-aspect-ratio: 5/4) and (min-width: 900px), (max-height: 500px) {
  .screen-play .ask-light .play-ask { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.1fr); grid-template-areas: "head stim fb"; min-block-size: 100px; }
}
@media (min-aspect-ratio: 5/4) and (min-width: 900px) {
  /* the band keeps one height idle and hinted (a two-line hint fits), so the answer cards never move under her finger */
  .screen-play .ask-light .play-ask { min-block-size: 128px; }
  /* the page chip runs on at the end of the hint's last line instead of taking a row of its own */
  .screen-play .bubble:is(.is-hint, .is-reveal) { display: block; align-content: center; }
  .screen-play .bubble:is(.is-hint, .is-reveal) > p { display: inline; }
  .screen-play .bubble:is(.is-hint, .is-reveal) > .pchip { margin-inline-start: 12px; vertical-align: middle; line-height: 1.2; }
  /* steps: the band keeps its two-line height from the start, so the column board never shrinks as the hint arrives */
  .screen-play.mech-steps .play-feedback { min-block-size: 96px; }
}
.screen-play .ask-light .play-answer { padding: 24px 28px; }
.screen-play .ask-light .play-answer > .ans-status,
.screen-play .ask-light .play-answer > .btn-next,
.screen-play .ask-light .play-answer > .bb-check { inline-size: min(100%, 560px); align-self: center; }
.screen-play .ask-light .opts { inline-size: min(100%, 1000px); align-self: center; grid-auto-rows: minmax(150px, 220px); gap: 18px; }
.screen-play .ask-light .opts-stack { inline-size: min(100%, 760px); grid-auto-rows: minmax(112px, auto); }
.screen-play .ask-light .opt-word .opt-text { font-size: clamp(24px, 1.6vmin + 14px, 32px); }
.screen-play .ask-light .opts-pics { inline-size: min(100%, 1000px); }
.screen-play .ask-light .np { inline-size: min(100%, 620px); align-self: center; }
.screen-play .ask-light .bb { inline-size: min(100%, 1000px); align-self: center; }
.screen-play .ask-light .match { inline-size: min(100%, 920px); align-self: center; flex: 1 1 auto; min-block-size: 0; align-content: center; padding-block: 14px 0; }
/* four pairs plus «أحسنتِ!» and «التالي» must fit: the cards take their height from the screen height */
.screen-play .ask-light .match .opt { min-block-size: 104px; }
.screen-play .ask-light .match:not(.match-n2):not(.match-n3) .opt { min-block-size: clamp(64px, calc((100dvh - 500px) / 4), 104px); padding-block: 6px; }
.screen-play .ask-light .match ~ .ans-status { flex: none; }
.screen-play .ask-light :is(.ord-slots, .ord-pool, .sort-items, .sort-bins) { inline-size: min(100%, 960px); align-self: center; }
.screen-play .ask-light .ord-slots .slot { min-block-size: 132px; }
.screen-play .ask-light .ord-pool .opt { min-inline-size: 132px; min-block-size: 96px; }
/* landscape: short options sit in one row of big cards; numbers to type sit beside the keypad */
@media (min-aspect-ratio: 5/4) and (min-width: 900px) {
  .screen-play .ask-light .opts:not(.opts-stack):not(.opts-pics) { grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); grid-auto-rows: minmax(180px, 240px); }
  .screen-play .ask-light .opts-2:not(.opts-stack):not(.opts-pics) { --n: 2; inline-size: min(100%, 720px); }
  .screen-play .ask-light .opts-3:not(.opts-stack):not(.opts-pics) { --n: 3; inline-size: min(100%, 900px); }
  .screen-play .ask-light .opts-4:not(.opts-stack):not(.opts-pics) { --n: 4; }
  .screen-play .ask-light .opts-3:not(.opts-stack):not(.opts-pics) > .opt:last-child { grid-column: auto; inline-size: auto; }
  .screen-play .ask-light .np {
    inline-size: 100%; max-inline-size: 1040px; display: grid; column-gap: 48px; row-gap: 12px; align-items: center;
    grid-template-columns: minmax(0, 1fr) minmax(0, 500px);
    grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr) auto;
    grid-template-areas: ". pad" "slot pad" "status pad" ". pad" ". check";
  }
  .screen-play .ask-light .np > .np-row { grid-area: slot; }
  .screen-play .ask-light .np > .ans-status { grid-area: status; }
  .screen-play .ask-light .np > .keypad { grid-area: pad; align-self: stretch; }
  .screen-play .ask-light .np > .key-check { grid-area: check; }
  .screen-play .ask-light .np-display { min-inline-size: 220px; block-size: 120px; font-size: 64px; }
  .screen-play .ask-light .np-display.is-empty .np-caret { block-size: 64px; }
  .screen-play .ask-light .play-answer:has(> .np) > .btn-next { position: absolute; inset-block-end: 24px; inset-inline-end: max(28px, calc((100% - 1040px) / 2)); inline-size: min(500px, calc((100% - 104px) / 2)); }
  .screen-play.is-answered .ask-light .np > .key-check, .screen-play.is-teaching .ask-light .np > .key-check { display: inline-flex; visibility: hidden; }
}
/* portrait: three short options side by side, four in two rows */
@media not all and (min-aspect-ratio: 5/4), (max-width: 899px) {
  .screen-play .ask-light .opts-3:not(.opts-stack):not(.opts-pics) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .screen-play .ask-light .opts-3:not(.opts-stack):not(.opts-pics) > .opt:last-child { grid-column: auto; inline-size: auto; }
  .screen-play .ask-light .opts { grid-auto-rows: minmax(150px, 200px); }
  .screen-play .ask-light .np .keypad { grid-auto-rows: 72px; }
}

/* option cards that each hold a column sum: side by side in the wide light card (landscape), one per row elsewhere */
.screen-play .ask-light .opts-cols { grid-auto-rows: minmax(0, 1fr); inline-size: min(100%, 1000px); }
@media (min-aspect-ratio: 5/4) and (min-width: 900px) {
  .screen-play .ask-light .opts-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 380px); }
  .screen-play .ask-light .opts-cols .colboard { --cb: clamp(40px, min(13cqi, 8vh), 68px); }
}

/* ---------- compare: the two number cards on top, the three symbols right under them, full width ---------- */
.screen-play .play-stage.ask-stack { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.screen-play .ask-stack .play-answer {
  display: grid; padding: 20px 28px; column-gap: 32px; row-gap: 8px; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: ". opts next" ". status .";
}
.screen-play .ask-stack .opts-sym { grid-area: opts; inline-size: 468px; grid-template-columns: repeat(3, 140px); grid-auto-rows: 140px; gap: 24px; }
.screen-play .ask-stack .opt-sym .sym { font-size: 60px; }
.screen-play .ask-stack .ans-status { grid-area: status; }
.screen-play .ask-stack .btn-next { grid-area: next; justify-self: start; inline-size: min(100%, 280px); }
.screen-play .ask-stack .cmp { gap: clamp(20px, 3vw, 44px); }
.screen-play .ask-stack .cmp-side { min-inline-size: min(320px, 34cqw); padding: 22px 26px; gap: 16px; border-radius: var(--r-lg); }
.screen-play .ask-stack .cmp-value { font-size: clamp(52px, 4vmin + 24px, 64px); }
.screen-play .ask-stack .cmp-slot { inline-size: 110px; block-size: 126px; }
.screen-play .ask-stack .cmp .stim-placevalue.is-small { border-spacing: 6px 0; }
.screen-play .ask-stack .cmp .stim-placevalue.is-small th { font-size: 20px; padding: 6px 10px; }
.screen-play .ask-stack .cmp .stim-placevalue.is-small td { font-size: 34px; padding: 4px 10px 6px; min-inline-size: 2em; }
.screen-play .ask-stack .cmp .stim-blocks.is-small { --blk: 72px; }
@media not all and (min-aspect-ratio: 5/4), (max-width: 899px) {
  .screen-play .ask-stack .play-answer { grid-template-columns: minmax(0, 1fr); grid-template-areas: "opts" "status" "next"; justify-items: center; }
  .screen-play .ask-stack .btn-next { justify-self: stretch; inline-size: min(100%, 560px); margin-inline: auto; }
  .screen-play .ask-stack .btn-next[hidden] { display: inline-flex; visibility: hidden; }
}

/* the number line to place on: as wide as the card allows */
.screen-play .wide-answer .nl-place-inner { max-inline-size: 1000px; margin-inline: auto; }

.screen-play .play-ask, .screen-play .play-answer {
  position: relative; min-block-size: 0; min-inline-size: 0;
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--lift-1);
}
.screen-play .play-ask { display: flex; flex-direction: column; gap: 14px; padding: 24px 28px 18px; flex: none; }
.screen-play .play-answer { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 20px; flex: none; }

/* the question */
.screen-play .q-head { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; flex: none; }
.screen-play .q-text { font-size: var(--fs-question); font-weight: 800; line-height: 1.3; text-align: start; text-wrap: balance; color: var(--ink); }
.screen-play .q-text bdi.n { color: var(--unit-dark, var(--ink)); }
/* unit 3's dark olive is too close to the green of a right answer: its numbers stay in ink before she answers */
.screen-play.u3 .q-text bdi.n { color: var(--ink); }
.screen-play .ord-dir {
  align-self: flex-start; display: inline-flex; align-items: center; padding: 4px 16px; border-radius: var(--r-pill);
  background: var(--paper-2); color: var(--ink-2); font-size: var(--fs-body); font-weight: 800;
}
.screen-play .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; align-content: center; gap: 16px 24px;
}

/* ============================== feedback band, hint bee ============================== */
.screen-play .play-feedback {
  display: flex; align-items: flex-end; min-block-size: 64px; flex: none; gap: 0; padding: 0;
  grid-template-columns: none;
}
.screen-play .bubble {
  flex: 1 1 auto; min-inline-size: 0; min-block-size: 64px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 12px 20px; border-radius: var(--r-md); background: transparent; box-shadow: none;
  font-size: var(--fs-body); font-weight: 800; line-height: 1.4; color: var(--ink);
}
.screen-play .bubble:empty { visibility: hidden; }
.screen-play .bubble.is-hint, .screen-play .bubble.is-reveal { background: var(--hint); box-shadow: none; padding: 12px 20px; }
.screen-play .bubble.is-praise { background: var(--right-tint); box-shadow: none; padding: 12px 20px; }
.screen-play .bubble p { margin: 0; }
.screen-play .bubble bdi.n { white-space: nowrap; } /* a number list or an equation never breaks across lines */
.screen-play .opt-text .and { display: inline-block; margin-inline: .32em; } /* «70 وَ 80»: even room on both sides of the joiner */
.screen-play .bubble .bubble-hint, .screen-play .bubble .bubble-why, .screen-play .bubble .bubble-answer { color: var(--ink); font-weight: 800; }
.screen-play .bubble .art-check { inline-size: 30px; block-size: 30px; flex: none; }
.screen-play .pchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 14px 2px 12px; border-radius: var(--r-pill);
  background: var(--paper); border: 2px solid var(--honey); white-space: nowrap; font-weight: 800;
}
.screen-play .pchip svg { inline-size: 22px; block-size: 22px; color: var(--u3-dark); }
.screen-play .fb-mascot {
  position: absolute; z-index: 20; inset-inline-end: 8px; inset-block-end: 4px;
  inline-size: var(--hint-bee-w); block-size: calc(var(--hint-bee-w) * 1.033); pointer-events: none; display: none;
}
.screen-play .fb-mascot.is-on { display: block; animation: pop-in var(--t-slow) var(--ease-out) both; }
/* set by beeRoom() in app.js when the bee would stand on the figure: the hint row takes her height */
.screen-play .play-feedback.has-bee-room { min-block-size: calc(var(--hint-bee-w) * 1.033 - 4px); }
.screen-play .fb-mascot svg { inline-size: 100%; block-size: 100%; }
.screen-play .play-feedback:has(.fb-mascot.is-on) .bubble { margin-inline-end: calc(var(--hint-bee-w) + 4px); }

/* the line right at the answer */
.screen-play .ans-status {
  min-block-size: 30px; margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  font-size: var(--fs-body); font-weight: 800; line-height: 1.3; color: var(--ink-2); text-align: center;
}
.screen-play .ans-status .art-cross, .screen-play .ans-status .art-check { inline-size: 26px; block-size: 26px; flex: none; }
.screen-play .ans-status.is-right { color: var(--ink); } /* the green ✓ beside it carries the meaning; words stay in ink */
.screen-play .ans-status.is-right, .screen-play .ans-status.is-miss { animation: pop-in var(--t-med) var(--ease-out); }
.screen-play .ans-status.is-reveal { color: var(--ink); }
.screen-play .status-chip, .screen-play .ans-chip {
  display: inline-grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 50%; flex: none;
  background: var(--honey); color: var(--ink);
}
.screen-play .status-chip svg, .screen-play .ans-chip svg { inline-size: 20px; block-size: 20px; }
.screen-play .ans-chip {
  position: absolute; z-index: 3; inset-block-start: -18px; inset-inline-start: 50%; translate: 50% 0;
  inline-size: 36px; block-size: 36px; box-shadow: 0 0 0 3px var(--paper);
}
.screen-play .ans-chip svg { inline-size: 22px; block-size: 22px; }

/* «التالي» waits where «تحقّق» was */
.screen-play .btn-next, .screen-play .key.key-check, .screen-play .bb-check {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; flex: none;
  inline-size: 100%; min-inline-size: 0; block-size: 76px; min-block-size: 64px; padding: 0 24px; margin: 0;
  border: 0; border-radius: var(--r-md); border-bottom: var(--lip) solid var(--action-lip); box-shadow: none;
  background: var(--action); color: var(--ink-on-dark); font-size: var(--fs-title); font-weight: 800;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}
.screen-play .btn-next[hidden] { display: none; }
.screen-play .btn-next svg, .screen-play .key-check svg, .screen-play .bb-check svg { inline-size: 28px; block-size: 28px; flex: none; }
.screen-play .btn-next:active, .screen-play .key.key-check:active, .screen-play .bb-check:active { transform: translateY(2px); border-bottom-width: 2px; background: var(--action-press); }
/* «التالي» arrives calmly: the single ✓ pop belongs to the answer */
@keyframes next-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen-play .btn-next:not([hidden]) { animation: next-in var(--t-med) var(--ease-out) both; }
.screen-play .play-answer.is-arming, .screen-play .play-answer.is-settling { pointer-events: none; } /* the first moments of a new question ignore taps (double tap on «التالي») */
.screen-play .btn-next.is-waiting { opacity: .45; pointer-events: none; animation: none; transition: opacity var(--t-slow) var(--ease-out); }
.screen-play.is-teaching .key-check { display: none; }
.screen-play.is-answered .key-check, .screen-play.is-answered .bb-check { display: none; }

/* ============================== motion helpers (engine classes) ============================== */
.screen-play .is-shake { animation: nudge var(--t-fast) var(--ease-out) 2; }
.screen-play .is-pop { animation: pop-in var(--t-slow) var(--ease-spring); }
.screen-play .is-glow { animation: honey-ring 1.8s ease-in-out infinite; }
@keyframes honey-ring { 0%, 100% { box-shadow: 0 0 0 4px var(--honey), var(--lift-1); } 50% { box-shadow: 0 0 0 7px var(--honey-light), var(--lift-1); } }
@media (prefers-reduced-motion: reduce) { .screen-play .is-glow { animation: none; box-shadow: 0 0 0 5px var(--honey); } }

/* the ✓ / ✗ badge on the top end corner of whatever was tried */
.screen-play .stamp {
  position: absolute; z-index: 3; inset-block-start: -14px; inset-inline-end: -14px; inline-size: 36px; block-size: 36px;
  display: block; padding: 0; border-radius: 50%; background: none; color: inherit; font-size: 0; line-height: 0;
}
.screen-play .stamp svg { inline-size: 100%; block-size: 100%; }
.screen-play .stamp.stamp-ok { animation: pop-in var(--t-slow) var(--ease-spring); }

/* ============================== option cards (pick · odd · tf · compare · numline pick) ============================== */
.screen-play .opts { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(120px, auto); }
.screen-play .opts-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.screen-play .opts-stack { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(96px, auto); }
.screen-play .opts-pics.opts-3 { grid-template-columns: minmax(0, 1fr); }
.screen-play .opt {
  position: relative; min-block-size: 96px; padding: 12px 16px; margin: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: var(--paper); color: var(--ink); opacity: 1; filter: none;
  border: 3px solid var(--paper-3); border-bottom: 7px solid var(--wax-lip); border-radius: var(--r-md); box-shadow: none;
  font-size: var(--fs-title); font-weight: 800; line-height: 1.25; text-align: center;
  transition: transform var(--t-fast) var(--ease-out), opacity var(--t-med) var(--ease-out), background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.screen-play .opt:active:not(:disabled) { transform: translateY(2px); background: var(--paper-2); border-bottom-width: 5px; }
@media (hover: hover) { .screen-play .opt:hover:not(:disabled) { background: #FFF8E4; } }
.screen-play .opt:disabled { cursor: default; }
.screen-play .opt-text { line-height: 1.25; overflow-wrap: anywhere; max-inline-size: 100%; }
.screen-play .opts > .opt { container-type: inline-size; }
.screen-play .opt-num .opt-text, .screen-play .opt-sym .sym { font-size: clamp(34px, 3.4vmin + 10px, 46px); line-height: 1.1; }
/* a number never breaks inside its card; a long one ('900 + 50 + 1') steps down to fit the card's width */
.screen-play .opt-num .opt-text { white-space: nowrap; overflow-wrap: normal; font-size: min(clamp(34px, 3.4vmin + 10px, 46px), calc(150cqi / var(--chars, 3))); }
.screen-play .opt-word .opt-text { font-size: clamp(22px, 1.4vmin + 13px, 28px); text-wrap: balance; }
.screen-play .opt-icons .opt-text { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; direction: ltr; }
.screen-play .opt-icons .ico-art { inline-size: 34px; block-size: 34px; }
.screen-play .opt-icons .ico-run { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.screen-play .opt-stim { display: flex; justify-content: center; max-inline-size: 100%; }
.screen-play .opt-figure { display: block; }
.screen-play .opt-img { max-block-size: 110px; max-inline-size: 100%; object-fit: contain; border-radius: var(--r-sm); }
.screen-play .opt-figure.is-missing { display: none; }
.screen-play .opts-cols { flex: 1 1 auto; min-block-size: 0; grid-auto-rows: minmax(0, 1fr); align-content: center; }
.screen-play .opts-cols .opt { padding: 8px 12px; min-block-size: 0; gap: 4px; }
.screen-play .opt-stim .colboard { --cb: clamp(32px, min(15cqi, 5.6vh), 56px); padding: 6px 12px 8px; grid-template-rows: 0 calc(var(--cb) * .4) var(--cb) var(--cb) calc(var(--cb) + 6px); }
.screen-play .opt-stim .colboard .cb-head { visibility: hidden; font-size: 0; }
.screen-play .opt-stim .stim-tally { font-size: 28px; }
.screen-play .opt-stim .tally th:empty { display: none; }
.screen-play .opt-stim .tally td { background: none; padding: 0 .2em; }
/* marks sit straight on the card's own tint (right, selected, tried): no paper box behind them */
.screen-play .stim-tally .tally, .screen-play .stim-pictograph .picto { background: none; }
.screen-play .match .opt-stim .stim-tally { font-size: 24px; }

.screen-play .opt.is-selected { border-color: var(--honey); border-bottom-color: var(--honey-deep); background: #FFF8E4; box-shadow: 0 0 0 3px var(--honey-light); }
.screen-play .opt.is-miss {
  background: var(--notyet-tint); color: var(--ink-2); opacity: 1; filter: none; transform: none;
  border: 3px dashed var(--notyet-line); border-bottom-width: 3px;
}
.screen-play .opt.is-miss.is-shake { animation: nudge var(--t-fast) var(--ease-out) 2; }
.screen-play .opt.is-miss bdi.n { color: var(--ink-2); }
/* a tried number gets a diagonal slash, never a horizontal line: a line through «1» reads as «4» or «+».
   Labels in a picture option («الورقة 1») are not slashed: the dashed border and the ✗ already say «ليس بعد» */
.screen-play .opt.is-miss:not(.opt-pic) .opt-text bdi.n, .screen-play .np-display.is-miss .np-value,
.colboard .cb-ans.is-miss, .colboard .cb-wrong, .colboard .cb-top.is-struck .cb-d {
  text-decoration: none; padding-inline: 4px; background-repeat: no-repeat;
  background-image: linear-gradient(to bottom right, transparent calc(50% - 2px), var(--notyet) calc(50% - 2px), var(--notyet) calc(50% + 2px), transparent calc(50% + 2px));
}
.screen-play .opt.is-right, .screen-play .opt.is-matched {
  background: var(--right-tint); color: var(--ink); opacity: 1; border: 3px solid var(--right); border-bottom-width: 3px;
}
.screen-play .opt.is-answer { background: var(--paper); border: 4px solid var(--honey); border-bottom-width: 4px; box-shadow: var(--lift-2); }
.screen-play .opt.is-folded { opacity: 0; transform: scale(.96); pointer-events: none; }
/* while the answer is taught, the cards she tried step back too: no row of ✗ beside the answer */
.screen-play.is-revealed .opt.is-miss { opacity: .45; transform: scale(.96); transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out); }
.screen-play.is-revealed .opt.is-miss .stamp { display: none; }
.screen-play .opt.is-placed { opacity: .35; border-style: dashed; border-bottom-width: 3px; background: var(--wax-raw); }

/* landscape: options get tall cards; three short ones sit two over one, like cells of a comb */
@media (min-aspect-ratio: 5/4) and (min-width: 900px) {
  .screen-play .opts { grid-auto-rows: minmax(150px, auto); }
  .screen-play .opts-stack { grid-auto-rows: minmax(110px, auto); }
  .screen-play .opts-3:not(.opts-stack):not(.opts-sym):not(.opts-pics) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen-play .opts-3:not(.opts-stack):not(.opts-sym):not(.opts-pics) > .opt:last-child { grid-column: 1 / -1; justify-self: center; inline-size: calc(50% - 7px); }
}

/* true / false */
.screen-play .opt-tf { flex-direction: row; gap: 12px; min-block-size: 150px; }
.screen-play .opt-tf .opt-text { font-size: clamp(30px, 2vmin + 18px, 40px); }
.screen-play .tf-glyph { display: grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 50%; background: var(--paper-2); color: var(--ink-2); font-size: 0; }
.screen-play .tf-glyph svg { inline-size: 28px; block-size: 28px; }

/* ============================== compare ============================== */
.screen-play .cmp { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2.4vw, 28px); inline-size: auto; max-inline-size: none; direction: ltr; }
.screen-play .cmp-side {
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 14px; min-inline-size: 150px; flex: none;
  border-radius: var(--r-md); background: var(--paper-2);
}
.screen-play .cmp-value { font-size: clamp(44px, 5vmin + 12px, 72px); font-weight: 800; line-height: 1; color: var(--ink); font-family: var(--font); }
.screen-play .cmp-slot {
  position: relative; flex: none; inline-size: 96px; block-size: 110px; display: grid; place-items: center;
  clip-path: var(--hex); background: var(--wax-rim); border: 0; border-radius: 0; font-size: 48px; font-weight: 800;
}
.screen-play .cmp-slot::before { content: ""; position: absolute; inset: 4px; clip-path: var(--hex); background: var(--wax-empty); }
.screen-play .cmp-slot > * { position: relative; }
.screen-play .cmp-slot .blank { border: 0; background: none; min-inline-size: 0; padding: 0; margin: 0; color: var(--ink-2); font-size: 44px; block-size: auto; }
.screen-play .cmp-slot.is-filled { border: 0; animation: pop-in var(--t-slow) var(--ease-spring); }
.screen-play .cmp-slot.is-filled::before { background: var(--honey-light); }
.screen-play .cmp-slot .sym { color: var(--ink); font-size: 52px; line-height: 1; }
.screen-play .opts-sym { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(120px, auto); direction: ltr; }
.screen-play .opt-sym .sym { font-size: 56px; font-family: var(--font); }
.screen-play .opts-cards { direction: ltr; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(150px, auto); }
.screen-play .opt-card .opt-text { font-size: clamp(40px, 4vmin + 10px, 56px); }

/* ============================== answer slot + keypad ============================== */
.screen-play .np { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-block-size: 0; align-items: stretch; }
.screen-play .np-row { display: flex; align-items: center; justify-content: center; gap: 16px; flex: none; }
.screen-play .np-display {
  position: relative; min-inline-size: 150px; block-size: 92px; min-block-size: 0; padding-inline: 22px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: var(--paper-2); border: 3px solid var(--wax-rim); border-radius: var(--r-md); box-shadow: none;
  font-size: var(--fs-answer); font-weight: 800; color: var(--ink); line-height: 1; font-family: var(--font);
}
.screen-play .np-caret { display: none; }
.screen-play .np-display.is-empty .np-caret { display: block; inline-size: 4px; block-size: 52px; border-radius: 2px; background: var(--honey-deep); animation: caret 1.1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.screen-play .np-unit { font-size: clamp(26px, 1.6vmin + 16px, 32px); font-weight: 800; color: var(--ink); margin: 0; text-align: center; }
.screen-play .np-display.is-miss { background: var(--notyet-tint); border: 3px dashed var(--notyet-line); color: var(--ink-2); }
.screen-play .np-display.is-miss .np-value { display: inline-block; padding-inline: .3em; } /* a wider box, a gentler slash */
.screen-play .np-display.is-right { background: var(--right-tint); border: 3px solid var(--right); color: var(--ink); }
.screen-play .np-display.is-answer { background: var(--paper); border: 4px solid var(--honey); box-shadow: var(--lift-2); }

.screen-play .keypad {
  flex: 1 1 auto; min-block-size: 0; display: grid; direction: ltr; gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(48px, 1fr);
}
.screen-play .key {
  min-block-size: 48px; block-size: auto; min-inline-size: 0; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--paper-2); color: var(--ink); border: 0; border-bottom: var(--lip) solid var(--paper-3); border-radius: var(--r-md); box-shadow: none;
  font-size: var(--fs-numeral); font-weight: 800; font-family: var(--font); line-height: 1;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.screen-play .key:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; background: var(--paper-3); }
@media (hover: hover) { .screen-play .key-digit:hover:not(:disabled), .screen-play .key-clear:hover:not(:disabled) { background: #F8EBC8; } }
.screen-play .key:disabled { cursor: default; }
.screen-play .key-zero { grid-column: span 2; }
.screen-play .key-clear { direction: rtl; font-size: var(--fs-body); color: var(--ink-2); gap: 6px; }
.screen-play .key-clear svg { inline-size: 28px; block-size: 28px; }
.screen-play .key-label { font-size: var(--fs-body); }
.screen-play .key-spacer { display: block; }
.screen-play .np .key-check { block-size: 76px; }
.screen-play .np.is-empty .key-check {
  /* waiting for a digit: the primary colour at 55%, no lip (DESIGN › keypad); dashes belong to «ليس بعد» only */
  opacity: .55; background: var(--action); color: var(--ink-on-dark); border: 0; border-bottom-width: 0; box-shadow: none;
}
.screen-play .np.is-empty .key-check:active { transform: none; background: var(--action); }
.screen-play .key-check.is-shake { animation: nudge var(--t-fast) var(--ease-out) 2; }
.screen-play.is-answered .keypad .key { opacity: .7; }

/* ============================== blocks builder ============================== */
.screen-play .bb { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-columns: none; gap: 10px; flex: 1 1 auto; min-block-size: 0; direction: ltr; }
.screen-play .bb-n3 { grid-template-columns: 1.4fr 1fr 1fr; grid-auto-flow: row; }
.screen-play .bb-col {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 0 0 10px; min-block-size: 0;
  background: var(--paper-2); border: 3px solid transparent; border-radius: var(--r-md); overflow: visible;
}
.screen-play .bb-head {
  display: flex; align-items: center; justify-content: center; gap: 6px; block-size: 52px; flex: none; padding-inline: 4px;
  border-radius: 17px 17px 0 0; background: rgba(240, 206, 116, .38); direction: rtl;
  font-size: var(--fs-label); font-weight: 800; color: var(--ink); white-space: nowrap;
}
.screen-play .bb-ico svg { block-size: 26px; inline-size: auto; }
.screen-play .bb-area { flex: 1 1 auto; min-block-size: 60px; block-size: auto; display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center; gap: 4px 6px; padding: 6px; overflow: hidden; }
.screen-play .bb-area .blk { display: block; line-height: 0; }
.screen-play .bb { --bbk: clamp(44px, 7.4vh, 64px); }
.screen-play .bb-area-h .art-hundred, .screen-play .bb-area-t .art-ten { block-size: var(--bbk); inline-size: auto; }
.screen-play .bb-area-o { max-inline-size: none; display: grid; grid-template-columns: repeat(3, auto); align-content: end; }
.screen-play .bb-area-o .art-one { block-size: max(16px, calc(var(--bbk) * 18 / 108 * 1.5)); inline-size: auto; }
.screen-play .bb-count { text-align: center; font-size: 34px; font-weight: 800; line-height: 1.1; color: var(--ink); }
.screen-play .bb-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-inline: 8px; }
.screen-play .bb-btn {
  min-block-size: 56px; block-size: 56px; min-inline-size: 0; padding: 0; display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--paper); border: 0; border-bottom: var(--lip) solid var(--paper-3);
  font-size: 34px; font-weight: 800; line-height: 1; color: var(--ink); font-family: var(--font);
}
.screen-play .bb-btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.screen-play .bb-btn:disabled { opacity: .4; }
.screen-play .bb-col.is-locked { border-color: var(--right); background: var(--right-tint); }
.screen-play .bb-col.is-locked .bb-head { background: rgba(37, 94, 34, .10); }
.screen-play .bb-col.is-cleared { border: 3px dashed var(--notyet-line); background: var(--notyet-tint); }
.screen-play .bb-col.is-answer { border: 4px solid var(--honey); background: var(--paper); }
.screen-play .bb-col .stamp { inset-block-start: -14px; }

/* ============================== order ============================== */
.screen-play .ord-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; flex: none; }
.screen-play .ord-slots .slot {
  position: relative; min-block-size: 112px; padding: 24px 6px 10px; margin-block-start: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 3px solid var(--wax-rim); border-radius: var(--r-md); background: var(--wax-empty);
}
.screen-play .slot-n {
  /* the slot's number: a paper hex (34 × 39, like the progress cells) sitting on the slot's top edge */
  position: absolute; inset-block-start: -21px; inset-inline-start: 50%; translate: 50% 0;
  display: grid; place-items: center; inline-size: 34px; block-size: 39px; clip-path: var(--hex); background: var(--wax-rim);
  font-size: 20px; font-weight: 800; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums;
}
.screen-play .slot-n::before { content: ""; position: absolute; inset: 3px; clip-path: var(--hex); background: var(--paper); z-index: -1; }
.screen-play .slot-n { isolation: isolate; }
.screen-play .ord-slots .slot.is-filled .slot-n { background: var(--right); }
[dir="ltr"] > .slot > .slot-n, .screen-play .ord-slots[dir="ltr"] .slot-n { translate: -50% 0; }
.screen-play .slot-v { font-size: clamp(28px, 2.6vmin + 12px, 40px); font-weight: 800; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.screen-play .ord-slots .slot.is-filled { border: 3px solid var(--right); background: var(--right-tint); }
.screen-play .ord-slots[dir="ltr"] { position: relative; margin-block-end: 26px; }
.screen-play .ord-slots[dir="ltr"]::after {
  content: ""; position: absolute; inset-inline: 12% 12%; inset-block-end: -18px; block-size: 4px; border-radius: 2px; background: var(--wax-rim);
}
.screen-play .ord-slots[dir="ltr"]::before {
  content: ""; position: absolute; inset-inline-end: calc(12% - 10px); inset-block-end: -24px; inline-size: 16px; block-size: 16px;
  background: var(--wax-rim); clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.screen-play .ask-light .slot-v { font-size: clamp(34px, 3vmin + 14px, 48px); }
.screen-play .ask-light .chip .opt-text { font-size: clamp(34px, 3vmin + 12px, 44px); }
.screen-play .ord-pool { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 12px; flex: none; min-block-size: 0; padding-block: 12px; }
.screen-play .ord-pool .opt, .screen-play .sort-items .opt { min-inline-size: 104px; min-block-size: 76px; padding-inline: 20px; }
.screen-play .chip .opt-text { font-size: clamp(28px, 2.4vmin + 12px, 38px); }
.screen-play .chip.opt .opt-figure .opt-img { max-block-size: 72px; }

/* ============================== sort ============================== */
.screen-play .sort-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; flex: none; }
.screen-play .sort-bins { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; flex: 1 1 auto; min-block-size: 150px; }
.screen-play .bin {
  position: relative; min-block-size: 150px; padding: 0; margin: 0; display: flex; flex-direction: column; align-items: stretch; gap: 0;
  background: var(--paper); border: 0; border-radius: var(--r-md); box-shadow: var(--lift-1); overflow: visible;
  transition: transform var(--t-fast) var(--ease-out);
}
.screen-play .bin:active { transform: translateY(2px); }
.screen-play .bin-label {
  display: block; padding: 10px 12px; border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--unit-tint, var(--paper-2)); color: var(--ink); font-size: var(--fs-title); font-weight: 800; text-align: center;
}
.screen-play .bin-items {
  flex: 1 1 auto; margin: 10px; padding: 10px; min-block-size: 70px; display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 8px;
  border: 3px dashed var(--wax); border-radius: var(--r-md);
}
.screen-play .bin-chip {
  position: relative; display: inline-flex; align-items: center; padding: 4px 16px; border-radius: var(--r-pill);
  background: var(--right-tint); border: 2px solid var(--right); font-size: clamp(24px, 1.6vmin + 12px, 30px); font-weight: 800;
}
.screen-play .bin-chip .stamp { inline-size: 24px; block-size: 24px; inset-block-start: -10px; inset-inline-end: -10px; }
.screen-play .bin.is-glow { animation: honey-ring 1.8s ease-in-out infinite; }
.screen-play .sort-bins { align-items: start; }
/* a bin grows with what she puts in it (up to 3 chips a bin): no fixed height, nothing spills or clips */
.screen-play .bin { block-size: auto; max-block-size: none; min-block-size: 150px; }
.screen-play .ask-light .sort-items .opt { min-inline-size: 120px; min-block-size: 88px; }
.screen-play .ask-light .sort-items { padding-block: 8px 4px; }
.screen-play .ask-light .sort-bins { flex: 0 1 auto; block-size: auto; }
/* a placed card has moved into its bin: it leaves the pool (no faded twin), and the pool goes once all are placed */
.screen-play .sort-items .opt.is-placed { display: none; }
.screen-play .ord-pool .opt.is-placed { visibility: hidden; }
.screen-play.is-answered .sort-items, .screen-play.is-answered .ord-pool { display: none; }
.screen-play .ask-light .bin-chip { font-size: clamp(30px, 2.4vmin + 12px, 38px); padding: 6px 18px; }
.screen-play .sort-items .opt.is-tried:not(.is-selected) { border: 3px dashed var(--notyet-line); background: var(--notyet-tint); }
/* match / ord: the card she tried stays dashed and tinted until her next tap */
.screen-play .match .opt.is-tried, .screen-play .ord-pool .opt.is-tried { border: 3px dashed var(--notyet-line); background: var(--notyet-tint); color: var(--ink-2); }
.screen-play .sort-items .opt.is-tried.is-selected { border-style: dashed; }

/* ============================== match ============================== */
.screen-play .match { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; flex: 1 1 auto; min-block-size: 0; align-content: center; }
.screen-play .match-col { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.screen-play .match .opt { min-block-size: 96px; }
.screen-play .match .opt-text { font-size: clamp(22px, 1.4vmin + 13px, 28px); }
.screen-play .match .opt-num .opt-text { font-size: clamp(30px, 2.4vmin + 14px, 40px); }
.screen-play .pair-n {
  position: absolute; inset-block-start: 6px; inset-inline-start: 8px; display: grid; place-items: center;
  inline-size: 28px; block-size: 32px; clip-path: var(--hex); background: var(--paper); color: var(--right);
  font-size: var(--fs-label); font-weight: 800; line-height: 1;
}

/* ============================== number line: place ============================== */
.screen-play .nl-place { inline-size: 100%; flex: 1 1 auto; display: flex; align-items: center; }
.screen-play .nl-place-inner { position: relative; inline-size: 100%; }
.screen-play .nl-ticks { position: absolute; inset: 0; }
.screen-play .nl-tick-btn {
  --bw: clamp(40px, var(--tw, 8%), 64px); --bh: 64px;
  position: absolute; inset-block-start: calc(61.3% - var(--bh) / 2); margin-inline-start: calc(var(--bw) * -.5);
  inline-size: var(--bw); block-size: var(--bh); min-inline-size: 0; min-block-size: 0; padding: 0;
  display: grid; place-items: center; border-radius: var(--r-sm); background: transparent; box-shadow: none;
}
@media (hover: hover) { .screen-play .nl-tick-btn:hover:not(:disabled) { background: rgba(245, 177, 32, .14); } }
.screen-play .tick-dot { inline-size: 22px; block-size: 22px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink-2); transition: transform var(--t-med) var(--ease-out); }
.screen-play .nl-tick-btn.is-right .tick-dot, .screen-play .nl-tick-btn.is-answer .tick-dot {
  inline-size: 28px; block-size: 32px; border: 0; border-radius: 0; clip-path: var(--hex); background: var(--honey);
  animation: honey-fall var(--t-slow) var(--ease-honey) both;
}
.screen-play .nl-tick-btn.is-answer { box-shadow: 0 0 0 4px var(--honey); background: var(--paper); }
.screen-play .nl-tick-btn.is-miss { opacity: 1; filter: none; transform: none; border: 0; }
.screen-play .nl-tick-btn.is-miss .tick-dot { background: var(--notyet-tint); border: 3px dashed var(--notyet-line); }
.screen-play .tick-label {
  position: absolute; inset-block-end: calc(100% + 2px); padding: 2px 10px; border-radius: var(--r-sm); background: var(--paper);
  font-size: 26px; font-weight: 800; color: var(--ink); white-space: nowrap; font-family: var(--font);
}
.screen-play .nl-tick-btn.is-right .tick-label { inset-block-end: calc(100% + 26px); } /* the ✓ sits between her number and the hex, never on the number */
.screen-play .nl-tick-btn .stamp { inset-block-start: -22px; inset-block-end: auto; inset-inline-end: auto; inset-inline-start: 50%; translate: -50% 0; inline-size: 28px; block-size: 28px; }

/* ============================== steps (column board, digit by digit) ============================== */
.screen-play .steps-panel {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 12px 14px;
  align-items: center; flex: 1 1 auto; min-block-size: 0;
}
/* top row: the place she is on (start) and the line about it; the same keypad as numpad fills the rest */
.screen-play .steps-panel > .steps-col { grid-area: 1 / 1; justify-self: start; }
.screen-play .steps-panel > .ans-status { grid-area: 1 / 2; justify-content: flex-start; text-align: start; min-block-size: 44px; }
.screen-play .steps-panel > .keypad { grid-column: 1 / -1; grid-row: 2; align-self: stretch; }
.screen-play .steps-col {
  align-self: center; min-block-size: 44px; margin: 0; padding: 4px 22px; border-radius: var(--r-pill);
  background: var(--honey-shine); font-size: var(--fs-title); font-weight: 800; color: var(--ink); text-align: center;
}
.screen-play .steps-col:empty { visibility: hidden; }
@media (min-aspect-ratio: 5/4) and (min-width: 900px) {
  /* steps: «ليس بعد · حاولي مرة أخرى» gets a centred row of its own under the place chip, as in every other mechanic */
  .screen-play .steps-panel { grid-template-rows: auto auto minmax(0, 1fr); }
  .screen-play .steps-panel > .ans-status { grid-area: 2 / 1 / 3 / -1; justify-content: center; text-align: center; }
  .screen-play .steps-panel > .keypad { grid-row: 3; }
}
.screen-play .keypad-digits { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ============================== STIMULI (also used by learn and inside options) ==============================
   Sizes are in em: inside the play card the base grows with the space the card gives (container units),
   elsewhere it follows the surrounding text. The engine zooms a stimulus down only if it still overflows. */
.stim { max-inline-size: 100%; }
.q-stim > *, .screen-play .q-stim > .stim { font-size: clamp(18px, min(7cqh, 4.8cqw), 34px); }
.stim.is-small, .screen-play .q-stim .stim.is-small, .screen-play .opt .stim.is-small { font-size: 18px; }
.stim-title { font-size: 1.05em; font-weight: 800; color: var(--ink); text-align: center; margin: 0 0 .3em; }

/* base-ten blocks in the book's blue, all at one scale */
.stim-blocks { --blk: 112px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 18px 32px; }
.q-stim > .stim-blocks { --blk: clamp(64px, min(26cqh, 17cqw), 132px); }
.q-stim > .stim-blocks.sb-groups-1 { --blk: clamp(72px, min(44cqh, 24cqw), 170px); }
.stim-blocks .sb-group { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 12px 14px; max-inline-size: 100%; }
.stim-blocks .blk { display: block; line-height: 0; }
.stim-blocks .sb-h .art-hundred, .stim-blocks .sb-t .art-ten { block-size: var(--blk); inline-size: auto; }
.stim-blocks .sb-t { gap: 8px; }
.stim-blocks .sb-o { display: grid; grid-template-columns: repeat(5, auto); gap: 8px; max-inline-size: none; align-content: end; }
.stim-blocks .sb-o .art-one { block-size: max(18px, calc(var(--blk) * 18 / 108 * 1.25)); inline-size: auto; }
.stim-blocks.sb-groups-1 { --blk: 150px; }
.stim-blocks.sb-groups-1 .sb-h { max-inline-size: calc(var(--blk) * 3.7); }
.stim-blocks.is-small, .q-stim .stim-blocks.is-small { --blk: 56px; gap: 8px 12px; }
.stim-blocks.is-small .sb-group { gap: 4px 6px; }
.stim-blocks.is-small.sb-groups-1 { --blk: 64px; }

/* place-value table: مئات on the left, آحاد on the right, as the book prints it */
.stim-placevalue { border-collapse: separate; border-spacing: .25em 0; margin-inline: auto; background: none; border: 0; border-radius: 0; overflow: visible; }
.stim-placevalue th, .stim-placevalue td { border: 0; box-shadow: none; text-align: center; }
.stim-placevalue th {
  padding: .45em .8em; border-radius: .65em .65em 0 0; background: #F7E3AE; direction: rtl;
  font-size: 1em; font-weight: 800; color: var(--ink); white-space: nowrap;
}
.stim-placevalue .pv-ico { display: inline-block; vertical-align: middle; margin-inline-end: .35em; line-height: 0; }
.stim-placevalue .pv-ico svg { block-size: 1.2em; inline-size: auto; }
.stim-placevalue .pv-word { vertical-align: middle; }
.stim-placevalue td {
  padding: .35em .8em .45em; min-inline-size: 3.6em; border-radius: 0 0 .65em .65em; background: var(--paper-2);
  font-size: 2.6em; font-weight: 800; line-height: 1.1; color: var(--ink);
}
.stim-placevalue td .blank { font-size: .8em; }
/* in the question card: equal columns that fit the card, so the engine never has to shrink the words below 18px */
.screen-play .q-stim > .stim-placevalue { inline-size: min(100%, 18em); table-layout: fixed; }
.screen-play .q-stim > .stim-placevalue th { font-size: clamp(20px, 2.2cqw, 26px); padding: .45em .3em; }
.screen-play .q-stim > .stim-placevalue td { min-inline-size: 0; padding-inline: .15em; }
.stim-placevalue.is-small { border-spacing: 4px 0; }
.stim-placevalue.is-small th { padding: 4px 6px; font-size: 18px; }
.stim-placevalue.is-small .pv-ico { display: none; }
.stim-placevalue.is-small td { padding: 4px 8px 6px; min-inline-size: 2.4em; font-size: 1.6em; }

/* the blank: a solid wax slot that fills in green (dashed means only «ليس بعد») */
.blank {
  display: inline-grid; place-items: center; min-inline-size: 1.5em; block-size: 1.25em; padding-inline: .15em; margin-inline: .1em;
  border: 3px solid var(--wax-rim); border-radius: .3em; background: var(--wax-empty); color: var(--ink-2);
  line-height: 1; vertical-align: middle; font-family: var(--font);
}
.blank.is-filled { border: 3px solid var(--right); background: var(--right-tint); color: var(--ink); }
/* a taught answer is honey (like the slot and the status line), never the green of her own right answer */
.screen-play.is-revealed .blank.is-filled, .screen-play.is-revealed .colboard .cb-ans.is-filled { border-color: var(--honey); background: var(--hint); }

/* number line (drawn by the engine in the art style) */
.stim-numline { inline-size: 100%; display: flex; justify-content: center; }
.nl-svg { inline-size: 100%; block-size: auto; overflow: visible; }
.q-stim .stim-numline .nl-svg { inline-size: min(100cqw, 820px); max-block-size: 100cqh; }
.nl-axis { stroke: var(--ink-2); stroke-width: 4; stroke-linecap: round; }
.nl-end { fill: var(--ink-2); }
.nl-tick { stroke: var(--ink-2); stroke-width: 3; stroke-linecap: round; }
.nl-tick.is-major { stroke-width: 3.5; }
.nl-label { font-family: var(--font); font-size: 26px; font-weight: 800; fill: var(--ink); font-variant-numeric: tabular-nums; }
.nl-svg.is-sparse .nl-label.is-alt { display: none; } /* set by fitNumlines when 18px labels would touch */
.nl-mark { fill: var(--honey); stroke: var(--wax-rim); stroke-width: 2.5; stroke-linejoin: round; }
.nl-mark-stem { stroke: var(--honey-deep); stroke-width: 3; stroke-linecap: round; }
.nl-mark-label { font-family: var(--font); font-size: 30px; font-weight: 800; fill: var(--ink); }
.nl-mark-arrow { fill: var(--honey-deep); stroke: var(--wax-rim); stroke-width: 1.5; stroke-linejoin: round; }
.nl-mark-label.is-shown { fill: var(--unit-dark, var(--ink)); }

/* column arithmetic (book layout, LTR): place names, carry/borrow marks, the two rows, the line, the answer */
.colboard {
  --cb: clamp(48px, 7vmin, 72px);
  display: grid; direction: ltr; justify-content: center; align-content: center;
  grid-template-columns: repeat(var(--cols), var(--cb));
  grid-template-rows: 30px calc(var(--cb) * .5) var(--cb) var(--cb) calc(var(--cb) + 10px);
  column-gap: 6px; padding: 12px 18px 14px; border-radius: var(--r-md); background: var(--paper-2);
  font-family: var(--font); font-size: calc(var(--cb) * .72); font-weight: 800; line-height: 1; color: var(--ink);
}
.q-stim .colboard { --cb: clamp(44px, min(16cqh, 14cqw), 96px); font-size: calc(var(--cb) * .72); }
.colboard .cb { position: relative; display: grid; place-items: center; block-size: 100%; border-radius: 12px; }
.colboard .cb-head { font-size: 18px; font-weight: 800; color: var(--ink-2); white-space: nowrap; overflow: visible; }
.colboard .cb-mark { align-items: end; font-size: .5em; color: var(--unit-dark, var(--action)); }
.colboard .cb-sign { font-size: 1em; color: var(--ink); }
.colboard .cb-head { font-size: var(--fs-label, 18px); }
.colboard .cb-rule, .colboard .cb-op.cb-rule { border: 0; border-radius: 0; }
.colboard .cb-op.cb-rule::after {
  content: ""; position: absolute; inset-block-start: 0; inset-inline-start: -6px; z-index: 1; pointer-events: none;
  inline-size: calc(var(--cols) * var(--cb) + (var(--cols) - 1) * 6px + 12px); border-block-start: 4px solid var(--ink); border-radius: 2px;
}
.colboard .cb-ans {
  margin: 10px 3px 0; block-size: calc(100% - 10px); border-radius: 12px;
  background: var(--wax-empty); border: 3px solid var(--wax-rim); outline: 0;
}
.colboard .cb-op.cb-rule { margin: 0; }
.colboard .cb.is-active:not(.cb-ans) { background: var(--honey-shine); }
.colboard .cb-head.is-active { color: var(--ink); }
.colboard .cb-ans.is-active { background: var(--paper); border: 3px solid var(--honey-deep); box-shadow: 0 0 0 3px var(--honey-light); }
.colboard .cb-ans.is-filled { background: var(--right-tint); border: 3px solid var(--right); color: var(--ink); }

.colboard .cb-ans.is-miss, .colboard .cb-ans.is-active.is-miss {
  background-color: var(--notyet-tint); border: 3px dashed var(--notyet-line); box-shadow: none; color: var(--ink-2);
  background-repeat: no-repeat; background-image: linear-gradient(to bottom right, transparent calc(50% - 2px), var(--notyet) calc(50% - 2px), var(--notyet) calc(50% + 2px), transparent calc(50% + 2px));
}
.colboard .cb-ans.is-answer { background: var(--paper); border: 4px solid var(--honey); box-shadow: none; }
.colboard .cb-ans .stamp { inline-size: 22px; block-size: 22px; inset-block-start: -10px; inset-inline-end: -10px; }
.stim-column:not(.stim-steps) .colboard .cb-ans:not(.is-filled) { background: none; border-color: transparent; }
/* a board she only reads (numpad, pick, tf): no empty answer row under the line, so the digits can grow;
   the row comes back when the answer is written in (engine: colAnswer) */
.screen-play .q-stim > .stim-column:not(.stim-steps) > .colboard.is-readonly { grid-template-rows: 30px calc(var(--cb) * .5) var(--cb) var(--cb) 8px; padding-block-end: 6px; }
.screen-play .q-stim > .stim-column:not(.stim-steps) > .colboard.is-readonly .cb-ans { visibility: hidden; }
.colboard .cb-wrong { color: var(--ink-2); }
.colboard .cb-top.is-struck .cb-d { color: var(--ink-2); }
.colboard .cb-new, .colboard .cb-carry {
  display: inline-grid; place-items: center; min-inline-size: 1.4em; padding: 0 .2em; border-radius: 10px;
  background: var(--paper); color: var(--unit-dark, var(--action)); font-size: 1.15em; line-height: 1.2; box-shadow: 0 0 0 2px var(--honey-light);
}
.colboard .cb-pre { font-size: .5em; align-self: start; margin-inline-end: 1px; color: var(--unit-dark, var(--action)); }
.colboard .cb-top:has(.cb-pre) { display: flex; justify-content: center; align-items: center; }

/* pictograph, tally, table: paper tables, rows separated by tone */
.stim-pictograph, .stim-tally { display: flex; flex-direction: column; align-items: center; gap: .35em; }
.picto, .tally { border-collapse: separate; border-spacing: 0 .25em; margin-inline: auto; background: none; }
.picto th, .tally th {
  padding: .35em .8em; background: #F7E3AE; text-align: start; white-space: nowrap; border: 0;
  font-size: 1em; font-weight: 800; color: var(--ink); border-start-start-radius: .55em; border-end-start-radius: .55em;
}
.picto td, .tally td { padding: .25em .7em; background: var(--paper-2); border: 0; border-start-end-radius: .55em; border-end-end-radius: .55em; }
.picto-icons { display: flex; flex-wrap: wrap; gap: .25em; align-items: center; min-block-size: 1.9em; min-inline-size: 8em; }
.picto th { font-size: 1.05em; }
/* a row still to be drawn: a solid wax slot, the same vocabulary as an answer slot */
.picto tr.is-empty .picto-icons { background: var(--wax-empty); outline: 3px solid var(--wax-raw-rim); outline-offset: -3px; }
/* the row the question is about: a honey ring and a honey wash */
.picto tr.is-focus th, .tally tr.is-focus th { background: var(--honey-light); box-shadow: inset -4px 0 0 var(--honey-deep), inset 0 4px 0 var(--honey-deep), inset 0 -4px 0 var(--honey-deep); }
.picto tr.is-focus td, .tally tr.is-focus td { background: var(--honey-shine); box-shadow: inset 4px 0 0 var(--honey-deep), inset 0 4px 0 var(--honey-deep), inset 0 -4px 0 var(--honey-deep); }
.picto tr.is-focus.is-empty .picto-icons { outline: 0; }
/* the row she was asked to draw, drawn in once the answer is known */
.screen-play .picto tr.is-drawn .ico-art { animation: pop-in var(--t-slow) var(--ease-out) both; }
.ico-run { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .15em; vertical-align: middle; }
.ico { display: inline-block; font-size: 1.45em; line-height: 1; inline-size: auto; text-align: center; }
img.ico { inline-size: 1.8em; block-size: 1.8em; object-fit: contain; }
.ico-art { display: inline-block; inline-size: 1.6em; block-size: 1.6em; vertical-align: middle; font-size: 1em; }
.ico-art svg { inline-size: 100%; block-size: 100%; }
.ico-half { display: inline-block; inline-size: .9em; overflow: hidden; direction: ltr; }
.picto-key {
  display: inline-flex; align-items: center; gap: .3em; padding: .15em .7em; border-radius: var(--r-pill); background: var(--hint);
  font-size: max(18px, .9em); font-weight: 800; color: var(--ink);
}
.picto-key .ico-art { inline-size: 1.25em; block-size: 1.25em; }
.tally-cell { direction: ltr; }
.tally-svg { block-size: 1.9em; inline-size: calc(var(--tally-w) * .0475em); stroke: var(--ink-2); stroke-width: 4; stroke-linecap: round; overflow: visible; }
.tally-svg .tally-cross { stroke: var(--ink); }
.stim-tally.is-lone .tally td { background: none; }
.stim-tally.is-lone .tally-svg { block-size: 2.4em; inline-size: calc(var(--tally-w) * .06em); }

.stim-table { border-collapse: separate; border-spacing: .2em; margin-inline: auto; background: none; }
.stim-table th, .stim-table td { border: 0; border-radius: .5em; padding: .4em .9em; text-align: center; }
.stim-table th { background: #F7E3AE; font-size: 1em; font-weight: 800; color: var(--ink); }
.stim-table td { background: var(--paper-2); font-size: 1.1em; font-weight: 800; color: var(--ink); }
.stim-table td .ico-art { inline-size: 1.5em; block-size: 1.5em; }
.stim-table th.is-empty { background: none; }

/* equations print left to right; the book colours the digit that changes */
.stim-eq { text-align: center; font-size: clamp(36px, 6vmin, 64px); font-weight: 800; line-height: 1.35; color: var(--ink); }
.screen-play .q-stim > .stim-eq { font-size: clamp(32px, min(18cqh, 9cqw, calc(150cqw / var(--len, 12))), 76px); max-inline-size: 100%; }
.stim-eq .eq-line { display: inline; }
.stim-eq .hl, .stim-eq .hl-o, .stim-eq .hl-t { color: var(--blk-side); }
.stim-eq .hl-h { color: var(--u2-dark); }
.stim-eq.is-small { font-size: 26px; }

/* blocks: the number to build, on a wax plaque */
.stim-target { text-align: center; }
.stim-target .target-n {
  display: inline-block; padding: .08em .5em; border-radius: var(--r-lg); background: var(--wax-empty); border: 4px solid var(--wax);
  font-size: clamp(56px, 6vmin + 20px, 96px); font-weight: 800; line-height: 1.2; color: var(--ink);
}

/* objects in dashed wax groups */
.stim-objects { display: flex; flex-wrap: wrap; gap: .6em; justify-content: center; }
.obj-group { display: grid; grid-template-columns: repeat(5, auto); gap: .25em; padding: .4em; border: 3px dashed var(--wax); border-radius: var(--r-md); background: var(--paper-2); }

/* the book's own pictures, in a paper frame */
.screen-play .q-figure { margin: 0; display: flex; justify-content: center; max-block-size: 100%; min-block-size: 0; }
.screen-play .q-figure.is-missing { display: none; }
.screen-play .q-img {
  max-block-size: min(100cqh, 380px); max-inline-size: 100%; object-fit: contain;
  padding: 10px; border-radius: var(--r-md); background: var(--paper-2);
}
.screen-play .q-stim:has(.stim) .q-img { max-block-size: min(60cqh, 300px); max-inline-size: min(100%, 46cqw); }
.screen-play.mech-tf .q-stim:has(> .stim-eq):has(> .q-figure) { flex-direction: column; flex-wrap: nowrap; gap: 12px; }
.screen-play.mech-tf .q-stim:has(> .stim-eq):has(> .q-figure) > .stim-eq { font-size: 40px; flex: none; }
.screen-play.mech-tf .q-stim:has(> .stim-eq) .q-figure { flex: 1 1 auto; min-block-size: 0; align-items: center; }
.screen-play.mech-tf .q-stim:has(> .stim-eq) .q-img { max-block-size: min(calc(100cqh - 80px), 440px); max-inline-size: 100%; inline-size: auto; block-size: 100%; }

/* ============================== portrait (820 × 1180) ============================== */
@media not all and (min-aspect-ratio: 5/4), (max-width: 899px) {
  .screen-play { --hint-bee-w: 112px; }
  .screen-play .play-answer { padding: 16px 20px; gap: 10px; }
  .screen-play .np .keypad { flex: none; grid-auto-rows: 64px; }
  .screen-play .bb-btn { min-block-size: 64px; block-size: 64px; }
  /* a column sum with a picture: the board is the content; the picture stays a small thumbnail at its side */
  .screen-play .q-stim:has(> .stim-column):has(> .q-figure) { flex-wrap: nowrap; gap: 16px; }
  .screen-play .q-stim:has(> .stim-column) .q-figure { flex: 0 1 auto; }
  .screen-play .q-stim:has(> .stim-column) .q-img { max-block-size: min(70cqh, 150px); max-inline-size: 24cqw; padding: 6px; }
  /* compare: taller number cards in the tall card */
  .screen-play .ask-stack .cmp { gap: 18px; }
  .screen-play .ask-stack .cmp-side { min-inline-size: 0; padding: 28px 16px; gap: 22px; }
  .screen-play .ask-stack .cmp-value { font-size: 72px; }
  .screen-play .ask-stack .cmp .stim-placevalue.is-small td { font-size: 38px; min-inline-size: 1.6em; }
  .screen-play .ask-stack .opts-sym { grid-template-columns: repeat(3, 150px); grid-auto-rows: 150px; inline-size: 498px; }
  /* the number line to place on: a board under the question, the garden below it */
  /* the number line to place on fills the stage like every other item; the line sits in the middle of its card,
     with bigger dots, a bigger hex and taller tap targets */
  .screen-play .play-stage.wide-answer { grid-template-rows: auto minmax(0, 1fr); align-content: stretch; }
  .screen-play .wide-answer .play-answer { justify-content: center; }
  .screen-play .wide-answer .nl-place { flex: 1 1 auto; }
  .screen-play .wide-answer .nl-tick-btn { --bh: 88px; }
  .screen-play .wide-answer .tick-dot { inline-size: 30px; block-size: 30px; }
  .screen-play .wide-answer .nl-tick-btn.is-right .tick-dot, .screen-play .wide-answer .nl-tick-btn.is-answer .tick-dot { inline-size: 34px; block-size: 39px; }
  .screen-play .wide-answer .tick-label { font-size: 32px; }
  .screen-play .np .key-check, .screen-play .btn-next, .screen-play .bb-check { block-size: 68px; }
  .screen-play .steps-panel .keypad { flex: none; grid-auto-rows: 64px; }
  /* numpad beside a figure: the slot at the start with its status line beside it (no reserved row), keys 58px,
     so the figure above gets the height */
  .screen-play .play-stage:not(.ask-light) .np {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "slot status" "pad pad" "check check";
    gap: 10px 20px; align-items: center;
  }
  .screen-play .play-stage:not(.ask-light) .np > .np-row { grid-area: slot; }
  .screen-play .play-stage:not(.ask-light) .np > .ans-status { grid-area: status; justify-content: flex-start; text-align: start; }
  .screen-play .play-stage:not(.ask-light) .np > .keypad { grid-area: pad; grid-auto-rows: 58px; }
  .screen-play .play-stage:not(.ask-light) .np > .key-check { grid-area: check; }
  .screen-play .opts-stack { grid-template-columns: minmax(0, 1fr); }
  .screen-play .match { gap: 16px; flex: none; }
  .screen-play .match .opt { min-block-size: 100px; }
  .screen-play .ord-slots .slot { min-block-size: 140px; }
  .screen-play .play-answer:has(.ord-slots) { gap: 24px; }
}
/* portrait tablet (820 × 1180, 768 × 1024): the tall cards are filled by what she reads and taps, not by empty paper */
@media (min-width: 601px) and (min-height: 700px) and (not (min-aspect-ratio: 5/4)), (min-width: 601px) and (min-height: 700px) and (max-width: 899px) {
  /* options under a figure: taller cards (the figure card above still keeps most of the height) */
  .screen-play .play-stage:not(.ask-light):not(.ask-stack) .play-answer > .opts:not(.opts-stack):not(.opts-pics) { grid-auto-rows: clamp(150px, 15vh, 168px); }
  /* a base-ten picture with more than one place: the blocks grow into the card */
  .screen-play .q-stim > .stim-blocks:not(.sb-groups-1) { --blk: clamp(64px, min(30cqh, 24cqw), 170px); }
  /* building a number: the blocks she adds fill the tall place-value columns */
  .screen-play .bb { --bbk: clamp(64px, 9.5vh, 104px); }
  /* match and placing on the line: one block in the middle of the card, the status line right under it */
  .screen-play .ask-light .match { flex: none; }
  .screen-play .ask-light .match .opt { min-block-size: 128px; }
  .screen-play .wide-answer .nl-place { flex: none; }
  /* sort: two big bins to drop into, right under the numbers */
  .screen-play .ask-light .sort-bins { flex: none; }
  .screen-play .ask-light .bin { min-block-size: 260px; }
  /* the hint bee in the short question band stays clear of the target chip */
  .screen-play .ask-light .play-feedback { --hint-bee-w: 72px; padding-block-start: 6px; }
  /* an equation is a short figure: the keys she taps get the room (72px rows) */
  .screen-play .play-stage:not(.ask-light):has(.q-stim > .stim-eq:only-child) .np > .keypad { grid-auto-rows: 72px; }
  /* a width-bound figure (number line, short sum) with option cards: the question card hugs the figure and
     question + answers sit together in the middle of the garden (class set by hugStage in app.js) */
  .screen-play .play-stage.is-hug { grid-template-rows: auto auto; align-content: center; gap: 28px; }
  .screen-play .play-stage.is-hug .play-ask { padding-block-end: 20px; }
  .screen-play .play-stage.is-hug .q-stim { flex: none; min-block-size: 0; }
  .screen-play .play-stage.is-hug .play-answer > .opts:not(.opts-stack):not(.opts-pics) { grid-auto-rows: clamp(176px, 18vh, 212px); }
  .screen-play .play-stage.is-hug .opt .opt-text { font-size: clamp(34px, 3.4vh, 42px); }
  /* a pictograph is bound by its height (title, rows, key): its rows reach across the card instead,
     so the chart reads as a full-width figure, with room for the symbols she draws */
  .screen-play .q-stim .picto:has(tr.is-empty) .picto-icons { min-inline-size: 15em; }
  .screen-play .q-stim .picto th { padding-inline: .8em; }
}

/* ============================== phone (390 × 844) ============================== */
@media (max-width: 600px) {
  .screen-play { --gutter: 12px; --stage-top: 140px; --stage-bottom: 12px; --hint-bee-w: 76px; }
  .screen-play .play-bar { block-size: 116px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: 56px 52px; row-gap: 8px; }
  .screen-play .play-bar-start { grid-row: 1; grid-column: 1; gap: 8px; }
  .screen-play .play-bar-end { grid-row: 1; grid-column: 3; gap: 8px; }
  .screen-play .progress { grid-row: 2; grid-column: 1 / -1; justify-self: center; block-size: 52px; padding-inline: 12px; }
  .screen-play .dots { gap: 6px; }
  .screen-play .dot-hex { inline-size: 28px; block-size: 32px; }
  .screen-play .dot-bee { inline-size: 32px; block-size: 34px; }
  .screen-play .page-chip { block-size: 52px; padding-inline: 12px 16px; font-size: var(--fs-body); }
  .screen-play .btn-exit { inline-size: 52px; block-size: 52px; min-inline-size: 52px; min-block-size: 52px; }
  .screen-play .btn-howto { inline-size: 52px; block-size: 52px; min-inline-size: 52px; min-block-size: 52px; }
  .screen-play .play-stage { gap: 12px; }
  .screen-play .play-ask { padding: 14px 16px 12px; gap: 10px; }
  .screen-play .play-answer { padding: 12px; gap: 8px; }
  .screen-play .q-text { font-size: 28px; line-height: 1.25; }
  .colboard, .screen-play .q-stim .colboard { grid-template-rows: 0 calc(var(--cb) * .5) var(--cb) var(--cb) calc(var(--cb) + 10px); padding: 8px 10px 10px; }
  .colboard .cb-head { visibility: hidden; font-size: 0; }
  .screen-play .q-stim > .stim-column:not(.stim-steps) > .colboard.is-readonly { grid-template-rows: 0 calc(var(--cb) * .5) var(--cb) var(--cb) 8px; }
  .screen-play .no-stim .q-text { font-size: 30px; }
  .screen-play .play-feedback, .screen-play .bubble { min-block-size: 0; }
  .screen-play .bubble { padding: 8px 12px; font-size: var(--fs-label); gap: 4px 8px; }
  .screen-play .bubble.is-hint, .screen-play .bubble.is-reveal, .screen-play .bubble.is-praise { padding: 8px 12px; }
  .screen-play .ans-status { min-block-size: 24px; font-size: var(--fs-label); }
  .screen-play .ans-status:empty { display: none; }
  .screen-play .play-ask { gap: 8px; }
  .screen-play .np-display { block-size: 60px; min-inline-size: 120px; font-size: 38px; }
  .screen-play .np-display.is-empty .np-caret { block-size: 38px; }
  .screen-play .np-unit { font-size: 24px; }
  .screen-play .np .keypad, .screen-play .steps-panel .keypad { grid-auto-rows: 48px; gap: 8px; }
  .screen-play .key { font-size: 28px; }
  .screen-play .np .key-check, .screen-play .btn-next, .screen-play .bb-check { block-size: 56px; min-block-size: 56px; }
  .screen-play .opts { gap: 10px; grid-auto-rows: minmax(76px, auto); }
  .screen-play .opt { min-block-size: 72px; padding: 8px 10px; }
  .screen-play .opt-tf { min-block-size: 96px; }
  .screen-play .opts-sym { grid-auto-rows: minmax(84px, auto); }
  .screen-play .opts-cards { grid-auto-rows: minmax(100px, auto); }
  .screen-play .opt-num .opt-text, .screen-play .opt-sym .sym { font-size: 32px; }
  .screen-play .opt-word .opt-text { font-size: 20px; }
  .screen-play .cmp-side { padding: 10px 12px; min-inline-size: 0; }
  .screen-play .cmp-value { font-size: 40px; }
  .screen-play .cmp-slot { inline-size: 64px; block-size: 74px; }
  .screen-play .cmp-slot .sym, .screen-play .cmp-slot .blank { font-size: 34px; }
  .screen-play .ord-slots .slot { min-block-size: 84px; padding-top: 24px; }
  .screen-play .ord-pool .opt, .screen-play .sort-items .opt { min-inline-size: 84px; min-block-size: 60px; padding-inline: 12px; }
  .screen-play .bin { min-block-size: 110px; }
  .screen-play .bin-items { margin: 6px; padding: 6px; min-block-size: 50px; }
  .screen-play .bb-head { block-size: 44px; }
  .screen-play .bb-btn { block-size: 48px; min-block-size: 48px; }
  .screen-play .bb-count { font-size: 28px; }
  .screen-play .steps-col { min-block-size: 36px; font-size: var(--fs-body); }
  .nl-label, .screen-play .wide-answer .nl-label { font-size: 30px !important; }
  /* a long line (7+ labels) keeps every other label on a phone, so the numbers stay apart and readable */
  .nl-svg:has(.nl-label:nth-of-type(7)) .nl-label { font-size: 34px !important; }
  .nl-svg:has(.nl-label:nth-of-type(7)) .nl-label.is-alt { display: none; }
  .nl-mark-label { font-size: 32px; }
  .screen-play .q-stim:has(.stim-column) .q-figure { display: none; }
  .picto-icons { min-inline-size: 4.5em; }
  .picto-key { font-size: 1em; }
  .screen-play .ask-light .play-ask { padding: 12px 16px; column-gap: 12px; }
  .screen-play .ask-light .play-feedback { min-block-size: 0; --hint-bee-w: 64px; }
  .screen-play .ask-light .play-answer { padding: 12px; }
  .screen-play .ask-light .opts { grid-auto-rows: minmax(84px, auto); gap: 10px; }
  .screen-play .ask-light .opts-stack { grid-auto-rows: minmax(72px, auto); }
  .screen-play .ask-light .opt-word .opt-text { font-size: 20px; }
  .screen-play .ask-light .ord-slots .slot { min-block-size: 84px; }
  .screen-play .ask-light .ord-pool .opt, .screen-play .ask-light .sort-items .opt { min-inline-size: 84px; min-block-size: 60px; }
  .screen-play .ask-light .slot-v, .screen-play .ask-light .chip .opt-text { font-size: 28px; }
  .screen-play .ask-light .np .keypad { grid-auto-rows: 52px; }
  .screen-play .ask-light .match .opt { min-block-size: 72px; }
  .screen-play .ask-stack .play-answer { padding: 12px; }
  .screen-play .ask-stack .opts-sym { inline-size: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 84px; gap: 10px; }
  .screen-play .ask-stack .opt-sym .sym { font-size: 40px; }
  .screen-play .ask-stack .cmp-side { min-inline-size: 0; padding: 10px 10px; gap: 8px; }
  .screen-play .ask-stack .cmp-value { font-size: 40px; }
  .screen-play .ask-stack .cmp-slot { inline-size: 64px; block-size: 74px; }
  .screen-play .ask-stack .cmp .stim-placevalue.is-small th { font-size: 18px; padding: 4px 4px; }
  .screen-play .ask-stack .cmp .stim-placevalue.is-small td { font-size: 26px; padding: 2px 4px; min-inline-size: 1.4em; }
  .screen-play .play-stage.wide-answer { grid-template-rows: auto minmax(0, 1fr); }
  .screen-play .wide-answer .nl-tick-btn { --bh: 64px; }
  .screen-play .wide-answer .tick-label { font-size: 26px; }
}
/* phone: one tap target per tick, as wide as the gap between ticks (they never overlap), with a smaller dot */
@media (max-width: 480px) {
  .screen-play .nl-tick-btn { --bw: var(--tw, 8%); }
  .screen-play .tick-dot, .screen-play .wide-answer .tick-dot { inline-size: 20px; block-size: 20px; }
  .screen-play .nl-tick-btn.is-right .tick-dot, .screen-play .nl-tick-btn.is-answer .tick-dot,
  .screen-play .wide-answer .nl-tick-btn.is-right .tick-dot, .screen-play .wide-answer .nl-tick-btn.is-answer .tick-dot { inline-size: 26px; block-size: 30px; }
  .screen-play .bin-chip, .screen-play .ask-light .bin-chip { font-size: 24px; padding: 4px 10px; max-inline-size: 100%; }
  /* sort on a phone: two cards a row in the pool, one-line bin labels, so the bins stay on screen */
  .screen-play .sort-items { gap: 8px; }
  .screen-play .sort-items .opt, .screen-play .ask-light .sort-items .opt { min-inline-size: 0; min-block-size: 52px; padding: 4px 12px; border-bottom-width: 5px; }
  .screen-play .sort-items .chip .opt-text, .screen-play .ask-light .sort-items .chip .opt-text { font-size: 24px; }
  .screen-play .bin-label { font-size: var(--fs-label); padding: 6px 8px; }
  .screen-play .bin-label .ico-art { inline-size: 1.2em; block-size: 1.2em; }
}
