/* play & learn ♡ — question types and the visual base (R3). Tokens (--ink, --milk, --pink…) come from style.css;
   every var() here carries the game's value as a fallback so a visual still reads if it loads first. */

/* ---------- the visual registry (ui/visuals.js) ---------- */

/* a drawer's max height per tier arrives as --v-p (phone) / --v-t (tablet, desk) on the wrapper; --v-max is the one
   that applies (ux 8: 240 / 320 by default) */
.visual {
  --v-max: var(--v-p, 240px);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  margin-inline: auto;
}
html[data-layout="tablet"] .visual,
html[data-layout="desk"] .visual { --v-max: var(--v-t, 320px); }

/* visual() gives each viewBox svg the width that fills --v-max (or the column, whichever is less) by CSSOM; the 100 %
   here is for an svg a caller appends itself */
.visual > .v-svg,
.visual > svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: var(--v-max);
  overflow: visible;
  /* one drop per visual, never per shape (60 fps, ux 8) */
  filter: drop-shadow(0 2px 0 var(--pink, #ff8fb1));
}
.visual.v-text { display: block; }

/* the sticker edge: a white 3 px ring behind a 2.5 px ink line, round joins, at any scale */
.v-ring {
  fill: var(--white, #fff);
  stroke: var(--white, #fff);
  stroke-width: 8.5px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.v-line {
  stroke: var(--ink, #5b2a3c);
  stroke-width: 2.5px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* palette fills and strokes for drawers (SVG presentation attributes cannot read var()) */
.f-milk { fill: var(--milk, #ffe3ec); }
.f-pink { fill: var(--pink, #ff8fb1); }
.f-bow { fill: var(--bow, #e8384f); }
.f-bow-pink { fill: var(--bow-pink, #ff5c8a); }
.f-ear-pink { fill: var(--ear-pink, #ffc2d4); }
.f-nose { fill: var(--nose, #ffcf3f); }
.f-mint { fill: var(--mint, #7fdcc2); }
.f-lavender { fill: var(--lavender, #b49cff); }
.f-sky { fill: var(--sky, #8fd3ff); }
.f-ink { fill: var(--ink, #5b2a3c); }
.f-white { fill: var(--white, #fff); }
.f-blush { fill: var(--blush, #fff2f6); }
.f-none { fill: none; }
.s-ink { stroke: var(--ink, #5b2a3c); }
.s-pink { stroke: var(--pink, #ff8fb1); }
.s-bow { stroke: var(--bow, #e8384f); }
.s-white { stroke: var(--white, #fff); }
.s-dash { stroke-dasharray: 5 5; }
.v-t {
  fill: var(--ink, #5b2a3c);
  font-family: var(--font-display, "Mochiy Pop One", system-ui, sans-serif);
  font-size: 16px;
  dominant-baseline: central;
  text-anchor: middle;
}
.v-t-small { font-size: 13px; font-family: var(--font-ui, "M PLUS Rounded 1c", system-ui, sans-serif); font-weight: 800; }

.v-face .v-smile { fill: none; stroke: var(--ink, #5b2a3c); stroke-width: 2px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.v-tick { fill: none; stroke: var(--mint, #7fdcc2); stroke-width: 5px; stroke-linecap: round; stroke-linejoin: round; }
.v-arrow { fill: none; stroke: var(--ink-soft, rgba(91, 42, 60, 0.8)); stroke-width: 2.5px; stroke-dasharray: 4 4; stroke-linecap: round; stroke-linejoin: round; }
.v-zig { fill: none; stroke: var(--white, #fff); stroke-width: 3px; stroke-dasharray: 3 3; }

.v-sticker-img {
  display: block;
  width: var(--v-max);
  height: auto;
  max-width: 100%;
}
.v-sticker .v-badge { max-width: var(--v-max); }

/* an unknown kind, or a drawer that failed: the alt text in a milk box (ux 8 rule 6) */
.visual.v-missing {
  display: block;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--milk, #ffe3ec);
  border: 2px dashed var(--dash, rgba(255, 143, 177, 0.55));
}
.v-alt { margin: 0; font-weight: 800; color: var(--ink, #5b2a3c); text-align: center; overflow-wrap: break-word; }

/* ---------- inline markup (§5.4, rendered by richText) ---------- */

.blank-slot { display: inline-block; vertical-align: baseline; }
/* a word with a blank in it ("b▢d") stays on one line (richText wraps it) */
.nobr { white-space: nowrap; }
/* a slot no input was mounted into (a printed worksheet, a preview): a writing box */
.blank-slot:empty { min-width: 2.6em; height: 1.25em; margin: 0 0.12em; vertical-align: -0.2em; border: 2px solid currentColor; border-radius: 6px; }
.op-slot {
  display: inline-block;
  width: 1.5em;
  height: 1.3em;
  margin: 0 0.15em;
  vertical-align: -0.2em;
  border: 2.5px dashed var(--lavender, #b49cff);
  border-radius: 8px;
  background: var(--white, #fff);
}
.gap {
  --n: 4;
  display: inline-block;
  width: calc(var(--n) * 0.6em);
  height: 1em;
  margin: 0 0.1em;
  vertical-align: -0.15em;
  border-bottom: 3px solid var(--pink, #ff8fb1);
  border-radius: 2px;
}
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.12em;
  line-height: 1;
  font-size: 0.85em;
}
.frac-n { padding: 0 0.15em 0.08em; border-bottom: 2px solid currentColor; }
.frac-d { padding: 0.08em 0.15em 0; }
.frac-slash { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
mark.chunk {
  background: none;
  color: inherit;
  text-decoration: underline wavy var(--pink, #ff8fb1);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}
b.kw {
  font-weight: 900;
  text-decoration: underline wavy var(--bow-pink, #ff5c8a);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

/* ---------- the strawberries card (mountQuestion's fallback) ---------- */

.q-oops {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  text-align: center;
}
.q-oops .visual { width: 64px; }
.q-oops-text { margin: 0; font-weight: 800; font-size: var(--fs-body, 16px); color: var(--ink, #5b2a3c); }

/* ---------- the 13 question types: shared pieces ---------- */

.qt {
  position: relative;
  width: 100%;
  max-width: var(--inner, 640px);
  margin-inline: auto;
  color: var(--ink, #5b2a3c);
  font-family: var(--font-ui, "M PLUS Rounded 1c", system-ui, sans-serif);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.qt.is-done,
.qt.is-disabled { cursor: default; }
.qt input,
.qt textarea { -webkit-user-select: text; user-select: text; }
.big-only { display: none !important; }
:root[data-big="true"] .big-only { display: block !important; }

/* the mint check sticker of a correct element (ux 1.3) */
.qt-check {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--ink, #5b2a3c);
  background: var(--mint, #7fdcc2);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 50%;
  box-shadow: 0 0 0 2.5px var(--white, #fff), 0 2px 0 2.5px var(--ink, #5b2a3c);
  pointer-events: none;
  animation: qt-sticker 0.45s var(--boing, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
}
.qt-check .icon { width: 16px; height: 16px; }

/* the tiny "answer" tag on a revealed answer (attempt 2) */
.qt-tag {
  position: absolute;
  right: 10px;
  bottom: -11px;
  z-index: 3;
  padding: 3px 9px 4px;
  font: 800 calc(11px * var(--k-small, 1))/1 var(--font-ui, system-ui, sans-serif);
  letter-spacing: 0.02em;
  color: var(--ink, #5b2a3c);
  white-space: nowrap;
  background: var(--mint, #7fdcc2);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 999px;
  pointer-events: none;
}
.qt-tag::before { content: attr(data-text); }

.qt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  padding: 6px 13px 7px;
  font: 800 var(--fs-ui, 14px)/1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  white-space: nowrap;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink, #5b2a3c);
}
.qt-wrote {
  margin: 4px 0 0;
  text-align: center;
  font: 800 var(--fs-small, 12px)/1.3 var(--font-ui, system-ui, sans-serif);
  color: var(--ink-soft, rgba(91, 42, 60, 0.8));
}

/* the floating copy a drag carries (ghost(); transform only) */
.qt-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  margin: 0;
  pointer-events: none;
  opacity: 0.95;
  box-shadow: 0 10px 0 rgba(91, 42, 60, 0.22) !important;
  transition: none !important;
}

/* one-shot feedback moves (ux 1.4: transform only; calm: style.css makes them instant) */
.qt-pop { animation: qt-pop 0.45s var(--boing, cubic-bezier(0.34, 1.56, 0.64, 1)); }
.qt-wobble { animation: qt-wobble 0.5s ease-in-out; }
.qt-hop { animation: qt-hop 0.32s var(--boing, cubic-bezier(0.34, 1.56, 0.64, 1)); }
@keyframes qt-pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes qt-wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-3deg); } 45% { transform: rotate(3deg); } 70% { transform: rotate(-2deg); } }
@keyframes qt-hop { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-7px) scale(1.04, 0.97); } 100% { transform: none; } }
@keyframes qt-sticker { from { transform: scale(0.2) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes qt-flash { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes qt-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
/* calm: a correct answer gets a 0.15 s opacity flash instead of the pop; nothing wobbles or hops */
:root[data-motion="calm"] .qt .qt-pop.is-correct,
:root[data-motion="calm"] .qt .is-correct.qt-pop { animation: qt-flash 0.15s ease-out !important; }

/* ---------- optionGrid: choice and tf (ux 6.1, 6.7) ---------- */

.qt-choice,
.qt-tf { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.opt-count { align-self: center; }
.opt-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}
.opt-grid[data-shape="list"] { grid-template-columns: minmax(0, 1fr); }
.opt-grid[data-shape="glyphs"] { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.opt-grid[data-shape="row"] { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.opt-grid[data-shape="tf"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
:root[data-layout="tablet"] .opt-grid[data-shape="grid"][data-tiny="true"]:is([data-n="3"], [data-n="5"], [data-n="6"]) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
:root[data-layout="desk"] .opt-grid { max-width: 640px; margin-inline: auto; }
/* big letters on a phone: word options stack in one column (ux 1.5); pictures and single signs keep their row */
:root[data-big="true"][data-layout="phone"] .opt-grid[data-shape="grid"]:not([data-visual]):not([data-tiny]) { grid-template-columns: minmax(0, 1fr); }

.opt {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: var(--option-h, 64px);
  margin: 0;
  padding: 12px 16px 12px 34px;
  font: 800 var(--fs-option, 20px)/1.2 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  text-align: center;
  overflow-wrap: break-word;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 18px;
  box-shadow: var(--drop);
  cursor: pointer;
  touch-action: manipulation;
  transition: translate 0.12s, box-shadow 0.12s, background-color 0.15s, border-color 0.15s, opacity 0.2s;
}
.opt-grid[data-shape="list"] .opt { align-items: flex-start; text-align: left; padding-left: 40px; }
.opt-grid[data-shape="glyphs"] .opt { padding: 12px 8px; font: 400 calc(var(--fs-option, 20px) * 1.3)/1 var(--font-display, system-ui, sans-serif); }
.opt-grid[data-visual] .opt { padding: 26px 10px 10px; }
/* multi: the check box (top right) keeps its own lane, so no word ever runs under it */
.opt-grid:not([data-visual]) .opt[role="checkbox"] { padding-right: 40px; }
/* a phone keeps 3+ picture options about 92 px tall (ux 5.4 budget): the letter badge and the check box sit in the
   corners beside the centred picture instead of above it */
:root[data-layout="phone"] .opt-grid[data-visual]:not([data-n="2"]) .opt { padding: 8px 10px; }
:root[data-layout="phone"] .opt-grid[data-visual]:not([data-n="2"]) .opt-pic .visual { --v-max: 72px; max-width: 72px; }
.opt::before {
  content: attr(data-key);
  position: absolute;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font: 800 11px/1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--milk, #ffe3ec);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
}
.opt-text { display: block; max-width: 100%; }
/* a long word shrinks to fit its box rather than splitting mid-word ("amphibia / n"): fitWords (qtypes/index.js) sets
   --lw = the word's width in em, 100cqi is the box's content width; only past the 13 px floor may a word still break */
.fit-box,
.sort-in,
.sort-tray { container-type: inline-size; }
.fit-words { font-size: max(13px, min(1em, calc((100cqi - var(--fit-off, 0px)) / var(--lw, 1)))); }
.opt-pic { display: block; width: 100%; }
.opt-pic .visual { width: 100%; max-width: 120px; }
.opt-box {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 7px;
}
.opt[aria-checked="true"] .opt-box { background: var(--bow, #e8384f); box-shadow: inset 0 0 0 3px var(--white, #fff); }
.opt:active { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; }
@media (hover: hover) {
  .opt:not(.is-notyet):not(.is-correct):not([aria-checked="true"]):hover { --drop: 0 4px 0 var(--ink, #5b2a3c); translate: 0 -1px; background: #fff5f8; }
}
.opt.is-picked,
.opt[aria-checked="true"] { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; background: var(--pink, #ff8fb1); }
.opt.is-correct { --drop: 0 3px 0 var(--ink, #5b2a3c); translate: 0 0; background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.opt.is-correct::before { background: var(--mint, #7fdcc2); }
/* not yet: the dashed lavender-ink edge stays at full strength (5:1 on milk, ux 7.7 non-text ≥ 3:1); only what is
   inside the card fades */
.opt.is-notyet { --drop: 0 0 #0000; translate: 0 3px; background: var(--hmm-soft, #f3efff); border: 3px dashed var(--lavender-ink, #6a4fd1); cursor: default; }
.opt.is-notyet > *,
.opt.is-notyet::before { opacity: 0.6; }
.opt.is-faded:not(.is-notyet) { opacity: 0.6; }
.opt-grid.is-locked .opt { cursor: default; }
.qt-tf .opt { min-height: max(80px, var(--option-h, 64px)); padding-inline: 30px; font: 400 calc(var(--fs-option, 20px) * 1.1)/1.15 var(--font-display, system-ui, sans-serif); }

/* ---------- type (ux 6.2) ---------- */

.qt-type { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.type-row { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.ans {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  display: block;
  width: 100%;
  max-width: 280px;
  height: 64px;
  margin: 0;
  padding: 0 16px;
  font: 800 calc(var(--fs-option, 20px) * 1.2)/1 var(--font-ui, system-ui, sans-serif);
  letter-spacing: 0.02em;
  color: var(--ink, #5b2a3c);
  text-align: center;
  caret-color: var(--bow, #e8384f);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 18px;
  box-shadow: var(--drop);
  outline-offset: 3px;
  appearance: none;
  transition: background-color 0.15s, border-color 0.15s;
}
.type-row > .ans { min-width: min(100%, 150px); }
.ans::placeholder { color: var(--ink-soft, rgba(91, 42, 60, 0.8)); opacity: 0.75; font-size: calc(var(--fs-option, 20px) * 0.8); }
.qt-type:is(.is-text, .is-sentence) .ans { max-width: 100%; letter-spacing: 0.06em; }
.ans.sentence {
  height: auto;
  min-height: 64px;
  max-height: calc(3 * 1.4em + 26px);
  padding: 12px 16px;
  font-size: var(--fs-option, 20px);
  line-height: 1.4;
  text-align: left;
  resize: none;
  overflow-y: auto;
}
.ans.is-correct { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.ans.is-notyet { background: var(--hmm-soft, #f3efff); border: 3px dashed var(--lavender-ink, #6a4fd1); }
/* never red for a miss (§9.8): focus on (or inside) a "not yet" answer wears a lavender-ink ring (5.8:1 on white) */
.is-notyet:focus-visible,
.is-notyet :focus-visible { outline-color: var(--lavender-ink, #6a4fd1); }
.ans[readonly] { cursor: default; }
/* look, cover, write: the box rests while a listen task's peek shows the word (type.js); reaching early nudges it */
.qt-type.is-looking .ans { background: var(--blush, #fff2f6); border-color: var(--pink, #ff8fb1); box-shadow: none; }
.qt-nudge { animation: qt-nudge 0.35s ease-out; }
@keyframes qt-nudge { 0%, 100% { transform: none; } 45% { transform: scale(0.96); } }
.qt-unit {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 44px;
  height: 48px;
  padding: 0 12px;
  font: 800 var(--fs-option, 20px)/1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--milk, #ffe3ec);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 999px;
}
.type-row .qt-check { right: auto; left: calc(50% + 120px); }
.qt-type:is(.is-text, .is-sentence) .type-row .qt-check { left: auto; right: -6px; }
.type-shape { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.type-box {
  display: grid;
  place-items: center;
  width: 30px;
  height: 36px;
  font: 400 20px/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--white, #fff);
  border: 2px solid var(--ink, #5b2a3c);
  border-bottom-width: 4px;
  border-radius: 8px;
}
.type-box.is-ghost { color: var(--ink-soft, rgba(91, 42, 60, 0.8)); opacity: 0.6; }
.type-box.is-extra { border-style: dashed; border-color: var(--lavender-ink, #6a4fd1); }
.type-words { font-size: var(--fs-small, 12px); }

/* ---------- the keypad (ux 4.9) ---------- */

.qt-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin: 4px auto 0;
}
.qt-keypad.has-extra { grid-template-columns: repeat(3, minmax(72px, 1fr)); }
.qt-key {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  display: grid;
  place-items: center;
  height: 52px;
  margin: 0;
  padding: 0;
  font: 400 var(--fs-option, 20px)/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 16px;
  box-shadow: var(--drop);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: translate 0.08s, box-shadow 0.08s;
}
.qt-key.is-down,
.qt-key:active { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; }
.qt-key-del { background: var(--ear-pink, #ffc2d4); }
.qt-key-ctx { background: var(--milk, #ffe3ec); }
.qt-key-spacer { background: none; border: 0; box-shadow: none; pointer-events: none; }
.qt-key-icon { width: 30px; height: 22px; overflow: visible; }
.qt-key-tag { fill: var(--white, #fff); stroke: var(--ink, #5b2a3c); stroke-width: 2.4px; stroke-linejoin: round; }
.qt-key-x { fill: none; stroke: var(--ink, #5b2a3c); stroke-width: 2.6px; stroke-linecap: round; }
:root[data-layout="tablet"] .qt-keypad { max-width: 360px; }
:root[data-layout="tablet"] .qt-key { height: 56px; }
:root[data-big="true"] .qt-key { height: 60px; }
:root[data-short="true"] .qt-keypad { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 300px; gap: 6px; }
:root[data-short="true"] .qt-key { height: 44px; border-radius: 12px; }
:root:not([data-pointer="coarse"]) .qt-keypad { display: none; }
/* short landscape: the 6 × 2 keypad sits under the box, not beside it — the answer column (about 400 px) cannot hold
   300 px of keys and a box with its $ or unit chip side by side, and it has the height for both (§8.5, §12.5 #25) */
:root[data-short="true"] .qt-type.has-keypad { gap: 8px; }
:root[data-short="true"] .qt-type.has-keypad .qt-keypad { margin: 0 auto; }

/* ---------- blanks (ux 6.3) ---------- */

/* every blank is a full target: at least 44 × 44 (52 in big letters, §5.2), however small the text around it */
.blank {
  --drop: 0 2px 0 var(--ink, #5b2a3c);
  display: inline-block;
  box-sizing: border-box;
  width: calc(var(--w, 3) * 0.66em + 0.5em + 5px);
  min-width: var(--target, 44px);
  height: max(var(--target, 44px), 1.5em);
  margin: 4px 0.1em;
  padding: 0 0.25em;
  vertical-align: middle;
  font: inherit;
  font-weight: 800;
  line-height: 1;
  color: var(--ink, #5b2a3c);
  text-align: center;
  caret-color: var(--bow, #e8384f);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 10px;
  box-shadow: var(--drop);
  appearance: none;
  touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s;
}
.blank-letter,
.blank-digit { width: max(var(--target, 44px), 1.35em); padding: 0; }
/* a blank inside a word ("c▢er") keeps its focus ring off the letters beside it: the ring hugs the box (1 px gap, 3 px
   ring, the white halo under it) and the box keeps 5 px of air each side */
.blank:focus-visible { outline-offset: 1px; }
.nobr > .blank-slot > .blank { margin-inline: max(5px, 0.1em); }
/* a blank inside a drawer's cell (column, grid, pyramid bricks) is the whole cell: tap anywhere in it, never a box in
   a box; the cells are at least a target tall (a table cell just grows around its blank) */
:is(.vn-cell, .vn-gcell, .vn-brick):has(> .blank-slot > .blank) { position: relative; }
.vn-pyramid:has(.blank) .vn-brick { min-height: calc(var(--target, 44px) + 4px); }
:is(.vn-cell, .vn-gcell, .vn-brick) > .blank-slot:has(> .blank) { position: absolute; inset: -2px; display: block; min-width: 0 !important; }
.vn-brick > .blank-slot:has(> .blank) { inset: -2.5px; }
/* a column's answer row sits under the 3 px sum line: its blank keeps the line and reaches into the card's padding */
.vn-cell > .blank-slot:has(> .blank) { inset: 1px -1.5px -4px 1px; }
:is(.vn-cell, .vn-gcell, .vn-brick) > .blank-slot > .blank { display: block; width: 100%; height: 100%; min-width: 0; margin: 0; padding: 0 2px; border-radius: 12px; }
.vn-cell > .blank-slot > .blank { border-radius: 9px; }
td > .blank-slot > .blank { margin-block: -4px; }
.blank.is-correct { --drop: 0 3px 0 var(--mint, #7fdcc2); background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.blank.is-answer { font-weight: 900; }
.blank.is-notyet { background: var(--hmm-soft, #f3efff); border: 3px dashed var(--lavender-ink, #6a4fd1); }
.blank.is-bank { cursor: pointer; caret-color: transparent; }
.blank[readonly] { cursor: default; }
.blank.pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  width: auto;
  min-width: max(var(--target, 44px), 2.6em);
  padding: 0 0.35em;
  cursor: pointer;
}
.blank.pick:not(.is-filled) { background: var(--milk, #ffe3ec); border-style: dashed; }
.blank.pick:not(.is-filled) .pick-face::before { content: "?"; }
.pick-caret { width: 0.42em; height: 0.42em; margin-left: 0.12em; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; rotate: 45deg; translate: 0 -0.12em; }
.blank-pop {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
  max-width: calc(100vw - 16px);
  padding: 8px;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--ink, #5b2a3c);
  animation: qt-hop 0.25s var(--boing, ease-out);
}
.pop-opt {
  min-height: var(--target, 44px);
  padding: 6px 16px;
  font: 800 var(--fs-option, 20px)/1.1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  text-align: left;
  background: var(--blush, #fff2f6);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 12px;
  cursor: pointer;
}
.pop-opt[aria-checked="true"] { background: var(--pink, #ff8fb1); }
@media (hover: hover) { .pop-opt:hover { background: #ffe8ef; } }
.blank-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.bank-chip {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  min-height: var(--target, 44px);
  padding: 6px 16px 7px;
  font: 800 var(--fs-option, 20px)/1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 999px;
  box-shadow: var(--drop);
  cursor: pointer;
  transition: opacity 0.15s, translate 0.12s;
}
.bank-chip:active { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; }
.bank-chip.is-used { --drop: 0 0 #0000; translate: 0 3px; opacity: 0.4; cursor: default; }
.bank-chip.is-off { cursor: default; }
.qt-blanks.is-done .blank-bank { opacity: 0.6; }
/* a final answer needs no more keys: they stay where they were, dimmed and inert (keypad rest()), so the page does not
   jump and the celebration never plays on a half-empty screen */
.qt-keypad { transition: opacity 0.3s; }
.qt.is-done .qt-keypad,
.qt-keypad.is-rest { opacity: 0.45; pointer-events: none; }
.blank-fallback { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 16px; margin: 4px 0; font-size: var(--fs-prompt, 24px); }
.blank-row { display: inline-flex; align-items: center; gap: 8px; }
.blank-row-name { font: 800 var(--fs-ui, 14px)/1 var(--font-ui, system-ui, sans-serif); color: var(--ink-soft, rgba(91, 42, 60, 0.8)); }
.qt-blanks > .qt-check { top: -18px; right: 0; }
.qt-blanks .qt-keypad { margin-top: 2px; }

/* ---------- tiles (ux 6.4; tileTray) ---------- */

.qt-tiles { --s: 48px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
:root[data-big="true"] .qt-tiles { --s: 58px; }
.tiles-answer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: calc(var(--s) + 4px);
  padding: 2px 0;
  border-radius: 16px;
}
.tiles-row { display: flex; justify-content: center; gap: 6px; max-width: 100%; }
.is-words .tiles-row { flex-wrap: wrap; }
.tile-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--s);
  height: var(--s);
  background: var(--milk, #ffe3ec);
  border: 2.5px dashed rgba(91, 42, 60, 0.45);
  border-radius: 12px;
}
.is-words .tile-slot { width: auto; min-width: calc(var(--chars, 3) * 0.62em + 30px); font-size: var(--fs-option, 20px); }
.tile-slot.is-filled { background: none; border-color: transparent; }
.tile-slot.is-over,
.tiles-tray.is-over { background: var(--ear-pink, #ffc2d4); }
.tiles-answer.is-notyet .tile-slot { border: 2.5px dashed var(--lavender-ink, #6a4fd1); }
.tiles-answer.is-notyet .tile { background: var(--hmm-soft, #f3efff); border-style: dashed; border-color: var(--lavender-ink, #6a4fd1); }
.tiles-answer > .qt-check { top: -12px; right: 4px; }
.tiles-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; padding: 4px 0; border-radius: 16px; }
.tile-spot { display: inline-grid; place-items: center; min-width: var(--s); height: var(--s); border-radius: 12px; }
/* where a placed tile came from: a soft dent, never a dashed slot (the answer row alone has those) */
.tile-spot.is-empty { background: rgba(91, 42, 60, 0.07); box-shadow: inset 0 2px 0 rgba(91, 42, 60, 0.08); }
.qt-tiles.is-done .tile-spot.is-empty { visibility: hidden; }
.is-words .tile-spot { min-width: calc(var(--chars, 3) * 0.62em + 30px); font-size: var(--fs-option, 20px); }
.tile {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  display: grid;
  place-items: center;
  width: var(--s);
  height: var(--s);
  margin: 0;
  padding: 0;
  font: 400 var(--fs-option, 20px)/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 12px;
  box-shadow: var(--drop);
  cursor: pointer;
  touch-action: none;
  transition: translate 0.12s, box-shadow 0.12s, background-color 0.15s, opacity 0.15s;
}
.is-words .tile { width: auto; min-width: var(--s); padding: 0 14px; font: 800 var(--fs-option, 20px)/1 var(--font-ui, system-ui, sans-serif); white-space: nowrap; }
.tile-slot > .tile { --drop: 0 2px 0 var(--ink, #5b2a3c); background: var(--blush, #fff2f6); }
.tile:active { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; }
.tile.is-lifted { opacity: 0.3; }
.tile.is-correct { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.tiles-tools { display: flex; justify-content: center; gap: 10px; }
.qt-tiles.is-done .tiles-tools { visibility: hidden; }

/* ---------- order (ux 6.5; orderList) ---------- */

.qt-order { display: flex; flex-direction: column; gap: 6px; }
.order-end {
  margin: 0;
  font: 800 var(--fs-small, 12px)/1 var(--font-ui, system-ui, sans-serif);
  letter-spacing: 0.02em;
  color: var(--ink-soft, rgba(91, 42, 60, 0.8));
}
.order-low::before { content: "↑ "; }
.order-high::before { content: "↓ "; }
.order-list { position: relative; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.order-item {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 5px 6px 5px 8px;
  font: 800 var(--fs-option, 20px)/1.2 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 16px;
  box-shadow: var(--drop);
  cursor: grab;
  touch-action: pan-y;
  transition: translate 0.12s, box-shadow 0.12s, background-color 0.15s, border-color 0.15s;
}
.order-grip { display: grid; place-items: center; flex: none; width: 18px; color: var(--ink-soft, rgba(91, 42, 60, 0.8)); }
.order-grip .icon { width: 18px; height: 18px; }
.order-body { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; overflow-wrap: break-word; }
.order-pic { flex: none; width: 44px; }
.order-moves { display: flex; flex: none; gap: 6px; }
.order-move {
  display: grid;
  place-items: center;
  width: var(--target, 44px);
  height: var(--target, 44px);
  color: var(--ink, #5b2a3c);
  background: var(--milk, #ffe3ec);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
  cursor: pointer;
}
.order-move .icon { width: 20px; height: 20px; }
.order-move:active { translate: 0 2px; }
.order-move .when-row { display: none; }
.order-item.is-lifted,
.order-item[aria-selected="true"] { --drop: 0 6px 0 var(--ink, #5b2a3c); translate: 0 -3px; background: #fff0f5; border-color: var(--bow-pink, #ff5c8a); }
.order-item.is-dragging-card { z-index: 5; cursor: grabbing; --drop: 0 10px 0 rgba(91, 42, 60, 0.22); transition: none; }
.order-item.is-correct { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.order-item.is-right { border-color: var(--mint, #7fdcc2); }
.order-item.is-right::after {
  content: "✓";
  position: absolute;
  top: -9px;
  left: -9px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font: 900 13px/1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--mint, #7fdcc2);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
}
.qt-order.is-notyet .order-item:not(.is-right) { border: 3px dashed var(--lavender-ink, #6a4fd1); background: var(--hmm-soft, #f3efff); }
.qt-order > .qt-check { top: -12px; right: -6px; }
.qt-order > .qt-tag { bottom: -14px; }
.qt-order.is-done .order-moves { visibility: hidden; }
/* row: number ladders left to right, ◀ ▶ under each card */
.qt-order.is-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qt-order.is-row .order-list { grid-column: 1 / -1; grid-row: 1; flex-direction: row; gap: 8px; }
.qt-order.is-row .order-low { grid-row: 2; justify-self: start; }
.qt-order.is-row .order-high { grid-row: 2; justify-self: end; }
.qt-order.is-row .order-low::before { content: "← "; }
.qt-order.is-row .order-high::before { content: none; }
.qt-order.is-row .order-high::after { content: " →"; }
.qt-order.is-row .order-item { flex: 1 1 0; flex-direction: column; justify-content: space-between; min-width: calc(2 * var(--target, 44px) + 14px); padding: 10px 4px 6px; touch-action: pan-x; }
.qt-order.is-row .order-grip { display: none; }
.qt-order.is-row .order-body { flex-direction: column; justify-content: center; text-align: center; font-family: var(--font-display, system-ui, sans-serif); font-weight: 400; }
.qt-order.is-row .order-move .when-row { display: block; }
.qt-order.is-row .order-move .when-column { display: none; }
/* a phone has room for three ◀ ▶ cards in a row; longer ladders stand up as a column */
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) { display: flex; flex-direction: column; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-list { flex-direction: column; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-item { flex-direction: row; min-width: 0; padding: 5px 6px 5px 12px; touch-action: pan-y; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-body { flex-direction: row; justify-content: flex-start; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-grip { display: grid; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-move .when-row { display: none; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-move .when-column { display: block; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-low::before { content: "↑ "; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-high::before { content: "↓ "; }
:root[data-layout="phone"] .qt-order.is-row:not([data-n="2"]):not([data-n="3"]) .order-high::after { content: none; }

/* ---------- match (ux 6.6; matchBoard) ---------- */

.match-board { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 32px; align-items: stretch; }
:root:is([data-layout="tablet"], [data-layout="desk"]) .match-board { column-gap: 64px; }
.match-col { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.match-card {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 8px 12px;
  font: 800 var(--fs-option, 20px)/1.2 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  text-align: left;
  overflow-wrap: break-word;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 16px;
  box-shadow: var(--drop);
  cursor: pointer;
  touch-action: none;
  transition: translate 0.12s, box-shadow 0.12s, background-color 0.15s, border-color 0.15s;
}
.match-right .match-card { background: var(--milk, #ffe3ec); }
.match-card.is-picked { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; background: var(--pink, #ff8fb1); }
.match-card.is-over { border-color: var(--bow-pink, #ff5c8a); background: #fff0f5; }
.match-card.is-correct { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.match-card.is-notyet { background: var(--hmm-soft, #f3efff); border: 3px dashed var(--lavender-ink, #6a4fd1); }
.match-pic { flex: none; width: 44px; }
.match-pic + .fit-words { --fit-off: 52px; }
.match-text { flex: 1; min-width: 0; }
.match-badge {
  position: absolute;
  top: -10px;
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  font: 800 13px/1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--nose, #ffcf3f);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
}
.match-left .match-badge { right: -10px; }
.match-right .match-badge { left: -10px; }
.match-card.is-matched .match-badge { display: grid; }
.match-badge::before { content: attr(data-k); }
.match-card[data-pair="1"] .match-badge { background: var(--sky, #8fd3ff); }
.match-card[data-pair="2"] .match-badge { background: var(--pink, #ff8fb1); }
.match-card[data-pair="3"] .match-badge { background: var(--nose, #ffcf3f); }
.match-card[data-pair="4"] .match-badge { background: var(--lavender, #b49cff); }
.match-card[data-pair="5"] .match-badge { background: var(--mint, #7fdcc2); }
.match-lines { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ml-under { fill: none; stroke: var(--white, #fff); stroke-width: 11px; stroke-linecap: round; }
.ml-line { fill: none; stroke: var(--subj, var(--pink, #ff8fb1)); stroke-width: 6px; stroke-linecap: round; }
.ml-line.is-new { stroke-dasharray: 1; stroke-dashoffset: 0; animation: qt-draw 0.25s ease-out both; }
.ml-line.is-correct { stroke: var(--mint, #7fdcc2); }
.ml-line.is-notyet { stroke: var(--lavender-ink, #6a4fd1); stroke-dasharray: 9 8; }
.ml-line.is-temp { stroke-dasharray: 7 9; opacity: 0.85; }
.ml-dot { fill: var(--subj, var(--pink, #ff8fb1)); stroke: var(--ink, #5b2a3c); stroke-width: 2px; }
.ml-dot.is-correct { fill: var(--mint, #7fdcc2); }
.ml-dot.is-notyet { fill: var(--lavender-ink, #6a4fd1); }
.match-board > .qt-check { top: -14px; right: -6px; }
.match-board > .qt-tag { bottom: -16px; }

/* ---------- sort (ux 6.8; buckets) ---------- */

.qt-sort { display: flex; flex-direction: column; gap: 12px; }
.sort-buckets { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sort-buckets[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
:root:is([data-layout="tablet"], [data-layout="desk"]) .sort-buckets[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sort-bucket {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 120px;
  background: var(--milk, #ffe3ec);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 20px;
  box-shadow: 0 3px 0 var(--ink, #5b2a3c);
  transition: background-color 0.15s;
}
.sort-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 6px;
  width: 100%;
  min-height: max(48px, var(--target, 44px));
  margin: 0;
  padding: 8px 8px 7px;
  font: 400 calc(18px * var(--k-option, 1))/1.15 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  text-align: center;
  overflow-wrap: break-word;
  background: var(--white, #fff);
  border: 0;
  border-bottom: 2.5px dashed var(--dash, rgba(255, 143, 177, 0.55));
  border-radius: 18px 18px 0 0;
  cursor: pointer;
}
.sort-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  font: 800 11px/1 var(--font-ui, system-ui, sans-serif);
  background: var(--milk, #ffe3ec);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
}
.sort-num::before { content: attr(data-n); }
.sort-pic { flex: none; width: 36px; }
.sort-hint { flex-basis: 100%; font: 500 var(--fs-small, 12px)/1.25 var(--font-ui, system-ui, sans-serif); color: var(--ink-soft, rgba(91, 42, 60, 0.8)); }
.sort-in { display: flex; flex: 1; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 6px; min-height: 60px; padding: 8px 6px 10px; }
.sort-bucket.is-target { background: #fff0f5; }
.sort-bucket.is-target .sort-head { border-bottom-color: var(--bow-pink, #ff5c8a); }
.sort-bucket.is-over { background: var(--ear-pink, #ffc2d4); }
.sort-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  padding: 8px;
  border: 2.5px dashed var(--dash, rgba(255, 143, 177, 0.55));
  border-radius: 18px;
  transition: background-color 0.15s;
}
.sort-tray.is-empty { min-height: 40px; border-color: transparent; }
.sort-tray.is-over { background: var(--ear-pink, #ffc2d4); }
.sort-chip {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  max-width: 100%;
  min-height: max(48px, var(--target, 44px));
  margin: 0;
  padding: 6px 12px;
  font: 800 var(--fs-option, 20px)/1.1 var(--font-ui, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  overflow-wrap: break-word;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 14px;
  box-shadow: var(--drop);
  cursor: pointer;
  touch-action: none;
  transition: translate 0.12s, box-shadow 0.12s, background-color 0.15s, border-color 0.15s, opacity 0.15s;
}
.sort-chip.in-bucket { min-height: var(--target, 44px); padding: 4px 10px; font-size: calc(var(--fs-option, 20px) * 0.85); }
.sort-chip.is-picked { --drop: 0 6px 0 var(--ink, #5b2a3c); translate: 0 -3px; background: var(--pink, #ff8fb1); }
.sort-chip.is-lifted { opacity: 0.3; }
.sort-chip.is-correct { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.sort-chip.is-correct.in-bucket::after {
  content: "✓";
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font: 900 12px/1 var(--font-ui, system-ui, sans-serif);
  background: var(--mint, #7fdcc2);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
}
.sort-chip.is-notyet { background: var(--hmm-soft, #f3efff); border: 3px dashed var(--lavender-ink, #6a4fd1); }
.sort-chip-pic { display: block; width: 40px; }
.sort-chip .fit-words { --fit-off: 30px; }
.sort-chip-text.is-masked { font-family: var(--font-display, system-ui, sans-serif); font-weight: 400; letter-spacing: 0.08em; }
.sort-gap { display: inline-block; min-width: 1.4em; margin: 0 0.06em; color: transparent; border-bottom: 3px solid var(--bow-pink, #ff5c8a); border-radius: 2px; letter-spacing: 0; line-height: 0.9; }
.sort-clue { max-width: 18ch; font: 500 var(--fs-small, 12px)/1.2 var(--font-ui, system-ui, sans-serif); color: var(--ink-soft, rgba(91, 42, 60, 0.8)); text-align: center; }
.sort-buckets > .qt-check { top: -14px; right: -6px; }
.sort-buckets > .qt-tag { bottom: -14px; }

/* ---------- numberline (ux 6.9; numberLine) ---------- */

.qt-numberline { padding-top: 40px; }
.nl-stage { position: relative; width: 100%; height: var(--h, 120px); cursor: pointer; touch-action: none; }
.nl-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.nl-base { stroke: var(--ink, #5b2a3c); stroke-width: 6px; stroke-linecap: round; }
.nl-tick { stroke: var(--ink, #5b2a3c); stroke-width: 2.5px; stroke-linecap: round; }
.nl-major { stroke-width: 3.5px; }
.nl-label { font-size: 15px; }
.nl-mark-label { font-size: 13px; }
.nl-berry { fill: var(--bow, #e8384f); stroke: var(--ink, #5b2a3c); stroke-width: 1.8px; paint-order: stroke; }
.nl-leaf { fill: none; stroke: var(--mint, #7fdcc2); stroke-width: 2.6px; stroke-linecap: round; stroke-linejoin: round; }
.nl-marker,
.nl-ghost {
  position: absolute;
  left: 0;
  top: calc(var(--h, 120px) * 0.56 - 58px);
  width: 56px;
  height: 60px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 14px;
  cursor: grab;
  touch-action: none;
  transition: translate 0.22s var(--boing, ease-out);
}
.nl-marker.is-dragging { cursor: grabbing; transition: none; }
.nl-ghost { pointer-events: none; z-index: 0; }
.nl-marker { z-index: 1; }
.nl-bow { display: block; }
.nl-bow-svg { display: block; width: 40px; height: 56px; margin: 2px auto 0; overflow: visible; filter: drop-shadow(0 2px 0 var(--white, #fff)); }
.nl-stem { stroke: var(--ink, #5b2a3c); stroke-width: 3px; stroke-linecap: round; }
.nl-bow-wing { fill: var(--bow-pink, #ff5c8a); stroke: var(--ink, #5b2a3c); stroke-width: 2.2px; stroke-linejoin: round; }
.nl-bow-knot { fill: var(--pink, #ff8fb1); stroke: var(--ink, #5b2a3c); stroke-width: 2.2px; }
.nl-marker.is-parked .nl-bow-wing,
.nl-marker.is-parked .nl-bow-knot { fill: #ddd2d6; }
.nl-marker.is-parked .nl-stem { stroke-dasharray: 3 4; }
.nl-readout {
  position: absolute;
  bottom: 100%;
  left: 50%;
  min-width: 36px;
  padding: 4px 9px 5px;
  translate: -50% -2px;
  font: 400 18px/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  white-space: nowrap;
  text-align: center;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 12px;
  box-shadow: 0 2px 0 var(--ink, #5b2a3c);
}
.nl-readout::before { content: attr(data-v); }
.nl-readout.is-blank { min-width: 0; width: 16px; height: 16px; padding: 0; border-radius: 50%; background: var(--nose, #ffcf3f); }
.nl-marker.is-parked .nl-readout { color: var(--ink-soft, rgba(91, 42, 60, 0.8)); }
.nl-marker.is-correct .nl-readout { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.nl-marker.is-notyet .nl-readout { background: var(--hmm-soft, #f3efff); border: 2.5px dashed var(--lavender-ink, #6a4fd1); }
.nl-marker.is-greyed { opacity: 0.45; }
.nl-ghost .nl-bow-wing { fill: var(--mint, #7fdcc2); }
.nl-ghost .nl-readout { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.nl-readout > .qt-check { top: -15px; right: -19px; width: 26px; height: 26px; }

/* ---------- clock (ux 6.10; clockFace) ---------- */

.qt-clock { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ck-stage { position: relative; width: calc(240px * var(--ck-k, 1)); max-width: 100%; }
:root:is([data-layout="tablet"], [data-layout="desk"]) .ck-stage { width: calc(280px * var(--ck-k, 1)); }
:root[data-short="true"] .ck-stage { width: 200px; }
:root[data-big="true"] .qt-clock { --ck-k: 1.15; }
.ck-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: none; filter: drop-shadow(0 3px 0 var(--ink, #5b2a3c)); }
.ck-face { fill: var(--white, #fff); }
.ck-ring { fill: none; stroke: var(--ink, #5b2a3c); stroke-width: 4px; }
.ck-tick { stroke: var(--ink-soft, rgba(91, 42, 60, 0.8)); stroke-width: 1.4px; stroke-linecap: round; }
.ck-tick-h { stroke: var(--ink, #5b2a3c); stroke-width: 3px; }
.ck-num { font-size: 19px; cursor: pointer; }
.ck-hand { transform-box: view-box; transform-origin: 120px 120px; cursor: grab; }
.ck-edge { stroke: var(--ink, #5b2a3c); stroke-linecap: round; }
.ck-hour-edge { stroke-width: 14px; }
.ck-minute-edge { stroke-width: 12px; }
.ck-hour-line { stroke: var(--ink, #5b2a3c); stroke-width: 10px; stroke-linecap: round; }
.ck-minute-line { stroke: var(--bow-pink, #ff5c8a); stroke-width: 8px; stroke-linecap: round; }
.ck-heart { fill: var(--bow-pink, #ff5c8a); stroke: var(--ink, #5b2a3c); stroke-width: 1.6px; stroke-linejoin: round; }
.ck-centre { fill: var(--nose, #ffcf3f); stroke: var(--ink, #5b2a3c); stroke-width: 2.5px; }
.ck-ghosts .ck-hand { pointer-events: none; }
.ck-ghosts .ck-hour-line { stroke: var(--mint, #7fdcc2); }
.ck-ghosts .ck-minute-line { stroke: var(--mint, #7fdcc2); opacity: 0.95; }
.ck-ghosts .ck-heart { fill: var(--mint, #7fdcc2); }
.qt-clock.is-revealed .ck-hand:not(.is-ghost) { opacity: 0.35; }
.qt-clock.is-correct .ck-ring { stroke: var(--mint, #7fdcc2); stroke-width: 6px; }
.qt-clock.is-correct .ck-minute-line,
.qt-clock.is-correct .ck-heart { stroke: var(--ink, #5b2a3c); }
.qt-clock.is-correct .ck-minute-line { stroke: var(--mint, #7fdcc2); }
.qt-clock.is-correct .ck-heart { fill: var(--mint, #7fdcc2); }
.qt-clock.is-notyet .ck-ring { stroke: var(--lavender-ink, #6a4fd1); stroke-width: 5px; stroke-dasharray: 11 8; }
.qt-clock:is(.is-dragging-minute, .is-dragging-hour) .ck-hand { cursor: grabbing; }
.ck-digital {
  min-width: 92px;
  margin: 0;
  padding: 7px 14px 8px;
  font: 400 22px/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  text-align: center;
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink, #5b2a3c);
}
.ck-digital.is-hidden { visibility: hidden; }
.ck-digital.is-answer { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.ck-steppers { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; }
.ck-row { display: flex; align-items: center; gap: 8px; }
.ck-row-name { min-width: 3.4em; font: 800 var(--fs-ui, 14px)/1 var(--font-ui, system-ui, sans-serif); color: var(--ink-soft, rgba(91, 42, 60, 0.8)); text-align: right; }
.ck-spin {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: var(--target, 44px);
  padding: 0 8px;
  font: 400 22px/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--milk, #ffe3ec);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 12px;
}
.ck-val::before { content: attr(data-v); }
.ck-spin.is-answer { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.ck-step-text { font: 800 calc(15px * var(--k-ui, 1))/1 var(--font-ui, system-ui, sans-serif); }
.ck-step-text.is-sign { font: 400 calc(24px * var(--k-ui, 1))/1 var(--font-display, system-ui, sans-serif); translate: 0 -1px; }
.qt-clock.is-done .ck-step { visibility: hidden; }
.ck-stage > .qt-check { top: 6px; right: 6px; }

/* ---------- grid (ux 6.11; cellGrid) ---------- */

.qt-grid { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gr-wrap { position: relative; max-width: 100%; isolation: isolate; }
/* a toggle picture sits on a soft white card, so the whole grid (every plain cell too) reads as one board */
.is-toggle .gr-wrap::before { content: ""; position: absolute; inset: -8px; z-index: -1; background: rgba(255, 255, 255, 0.82); border-radius: 16px; box-shadow: 0 3px 0 rgba(91, 42, 60, 0.18); }
.gr-board { display: grid; grid-template-columns: repeat(var(--cols, 4), var(--cell, 52px)); gap: 4px; touch-action: none; }
.is-fill .gr-board { gap: 2px; }
.gr-row { display: contents; }
.gr-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell, 52px);
  height: var(--cell, 52px);
  font: 400 calc(var(--cell, 52px) * 0.42)/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--milk, #ffe3ec);
  border: 2px solid transparent;
  border-radius: 9px;
  overflow: hidden;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.12s, border-color 0.12s;
}
.is-toggle .gr-cell { border: 2px solid rgba(91, 42, 60, 0.16); }
.is-toggle .gr-cell.is-edit { background: var(--white, #fff); border: 2px dashed rgba(91, 42, 60, 0.55); cursor: pointer; }
.is-toggle .gr-cell.is-on { background: var(--pink, #ff8fb1); border: 2px solid var(--ink, #5b2a3c); }
.is-toggle .gr-cell.is-sel { background: var(--mint, #7fdcc2); border: 2px solid var(--ink, #5b2a3c); }
.is-toggle .gr-cell.is-sel::after { content: "✦"; position: absolute; top: 2px; right: 4px; font: 400 11px/1 var(--font-display, system-ui, sans-serif); color: var(--white, #fff); }
/* the cell itself is always the pointer target (its value is drawn inside it), so a press keeps focus on the cell */
.gr-cell > * { pointer-events: none; }
.gr-cell.is-notyet { background: var(--hmm-soft, #f3efff) !important; border: 3px dashed var(--lavender-ink, #6a4fd1) !important; }
.is-toggle .gr-cell.is-notyet::after { content: none; }
.gr-cell.is-faded { opacity: 0.45; }
.gr-cell.is-correct { border-color: var(--mint, #7fdcc2); }
.gr-cell.is-answer { background: var(--mint, #7fdcc2); border: 2px solid var(--ink, #5b2a3c); }
.gr-bow { width: 22px; height: 15px; }
.gr-bow-wing { fill: var(--white, #fff); stroke: var(--ink, #5b2a3c); stroke-width: 1.8px; stroke-linejoin: round; }
.gr-bow-knot { fill: var(--bow-pink, #ff5c8a); stroke: var(--ink, #5b2a3c); stroke-width: 1.6px; }
.gr-line { position: absolute; inset: -2px; width: calc(100% + 4px); height: calc(100% + 4px); overflow: visible; pointer-events: none; }
.gr-mirror { stroke: var(--bow, #e8384f); stroke-width: 3.5px; stroke-dasharray: 7 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.is-fill .gr-cell { border: 1.5px solid var(--ink, #5b2a3c); border-radius: 6px; }
.is-fill .gr-cell.is-given { background: var(--milk, #ffe3ec); }
.is-fill .gr-cell.is-edit { background: var(--white, #fff); border-style: dashed; cursor: pointer; }
.is-fill .gr-cell.is-filled { border-style: solid; }
.is-fill .gr-cell.is-cur { border: 2px solid var(--bow-pink, #ff5c8a); box-shadow: inset 0 0 0 3px var(--ear-pink, #ffc2d4); }
.is-fill .gr-cell.is-correct { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.is-fill .gr-cell.is-answer { background: var(--mint-soft, #e6f9f2); border: 2.5px solid var(--mint, #7fdcc2); }
/* a sudoku's boxes stand apart: grid.js adds an air track at every box boundary, rows and columns alike, and an ink
   bar fills it, so the boxes read the same on both axes whatever state the cells are in (fit() counts the air) */
.gr-sep { display: block; pointer-events: none; background: var(--ink, #5b2a3c); border-radius: 3px; }
.gr-sep.is-v { justify-self: center; width: 4px; }
.gr-sep.is-h { align-self: center; height: 4px; }
.gr-sym { display: grid; place-items: center; width: 78%; }
.gr-sym .visual { width: 100%; }
.gr-val { font: 400 min(calc(var(--cell, 52px) * 0.44), calc(var(--cell, 52px) * 1.15 / var(--len, 1))) / 1 var(--font-display, system-ui, sans-serif); }
/* symbol names as words (a palette without pictures): the narrower ui font, one size for the board, never under 13 px */
.gr-board.is-words .gr-val { font: 800 max(13px, min(calc(var(--cell, 52px) * 0.34), calc(var(--cell, 52px) * 1.5 / var(--len, 1)))) / 1 var(--font-ui, system-ui, sans-serif); letter-spacing: -0.01em; }
.gr-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.gr-palette { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.gr-pal {
  --drop: 0 3px 0 var(--ink, #5b2a3c);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 52px;
  min-height: 52px;
  padding: 4px 8px;
  font: 400 var(--fs-option, 20px)/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--white, #fff);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 14px;
  box-shadow: var(--drop);
  cursor: pointer;
}
.gr-pal .visual { width: 36px; }
.gr-pal-name { font: 800 var(--fs-small, 12px)/1 var(--font-ui, system-ui, sans-serif); }
.gr-pal-name.is-word { font: 400 var(--fs-option, 20px)/1 var(--font-display, system-ui, sans-serif); }
.gr-pal:active { --drop: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; }
.gr-sum { order: -1; }
.qt-grid.is-done .gr-clear,
.qt-grid.is-done .gr-palette { visibility: hidden; }
.gr-wrap > .qt-check { top: -14px; right: -14px; }

/* ---------- balance (ux 6.12; balanceScale) ---------- */

.qt-balance { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.bal-scales { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.bal-stage { position: relative; width: 100%; max-width: 400px; height: max(var(--h, 230px), 190px); }
:root:is([data-layout="tablet"], [data-layout="desk"]) .bal-stage { max-width: 480px; }
.bal-stage.is-other { max-width: 300px; opacity: 0.92; }
:root:is([data-layout="tablet"], [data-layout="desk"]) .bal-stage.is-other { max-width: 340px; }
.bal-num {
  position: absolute;
  top: 0;
  left: 4px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font: 400 14px/1 var(--font-display, system-ui, sans-serif);
  background: var(--white, #fff);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 50%;
}
.bal-stage.is-target .bal-num { background: var(--nose, #ffcf3f); }
.bal-svg { position: absolute; left: 0; top: 0; width: 100%; height: auto; overflow: visible; }
.bal-beam { transform-box: view-box; transform-origin: 160px 61px; transition: transform 0.4s var(--boing, ease-out); }
.bal-beam-bar { fill: var(--lavender, #b49cff); stroke: var(--ink, #5b2a3c); stroke-width: 2.5px; }
.bal-pivot { fill: var(--nose, #ffcf3f); stroke: var(--ink, #5b2a3c); stroke-width: 2.5px; }
.bal-post { stroke: var(--ink, #5b2a3c); stroke-width: 6px; stroke-linecap: round; }
.bal-star { fill: var(--nose, #ffcf3f); stroke: var(--ink, #5b2a3c); stroke-width: 2.5px; stroke-linejoin: round; }
.bal-pan { position: absolute; left: 0; top: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 36%; max-width: 176px; transition: transform 0.4s var(--boing, ease-out); }
.bal-hang { display: block; width: 74%; height: 26px; border: 2.5px solid var(--ink, #5b2a3c); border-bottom: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.bal-items {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 52px;
  padding: 6px 6px 10px;
  background: var(--milk, #ffe3ec);
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 8px 8px 36px 36px;
  box-shadow: 0 3px 0 var(--ink, #5b2a3c);
}
.bal-group { display: inline-flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.bal-tok {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  font: 400 16px/1 var(--font-display, system-ui, sans-serif);
  color: var(--ink, #5b2a3c);
  background: var(--sky, #8fd3ff);
  border: 2px solid var(--ink, #5b2a3c);
  border-radius: 9px;
}
.bal-tok.is-box { min-width: 40px; height: 40px; background: var(--white, #fff); }
.bal-q { font-size: 20px; }
.bal-bow { position: absolute; top: -7px; left: 50%; width: 16px; height: 9px; translate: -50% 0; background: var(--bow-pink, #ff5c8a); border: 1.6px solid var(--ink, #5b2a3c); border-radius: 50%; }
/* the box says what it holds: "?=3" (ux 6.12) */
.bal-tok.has-total.is-filled { grid-auto-flow: column; gap: 1px; min-width: 56px; padding: 0 7px; background: var(--blush, #fff2f6); }
.bal-tok.is-box.is-filled .bal-q { color: var(--ink-soft, rgba(91, 42, 60, 0.8)); }
.bal-tok.is-sym.is-filled .bal-total { font-size: 16px; }
.bal-total { font: 400 19px/1 var(--font-display, system-ui, sans-serif); white-space: nowrap; }
.bal-total:empty { display: none; }
.bal-tok.is-sym { background: var(--white, #fff); font-size: 22px; }
.bal-tok.is-weight { background: var(--nose, #ffcf3f); }
.bal-tok.is-item { width: 40px; min-width: 40px; height: 40px; padding: 0; background: none; border: 0; }
.bal-tok.is-item .visual { width: 40px; }
.bal-mine { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
/* numbers: under the scale, "box: 3" and the tokens inside the box, as round coins the child can tap out again */
.bal-inbox { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; min-height: var(--target, 44px); }
.bal-tok.is-coin { min-width: 52px; height: var(--target, 44px); padding: 0 10px; font: 400 18px/1 var(--font-display, system-ui, sans-serif); background: var(--ear-pink, #ffc2d4); border: 2.5px solid var(--ink, #5b2a3c); border-radius: 999px; box-shadow: 0 3px 0 var(--ink, #5b2a3c); cursor: pointer; }
.bal-tok.is-coin:active { box-shadow: 0 0 0 var(--ink, #5b2a3c); translate: 0 3px; }
.bal-tok.is-mine { min-width: 44px; height: 44px; margin: 0; font-size: 17px; background: var(--ear-pink, #ffc2d4); cursor: pointer; }
.bal-stage.is-level .bal-items { box-shadow: 0 3px 0 var(--ink, #5b2a3c), 0 0 0 4px rgba(127, 220, 194, 0.35); }
.qt-balance.is-correct .bal-stage.is-target .bal-items { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.qt-balance.is-revealed .bal-tok.is-mine { background: var(--mint, #7fdcc2); }
.qt-balance.is-notyet .bal-stage.is-target .bal-tok.is-box { border: 2.5px dashed var(--lavender-ink, #6a4fd1); background: var(--hmm-soft, #f3efff); }
.bal-tokens { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.bal-stage.is-target.is-over .bal-items { background: var(--ear-pink, #ffc2d4); }
.bal-add { touch-action: none; min-width: 64px; font: 400 calc(20px * var(--k-option, 1))/1 var(--font-display, system-ui, sans-serif); }
.bal-status { font-variant-numeric: tabular-nums; }
.bal-type { gap: 10px; }
.bal-type-label { font: 400 var(--fs-option, 20px)/1 var(--font-display, system-ui, sans-serif); white-space: nowrap; }
.bal-stage > .qt-check { top: 8px; right: 8px; }
.qt-balance.is-done .bal-tokens { opacity: 0.45; pointer-events: none; transition: opacity 0.3s; }

/* ---------- pairs (ux 6.13; pairGrid) ---------- */

.qt-pairs { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pr-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(64px, 1fr)); gap: 8px; width: 100%; max-width: 460px; }
:root:is([data-layout="tablet"], [data-layout="desk"]) .pr-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)); max-width: 560px; }
/* 6 or 9 cards make whole rows of 3 (never a ragged 4 + 2) */
:root:is([data-layout="tablet"], [data-layout="desk"]) .pr-grid:is([data-n="6"], [data-n="9"]) { grid-template-columns: repeat(3, minmax(64px, 1fr)); max-width: 440px; }
:root[data-short="true"] .pr-grid { grid-template-columns: repeat(6, minmax(52px, 1fr)); max-width: none; }
.pr-row { display: contents; }
.pr-cell { min-width: 0; }
.pr-card { display: block; width: 100%; aspect-ratio: 4 / 5; margin: 0; padding: 0; background: none; border: 0; border-radius: 16px; perspective: 700px; cursor: pointer; touch-action: manipulation; }
.pr-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.4s var(--boing, ease-out); }
.pr-card.is-up .pr-inner { transform: rotateY(180deg); }
.pr-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  overflow: hidden;
  border: 2.5px solid var(--ink, #5b2a3c);
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--ink, #5b2a3c);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* from game/public/game/style.css (the picnic gingham), in white on pink for the card backs */
.pr-back {
  background-color: var(--pink, #ff8fb1);
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 50%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.28) 50%, transparent 50%);
  background-size: 16px 16px;
}
.pr-heart::before { content: "♡"; font: 400 26px/1 var(--font-display, system-ui, sans-serif); color: var(--white, #fff); text-shadow: 0 2px 0 var(--ink, #5b2a3c); }
/* a face-down card's face is not there to read (or to find with innerText) until it turns */
.pr-card:not(.is-up) .pr-front { visibility: hidden; transition: visibility 0s linear 0.2s; }
.pr-card.is-up .pr-front { visibility: visible; transition: visibility 0s; }
.pr-front { background: var(--white, #fff); transform: rotateY(180deg); font: 400 var(--fs-option, 20px)/1.15 var(--font-display, system-ui, sans-serif); color: var(--ink, #5b2a3c); text-align: center; overflow-wrap: break-word; }
.pr-pic { display: block; width: 76%; }
.pr-pic .visual { width: 100%; }
.pr-text { display: block; }
.pr-text.is-long { font: 800 max(11px, min(var(--fs-option, 20px), calc(150px / var(--len, 12)))) / 1.15 var(--font-ui, system-ui, sans-serif); }
.pr-pic + .pr-text { font: 800 var(--fs-small, 12px)/1.15 var(--font-ui, system-ui, sans-serif); }
.pr-card.is-found .pr-front { background: var(--mint-soft, #e6f9f2); border-color: var(--mint, #7fdcc2); }
.pr-card .qt-check { top: -8px; right: -8px; }
.pr-card.is-found { cursor: default; }
.qt-pairs.is-peeking .pr-card:not(.is-found) .pr-front { background: #fffbea; }
.pr-status { font-variant-numeric: tabular-nums; }

/* ---------- the paper forms (printable(); worksheet preview on screen and on paper) ---------- */

.pq { break-inside: avoid; page-break-inside: avoid; color: var(--ink, #5b2a3c); font-family: var(--font-ui, system-ui, sans-serif); }
.pq-prompt { margin: 0 0 6px; font: 800 16px/1.4 var(--font-ui, system-ui, sans-serif); }
.pq .visual { margin: 4px 0 8px; max-width: 320px; margin-inline: 0; }
.pq-opts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 6px 0 0; padding: 0; list-style: none; font: 800 15px/1.3 var(--font-ui, system-ui, sans-serif); }
.pq-opt { display: inline-flex; align-items: center; gap: 6px; }
.pq-opt .visual { width: 64px; margin: 0; }
.pq-mark { font-size: 17px; line-height: 1; }
.pq-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.pq-box { display: inline-block; min-width: 76px; height: 30px; padding: 3px 8px; font: 800 15px/22px var(--font-ui, system-ui, sans-serif); border: 1.5px solid currentColor; border-radius: 6px; }
.pq-unit { font: 800 15px/1 var(--font-ui, system-ui, sans-serif); }
.pq-line { display: block; flex: 1 1 100%; min-height: 26px; padding: 0 2px 2px; font: 800 15px/24px var(--font-ui, system-ui, sans-serif); border-bottom: 1.5px solid currentColor; }
.pq-line + .pq-line { margin-top: 10px; }
.pq-letters { display: inline-flex; gap: 4px; }
.pq-letter { display: inline-grid; place-items: center; width: 26px; height: 30px; font: 800 16px/1 var(--font-ui, system-ui, sans-serif); border: 1.5px solid currentColor; border-radius: 4px; }
.pq-given { opacity: 0.55; }
.pq-blank { display: inline-block; min-width: calc(max(3, var(--w, 3)) * 0.62em); height: 1.25em; margin: 0 0.12em; padding: 0 0.2em; vertical-align: -0.2em; text-align: center; border: 1.5px solid currentColor; border-radius: 4px; }
.pq-blank-one { min-width: 1em; }
.pq-pick,
.pq-bank,
.pq-note { margin: 4px 0 0; font: 500 13px/1.35 var(--font-ui, system-ui, sans-serif); }
.pq-scramble { margin: 6px 0; font: 800 17px/1.2 var(--font-ui, system-ui, sans-serif); letter-spacing: 0.08em; }
.pq-order-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; font: 800 15px/1.3 var(--font-ui, system-ui, sans-serif); }
.pq-order-item { display: flex; align-items: center; gap: 8px; }
.pq-rank { min-width: 30px; text-align: center; }
.pq-order-item .visual { width: 44px; margin: 0; }
.pq-match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; margin-top: 6px; }
.pq-match-col { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; font: 800 15px/1.3 var(--font-ui, system-ui, sans-serif); }
.pq-left .pq-match-item { justify-content: space-between; }
.pq-match-item { display: flex; align-items: center; gap: 8px; }
.pq-match-item .visual { width: 36px; margin: 0; }
.pq-dot { font-size: 10px; }
.pq-num { font-weight: 800; }
.pq-key { font-weight: 500; }
.pq-items { margin: 6px 0; font: 800 15px/1.4 var(--font-ui, system-ui, sans-serif); }
.pq-sort-table,
.pq-grid-table { border-collapse: collapse; margin-top: 6px; font: 800 15px/1.2 var(--font-ui, system-ui, sans-serif); }
.pq-sort-table th,
.pq-sort-table td { min-width: 110px; padding: 6px 8px; text-align: left; vertical-align: top; border: 1.5px solid currentColor; }
.pq-sort-table td { height: 84px; }
.pq-grid-wrap { position: relative; display: inline-block; }
.pq-grid-table td { width: 34px; height: 34px; padding: 0; text-align: center; border: 1.5px solid currentColor; }
.pq-grid-table td.pq-on { background: #d6d6d6; }
.pq-grid-table td.pq-shade { background: #ececec; }
.pq-grid-table td.box-r { border-right-width: 3.5px; }
.pq-grid-table td.box-b { border-bottom-width: 3.5px; }
.pq-grid-wrap .gr-line { inset: 0; width: 100%; height: 100%; }
.pq-line-svg { display: block; width: 100%; max-width: 520px; height: auto; margin: 6px 0; overflow: visible; }
.pq-arrow { fill: currentColor; }
.pq-clock-face { width: 150px; height: auto; margin: 6px 0; filter: none; }
.pq-equation { margin: 6px 0 0; font: 800 17px/1.3 var(--font-ui, system-ui, sans-serif); letter-spacing: 0.02em; }
.pq-ans { font-weight: 900; }

/* ---------- print (worksheets; screen drawings in black ink, fills ≤ 20 % grey) ---------- */

@media print {
  .visual > .v-svg,
  .visual > svg { filter: none; }
  .v-line { stroke: #333; }
  .v-ring { stroke: #fff; fill: #fff; }
  /* glyphs (and everything built from them) sit in a .v-colour group: they keep their colour and add the colour
     word in 6 pt (logic drawers), so a grey copy is still solvable */
  .visual :is(.f-milk, .f-pink, .f-bow, .f-bow-pink, .f-ear-pink, .f-nose, .f-mint, .f-lavender, .f-sky, .f-blush):not(.v-colour *) { fill: #e6e6e6; }
  .visual .f-ink, .v-t { fill: #000; }
  .v-sticker-img { filter: grayscale(1); }
  /* a prompt's friend sticker is decoration: printHead leaves it off paper, and so does any other print path */
  .visual.v-sticker.v-in-print { display: none; }
  .visual.v-missing { background: none; border-color: #999; }
  .op-slot { border-color: #333; }
  .gap { border-bottom-color: #333; }
  mark.chunk, b.kw { text-decoration-color: #333; }
  .q-oops { display: none; }
  /* the paper forms and anything a component drew: black ink, #333 strokes, fills no darker than 20 % grey */
  .pq, .pq-prompt, .pq-note, .pq-equation { color: #000; }
  .pq-grid-table td.pq-on { background: #d6d6d6; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pq-grid-table td.pq-shade { background: #ececec; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .nl-base, .nl-tick, .ck-ring, .ck-tick, .ck-tick-h, .ck-hour-line, .ck-edge { stroke: #333; }
  .ck-minute-line { stroke: #555; }
  .ck-heart, .ck-centre, .nl-berry { fill: #d6d6d6; stroke: #333; }
  .nl-leaf { stroke: #333; }
  .ck-num, .nl-label, .nl-mark-label { fill: #000; }
  .gr-mirror { stroke: #333; }
  .qt-keypad, .tiles-tools, .bal-tokens, .gr-tools, .qt-check, .qt-tag, .blank-pop { display: none !important; }
  .pq .visual, .pq-match-cols, .pq-sort-table, .pq-grid-table, .pq-clock-face, .pq-line-svg { break-inside: avoid; page-break-inside: avoid; }
}
