/* ============================================================
   Shared stylesheet for every version.

   No colour is written here except as a default: each version supplies its own
   palette at runtime, so anything hardcoded would leak one version's brand into
   all the others. If you add a rule, take its colour from a --sga- token.
   ============================================================ */

/* Default palette. Every version overrides these at runtime from its own
   content file, so this block is only what shows before one loads. */
:root {
  color-scheme: light;

  --sga-navy: #16284b;
  --sga-navy-hi: #233a68;
  --sga-red: #ce2233;
  --sga-red-hi: #e03040;

  --sga-background: #f1f3f7;
  --sga-foreground: #16284b;
  --sga-card: #ffffff;
  --sga-primary: var(--sga-navy);
  --sga-primary-hi: var(--sga-navy-hi);
  --sga-primary-fg: #ffffff;
  --sga-secondary: #d9dee7;
  --sga-secondary-fg: #16284b;
  --sga-muted: #e7ebf1;
  --sga-muted-fg: #5c6880;
  --sga-accent: var(--sga-red);
  --sga-accent-fg: #ffffff;
  --sga-border: #c3cbd8;

  /* Right/wrong must stay legible as feedback, so green survives — but the
     "wrong" red is the school red, not a separate one. */
  --sga-correct: #12885f;
  --sga-correct-bg: #e4f6ee;
  --sga-wrong: var(--sga-red);
  --sga-wrong-bg: #fbe9eb;

  --sga-radius: 1.25rem;
  --sga-font-display: "Baloo 2", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --sga-font-sans: "Nunito", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* ---------- stage + phone frame ----------
   Layla's design is an app on a phone, not a web page. On anything wider than a
   phone it sits in a 420x860 device frame floating on the stage; below that it
   goes full-bleed, because there it IS the phone. */

html, body {
  margin: 0;
  background: var(--sga-secondary);
}

.sga-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--sga-secondary);
  padding: 0;
}

.sga-frame {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--sga-background);
}

@media (min-width: 640px) {
  .sga-stage { padding: 1.5rem; }

  .sga-frame {
    height: 860px;
    max-height: calc(100dvh - 3rem);
    max-width: 420px;
    border-radius: 2.75rem;
    border: 8px solid var(--sga-foreground);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .35);
  }
}

/* ---------- shell ---------- */

.sga {
  font-family: var(--sga-font-sans);
  background: var(--sga-background);
  color: var(--sga-foreground);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sga *,
.sga *::before,
.sga *::after { box-sizing: border-box; }

.sga button { font-family: inherit; cursor: pointer; }
.sga button:focus-visible,
.sga input:focus-visible,
.sga a:focus-visible {
  outline: 3px solid var(--sga-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .sga button:active { transform: scale(.95); }
}

/* ---------- header ---------- */

.sga-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border-bottom: 1px solid var(--sga-border);
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(8px);
  padding: 1.25rem 1.25rem .75rem;
}

.sga-header__left { display: flex; align-items: center; gap: .625rem; }

.sga-iconbtn {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: .75rem;
  background: var(--sga-secondary);
  color: var(--sga-secondary-fg);
  font-size: 1.1rem;
}

.sga-levelbadge {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-family: var(--sga-font-display);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.sga-title {
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1;
  color: var(--sga-primary);
  margin: 0;
}

.sga-subtitle {
  margin: .25rem 0 0;
  font-size: .75rem;
  font-weight: 700;
  color: var(--sga-muted-fg);
}

/* ---------- scrollable body ---------- */

.sga-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- the problem card ---------- */

.sga-problem {
  border-radius: 1.75rem;
  padding: 1.25rem;
  color: var(--sga-primary-fg);
  background: linear-gradient(to bottom right, var(--sga-primary), var(--sga-primary-hi));
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .18);
}

.sga-problem__eyebrow {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin-bottom: .5rem;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(255, 255, 255, .85);
}

.sga-problem__cheer { margin: 0; font-size: .875rem; font-weight: 600; line-height: 1.6; }
.sga-problem__q { margin: .5rem 0 0; font-size: .875rem; font-weight: 800; }

.sga-equation {
  margin-top: .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, .95);
  padding: .75rem 1rem;
}

.sga-equation__math {
  font-family: var(--sga-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-equation__meaning {
  text-align: right;
  font-size: .75rem;
  font-weight: 700;
  color: var(--sga-muted-fg);
}

.sga-howbtn {
  margin-top: .75rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: none;
  border-radius: 1rem;
  background: rgba(255, 255, 255, .95);
  padding: .75rem 1rem;
  font-family: var(--sga-font-display);
  font-size: .875rem;
  font-weight: 800;
  color: var(--sga-primary);
}

/* ---------- the student's steps ---------- */

.sga-steps { display: flex; flex-direction: column; gap: .625rem; }

.sga-step {
  display: flex;
  align-items: center;
  gap: .75rem;
  border-radius: 1rem;
  border: 2px solid;
  padding: .75rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.sga-step--ok { border-color: rgba(22, 185, 129, .3); background: var(--sga-correct-bg); }
.sga-step--no { border-color: rgba(216, 31, 51, .4); background: var(--sga-wrong-bg); }

.sga-step__mark {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
}

.sga-step--ok .sga-step__mark { background: var(--sga-correct); }
.sga-step--no .sga-step__mark { background: var(--sga-wrong); }

.sga-step__text {
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 700;
}

.sga-step__tag {
  margin-left: auto;
  font-size: .75rem;
  font-weight: 700;
  color: var(--sga-muted-fg);
}

.sga-step__msg {
  margin: .375rem 0 0 1rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  border-radius: 1rem .375rem 1rem 1rem;
  background: var(--sga-wrong-bg);
  padding: .625rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--sga-wrong);
}

/* ---------- hints ---------- */

.sga-hints {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border: 2px dashed var(--sga-accent);
  border-radius: 1.75rem;
  background: var(--sga-muted);
  padding: 1rem;
}

.sga-hints__eyebrow {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sga-accent);
}

.sga-hints p { margin: 0; font-size: .875rem; font-weight: 600; }

/* ---------- scratch pad ---------- */

.sga-scratch { position: relative; }

.sga-scratch__eyebrow {
  display: flex;
  min-height: 2.5rem;
  align-items: center;
  gap: .375rem;
  margin-bottom: .5rem;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--sga-primary);
}

.sga-scratch__surface { position: relative; }

.sga-scratch__canvas {
  width: 100%;
  height: 18rem;
  touch-action: none;
  border-radius: 1rem;
  /* Solid and themed, not a faint dashed hairline — the first child to use this
     scrolled straight past it looking for somewhere to work. */
  border: 3px solid var(--sga-primary);
  box-shadow: 0 2px 0 var(--sga-border);
  background:
    repeating-linear-gradient(0deg, transparent, transparent 31px, var(--sga-muted) 31px, var(--sga-muted) 32px);
  display: block;
}

.sga-scratch__label {
  position: absolute;
  left: 1rem;
  top: .75rem;
  pointer-events: none;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--sga-muted-fg);
}

.sga-scratch__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.sga-pill {
  display: flex;
  align-items: center;
  gap: .375rem;
  border: none;
  border-radius: 999px;
  background: var(--sga-card);
  box-shadow: 0 0 0 1px var(--sga-border);
  padding: .375rem .75rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--sga-secondary-fg);
}

.sga-swatch {
  width: .875rem;
  height: .875rem;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .1);
}

.sga-picker {
  position: absolute;
  right: .5rem;
  top: 2.5rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  border-radius: 1.75rem;
  background: var(--sga-card);
  box-shadow: 0 0 0 1px var(--sga-border), 0 20px 25px -5px rgba(0, 0, 0, .22);
  padding: 1rem;
}

.sga-picker__wheelwrap { position: relative; width: 168px; height: 168px; }
.sga-picker__wheel { width: 168px; height: 168px; border-radius: 999px; touch-action: none; display: block; }

.sga-picker__dot {
  position: absolute;
  width: 1.25rem;
  height: 1.25rem;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35);
  pointer-events: none;
}

.sga-picker__bright {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  font-size: .75rem;
  font-weight: 700;
  color: var(--sga-muted-fg);
}

.sga-picker__bright input { flex: 1; height: .5rem; }

/* ---------- input dock ---------- */

.sga-dock {
  border-top: 1px solid var(--sga-border);
  background: var(--sga-card);
  padding: .75rem 1.25rem 1.5rem;
  box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, .28);
}

.sga-chips { display: flex; flex-wrap: wrap; gap: .375rem; margin-bottom: .625rem; }

.sga-chip {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: .75rem;
  background: var(--sga-secondary);
  color: var(--sga-secondary-fg);
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 700;
}

.sga-entry { display: flex; align-items: center; gap: .5rem; }

.sga-input {
  height: 3.5rem;
  flex: 1;
  min-width: 0;
  border-radius: 1rem;
  border: 2px solid var(--sga-border);
  background: var(--sga-background);
  padding: 0 1rem;
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--sga-foreground);
}

.sga-input::placeholder {
  font-family: var(--sga-font-sans);
  font-size: 1rem;
  font-weight: 500;
  color: var(--sga-muted-fg);
}

.sga-input:focus { border-color: var(--sga-primary); outline: none; }

.sga-check {
  height: 3.5rem;
  flex-shrink: 0;
  border: none;
  border-radius: 1rem;
  background: var(--sga-primary);
  color: var(--sga-primary-fg);
  padding: 0 1.25rem;
  font-family: var(--sga-font-display);
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .22);
}

.sga-check:disabled { opacity: .5; }

.sga-actions {
  margin-top: .625rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.sga-action {
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  border: none;
  border-radius: .75rem;
  font-weight: 700;
}

.sga-action--hint { background: var(--sga-accent); color: var(--sga-accent-fg); }
.sga-action--undo { background: var(--sga-muted); color: var(--sga-secondary-fg); }
.sga-action:disabled { opacity: .45; }

/* ---------- tap-the-answer board ----------
   Sized for a six-year-old's finger and a six-year-old's reading: the question
   is large, the choices are enormous, and nothing requires the keyboard. */

.sga-problem__cheer--big {
  font-size: 1.0625rem;
  line-height: 1.7;
}

.sga-ask {
  margin-top: .875rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, .95);
  padding: 1rem;
  text-align: center;
  font-family: var(--sga-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.sga-choice {
  min-height: 5rem;
  border: 3px solid var(--sga-border);
  border-radius: 1.5rem;
  background: var(--sga-card);
  color: var(--sga-primary);
  font-family: var(--sga-font-display);
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .10);
}

.sga-choice--right {
  border-color: var(--sga-correct);
  background: var(--sga-correct-bg);
  color: var(--sga-correct);
}

/* A wrong answer fades out of the running rather than shouting. She is six. */
.sga-choice--wrong {
  border-color: var(--sga-border);
  background: var(--sga-muted);
  color: var(--sga-muted-fg);
  opacity: .5;
  text-decoration: line-through;
}

/* ---------- level navigation ---------- */

.sga-nav {
  margin-top: .5rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
}

.sga-nav__btn {
  height: 2.5rem;
  border: 1px solid var(--sga-border);
  border-radius: .75rem;
  background: var(--sga-card);
  color: var(--sga-secondary-fg);
  font-weight: 700;
  font-size: .875rem;
}

.sga-nav__btn--skip { color: var(--sga-muted-fg); }
.sga-nav__btn:disabled { opacity: .4; }

/* ---------- sheets and overlays ---------- */

.sga-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(4px);
}

.sga-overlay--bottom { flex-direction: column; justify-content: flex-end; }
.sga-overlay--center { align-items: center; justify-content: center; overflow: hidden; }

.sga-sheet {
  max-height: 88%;
  overflow-y: auto;
  border-radius: 2rem 2rem 0 0;
  background: var(--sga-card);
  padding: 1rem 1.25rem 2rem;
}

.sga-sheet__grab {
  width: 3rem;
  height: .375rem;
  margin: 0 auto .75rem;
  border-radius: 999px;
  background: var(--sga-border);
}

.sga-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: 1rem;
}

.sga-sheet__head h2 {
  margin: 0;
  font-family: var(--sga-font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-walk { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }

.sga-walk li {
  border: 2px solid var(--sga-secondary);
  border-radius: 1rem;
  background: var(--sga-muted);
  padding: 1rem;
}

.sga-walk__head { display: flex; align-items: center; gap: .625rem; }

.sga-walk__num {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--sga-primary);
  color: var(--sga-primary-fg);
  font-family: var(--sga-font-display);
  font-size: .875rem;
  font-weight: 800;
}

.sga-walk__head h3 {
  margin: 0;
  font-family: var(--sga-font-display);
  font-size: 1rem;
  font-weight: 800;
}

.sga-walk__body { margin: .5rem 0 0; font-size: .875rem; font-weight: 600; line-height: 1.6; }

.sga-walk__math {
  display: inline-block;
  margin-top: .625rem;
  border-radius: .75rem;
  background: var(--sga-card);
  padding: .375rem .75rem;
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-bigbtn {
  margin-top: 1.25rem;
  height: 3rem;
  width: 100%;
  border: none;
  border-radius: 1rem;
  background: var(--sga-primary);
  color: var(--sga-primary-fg);
  font-family: var(--sga-font-display);
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .22);
}

/* ---------- celebration ---------- */

.sga-confetti {
  position: absolute;
  top: 0;
  pointer-events: none;
  animation-name: sga-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.sga-win {
  margin: 0 1.5rem;
  width: 100%;
  max-width: 19rem;
  border-radius: 1.75rem;
  background: var(--sga-card);
  padding: 1.75rem;
  text-align: center;
  box-shadow: 0 0 0 4px var(--sga-secondary), 0 25px 50px -12px rgba(0, 0, 0, .35);
}

.sga-win__trophy { font-size: 3.75rem; }

.sga-win h2 {
  margin: 0;
  font-family: var(--sga-font-display);
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-win__answer {
  margin-top: 1rem;
  border-radius: 1rem;
  background: var(--sga-secondary);
  padding: .75rem 1rem;
}

.sga-win__answer p:first-child {
  margin: 0;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sga-secondary-fg);
}

.sga-win__answer p:last-child {
  margin: 0;
  font-family: var(--sga-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sga-secondary-fg);
}

/* ---------- level picker ---------- */

.sga-levels { display: flex; flex-direction: column; gap: .75rem; }

.sga-levelcard {
  display: block;
  width: 100%;
  text-align: left;
  border: 2px solid var(--sga-border);
  border-radius: 1.5rem;
  background: var(--sga-card);
  padding: 1rem 1.125rem;
  color: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.sga-levelcard__head { display: flex; align-items: center; gap: .625rem; }

.sga-levelcard__num {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-family: var(--sga-font-display);
  font-weight: 800;
}

.sga-levelcard__name {
  margin: 0;
  font-family: var(--sga-font-display);
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-levelcard__diff { margin: .125rem 0 0; font-size: .75rem; font-weight: 700; color: var(--sga-muted-fg); }
.sga-levelcard__tag { margin: .625rem 0 0; font-size: .875rem; font-weight: 600; }

/* ---------- drifting themed icons ----------
   A decorative layer behind everything. Kept faint and slow: a child is reading
   a maths question over the top of it, and anything brighter or faster competes
   with the thing she is meant to be looking at. */

.sga-icons {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.sga-icons__i {
  position: absolute;
  height: auto;
  will-change: transform;
}

/* Content sits above the layer. Without this the icons would swallow taps. */
.sga-frame > .sga { position: relative; z-index: 1; background: transparent; }
.sga-frame { background: var(--sga-background); }

@keyframes sga-drift {
  0%   { transform: translate(0, 0) rotate(0deg); }
  33%  { transform: translate(14px, -18px) rotate(8deg); }
  66%  { transform: translate(-10px, -8px) rotate(-6deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes sga-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-16px); }
}

@keyframes sga-turn {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes sga-throb {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

.sga-drift { animation-name: sga-drift; animation-timing-function: ease-in-out; animation-iteration-count: infinite; }
.sga-bob   { animation-name: sga-bob;   animation-timing-function: ease-in-out; animation-iteration-count: infinite; }
.sga-turn  { animation-name: sga-turn;  animation-timing-function: linear;      animation-iteration-count: infinite; }
.sga-throb { animation-name: sga-throb; animation-timing-function: ease-in-out; animation-iteration-count: infinite; }

@media (prefers-reduced-motion: reduce) {
  .sga-icons__i { animation: none !important; }
}

/* ---------- home ---------- */

/* Home spaces itself with per-block margins, exactly as the v0 design does.
   The shared body gap would stack on top of those and stretch the screen. */
.sga-body--home {
  gap: 0;
  padding: 2.5rem 1.5rem 1.5rem;
}

.sga-hero {
  margin: 1rem 0 0;
  font-family: var(--sga-font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--sga-primary);
  text-wrap: balance;
}

.sga-hero__sub {
  margin: .75rem auto 0;
  max-width: 16rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--sga-muted-fg);
}

.sga-crest {
  width: 6.5rem;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* A red wash over white reads as pink, which is the one thing this palette
   must not do. The fill stays silver; red carries the border and the label. */
.sga-howto {
  margin-top: 1.5rem;
  border: 2px dashed var(--sga-accent);
  border-radius: 1.75rem;
  background: var(--sga-muted);
  padding: 1rem;
}

.sga-howto__eyebrow {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sga-accent);
}

.sga-howto p { margin: .5rem 0 0; font-size: .875rem; font-weight: 600; line-height: 1.6; }
.sga-howto strong { color: var(--sga-primary); font-weight: 800; }

.sga-pick__title {
  margin: 1.75rem 0 0;
  text-align: center;
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 800;
}

.sga-pick__sub {
  margin: 0 0 .75rem;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--sga-muted-fg);
}

.sga-levelbtn {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 1.75rem;
  padding: .875rem 1rem;
  color: #fff;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .2);
}

/* Accent numeral on a primary tile puts both of a version's colours in one mark.
   These must be the themed tokens: --sga-navy and --sga-red are defaults that
   are never overridden per version, so using them here left every version's
   numerals stuck on the default red. */
.sga-levelbtn__num {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 1rem;
  background: var(--sga-accent);
  color: var(--sga-accent-fg);
  font-family: var(--sga-font-display);
  font-size: 1.5rem;
  font-weight: 800;
}

/* The version directory puts a two-letter id in this tile instead of a digit,
   which needs a smaller face to fit the same square. */
.sga-levelbtn__num--code { font-size: 1.05rem; letter-spacing: .02em; }

.sga-suggest {
  font-family: var(--sga-font-display);
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--sga-primary);
}

/* The last level's tile is already the accent, so its numeral inverts to stay legible. */
.sga-levels > .sga-levelbtn:last-child .sga-levelbtn__num {
  background: var(--sga-primary);
  color: var(--sga-primary-fg);
}

.sga-levelbtn__body { min-width: 0; flex: 1; }

.sga-levelbtn__line { display: flex; align-items: center; gap: .5rem; }

.sga-levelbtn__name {
  font-family: var(--sga-font-display);
  font-size: 1rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sga-levelbtn__diff {
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .25);
  padding: .125rem .5rem;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sga-levelbtn__tag {
  display: block;
  margin-top: .125rem;
  font-size: .75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sga-levelbtn__chev { flex-shrink: 0; font-size: 1.5rem; color: rgba(255, 255, 255, .7); }

.sga-footnote {
  border-top: 1px solid var(--sga-border);
  background: var(--sga-card);
  padding: 1rem 1.5rem 2rem;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--sga-muted-fg);
  box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, .28);
}

.sga-footnote a { color: var(--sga-primary); font-weight: 800; margin-left: .5rem; }

/* ---------- about ---------- */

.sga-story p {
  margin: 0 0 .75rem;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.7;
}

.sga-story p:last-child { margin-bottom: 0; }
.sga-story strong { font-weight: 800; }

.sga-signature {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  border-radius: 1.75rem;
  background: var(--sga-card);
  border: 1px solid var(--sga-border);
  padding: 1rem;
}

.sga-signature img { width: 3rem; height: auto; }

.sga-signature p {
  margin: 0;
  font-family: var(--sga-font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-mission {
  margin: 0;
  padding-left: 1.1rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.7;
}

.sga-mission li { margin-bottom: .35rem; }
.sga-mission strong { color: var(--sga-primary); font-weight: 800; }

.sga-crestrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: .5rem 0 1rem;
}

.sga-crestrow img { width: 4rem; height: auto; }

/* ---------- stats ---------- */

.sga-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .5rem; }

.sga-stat {
  border-radius: 1rem;
  background: rgba(255, 255, 255, .95);
  padding: .75rem 1rem;
}

.sga-stat__label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--sga-muted-fg);
}

.sga-stat__value {
  font-family: var(--sga-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sga-primary);
  font-variant-numeric: tabular-nums;
}

/* ---------- sync code ---------- */

.sga-code {
  font-family: var(--sga-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--sga-primary);
}

/* ---------- animations ---------- */

@keyframes sga-pop {
  0% { transform: scale(.85); opacity: 0; }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes sga-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes sga-fall {
  0% { transform: translateY(-12vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 1; }
}

@keyframes sga-bounce-in {
  0% { transform: scale(.5) translateY(20px); opacity: 0; }
  55% { transform: scale(1.08) translateY(0); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes sga-wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

.sga-pop { animation: sga-pop .28s ease-out both; }
.sga-shake { animation: sga-shake .4s ease-in-out both; }
.sga-bounce-in { animation: sga-bounce-in .5s cubic-bezier(.22, 1.2, .36, 1) both; }
.sga-wiggle { animation: sga-wiggle 1.1s ease-in-out infinite; display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  .sga-pop, .sga-shake, .sga-bounce-in, .sga-wiggle, .sga-confetti {
    animation: none !important;
  }
}

/* ---------- encouragement and verses ---------- */

/* The same bubble as a correction, but in the "you got it" colours. */
.sga-step__msg--ok {
  background: var(--sga-correct-bg);
  color: var(--sga-correct);
  border-radius: 1rem .375rem 1rem 1rem;
}

.sga-verse {
  margin: 1rem 0 0;
  padding: .875rem 1rem;
  border-left: 3px solid var(--sga-accent);
  border-radius: 0 .75rem .75rem 0;
  background: var(--sga-muted);
  text-align: left;
}

.sga-verse__text {
  margin: 0;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--sga-foreground);
}

.sga-verse__ref {
  display: block;
  margin-top: .375rem;
  font-size: .75rem;
  font-weight: 800;
  font-style: normal;
  letter-spacing: .04em;
  color: var(--sga-muted-fg);
}

/* ---------- lessons ---------- */

.sga-teach__heading {
  margin: .5rem 0 .625rem;
  font-family: var(--sga-font-display);
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.2;
}

/* Lesson answers are sentences, not numbers, so they stack full width. */
.sga-choices--stack { grid-template-columns: 1fr; }

.sga-choice--wide {
  min-height: 3.25rem;
  font-family: var(--sga-font-sans);
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  padding: .875rem 1rem;
  line-height: 1.4;
}

.sga-learnbtn {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  margin-top: 1.25rem;
  text-align: left;
  border: 2px dashed var(--sga-accent);
  border-radius: 1.5rem;
  background: var(--sga-muted);
  padding: .875rem 1rem;
  color: var(--sga-foreground);
}

.sga-learnbtn__icon { font-size: 1.5rem; }
.sga-learnbtn__body { flex: 1; min-width: 0; }

.sga-learnbtn__title {
  display: block;
  font-family: var(--sga-font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-learnbtn__sub {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--sga-muted-fg);
}

/* A locked lesson reads as "not yet", not as a wall. */
.sga-levelbtn--locked { opacity: .45; }

/* Counting prompts lay objects out in rows, so their line breaks are content.
   Emoji also need room to breathe at this size or they read as a solid block. */
.sga-prewrap { white-space: pre-wrap; }

.sga-problem__cheer--big.sga-prewrap {
  font-size: 1.9rem;
  line-height: 1.6;
  letter-spacing: .14em;
}

/* ---------- read aloud ---------- */

.sga-read { display: flex; flex-direction: column; gap: .5rem; }

.sga-read__w {
  border-radius: .5rem;
  /* Sized to match the highlight so words don't jump when one lights up. */
  padding: .05em .15em;
  margin: 0 -.15em;
  transition: background-color .12s ease, color .12s ease;
}

.sga-read__w--now {
  background: var(--sga-accent);
  color: var(--sga-accent-fg, #fff);
  box-shadow: 0 0 0 .12em var(--sga-accent);
}

.sga-readbtn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 3px solid var(--sga-primary);
  border-radius: 999px;
  background: var(--sga-card);
  color: var(--sga-primary);
  /* A big target: this is pressed by a five-year-old, repeatedly. */
  padding: .7rem 1.35rem;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 800;
  cursor: pointer;
}

.sga-readbtn--on {
  background: var(--sga-primary);
  color: var(--sga-primary-fg, #fff);
}

.sga-readbtn__icon { font-size: 1.35rem; line-height: 1; }

.sga-readbtn__icon--on { animation: sga-pulse 1s ease-in-out infinite; }

@keyframes sga-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* Words in a read-along are tappable too, so they are buttons - but they have
   to sit in the sentence as if they were plain text. */
.sga-read__w {
  display: inline;
  border: none;
  background: none;
  padding: .05em .15em;
  margin: 0 -.15em;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
}

/* The word he has to read, waiting for him to say it. */
.sga-read__w--flash {
  border-radius: .5rem;
  background: var(--sga-accent);
  color: var(--sga-accent-fg, #fff);
  box-shadow: 0 0 0 .12em var(--sga-accent);
  animation: sga-flash 1s ease-in-out infinite;
}

.sga-read__w--got {
  border-radius: .5rem;
  background: var(--sga-accent);
  color: var(--sga-accent-fg, #fff);
  box-shadow: 0 0 0 .12em var(--sga-accent);
  animation: sga-pop-in .45s ease;
}

@keyframes sga-flash {
  0%, 100% { transform: scale(1);    filter: brightness(1); }
  50%      { transform: scale(1.09); filter: brightness(1.18); }
}

@keyframes sga-pop-in {
  0%   { transform: scale(.7); }
  60%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.sga-read__turn {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-read__turn--yes { color: var(--sga-accent); }

.sga-read__mic { font-size: 1.3rem; animation: sga-pulse 1s ease-in-out infinite; }

.sga-read__nudge {
  margin: 0;
  font-size: .8125rem;
  font-weight: 700;
  color: inherit;
  opacity: .75;
}

.sga-read__nope {
  margin: 0;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--sga-muted-fg);
}

@media (prefers-reduced-motion: reduce) {
  .sga-readbtn__icon--on,
  .sga-read__mic,
  .sga-read__w--flash,
  .sga-read__w--got { animation: none; }
}

/* ---------- tap a hard word to hear it ---------- */

.sga-tap { display: flex; flex-direction: column; gap: .5rem; }

.sga-tapword {
  /* Sits inside a sentence, so it has to inherit everything about the text
     and change only the underline. */
  display: inline;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted currentColor;
  text-underline-offset: .22em;
  text-decoration-thickness: .12em;
  cursor: pointer;
}

.sga-tapword--on {
  background: var(--sga-accent);
  color: var(--sga-accent-fg, #fff);
  border-radius: .35rem;
  text-decoration: none;
  box-shadow: 0 0 0 .12em var(--sga-accent);
}

/* Tappable, but not flagged as hard - no underline, just a live word. */
.sga-tapword--plain { text-decoration: none; }

.sga-tapword--demo { cursor: default; }

.sga-tap__hint {
  margin: 0;
  font-size: .8125rem;
  font-weight: 700;
  /* Sits on whatever card it lands in - white, teal, pink - so it has to take
     the card's own text color rather than the muted grey meant for white. */
  color: inherit;
  opacity: .78;
}

/* ---------- silly sounds toggle ---------- */

.sga-silly {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-left: .6rem;
  border: 1px solid var(--sga-border);
  border-radius: 999px;
  background: var(--sga-card);
  color: var(--sga-muted-fg);
  padding: .25rem .6rem;
  font-family: inherit;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
}

.sga-silly:hover { color: var(--sga-primary); border-color: var(--sga-primary); }

/* ---------- grown-up gate before the microphone ---------- */

.sga-gate {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border: 3px solid var(--sga-primary);
  border-radius: 1rem;
  background: var(--sga-card);
  padding: .9rem 1rem;
}

.sga-gate__head {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--sga-primary);
}

.sga-gate__body {
  margin: 0;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--sga-muted-fg);
}

.sga-gate__ok {
  align-self: flex-start;
  border: none;
  border-radius: 999px;
  background: var(--sga-primary);
  color: var(--sga-primary-fg, #fff);
  padding: .55rem 1.1rem;
  font-family: inherit;
  font-size: .9375rem;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- worked-through lessons ---------- */

.sga-guide {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border-radius: 1rem;
  border: 2px solid var(--sga-border);
  background: var(--sga-card);
  padding: .9rem 1rem;
}

.sga-guide__num {
  font-family: inherit;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sga-muted-fg);
}

.sga-guide__say { margin: 0; font-size: 1.0625rem; font-weight: 600; }

.sga-guide__nudge {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: flex-start;
  border-radius: 1rem;
  background: var(--sga-muted);
  padding: .75rem .9rem;
}

.sga-guide__nudge p { margin: 0; font-size: .9375rem; font-weight: 700; }

.sga-guide__hintbtn {
  border: 2px solid var(--sga-accent);
  border-radius: 999px;
  background: var(--sga-card);
  color: var(--sga-foreground);
  padding: .5rem 1rem;
  font-family: inherit;
  font-size: .9375rem;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- the picture of the groups ---------- */

.sga-pic {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
}

.sga-pic__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem;
  width: 100%;
}

.sga-pic__group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: .25rem;
  min-width: 4.25rem;
  min-height: 4.25rem;
  padding: .55rem;
  border-radius: 1rem;
  border: 3px solid var(--sga-primary);
  background: var(--sga-card);
  animation: sga-pop-in .35s ease;
}

/* Groups not yet counted: outlined, so she can see how many are still coming. */
.sga-pic__group--waiting {
  border-style: dashed;
  border-color: var(--sga-border);
  background: transparent;
  animation: none;
}

.sga-pic__thing { font-size: 1.5rem; line-height: 1.1; }

.sga-pic__hole {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--sga-muted);
}

.sga-pic__cap {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--sga-muted-fg);
}

@media (prefers-reduced-motion: reduce) {
  .sga-pic__group { animation: none; }
}

/* ---------- mute, in every header ---------- */

.sga-header__right { display: flex; align-items: center; gap: .5rem; }

.sga-mute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid var(--sga-border);
  border-radius: 999px;
  background: var(--sga-card);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.sga-mute:hover { border-color: var(--sga-primary); }

/* Off is a state worth seeing at a glance, so nobody wonders why it went quiet. */
.sga-mute--off {
  background: var(--sga-muted);
  border-color: var(--sga-muted-fg);
  opacity: .85;
}

.sga-mute:focus-visible { outline: 3px solid var(--sga-primary); outline-offset: 2px; }
