:root {
  --bg1: #fff4d6;
  --bg2: #d6f5ff;
  --purple: #8b5cf6;
  --pink: #f472b6;
  --orange: #fb923c;
  --green: #34d399;
  --blue: #38bdf8;
  --yellow: #fbbf24;
  --red: #f87171;
  --ink: #3a2e5c;
  --card: #ffffff;
  --radius-lg: 28px;
  --radius-xl: 40px;
}

* { box-sizing: border-box; }

/* Bundled rather than loaded from Google Fonts: no third-party request (see
   legal.html#privacy) and it works offline. Variable font, so one file per
   script covers weights 500-800. License: assets/fonts/OFL.txt. */
@font-face {
  font-family: 'Rubik';
  font-weight: 300 900;
  font-display: swap;
  src: url(../assets/fonts/rubik-hebrew.woff2) format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Rubik';
  font-weight: 300 900;
  font-display: swap;
  src: url(../assets/fonts/rubik-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Pinch-zoom is allowed (accessibility), but a toddler's fast taps must not
   double-tap-zoom the page. */
html { touch-action: manipulation; }

/* Gear panel "Animations: off". Near-zero rather than `none`, so code waiting
   on `animationend` (confetti, milestone) still cleans up. */
html.no-motion *, html.no-motion *::before, html.no-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
html.no-motion .floaters { display: none; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  font-family: 'Rubik', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 10%, var(--bg2), transparent 45%),
              radial-gradient(circle at 85% 20%, var(--bg1), transparent 40%),
              linear-gradient(160deg, #fef9f0 0%, #eaf7ff 100%);
  min-height: 100vh;
  position: relative;
}

html[dir="rtl"] body {
  direction: rtl;
}

/* ---------- floating background shapes ---------- */
.floaters {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.floaters .shape {
  position: absolute;
  font-size: 2.6rem;
  opacity: 0.35;
  animation: floatUp linear infinite;
  bottom: -10%;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.35; }
  90% { opacity: 0.35; }
  100% { transform: translateY(-115vh) rotate(360deg); opacity: 0; }
}

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  gap: 12px;
  flex-wrap: wrap;
}

.home-link {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 16px;
}
.home-link:hover { background: rgba(139, 92, 246, 0.08); }
.home-icon { font-size: 1.6rem; }

.lang-switch {
  display: flex;
  gap: 8px;
  background: #ffffffaa;
  padding: 6px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(90, 60, 150, 0.12);
}

.lang-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.lang-btn:hover { transform: scale(1.05); }
.lang-btn.active {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: #fff;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.4);
}

/* ---------- app-wide settings (topbar gear) ---------- */
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Anchors the shared .cd-range-panel popover under the gear, the same way
   .cd-settings does inside a game. */
.app-settings {
  display: flex;
  position: relative;
}

/* The anchor here is just the 42px gear, and an absolutely positioned box only
   gets the width available inside its containing block — which would squeeze
   the panel into a 42px column. Inside a game the same panel is anchored to a
   full-width row, so it never needed this. */
.app-settings .cd-range-panel {
  width: max-content;
  max-width: min(360px, calc(100vw - 32px));
}

.cd-range-chip.danger {
  background: #ffe4e6;
  color: #9f1239;
}

/* ---------- main / views ---------- */
main#app {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 24px 60px;
}

.view { animation: viewIn 0.35s ease; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.tagline {
  text-align: center;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  font-weight: 700;
  color: var(--purple);
  margin: 10px 0 4px;
}

.menu-title {
  text-align: center;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  margin: 6px 0 30px;
}

/* ---------- game grid / cards ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 26px;
}

.game-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
  box-shadow: 0 10px 24px rgba(90, 60, 150, 0.14);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.game-card:hover, .game-card:focus-visible {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 30px rgba(90, 60, 150, 0.22);
  outline: none;
}
.game-card:active { transform: translateY(-2px) scale(0.99); }

.game-card .icon {
  font-size: 3.4rem;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.08));
}
.game-card .title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
}
.game-card .desc {
  font-size: 0.95rem;
  color: #6b6483;
  font-weight: 500;
}

.game-card .modes {
  display: flex;
  gap: 6px;
  font-size: 1.1rem;
  line-height: 1;
}
.game-card .modes span {
  background: #f1ecfb;
  border-radius: 999px;
  padding: 4px 8px;
}

.game-card.locked {
  opacity: 0.55;
  cursor: default;
}
.game-card.locked:hover { transform: none; box-shadow: 0 10px 24px rgba(90, 60, 150, 0.14); }
.game-card .soon-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--yellow);
  color: #6b4700;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- in-game header ---------- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  background: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(90, 60, 150, 0.14);
  color: var(--ink);
  transition: transform 0.15s ease;
}
.back-btn:hover { transform: scale(1.05); }

.score-badge {
  font-weight: 800;
  font-size: 1.15rem;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #6b3f00;
  padding: 8px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(251, 146, 60, 0.35);
}

.game-container {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: clamp(20px, 4vw, 44px);
  box-shadow: 0 14px 30px rgba(90, 60, 150, 0.16);
  min-height: 420px;
}

/* ---------- counting dots game ---------- */
.cd-settings {
  display: flex;
  justify-content: flex-end;
  position: relative;
  margin-bottom: 6px;
}

.cd-settings-toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #f3edff;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(90, 60, 150, 0.12);
  transition: transform 0.15s ease;
}
.cd-settings-toggle:hover { transform: rotate(25deg) scale(1.05); }

.cd-range-panel {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 8px 20px rgba(90, 60, 150, 0.18);
  position: absolute;
  top: 52px;
  inset-inline-end: 0;
  z-index: 5;
  max-width: min(360px, 90vw);
}
.cd-range-panel.open { display: flex; }

.cd-setting-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cd-range-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: #6b6483;
  white-space: nowrap;
}

.cd-range-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cd-range-chip {
  font-family: inherit;
  font-weight: 700;
  border: none;
  background: #f3edff;
  color: var(--ink);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}
.cd-range-chip.active {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: #fff;
}

.game-prompt {
  text-align: center;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 800;
  margin: 0 0 24px;
}

.game-mat {
  background: repeating-linear-gradient(135deg, #f6f0ff, #f6f0ff 12px, #efe6ff 12px, #efe6ff 24px);
  border: 4px dashed #c9b6f7;
  border-radius: 30px;
  min-height: 180px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 16px;
  padding: 26px;
  margin: 0 auto 34px;
  max-width: 720px;
}

.shape-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.2));
  animation: dotPop 0.4s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes dotPop {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes shapeJump {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-16px) scale(1.2); }
  55% { transform: translateY(0) scale(0.92); }
  75% { transform: translateY(-6px) scale(1.05); }
}

.cd-options {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 3vw, 28px);
  flex-wrap: wrap;
}

.cd-option {
  width: clamp(84px, 18vw, 110px);
  height: clamp(84px, 18vw, 110px);
  border-radius: 50%;
  border: none;
  font-family: inherit;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.15), 0 12px 20px rgba(0,0,0,0.15);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cd-option:nth-child(1) { background: linear-gradient(160deg, #60d1f7, var(--blue)); }
.cd-option:nth-child(2) { background: linear-gradient(160deg, #ff9fc4, var(--pink)); }
.cd-option:nth-child(3) { background: linear-gradient(160deg, #ffd36b, var(--orange)); }

.cd-option:hover { transform: translateY(-3px) scale(1.04); }
.cd-option:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 6px 10px rgba(0,0,0,0.15);
}

.is-correct {
  animation: correctPulse 0.6s ease;
}
@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.25); }
}

.is-wrong {
  animation: shake 0.5s ease;
  opacity: 0.45;
  pointer-events: none;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

/* Marks the right answer after repeated misses, so a child who can't read the
   feedback text still has somewhere obvious to go. Keeps pulsing (rather than
   playing once) because a toddler may look up well after the tap. */
.is-hint {
  position: relative;
  animation: hintPulse 1.1s ease-in-out infinite;
  outline: 5px solid var(--yellow);
  outline-offset: 4px;
}
@keyframes hintPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
/* Two rings rippling outward from the answer, half a beat apart — movement at
   the edge of the eye is what pulls a toddler's look across the board. */
.is-hint::before,
.is-hint::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 4px solid var(--yellow);
  pointer-events: none;
  animation: hintRing 1.6s ease-out infinite;
}
.is-hint::after { animation-delay: 0.8s; }
@keyframes hintRing {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.45); opacity: 0; }
}

.feedback-text {
  text-align: center;
  min-height: 2.4rem;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 800;
  margin-top: 22px;
  transition: opacity 0.2s ease;
}
.feedback-text.correct-text { color: #047857; }
.feedback-text.wrong-text {
  color: #c2410c;
  animation: feedbackPop 0.45s cubic-bezier(.34,1.56,.64,1);
}
.feedback-text.hint-text {
  color: var(--purple);
  animation: feedbackPop 0.45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes feedbackPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- colors game ---------- */
.color-mat { min-height: 220px; }

.color-blob {
  width: clamp(120px, 24vw, 160px);
  height: clamp(120px, 24vw, 160px);
  border-radius: 50%;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18), inset 0 -10px 16px rgba(0, 0, 0, 0.12), inset 0 6px 12px rgba(255, 255, 255, 0.5);
  animation: dotPop 0.5s cubic-bezier(.34,1.56,.64,1) both;
}

.col-options {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 3vw, 24px);
  flex-wrap: wrap;
}

.col-option {
  min-width: 120px;
  padding: 18px 22px;
  border-radius: 24px;
  border: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.15), 0 12px 20px rgba(0,0,0,0.15);
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.col-option:hover { transform: translateY(-3px) scale(1.04); }
.col-option:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 6px 10px rgba(0,0,0,0.15);
}

/* ---------- abc letters game ---------- */
.abc-mat { min-height: 260px; }

.abc-letter {
  width: clamp(160px, 34vw, 220px);
  height: clamp(160px, 34vw, 220px);
  border-radius: 40px;
  border: none;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(4rem, 16vw, 7rem);
  line-height: 1;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(0,0,0,0.15), 0 16px 26px rgba(0,0,0,0.18);
  text-shadow: 0 3px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.abc-letter:hover { transform: translateY(-4px) scale(1.03); }
.abc-letter:active {
  transform: translateY(5px) scale(0.97);
  box-shadow: 0 5px 0 rgba(0,0,0,0.15), 0 8px 14px rgba(0,0,0,0.18);
}
.abc-letter.abc-pop { animation: correctPulse 0.5s ease; }

/* The colors game's tile carries no glyph, so it is round rather than a
   rounded square -- a blank letter tile reads as a missing letter, a circle
   reads as "a color". The faint rim is what keeps the white tile from
   dissolving into the card behind it; it is too weak to tint any other color. */
.abc-letter.color-tile {
  border-radius: 50%;
  border: 3px solid rgba(15, 23, 42, 0.10);
}

.abc-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.abc-progress {
  font-weight: 700;
  color: #6b6483;
  font-size: 1rem;
  min-width: 64px;
  text-align: center;
}

.abc-next {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  padding: 14px 26px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(139, 92, 246, 0.35);
  transition: transform 0.15s ease;
}
.abc-next:hover { transform: scale(1.05); }
.abc-next:active { transform: scale(0.97); }

.mic-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--blue));
  border: none;
  padding: 14px 26px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(56, 189, 248, 0.3);
}
.mic-status.listening {
  opacity: 1;
  animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 14px rgba(56, 189, 248, 0.35); }
  50% { transform: scale(1.08); box-shadow: 0 6px 20px rgba(56, 189, 248, 0.55); }
}

/* ---------- confetti ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.confetti-piece {
  position: absolute;
  top: -40px;
  font-size: 1.8rem;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(400deg); opacity: 0.9; }
}

/* ---------- player chip + every-10-stars milestone ---------- */
.player-chip {
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  background: #ffffffaa;
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(90, 60, 150, 0.12);
  white-space: nowrap;
}
.milestone-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.milestone-pop {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: milestonePop 2.6s ease-in-out forwards;
}
.milestone-icon { font-size: clamp(7rem, 30vw, 12rem); line-height: 1; }
.milestone-count {
  font-weight: 800;
  font-size: clamp(2rem, 8vw, 3.5rem);
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #6b3f00;
  padding: 6px 28px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(251, 146, 60, 0.5);
}
@keyframes milestonePop {
  0%   { transform: scale(0) rotate(-200deg); opacity: 0; }
  25%  { transform: scale(1.25) rotate(15deg); opacity: 1; }
  35%  { transform: scale(0.95) rotate(-6deg); }
  45%, 55%, 65% { transform: scale(1.05) rotate(0); }
  50%, 60% { transform: scale(1) rotate(0); }
  85%  { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.3) translateY(-60vh); opacity: 0; }
}

@media (max-width: 480px) {
  .topbar { padding: 14px 16px; }
  main#app { padding: 6px 14px 40px; }
}

/* ---------- animal letters game ---------- */
/* Shares the letter tile with the ABC game, shrunk: here the letter is the
   question rather than the whole screen, so it has to leave room for three
   animal cards under it. Defined after `.abc-letter` so it wins on order. */
.an-mat {
  min-height: 0;
  max-width: 380px;
  padding: 20px;
  margin-bottom: 26px;
}

.an-letter {
  width: clamp(110px, 22vw, 150px);
  height: clamp(110px, 22vw, 150px);
  border-radius: 32px;
  font-size: clamp(3rem, 10vw, 4.6rem);
}

.an-options {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2.4vw, 24px);
}

/* One object repeated three times: same edges, same padding, the picture always
   in the same place, so the only thing that differs between the cards is the
   animal itself. */
.an-card {
  --an-disc: #ffffff;
  flex: 0 1 clamp(96px, 27vw, 184px);
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 8px 14px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), 0 12px 20px rgba(90, 60, 150, 0.16);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: dotPop 0.42s cubic-bezier(.34,1.56,.64,1) both;
}
.an-card:nth-child(1) { background: linear-gradient(165deg, #eaf7ff, #cfeaff); }
.an-card:nth-child(2) { background: linear-gradient(165deg, #fff0f7, #ffdcea); }
.an-card:nth-child(3) { background: linear-gradient(165deg, #fff8e2, #ffe9b8); }

.an-card:hover, .an-card:focus-visible {
  transform: translateY(-4px) scale(1.03);
  outline: none;
}
.an-card:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12), 0 6px 10px rgba(90, 60, 150, 0.16);
}

.an-art {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 3px 4px rgba(90, 60, 150, 0.16));
}

/* The name is the answer, so it stays hidden while the card is still a
   question — the child has to recognise the animal, not read it. It keeps its
   space the whole time, so uncovering it doesn't shift the row. */
.an-name {
  font-weight: 800;
  font-size: clamp(0.85rem, 2.4vw, 1.15rem);
  color: var(--ink);
  line-height: 1.15;
  text-align: center;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.an-card.revealed .an-name {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .an-card { animation: none; }
  .an-name { transition: none; transform: none; }
}

/* ---------- grouping game ---------- */
/* The cards are the Animal Letters card (same edges, same padding, the picture
   always in the same place) laid out on a grid instead of a row, because four
   or six of them have to sit on a phone screen without shrinking to nothing. */
.gr-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: center;
  gap: clamp(10px, 2.6vw, 22px);
  max-width: 400px;
  margin: 0 auto;
}
.gr-board.is-wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px;
}

.gr-card {
  position: relative;
}
/* .an-card colours the first three; the rest of the board continues the set. */
.gr-card:nth-child(4) { background: linear-gradient(165deg, #eefbe8, #d6f0c4); }
.gr-card:nth-child(5) { background: linear-gradient(165deg, #f4eeff, #e2d6ff); }
.gr-card:nth-child(6) { background: linear-gradient(165deg, #e6f8f5, #c6ece6); }

/* Once the board is settled, the family members get a ring and a tick, so the
   child sees which pictures went together. */
.gr-card.gr-picked {
  outline: 5px solid var(--green);
  outline-offset: 3px;
  transform: translateY(-4px);
}
.gr-check {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 28px;
  text-align: center;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.34,1.56,.64,1);
}
.gr-card.gr-picked .gr-check {
  opacity: 1;
  transform: none;
}

/* The family's name is the answer, so it stays hidden while the board is still
   a question. It keeps its space the whole time, so uncovering it doesn't shove
   the feedback line down. */
.gr-group {
  text-align: center;
  font-weight: 800;
  font-size: clamp(1.1rem, 2.8vw, 1.5rem);
  color: var(--purple);
  min-height: 1.9rem;
  margin: 20px 0 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.gr-group.revealed {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .gr-check { transition: none; }
  .gr-group { transition: none; transform: none; }
}

/* ---------- maze game ---------- */
/* One square board: the walls are an SVG underneath, the goal, hint ring and
   player are cell-sized boxes positioned over it in percentages, so the whole
   thing scales with the screen. */
.mz-board {
  position: relative;
  width: min(100%, 460px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, #eefbe8, #d6f0c4);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), 0 12px 20px rgba(90, 60, 150, 0.16);
  touch-action: none;
  user-select: none;
}
.mz-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.mz-wall {
  fill: none;
  stroke: #5b3fa8;
  stroke-width: 1.4;
  stroke-linecap: round;
}
.mz-path {
  fill: none;
  stroke: #f9a8d4;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mz-goal, .mz-player, .mz-board .mz-hint {
  position: absolute;
  pointer-events: none;
}
.mz-goal svg { display: block; width: 100%; height: 100%; }
.mz-goal { animation: hintPulse 1.8s ease-in-out infinite; }
.mz-player {
  --an-disc: #ffffff;
  transition: left 0.12s ease, top 0.12s ease;
}
.mz-board .mz-hint {
  border-radius: 50%;
  border: 6px solid transparent;
  background: rgba(251, 191, 36, 0.35);
  background-clip: padding-box;
  outline: none;
}
.mz-board .mz-hint[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mz-player { transition: none; }
  .mz-goal { animation: none; }
}

/* ---------- rhymes game ---------- */
/* The word to rhyme with is an Animal Letters card on the letter's mat, a
   little larger than the three answers under it. */
.rh-target {
  flex: 0 0 clamp(120px, 32vw, 180px);
}

/* ---------- shadows game ---------- */
/* The shadow is the answer's own picture, blacked out, with the white disc
   behind it hidden so only the outline is left. `.lit` (added when the round
   settles) fades the colour back in. Both filter lists have the same shape so
   the change animates instead of jumping. */
.sh-shadow { cursor: default; }
.sh-shadow:hover { transform: none; }
.sh-shadow .an-art {
  filter: brightness(0) opacity(0.82);
  transition: filter 0.6s ease;
}
.sh-shadow .an-art > circle:first-child {
  opacity: 0;
  transition: opacity 0.6s ease;
}
.sh-shadow.lit .an-art { filter: brightness(1) opacity(1); }
.sh-shadow.lit .an-art > circle:first-child { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .sh-shadow .an-art, .sh-shadow .an-art > circle:first-child { transition: none; }
}

/* ---------- connect the dots ---------- */
/* One square board: the picture in the middle, the line layer on top of it and
   the dots on top of that, all in the same 0-100 coordinates. Dot positions
   are geometry, not layout, so they stay physical left/top in RTL too. */
.ct-mat {
  min-height: 0;
  max-width: 440px;
  padding: 16px;
}
.ct-board {
  --an-disc: #ffffff;
  position: relative;
  width: min(78vw, 400px);
  aspect-ratio: 1;
  margin: 0 auto;
}
.ct-pic {
  position: absolute;
  inset: 17%;
}
/* Starts as a faint shadow of the picture (disc hidden, as in Shadows) and
   fills in with colour when the ring closes. */
.ct-pic .an-art {
  filter: brightness(0) opacity(0.12);
  transition: filter 0.8s ease;
}
.ct-pic .an-art > circle:first-child { opacity: 0; transition: opacity 0.8s ease; }
.ct-board.lit .ct-pic .an-art { filter: brightness(1) opacity(1); }
.ct-board.lit .ct-pic .an-art > circle:first-child { opacity: 1; }
.ct-board.lit .ct-pic { animation: correctPulse 0.6s ease 0.3s; }

.ct-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.ct-lines line {
  stroke: var(--purple);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.ct-dot {
  position: absolute;
  width: clamp(44px, 12vw, 56px);
  height: clamp(44px, 12vw, 56px);
  translate: -50% -50%;
  border-radius: 50%;
  border: 4px solid var(--purple);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(1.1rem, 3.6vw, 1.5rem);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  animation: dotPop 0.42s cubic-bezier(.34,1.56,.64,1) both;
}
.ct-dot.done {
  background: var(--purple);
  color: #fff;
  animation: correctPulse 0.4s ease;
}
.ct-dot.ct-wiggle { animation: shake 0.5s ease; }
.ct-dot.is-hint { animation: hintPulse 1.1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .ct-dot, .ct-dot.done, .ct-dot.ct-wiggle, .ct-board.lit .ct-pic { animation: none; }
  .ct-pic .an-art, .ct-pic .an-art > circle:first-child { transition: none; }
}

/* ---------- which has more ---------- */
/* Three plates in a row where they fit, wrapping to two-over-one on a phone
   so each stays big enough to count (flex, so RTL just mirrors them). The food sits on a
   fixed grid of spots in plate %, same size on every plate, so the amount is
   the only thing that differs. */
.mo-plates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px clamp(12px, 3vw, 32px);
}
.mo-plate {
  --an-disc: transparent;
  flex: 0 0 min(200px, calc(50% - 8px));
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: 50%;
  animation: dotPop 0.42s cubic-bezier(.34,1.56,.64,1) both;
  transition: transform 0.12s ease;
}
.mo-plate:hover, .mo-plate:focus-visible { transform: translateY(-4px) scale(1.03); outline: none; }
.mo-plate:active { transform: translateY(4px) scale(0.97); }
.mo-plate.is-hint { outline: none; animation: hintPulse 1.1s ease-in-out infinite; }
.mo-plate.is-hint::before, .mo-plate.is-hint::after { inset: 0 0 auto; aspect-ratio: 1; border-radius: 50%; }
.mo-plate.is-hint .mo-dish { box-shadow: 0 0 0 6px var(--yellow), 0 8px 0 rgba(0, 0, 0, 0.1); }
.mo-plate.mo-miss { animation: shake 0.5s ease; }

/* White dish with a rim: an inset ring rather than a border, so the food spots
   (in %) measure from the same box at every size. */
.mo-dish {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 62%, #f1ecff 63%, #ffffff 74%);
  box-shadow: inset 0 0 0 3px #e3dafc, 0 8px 0 rgba(0, 0, 0, 0.1), 0 12px 20px rgba(90, 60, 150, 0.16);
}
.mo-food {
  position: absolute;
  width: 24%;
  translate: -50% -50%;
}
.mo-food .an-art { display: block; width: 100%; height: auto; }

/* Hidden until the round settles: the child compares by eye, not by reading. */
.mo-count {
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.mo-plate.revealed .mo-count { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .mo-plate, .mo-plate.mo-miss { animation: none; }
}

/* ---------- memory ---------- */
/* Each card is a 3D flip: back and face stacked in .mp-inner, which turns
   180° on `.flipped`. Columns come from --mp-cols per level. */
.mp-board {
  display: grid;
  grid-template-columns: repeat(var(--mp-cols, 3), minmax(0, 1fr));
  gap: clamp(8px, 2.4vw, 18px);
  max-width: calc(var(--mp-cols, 3) * 150px);
  margin: 0 auto;
}
.mp-card {
  --an-disc: #ffffff;
  aspect-ratio: 1;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 600px;
  border-radius: var(--radius-lg);
  animation: dotPop 0.42s cubic-bezier(.34,1.56,.64,1) both;
}
.mp-card.is-hint { animation: hintPulse 1.1s ease-in-out infinite; }
.mp-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}
.mp-card.flipped .mp-inner { transform: rotateY(180deg); }
.mp-back, .mp-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  backface-visibility: hidden;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12), 0 10px 16px rgba(90, 60, 150, 0.16);
}
/* The back: a purple card with a dotted pattern, the same on every card so
   nothing gives a picture away. */
.mp-back {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.35) 18%, transparent 20%) 0 0 / 22% 22%,
    linear-gradient(160deg, #a78bfa, var(--purple));
}
.mp-face {
  transform: rotateY(180deg);
  background: linear-gradient(165deg, #fff8e2, #ffe9b8);
  padding: 8%;
}
.mp-face .an-art { display: block; width: 100%; height: 100%; }
/* The pulse goes on the button, not the face: the face's transform is what
   keeps it turned towards the viewer. */
.mp-card.matched { cursor: default; animation: correctPulse 0.6s ease; }
.mp-card.matched .mp-face { background: linear-gradient(165deg, #e6fbef, #c4f1d6); }

@media (prefers-reduced-motion: reduce) {
  .mp-card, .mp-card.is-hint, .mp-card.matched { animation: none; }
  .mp-inner { transition: none; }
}

/* ---------- what comes next ---------- */
/* The pattern row wraps rather than shrinking, so tiles stay a size a toddler
   can read even when the hard level shows nine or more. */
.pt-mat {
  min-height: 0;
  max-width: 640px;
  padding: 16px;
  margin-bottom: 22px;
}
.pt-row {
  --an-disc: #ffffff;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.pt-tile {
  flex: 0 0 clamp(48px, 13vw, 72px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: dotPop 0.42s cubic-bezier(.34,1.56,.64,1) both;
}
.pt-tile .an-art { width: 100%; height: auto; }
/* The gap: a dashed empty disc with a question mark, until the answer drops
   into it. */
.pt-gap {
  border: 3px dashed var(--purple);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--purple);
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 2rem);
}
.pt-gap.filled {
  border-color: transparent;
  background: none;
  animation: correctPulse 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
  .pt-tile, .pt-gap.filled { animation: none; }
}

/* ---------- puzzle ---------- */
/* One play area: the board square on top, the tray square below it, pieces
   positioned over both in % of the area (physical left/top: this is geometry,
   so it doesn't flip in RTL). The aspect ratio matches AREA_RATIO in
   puzzleGame.js. Sized by height as well as width so the whole thing fits on
   a phone without scrolling mid-drag. */
.pz-area {
  --an-disc: #ffffff;
  position: relative;
  /* ~360px is the topbar, prompt and feedback line above and below it. */
  width: min(76vw, calc((100vh - 360px) / 2.1), 340px);
  min-width: 150px;
  aspect-ratio: 1 / 2.1;
  margin: 0 auto;
  touch-action: none;
}
.pz-board {
  position: absolute;
  inset: 0 0 auto;
  aspect-ratio: 1;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 3px #e3dafc;
}
/* The picture to build, as a faint shadow (as in Connect the Dots). */
.pz-guide { position: absolute; inset: 0; }
.pz-guide .an-art { display: block; width: 100%; height: 100%; filter: brightness(0) opacity(0.1); }
.pz-guide .an-art > circle:first-child { opacity: 0; }
.pz-slot {
  position: absolute;
  border: 2px dashed rgba(139, 92, 246, 0.35);
  border-radius: 6px;
}
.pz-slot.is-hint { outline-offset: -4px; animation: none; }

.pz-piece {
  position: absolute;
  overflow: hidden;
  border-radius: 6px;
  background: #fff8e2;
  box-shadow: inset 0 0 0 2px #ffffff, 0 4px 10px rgba(90, 60, 150, 0.25);
  cursor: grab;
  touch-action: none;
  transition: left 0.25s ease, top 0.25s ease, box-shadow 0.2s ease;
}
.pz-piece.dragging {
  z-index: 5;
  cursor: grabbing;
  transition: none;
  box-shadow: inset 0 0 0 2px #ffffff, 0 10px 20px rgba(90, 60, 150, 0.35);
}
.pz-piece.placed {
  cursor: default;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}
.pz-piece.is-hint { position: absolute; }
.pz-art { position: absolute; }
.pz-art .an-art { display: block; width: 100%; height: 100%; }
/* Finished: the seams close and the picture pulses as one. */
.pz-area.done .pz-piece { box-shadow: none; border-radius: 0; }
.pz-area.done .pz-board { animation: correctPulse 0.6s ease; }

@media (prefers-reduced-motion: reduce) {
  .pz-piece { transition: none; }
  .pz-area.done .pz-board { animation: none; }
}

/* Keyboard focus (see App.ui.arrowFocus). An id selector so it outranks the
   per-game `:focus-visible { outline: none }` hover styles. */
#app :focus-visible {
  outline: 5px solid var(--purple);
  outline-offset: 4px;
}

/* ---------- legal links under the menu ---------- */
.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-top: 40px;
  font-size: 0.9rem;
}
.legal-links a { color: #6b6483; }
