:root {
  --bg-1: #f6fbdc;
  --bg-2: #d9f2a4;
  --ink: #1f3317;
  --ink-soft: #4d6440;
  --card: #ffffff;
  --line: #2f6b14;
  --whole: #7b5cff;
  --part-a: #ff9f1c;
  --part-b: #22b8cf;
  --good: #2fbf4a;
  --ok: #ffc83d;
  --bad: #ff5a5f;
  --pink: #ff5a8a;
  --shadow: 0 6px 0 rgba(31, 51, 23, 0.14);
  --radius: 22px;
  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Varela Round', 'Arial Rounded MT Bold', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

html {
  background: var(--bg-2);
}

body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, var(--bg-1) 0%, var(--bg-2) 70%) no-repeat;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 4px solid #1f6feb;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px clamp(12px, 3vw, 28px) 32px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  font-size: 1.35rem;
  font-weight: 800;
  padding: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.candy-jar,
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 3px solid rgba(47, 107, 20, 0.15);
  box-shadow: 0 3px 0 rgba(31, 51, 23, 0.12);
  font-weight: 800;
}

.candy-jar.bump {
  animation: bump 0.4s ease;
}

/* ---------- Shared bits ---------- */
.panel {
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  padding: 16px 18px 20px;
  margin-top: 18px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 1.2rem;
  font-weight: 800;
  min-height: 56px;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(31, 51, 23, 0.14);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-go {
  background: var(--good);
  color: #fff;
}

.btn-soft {
  background: var(--card);
}

.bubble {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.35;
  box-shadow: var(--shadow);
  min-height: 3.2em;
  display: flex;
  align-items: center;
}

.bubble::after {
  content: '';
  position: absolute;
  border: 12px solid transparent;
}

.bubble-left::after {
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: var(--card);
}

.bubble-down::after {
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  border-top-color: var(--card);
}

.bubble.pop {
  animation: pop 0.35s ease;
}

/* ---------- Home ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(140px, 240px) 1fr;
  align-items: center;
  gap: clamp(16px, 4vw, 40px);
  padding-top: 28px;
}

.hero-mascot {
  border: 0;
  background: none;
  padding: 0;
}

.hero-text h1 {
  margin: 16px 0 4px;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--line);
}

.tagline {
  margin: 0;
  font-size: 1.15rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.grade-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.grade-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  border-radius: 18px;
  border: 3px solid transparent;
  background: var(--card);
  box-shadow: 0 4px 0 rgba(31, 51, 23, 0.14);
  transition: transform 0.1s ease;
}

.grade-chip b {
  font-size: 1.7rem;
  line-height: 1;
}

.grade-chip small {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.grade-chip[aria-checked='true'] {
  background: var(--line);
  color: #fff;
  transform: translateY(-3px);
}

.grade-chip[aria-checked='true'] small {
  color: #d4f59e;
}

.grade-info {
  margin: 12px 0 0;
  font-weight: 700;
  color: var(--ink-soft);
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.mode-card {
  --c: var(--part-a);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  border-bottom: 6px solid var(--c);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}

.mode-card:hover {
  transform: translateY(-4px) rotate(-1deg);
}

.mode-add { --c: var(--part-a); }
.mode-sub { --c: var(--part-b); }
.mode-mul { --c: var(--whole); }
.mode-div { --c: var(--pink); }
.mode-mix { --c: var(--good); }

.mode-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.mode-name {
  font-size: 1.2rem;
  font-weight: 800;
}

.mode-desc {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-align: center;
}

.mode-stars span {
  font-size: 1.3rem;
  color: #d9dfd2;
}

.mode-stars span.on {
  color: #ffbf1f;
}

/* ---------- Game ---------- */
.game-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--card);
  box-shadow: 0 4px 0 rgba(31, 51, 23, 0.14);
  font-size: 1.6rem;
  font-weight: 800;
}

.game-label {
  font-weight: 800;
  font-size: 1.1rem;
}

.progress {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.p-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  border: 3px solid rgba(47, 107, 20, 0.2);
}

.p-current {
  border-color: var(--line);
  transform: scale(1.2);
}

.p-good { background: var(--good); border-color: var(--good); }
.p-ok { background: var(--ok); border-color: var(--ok); }
.p-miss { background: var(--bad); border-color: var(--bad); }

.streak {
  font-weight: 900;
  font-size: 1.2rem;
  background: #fff3d6;
  border-radius: 999px;
  padding: 6px 12px;
}

.game-body {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: clamp(16px, 3vw, 36px);
  margin-top: 16px;
  align-items: start;
}

.game-side {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  padding: 18px clamp(12px, 3vw, 28px) 22px;
  box-shadow: var(--shadow);
}

/* Number bond diagram */
.bond {
  position: relative;
  width: min(100%, 440px);
  aspect-ratio: 420 / 300;
  container-type: inline-size;
}

.bond-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bond-lines line {
  stroke: var(--line);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.6;
}

.node {
  position: absolute;
  width: 29%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border: 5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 6px 0 rgba(31, 51, 23, 0.18);
  user-select: none;
}

.node[data-size='xl'] { font-size: 13cqw; }
.node[data-size='l'] { font-size: 10.5cqw; }
.node[data-size='m'] { font-size: 8cqw; }
.node[data-size='s'] { font-size: 6.4cqw; }
.node[data-size='xs'] { font-size: 5cqw; }

.node-whole {
  left: 50%;
  top: 24%;
  width: 33%;
  background: var(--whole);
}

.node-a {
  left: 21.9%;
  top: 76%;
  background: var(--part-a);
}

.node-b {
  left: 78.1%;
  top: 76%;
  background: var(--part-b);
}

.node.unknown {
  background: #fff;
  color: var(--ink);
  border: 5px dashed var(--line);
  animation: glow 1.6s ease-in-out infinite;
}

.node.unknown.typing {
  border-style: solid;
  color: var(--whole);
}

.node.unknown.solved {
  background: var(--good);
  color: #fff;
  border: 5px solid rgba(0, 0, 0, 0.12);
  animation: none;
}

.node.unknown.revealed {
  background: #fff3d6;
  color: #b76e00;
  border: 5px solid var(--ok);
  animation: none;
}

.node.shake { animation: shake 0.45s ease, glow 1.6s ease-in-out 0.45s infinite; }
.node.nudge { animation: nudge 0.3s ease, glow 1.6s ease-in-out 0.3s infinite; }
.node.celebrate { animation: celebrate 0.6s ease; }

.bond-op {
  position: absolute;
  left: 50%;
  top: 76%;
  transform: translate(-50%, -50%);
  width: 12%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 4px solid var(--line);
  font-size: 7cqw;
  font-weight: 900;
}

/* Equation */
.equation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35em;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.eq-op {
  color: var(--ink-soft);
  min-width: 0.6em;
  text-align: center;
}

.eq-unknown {
  min-width: 1.6em;
  padding: 0 0.25em;
  text-align: center;
  border-radius: 12px;
  border: 3px dashed var(--line);
  background: #fff;
}

.eq-unknown.typing { color: var(--whole); border-style: solid; }
.eq-unknown.solved { background: var(--good); color: #fff; border-color: var(--good); }
.eq-unknown.revealed { background: #fff3d6; color: #b76e00; border-color: var(--ok); }

/* Help and fact family */
.help,
.family {
  width: min(100%, 520px);
  background: var(--card);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 4px 0 rgba(31, 51, 23, 0.1);
  animation: pop 0.3s ease;
}

.help {
  border-left: 6px solid var(--ok);
}

.help-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-badge {
  font-size: 1.25rem;
}

.help-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--ink);
}

.help-visual {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 2px;
}

.help-visual[hidden] {
  display: none;
}

/* Tones tie the pieces in the steps to the same pieces in the picture. */
.tone-1 { --tone: #f08a00; --tone-bg: #ffe7c7; --tone-ink: #a85400; }
.tone-2 { --tone: #14a3b8; --tone-bg: #d3f3f8; --tone-ink: #0d7b8c; }
.tone-3 { --tone: #ff5a8a; --tone-bg: #ffdbe6; --tone-ink: #c2185b; }

/* Steps */
.help-steps {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  counter-reset: step;
}

.step {
  counter-increment: step;
  position: relative;
  padding: 8px 10px 8px 42px;
  border-radius: 14px;
  background: #f7f9ef;
}

.step::before {
  content: counter(step);
  position: absolute;
  left: 9px;
  top: 9px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ok);
  font-weight: 900;
  font-size: 0.85rem;
}

.step-new {
  background: #fff6d8;
  animation: step-in 0.35s ease;
}

@keyframes step-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.step-say {
  margin: 2px 0 0;
  font-weight: 700;
  line-height: 1.35;
}

.step-say + .step-row {
  margin-top: 6px;
}

.step-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 6px;
  font-size: 1.35rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.r-num,
.r-op,
.r-eq,
.r-ask,
.r-sep {
  height: 1.55em;
  line-height: 1.55em;
}

.r-num {
  padding: 0 0.28em;
  border-radius: 9px;
  white-space: nowrap;
}

.r-num[class*='tone-'] {
  background: var(--tone-bg, transparent);
  color: var(--tone-ink, inherit);
}

.r-op,
.r-eq {
  color: var(--ink-soft);
}

.r-sep {
  margin-left: -4px;
  color: var(--ink-soft);
}

.r-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.r-ask {
  min-width: 1.6em;
  padding: 0 0.25em;
  text-align: center;
  border: 3px dashed var(--line);
  border-radius: 10px;
  background: #fff;
  line-height: calc(1.55em - 6px);
}

.r-ask.done {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

/* The "?" is ready for the answer once every box is filled in. */
.r-ask.active {
  border-style: solid;
  border-color: var(--whole);
  color: var(--whole);
  animation: ask-pulse 1.6s ease-in-out infinite;
}

/* Boxes the child fills in */
.r-box,
.r-slot {
  height: 1.55em;
  min-width: 1.9em;
  padding: 0 0.25em;
  border-radius: 10px;
  text-align: center;
  white-space: nowrap;
  line-height: calc(1.55em - 6px);
}

.r-blank {
  border: 3px dashed #c9cfbd;
  background: #fff;
}

.r-blank.active {
  border: 3px solid #e3a500;
  background: #fff1a8;
  color: #6a4b00;
  animation: blank-pulse 1.4s ease-in-out infinite;
}

.r-done {
  border: 3px solid var(--good);
  background: var(--tone-bg, #fff);
  color: var(--tone-ink, var(--ink));
}

.r-shown {
  border: 3px solid var(--ok);
  background: #fff3d6;
  color: #b76e00;
}

/* A part of the split that fills itself in once its box further down is solved. */
.r-slot {
  display: inline-block;
  border: 3px dashed var(--tone, var(--line));
  background: var(--tone-bg, #fff);
  opacity: 0.75;
}

.r-box.shake { animation: box-shake 0.45s ease; }
.r-box.nudge { animation: box-nudge 0.3s ease; }

@keyframes blank-pulse {
  50% { box-shadow: 0 0 0 5px rgba(255, 200, 61, 0.45); }
}

@keyframes ask-pulse {
  50% { box-shadow: 0 0 0 5px rgba(123, 92, 255, 0.2); }
}

@keyframes box-shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes box-nudge {
  50% { transform: scale(1.12); }
}

.step-current {
  box-shadow: inset 0 0 0 2px rgba(255, 200, 61, 0.9);
}

/* A number with legs down to its parts: 13 → 10 and 3 */
.r-split {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: calc(var(--n) * 2.3em);
}

.r-legs {
  width: 70%;
  height: 16px;
  overflow: visible;
}

.r-legs line {
  stroke: var(--line);
  stroke-width: 2.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.r-parts {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  justify-items: center;
  gap: 6px;
  width: 100%;
}

/* Ten-frames */
.frames {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.tenframe {
  display: grid;
  grid-template-columns: repeat(5, 30px);
  grid-auto-rows: 30px;
  border: 3px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.cell {
  display: grid;
  place-items: center;
  border: 1px solid rgba(47, 107, 20, 0.25);
}

.dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: relative;
}

.dot-base { background: var(--whole); }
.dot-e0 { border: 3px dashed #a9b39c; }
.dot-t1 { background: #f08a00; }
.dot-t2 { background: #14a3b8; }
.dot-t3 { background: #ff5a8a; }
.dot-e1 { border: 3px dashed #f08a00; }
.dot-e2 { border: 3px dashed #14a3b8; }
.dot-e3 { border: 3px dashed #ff5a8a; }
.dot-x1 { background: #ffe7c7; }
.dot-x2 { background: #d3f3f8; }
.dot-x3 { background: #ffdbe6; }

.dot-x1::after,
.dot-x2::after,
.dot-x3::after {
  content: '×';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
  line-height: 1;
}

.dot-x1::after { color: #a85400; }

.dot-pop { animation: dot-pop 0.45s ease; }

@keyframes dot-pop {
  0% { transform: scale(0.3); opacity: 0.3; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.dot-x2::after { color: #0d7b8c; }
.dot-x3::after { color: #c2185b; }

/* Equal groups */
.groups {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 132px;
  padding: 6px;
  border-radius: 12px;
  background: #f1ecff;
  border: 2px solid var(--whole);
}

.group .dot {
  width: 16px;
  height: 16px;
}

/* Number line */
.numberline {
  width: 100%;
  max-width: 480px;
  height: auto;
  overflow: visible;
  font-family: var(--font);
}

.nl-axis {
  stroke: var(--line);
  stroke-width: 3;
  stroke-linecap: round;
}

.nl-tick {
  stroke: var(--line);
  stroke-width: 2.5;
}

.nl-point {
  font-size: 15px;
  font-weight: 800;
  fill: var(--ink);
}

.nl-start {
  fill: var(--whole);
}

.nl-hop {
  fill: none;
  stroke: var(--tone);
  stroke-width: 3.5;
  stroke-linecap: round;
}

.nl-new {
  animation: draw 0.5s ease;
}

.nl-hop-label {
  font-size: 15px;
  font-weight: 900;
  fill: var(--tone-ink);
}

.nl-ask {
  fill: var(--line);
}

.numberline marker path {
  fill: var(--tone);
}

@keyframes draw {
  from { opacity: 0; }
}

/* Area model */
.area {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 6px;
  width: min(100%, 400px);
}

.area-side {
  padding-bottom: 18px;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ink-soft);
  align-self: center;
  margin-top: 26px;
}

.area-cols {
  display: flex;
  gap: 4px;
}

.area-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-basis: 0;
  min-width: 0;
}

.area-top {
  padding: 0 0.4em;
  border-radius: 8px;
  font-weight: 900;
  font-size: 1.1rem;
  background: var(--tone-bg);
  color: var(--tone-ink);
}

.area-top.area-ask {
  background: #fff;
  color: var(--line);
  border: 2px dashed var(--line);
}

.area-box {
  position: relative;
  width: 100%;
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: 10px;
  border: 3px solid var(--tone);
  background: var(--tone-bg);
}

.area-dots {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 3px;
  justify-items: center;
}

.area-dots .dot {
  width: 10px;
  height: 10px;
  background: var(--tone);
}

.area-sum {
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--tone-ink);
}

.area-new {
  animation: pop 0.3s ease;
}

.has-dots .area-sum {
  position: absolute;
  padding: 0 0.35em;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(31, 51, 23, 0.15);
}

/* Place-value chart */
.pv {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.pv-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(30px, 46px));
  gap: 3px;
}

.pv-head {
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
  color: var(--ink-soft);
}

.pv-cell {
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f1f5e8;
  font-size: 1.3rem;
  font-weight: 900;
}

/* The decimal comma sits after the ones digit when the chart has decimals. */
.pv-cell.pv-ones {
  position: relative;
}

.pv-dec .pv-cell.pv-ones::after {
  content: ',';
  position: absolute;
  right: -5px;
  bottom: -2px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink);
}

:lang(en) .pv-dec .pv-cell.pv-ones::after {
  content: '.';
}

.pv-head.pv-ones {
  color: var(--ink);
}

.pv-from {
  background: #e8e2ff;
  color: var(--whole);
}

.pv-to.tone-1 {
  background: var(--tone-bg);
  color: var(--tone-ink);
}

.pv-new {
  background: #fff;
  border: 2px dashed var(--line);
  color: var(--line);
}

.pv-gone {
  text-decoration: line-through;
  text-decoration-thickness: 3px;
  opacity: 0.45;
}

.pv-arrow {
  font-weight: 900;
  color: var(--ink-soft);
}

.btn-skip {
  display: block;
  margin: 10px 0 0 auto;
  padding: 6px 14px;
  border: 2px solid rgba(47, 107, 20, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-skip:hover { background: rgba(47, 107, 20, 0.06); }
.btn-skip:active { transform: translateY(1px); }
.btn-skip[hidden] { display: none; }

.family h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--ink-soft);
}

.family-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fact {
  padding: 6px 12px;
  border-radius: 12px;
  background: #eef9e2;
  font-weight: 800;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

/* Answer input */
.answer-area {
  width: 100%;
  display: flex;
  justify-content: center;
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: min(100%, 520px);
}

.choice {
  min-height: 84px;
  border: 0;
  border-radius: 22px;
  background: var(--card);
  font-size: 2.3rem;
  font-weight: 900;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}

.choice:active:not(:disabled) {
  transform: translateY(3px);
}

.choices.for-blank .choice:not(:disabled) {
  background: #fff7cc;
  box-shadow: inset 0 0 0 3px #e3a500, var(--shadow);
}

.choice.wrong {
  background: #ffe1e2;
  color: var(--bad);
  text-decoration: line-through;
}

.choice.right {
  background: var(--good);
  color: #fff;
  opacity: 1;
}

.choice:disabled {
  cursor: default;
}

.choice:disabled:not(.right) {
  opacity: 0.55;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 330px);
}

.key {
  min-height: 60px;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(31, 51, 23, 0.14);
}

.key:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(31, 51, 23, 0.14);
}

.key-fn {
  background: #eef9e2;
}

.key-blank {
  visibility: hidden;
}

.key-check {
  grid-column: span 2;
  background: var(--good);
  color: #fff;
  font-size: 1.4rem;
}

.key:disabled {
  opacity: 0.5;
  cursor: default;
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* The Danish multiplication dot (·) is tiny in most fonts – enlarge it. */
.op-mul {
  display: inline-block;
}

:lang(da) .op-mul {
  transform: scale(1.7);
}

:lang(da) .mode-mul .mode-icon,
:lang(da) .bond-op {
  font-size: 0;
}

:lang(da) .mode-mul .mode-icon {
  position: relative;
}

:lang(da) .mode-mul .mode-icon::after,
:lang(da) .bond-op::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Results ---------- */
.results {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 0 24px;
}

.results-mascot {
  width: min(60vw, 260px);
}

.results h2 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  margin: 8px 0;
}

.stars {
  display: flex;
  gap: 8px;
}

.star {
  font-size: clamp(3rem, 12vw, 4.5rem);
  color: #d9dfd2;
  animation: star-in 0.5s ease both;
}

.star.on {
  color: #ffbf1f;
  text-shadow: 0 4px 0 #d18e00;
}

.results-score,
.results-candy {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 6px 0;
}

.results-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Mascot ---------- */
.mascot svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.mascot .variant {
  display: none;
}

.mascot[data-mood='idle'] .show-idle,
.mascot[data-mood='happy'] .show-happy,
.mascot[data-mood='cheer'] .show-cheer,
.mascot[data-mood='eat'] .show-eat,
.mascot[data-mood='sad'] .show-sad,
.mascot[data-mood='think'] .show-think {
  display: inline;
}

.mascot .m-figure,
.mascot .m-arm,
.mascot .m-sprout,
.mascot .m-eyes,
.mascot .m-pupils {
  transform-box: fill-box;
}

.mascot .m-figure { transform-origin: 50% 100%; }
.mascot .m-arm-l { transform-origin: 80% 20%; }
.mascot .m-arm-r { transform-origin: 20% 20%; }
.mascot .m-sprout { transform-origin: 50% 100%; animation: sway 3s ease-in-out infinite; }
.mascot .m-eyes { transform-origin: 50% 50%; animation: blink 4.5s infinite; }
.mascot .m-pupils { transition: transform 0.3s ease; }

.mascot[data-mood='idle'] .m-figure { animation: breathe 2.4s ease-in-out infinite; }
.mascot[data-mood='sad'] .m-pupils { transform: translate(-4px, 6px); }
.mascot[data-mood='think'] .m-pupils { transform: translate(5px, -7px); }

.mascot.m-replay[data-mood='happy'] .m-figure { animation: hop 0.5s ease 2; }
.mascot.m-replay[data-mood='cheer'] .m-figure { animation: hop 0.6s ease infinite; }
.mascot.m-replay[data-mood='eat'] .m-figure { animation: wobble 0.3s ease-in-out 3; }
.mascot.m-replay[data-mood='sad'] .m-figure { animation: droop 0.6s ease forwards; }

.mascot[data-mood='happy'] .m-arm-l,
.mascot[data-mood='cheer'] .m-arm-l { animation: wave-l 0.5s ease-in-out infinite alternate; }
.mascot[data-mood='happy'] .m-arm-r,
.mascot[data-mood='cheer'] .m-arm-r { animation: wave-r 0.5s ease-in-out infinite alternate; }

.mascot[data-mood='eat'] .m-mouth-open { animation: chomp-open 0.3s steps(1) infinite; }
.mascot[data-mood='eat'] .m-mouth-chomp { animation: chomp-close 0.3s steps(1) infinite; }

/* ---------- Effects ---------- */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.fly-candy {
  position: fixed;
  font-size: 44px;
  line-height: 1;
  will-change: transform;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation-name: fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* ---------- Keyframes ---------- */
@keyframes pop { 0% { transform: scale(0.85); opacity: 0.4; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes glow { 50% { box-shadow: 0 0 0 10px rgba(123, 92, 255, 0.18), 0 6px 0 rgba(31, 51, 23, 0.18); } }
@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%); }
  20% { transform: translate(calc(-50% - 10px), -50%); }
  40% { transform: translate(calc(-50% + 10px), -50%); }
  60% { transform: translate(calc(-50% - 6px), -50%); }
  80% { transform: translate(calc(-50% + 6px), -50%); }
}
@keyframes nudge { 50% { transform: translate(-50%, -50%) scale(1.08); } }
@keyframes celebrate { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.25) rotate(-6deg); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes star-in { from { transform: scale(0) rotate(-90deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes breathe { 50% { transform: scale(1.02, 0.97); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scale(1); } 30% { transform: translateY(0) scale(1.06, 0.92); } 60% { transform: translateY(-16%) scale(0.96, 1.05); } }
@keyframes wobble { 25% { transform: rotate(-4deg) scale(1.04, 0.96); } 75% { transform: rotate(4deg) scale(0.97, 1.03); } }
@keyframes droop { to { transform: scale(1.04, 0.92); } }
@keyframes sway { 50% { transform: rotate(8deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
@keyframes wave-l { from { transform: rotate(0deg); } to { transform: rotate(50deg); } }
@keyframes wave-r { from { transform: rotate(0deg); } to { transform: rotate(-50deg); } }
@keyframes chomp-open { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes chomp-close { 0% { opacity: 0; } 50% { opacity: 1; } }
@keyframes fall {
  to { transform: translate(var(--drift), 105vh) rotate(720deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .mode-cards { grid-template-columns: repeat(3, 1fr); }
  .grade-picker { grid-template-columns: repeat(4, 1fr); }

  .game-body { grid-template-columns: 1fr; }
  .game-side {
    position: static;
    flex-direction: row-reverse;
    align-items: center;
    gap: 22px;
  }
  .game-mascot { width: 110px; flex-shrink: 0; }
  .game-side .bubble { flex: 1; }
  .bubble-down::after {
    left: -20px;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: var(--card);
  }
}

@media (max-width: 560px) {
  .hero { grid-template-columns: 120px 1fr; }
  .mode-cards { grid-template-columns: repeat(2, 1fr); }
  .mode-mix { grid-column: span 2; }
  .choices { grid-template-columns: repeat(2, 1fr); }
  .progress { width: 100%; justify-content: center; margin-left: 0; order: 5; }
  .p-dot { width: 14px; height: 14px; }
  .candy-jar, .pill-btn { padding: 4px 10px; }
  .brand span { display: none; }
  .help, .family { padding: 10px 12px; }
  .step { padding-left: 38px; }
  .step-row { font-size: 1.15rem; }
  .tenframe { grid-template-columns: repeat(5, 26px); grid-auto-rows: 26px; }
  .dot { width: 18px; height: 18px; }
  .pv-grid { grid-template-columns: repeat(var(--cols), minmax(24px, 40px)); }
  .nl-point, .nl-hop-label { font-size: 20px; }
}

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