/* ==================== LOCAL HEBREW STORYBOOK FONTS ==================== */
@font-face {
  font-family: 'NoamFredoka';
  src: url('../assets/fonts/Fredoka-Variable.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'NoamRubik';
  src: url('../assets/fonts/Rubik-Variable.ttf') format('truetype');
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: 'NoamVarela';
  src: url('../assets/fonts/VarelaRound-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

/* ==================== DESIGN TOKENS ==================== */
:root {
  --font-display: 'NoamFredoka', 'NoamVarela', 'Arial Rounded MT Bold', sans-serif;
  --font-body: 'NoamRubik', 'NoamFredoka', system-ui, -apple-system, sans-serif;

  --bg-top: #E6F6FF;
  --bg-bottom: #FFF8E6;
  --surface: #FFFFFF;
  --surface-warm: #FFFDF7;
  --surface-tint: rgba(255, 253, 245, 0.92);
  --ink: #2D3642;
  --ink-soft: #596778;
  --border-soft: rgba(70, 58, 40, 0.12);
  --shadow-card: 0 10px 28px rgba(60, 48, 28, 0.11);
  --shadow-btn: 0 6px 0 rgba(0, 0, 0, 0.16);

  /* Consistent Number Color Coding for Visual Memory */
  --n1: #FF595E; --n1-d: #C9363B;
  --n2: #1982C4; --n2-d: #0E5887;
  --n3: #FF9F1C; --n3-d: #C47100;
  --n4: #4CAF50; --n4-d: #2E7A31;
  --n5: #8E54E9; --n5-d: #602DB5;

  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-pill: 999px;
}

/* Theme Palettes */
body.theme-apples {
  --bg-top: #D7F2FF;
  --bg-bottom: #FFF8E3;
}
body.theme-frogs {
  --bg-top: #F7EBCC;
  --bg-bottom: #E8F4D9;
}
body.theme-dinosaurs {
  --bg-top: #FFEAD0;
  --bg-bottom: #E6F7DF;
}
body.theme-planets {
  --bg-top: #1E2859;
  --bg-bottom: #2E3D7A;
  --surface: #27346B;
  --surface-warm: #2B3975;
  --surface-tint: rgba(34, 46, 98, 0.92);
  --ink: #FFF9EB;
  --ink-soft: #D3DCFF;
  --border-soft: rgba(255, 255, 255, 0.18);
  --shadow-card: 0 12px 32px rgba(8, 12, 34, 0.42);
}

/* ==================== RESET & TOUCH ERGONOMICS ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: background 0.45s ease, color 0.3s ease;
}

button, input {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img, svg {
  display: block;
  max-width: 100%;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* Ambient Decorative Background */
.bg-scene {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-scene::before,
.bg-scene::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: 0.32;
}
.bg-scene::before {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, #FFE680 0%, transparent 70%);
  top: -80px;
  left: -60px;
}
.bg-scene::after {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #A9E69B 0%, transparent 70%);
  bottom: -140px;
  right: -90px;
}
body.theme-planets .bg-scene::before {
  background: radial-gradient(circle, #6E54B5 0%, transparent 70%);
  opacity: 0.42;
}
body.theme-planets .bg-scene::after {
  background: radial-gradient(circle, #2EC4B6 0%, transparent 70%);
  opacity: 0.25;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
}

/* ==================== APP SHELL & SCREENS ==================== */
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1120px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  animation: fadeSlideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.screen.active {
  display: flex;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Consistent Number Toy-Block Colors */
.num-color-1 { background: var(--n1); color: #FFF; box-shadow: 0 7px 0 var(--n1-d); }
.num-color-2 { background: var(--n2); color: #FFF; box-shadow: 0 7px 0 var(--n2-d); }
.num-color-3 { background: var(--n3); color: #FFF; box-shadow: 0 7px 0 var(--n3-d); }
.num-color-4 { background: var(--n4); color: #FFF; box-shadow: 0 7px 0 var(--n4-d); }
.num-color-5 { background: var(--n5); color: #FFF; box-shadow: 0 7px 0 var(--n5-d); }

/* ==================== TOP BARS & SHARED BUTTONS ==================== */
.top-bar, .game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-circle, .icon-circle-lg, .icon-circle-sm, .nav-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--border-soft);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.icon-circle, .nav-home-btn { width: 54px; height: 54px; font-size: 26px; }
.icon-circle-lg { width: 62px; height: 62px; font-size: 30px; background: #FFCA3A; border-color: #E0A800; box-shadow: 0 5px 0 #C49000; }
.icon-circle-sm { width: 42px; height: 42px; font-size: 20px; }

.icon-circle:active, .nav-home-btn:active, .icon-circle-lg:active, .icon-circle-sm:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
}
.icon-circle.muted { opacity: 0.65; }

/* Parent Long-Press Pill */
.parent-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-tint);
  border: 2px solid var(--border-soft);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}
.hold-ring-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hold-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.hold-ring-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.1);
  stroke-width: 3.5;
}
.hold-ring-fill {
  fill: none;
  stroke: #FF9F1C;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 95;
  stroke-dashoffset: 95;
}
.hold-icon { font-size: 17px; }
.parent-pill.holding { transform: scale(0.97); }

/* Mini Theme Switcher on Game Headers */
.mini-theme-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-tint);
  padding: 5px 8px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-soft);
}
.mini-theme-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, background 0.2s ease;
}
.mini-theme-btn.active {
  background: #FFE58F;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(255, 159, 28, 0.35);
}

/* Action Buttons */
.big-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: #FFF;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.big-action-btn:active {
  transform: translateY(4px);
}
.btn-go {
  background: #4CAF50;
  box-shadow: 0 6px 0 #2E7D32;
}
.btn-go:active { box-shadow: 0 2px 0 #2E7D32; }
.btn-warm {
  background: #FF9F1C;
  box-shadow: 0 6px 0 #C97500;
}
.btn-warm:active { box-shadow: 0 2px 0 #C97500; }

.soft-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 3px solid var(--border-soft);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}
.soft-pill-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); }

/* Submode Tabs */
.submode-tabs {
  display: flex;
  gap: 8px;
  background: var(--surface-tint);
  padding: 6px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-soft);
}
.subtab {
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.2s ease;
}
.subtab.active {
  background: #FF9F1C;
  color: #FFF;
  box-shadow: 0 4px 0 #C97500;
}

/* ==================== HOME SCREEN ==================== */
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding-bottom: 10px;
}

.home-hero {
  display: grid;
  grid-template-columns: 128px 1fr 136px;
  align-items: center;
  gap: 12px;
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 14px 20px;
  box-shadow: var(--shadow-card);
}

.hero-frog {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  animation: gentleBob 3.4s ease-in-out infinite;
}
.hero-puddle { animation-delay: 0.7s; }
.hero-frog img {
  width: 118px;
  height: 128px;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.14));
  transition: transform 0.2s ease;
}
.hero-frog:hover img { transform: scale(1.06); }
.hero-frog.frog-jump {
  animation: frogLeap 0.65s cubic-bezier(0.22, 1.4, 0.36, 1);
}

@keyframes gentleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes frogLeap {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-28px) scale(1.12) rotate(-5deg); }
  65% { transform: translateY(-10px) scale(1.05) rotate(4deg); }
  100% { transform: translateY(0) scale(1); }
}

.speech-bubble {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) scale(0.7);
  background: #FFF9D6;
  color: #3A2E1B;
  border: 3px solid #FFCA3A;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.speech-bubble.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px) scale(1);
}

.home-title-box {
  text-align: center;
}
.greeting-btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: var(--radius-lg);
}
.greeting-btn:active { transform: scale(0.97); }
.home-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}
.home-title .js-child-name {
  color: #FF595E;
}
body.theme-planets .home-title .js-child-name {
  color: #FFD166;
}
.home-subtitle {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: clamp(17px, 2.3vw, 22px);
  color: var(--ink-soft);
  font-weight: 500;
}

/* Theme Picker */
.theme-picker-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.theme-picker-label {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-soft);
}
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 3px solid var(--border-soft);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  transition: transform 0.14s ease, border-color 0.2s ease, background 0.2s ease;
}
.theme-btn .theme-emoji { font-size: 26px; }
.theme-btn.active {
  background: #FFF3C4;
  color: #2D3642;
  border-color: #FF9F1C;
  box-shadow: 0 5px 0 #D98200;
  transform: translateY(-2px);
}
.theme-btn:active { transform: translateY(3px); }

/* 3 Giant Core Game Cards */
.game-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 16px 18px;
  min-height: 225px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 4px solid var(--border-soft);
  box-shadow: 0 9px 0 rgba(0, 0, 0, 0.11), var(--shadow-card);
  text-align: center;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s ease;
}
.game-card:hover { transform: translateY(-4px); }
.game-card:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12); }

.card-learn { border-color: #FFB4B6; }
.card-count { border-color: #A8E0A9; }
.card-match { border-color: #D2B8FF; }
body.theme-planets .card-learn { border-color: #FF7579; }
body.theme-planets .card-count { border-color: #6FD673; }
body.theme-planets .card-match { border-color: #B48AF7; }

.card-badge {
  position: absolute;
  top: -14px;
  right: 18px;
  min-width: 48px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-art {
  width: 100%;
  height: 98px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mini-preview-single .item-svg,
.mini-preview-single .item-img { width: 86px; height: 86px; object-fit: contain; }

.mini-preview-trio {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.mini-preview-trio .item-svg,
.mini-preview-trio .item-img { width: 62px; height: 62px; object-fit: contain; }

.mini-preview-match {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.mini-num-pill {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--n2);
  color: #FFF;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--n2-d);
}
.mini-dashed-line {
  width: 42px;
  height: 0;
  border-top: 5px dashed #FF9F1C;
}
.mini-pair {
  display: flex;
  gap: 2px;
}
.mini-pair .item-svg,
.mini-pair .item-img { width: 46px; height: 46px; object-fit: contain; }

.card-text h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  color: var(--ink);
}
.card-text p {
  margin: 4px 0 0;
  font-size: 16px;
  color: var(--ink-soft);
  font-weight: 500;
}

/* Bonus Frog Theater Banner */
.frog-theater-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, #FFF3CC 0%, #E7F7D4 100%);
  border: 3px solid #8CC665;
  box-shadow: 0 6px 0 #5E973D;
  color: #2A3C24;
  transition: transform 0.14s ease;
}
.frog-theater-banner:active { transform: translateY(4px); box-shadow: 0 2px 0 #5E973D; }
.theater-thumb {
  width: 82px;
  height: 60px;
  object-fit: contain;
  flex-shrink: 0;
}
.theater-banner-text {
  flex: 1;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.theater-banner-text strong {
  font-family: var(--font-display);
  font-size: 21px;
}
.theater-banner-text span {
  font-size: 15px;
  opacity: 0.85;
}
.theater-play-pill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #4CAF50;
  color: #FFF;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #2E7D32;
  flex-shrink: 0;
}

/* ==================== MODE 1: LEARN NUMBERS ==================== */
.learn-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.learn-stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  align-items: center;
  gap: 24px;
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.learn-number-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.giant-number-btn {
  position: relative;
  width: clamp(190px, 28vw, 250px);
  height: clamp(190px, 28vw, 250px);
  border-radius: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.giant-number-btn::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 20px;
  right: 20px;
  height: 26%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.giant-number-btn:active { transform: scale(0.94) translateY(5px); }
.giant-number-btn.speaking-pop {
  animation: giantPulse 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes giantPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.13) rotate(-3deg); }
  75% { transform: scale(0.97) rotate(2deg); }
  100% { transform: scale(1); }
}

.giant-num-digit {
  font-family: var(--font-display);
  font-size: clamp(128px, 19vw, 175px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.16);
}

/* Radiating Sound Waves on Giant Number */
.sound-waves {
  position: absolute;
  inset: -14px;
  pointer-events: none;
  opacity: 0;
}
.sound-waves.on { opacity: 1; }
.sound-waves i {
  position: absolute;
  inset: 0;
  border-radius: 52px;
  border: 5px solid currentColor;
  opacity: 0;
}
.sound-waves.on i:nth-child(1) { animation: waveRing 0.9s ease-out infinite; }
.sound-waves.on i:nth-child(2) { animation: waveRing 0.9s ease-out 0.3s infinite; }
.sound-waves.on i:nth-child(3) { animation: waveRing 0.9s ease-out 0.6s infinite; }

@keyframes waveRing {
  0% { transform: scale(0.96); opacity: 0.65; }
  100% { transform: scale(1.18); opacity: 0; }
}

.learn-word-pill {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  padding: 6px 28px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 3px solid var(--border-soft);
  color: var(--ink);
}

.learn-items-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.learn-companion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  padding: 8px 18px 8px 12px;
  border-radius: var(--radius-pill);
  border: 3px solid var(--border-soft);
}
.buddy-avatar { width: 66px; height: 66px; object-fit: contain; }
.buddy-avatar-md { width: 72px; height: 72px; object-fit: contain; cursor: pointer; pointer-events: auto; }
.buddy-avatar-sm { width: 58px; height: 58px; object-fit: contain; }
.buddy-avatar-xs { width: 44px; height: 44px; object-fit: contain; }

.buddy-caption {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
}

.learn-items-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 150px;
}

.learn-item-chip {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 26px;
  background: var(--surface);
  border: 3px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
  transition: transform 0.16s ease;
}
.learn-item-chip .item-svg,
.learn-item-chip .item-img { width: 88px; height: 88px; object-fit: contain; }
.learn-item-chip.hop {
  animation: itemHop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.learn-item-idx {
  position: absolute;
  top: -10px;
  left: -8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}

@keyframes itemHop {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-22px) scale(1.14); }
  100% { transform: translateY(0) scale(1); }
}

.learn-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.num-picker-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
}
.num-pick-btn {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  opacity: 0.72;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.num-pick-btn.active {
  opacity: 1;
  transform: scale(1.14) translateY(-4px);
  outline: 4px solid #FFF;
}

/* Submode B: Find the Number */
.find-prompt-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 14px 22px;
  box-shadow: var(--shadow-card);
}
.find-prompt-text {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.6vw, 36px);
  font-weight: 700;
}

.find-hint-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 70px;
}
.hint-mini-item {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hint-mini-item .item-svg,
.hint-mini-item .item-img { width: 60px; height: 60px; object-fit: contain; }
.hint-mini-item.hop { animation: itemHop 0.6s ease; }

.find-choices {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.find-choice-card {
  width: clamp(150px, 24vw, 220px);
  height: clamp(170px, 26vw, 240px);
  border-radius: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease;
}
.find-choice-card:active { transform: translateY(5px) scale(0.96); }
.find-digit {
  font-family: var(--font-display);
  font-size: clamp(96px, 15vw, 145px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.16);
}
.find-choice-card.correct-win {
  animation: winBounce 0.75s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: 7px solid #FFE66D;
}
.find-choice-card.hint-glow {
  animation: hintPulse 1.1s ease-in-out infinite;
  outline: 7px solid #FFE66D;
}
.gentle-wobble {
  animation: gentleWobble 0.45s ease;
}

@keyframes winBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.18) rotate(-4deg); }
  70% { transform: scale(1.06) rotate(3deg); }
  100% { transform: scale(1.08); }
}
@keyframes hintPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
@keyframes gentleWobble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-2deg); }
  75% { transform: translateX(8px) rotate(2deg); }
}

/* ==================== MODE 2: SLOW COUNTING ==================== */
.count-target-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-tint);
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-soft);
}
.pills-caption {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
  padding-inline: 4px;
}
.target-pill {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  transition: all 0.16s ease;
}
.target-pill.active {
  background: #4CAF50;
  color: #FFF;
  box-shadow: 0 3px 0 #2E7D32;
}

.voice-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 3px solid #8E54E9;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(142, 84, 233, 0.35);
  transition: all 0.18s ease;
}
.voice-toggle-btn.active {
  background: #8E54E9;
  color: #FFF;
  box-shadow: 0 4px 0 #5C28B0;
  animation: micGlow 1.6s ease-in-out infinite;
}
@keyframes micGlow {
  0%, 100% { box-shadow: 0 4px 0 #5C28B0, 0 0 0 0 rgba(142, 84, 233, 0.45); }
  50% { box-shadow: 0 4px 0 #5C28B0, 0 0 0 12px rgba(142, 84, 233, 0); }
}

.count-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  min-height: 470px;
}

.count-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.count-showcase-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px;
  border-radius: var(--radius-xl);
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.count-big-badge {
  width: 118px;
  height: 118px;
  border-radius: 32px;
  background: #E8EEF5;
  color: #6B7B8E;
  font-family: var(--font-display);
  font-size: 74px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
}
.count-big-badge.pop-in {
  animation: badgePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgePop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.count-word-text {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
}

/* Slow Pacing & Voice Companion Panel */
.pace-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  transition: border-color 0.25s ease, background 0.25s ease;
}
.pace-panel.is-pacing {
  border-color: #FFCA3A;
}
.pace-panel.is-listening {
  border-color: #8E54E9;
}
.pace-panel.gentle-nudge {
  animation: gentleWobble 0.4s ease;
}

.pace-buddy-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pace-status-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pace-label {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
}
.pace-bar-track {
  width: 100%;
  height: 14px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
body.theme-planets .pace-bar-track { background: rgba(255, 255, 255, 0.16); }
.pace-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
}
.pace-panel.is-pacing .pace-bar-fill {
  background: linear-gradient(90deg, #FF9F1C, #FFCA3A);
}
.pace-panel.is-listening .pace-bar-fill {
  background: linear-gradient(90deg, #8E54E9, #C77DFF);
}

/* Live Voice Equalizer */
.voice-meter-box {
  background: rgba(142, 84, 233, 0.1);
  border: 2px solid rgba(142, 84, 233, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-meter-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}
.voice-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9E9E9E;
  flex-shrink: 0;
}
.voice-dot.live {
  background: #FF595E;
  animation: pulseDot 1s ease-in-out infinite;
}
.voice-dot.hearing {
  background: #4CAF50;
  transform: scale(1.3);
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.voice-bars {
  height: 34px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
}
.voice-bars span {
  width: 9px;
  height: 20%;
  border-radius: 6px;
  background: linear-gradient(180deg, #8E54E9, #FF9F1C);
  transition: height 0.08s ease;
}

.voice-skip-btn {
  align-self: center;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  background: #4CAF50;
  color: #FFF;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 3px 0 #2E7D32;
}

/* Interactive Count Scene */
.count-scene-wrap {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 5px solid var(--surface);
  box-shadow: var(--shadow-card);
  min-height: 430px;
  background: #DFF3FF;
}
.count-scene-bg, .count-scene-bg .scene-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.count-items-layer {
  position: absolute;
  inset: 0;
}

.count-item {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(92px, 13vw, 128px);
  height: clamp(92px, 13vw, 128px);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.count-item-visual {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.22));
}
.count-item-visual .item-svg,
.count-item-visual .item-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.count-item.is-inviting .count-item-visual {
  animation: inviteFloat 2.4s ease-in-out var(--float-delay, 0s) infinite;
}
.count-item.is-inviting:hover { transform: translate(-50%, -50%) scale(1.1); }
.count-item.is-inviting:active { transform: translate(-50%, -50%) scale(0.92); }

/* Calm sleeping state during anti-rushing slow pacing */
.count-item.is-sleeping {
  opacity: 0.45;
  filter: saturate(0.55);
  transform: translate(-50%, -50%) scale(0.92);
}

.count-item.is-counted {
  transform: translate(-50%, -50%) scale(1.06);
  filter: drop-shadow(0 0 14px rgba(255, 224, 102, 0.95));
}
.count-item.is-counted .count-item-visual {
  animation: countedPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.count-item.bounce-again .count-item-visual,
.book-image-frame.bounce-again {
  animation: itemHop 0.48s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.count-item-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes inviteFloat {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-9px) rotate(1.5deg); }
}
@keyframes countedPop {
  0% { transform: scale(0.75); }
  45% { transform: scale(1.25) rotate(-6deg); }
  100% { transform: scale(1); }
}

/* Giant Floating Number Burst */
.floating-pop-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  width: 170px;
  height: 170px;
  border-radius: 44px;
  border: 6px solid #FFFFFF;
  font-family: var(--font-display);
  font-size: 112px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
}
.floating-pop-number.pop-animate {
  animation: floatPopBurst 1.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes floatPopBurst {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.45); }
  20% { opacity: 1; transform: translate(-50%, -54%) scale(1.12); }
  75% { opacity: 1; transform: translate(-50%, -56%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -72%) scale(0.92); }
}

/* ==================== MODE 3: LINE DRAWING MATCH ==================== */
.match-instruction-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-tint);
  border: 3px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: clamp(17px, 2.4vw, 23px);
  font-weight: 700;
}

.match-stage {
  position: relative;
  flex: 1;
  min-height: 450px;
  display: grid;
  grid-template-columns: minmax(120px, 195px) 1fr minmax(175px, 290px);
  align-items: stretch;
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  touch-action: none; /* Crucial: smooth finger-drawing on iPad/iPhone without scrolling! */
}

.match-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}
.match-active-path {
  stroke-width: 11;
  stroke-linecap: round;
  stroke-dasharray: 14 10;
  filter: url(#line-glow);
}
.match-drag-tip {
  stroke: #FFFFFF;
  stroke-width: 4;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.match-drag-tip.visible { opacity: 1; }

.line-draw-in {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: drawStroke 0.45s ease-out forwards;
}
@keyframes drawStroke {
  to { stroke-dashoffset: 0; }
}

.match-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 18px;
  z-index: 5;
}

.match-card {
  position: relative;
  min-height: 118px;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
}

.match-num-card {
  padding: 12px 20px;
}
.match-big-digit {
  font-family: var(--font-display);
  font-size: clamp(66px, 9vw, 88px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
}

.match-group-card {
  background: var(--surface);
  border: 4px solid var(--border-soft);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.1);
  padding: 12px 16px;
}

.match-group-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 240px;
}
.match-group-item {
  width: 68px;
  height: 68px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.match-group-card.count-of-1 .match-group-item { width: 88px; height: 88px; }
.match-group-card.count-of-4 .match-group-item,
.match-group-card.count-of-5 .match-group-item { width: 56px; height: 56px; }
.match-group-item .item-svg,
.match-group-item .item-img { width: 100%; height: 100%; object-fit: contain; }
.match-group-item.mini-hop { animation: itemHop 0.45s ease; }

/* Glowing Magnetic Anchor Dots */
.match-anchor {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFF9D6;
  border: 5px solid #FF9F1C;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.anchor-left { left: -14px; }
.anchor-right { right: -14px; }

.match-card.is-selected,
.match-card.is-dragging {
  transform: scale(1.07);
  outline: 6px solid #FFE66D;
}
.match-card.is-hover-target {
  transform: scale(1.09);
  outline: 6px solid #4CAF50;
}
.match-card.is-matched {
  opacity: 0.92;
  outline: 5px solid #8BC34A;
}

/* ==================== BONUS: FROG THEATER ==================== */
.theater-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.theater-canvas-card {
  position: relative;
  width: 100%;
  max-width: 820px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 5px solid #FFFFFF;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}
.theater-canvas-card canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}
.theater-tap-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 252, 238, 0.92);
  color: #3A2E1B;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}
.theater-caption-box {
  width: 100%;
  max-width: 820px;
  text-align: center;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface-tint);
  border: 3px solid var(--border-soft);
  font-family: var(--font-display);
  font-size: clamp(20px, 2.8vw, 26px);
  font-weight: 700;
}
.theater-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Storybook Gallery */
.book-viewer-card {
  width: 100%;
  max-width: 840px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.book-image-frame {
  flex: 1;
  max-width: 680px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 6px solid #FFFFFF;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}
.book-image-frame img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}
.book-arrow {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #FF9F1C;
  color: #FFF;
  font-size: 28px;
  box-shadow: 0 5px 0 #C47100;
  flex-shrink: 0;
}
.book-arrow:active { transform: translateY(3px); }

.book-dots {
  display: flex;
  gap: 10px;
}
.book-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, background 0.2s ease;
}
.book-dot.active {
  background: #FF9F1C;
  transform: scale(1.3);
}

/* ==================== MODALS (CELEBRATION & PARENT SETTINGS) ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(20, 26, 40, 0.58);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fadeIn 0.22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.celebration-card {
  width: 100%;
  max-width: 520px;
  background: #FFFDF6;
  color: #2D3642;
  border-radius: 36px;
  border: 6px solid #FFCA3A;
  padding: 22px 24px 24px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  animation: modalPop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.75) translateY(24px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.celebration-stars { font-size: 38px; line-height: 1; }
.celebration-title {
  margin: 8px 0 12px;
  font-family: var(--font-display);
  font-size: 36px;
  color: #FF595E;
}
.celebration-frog-scene {
  border-radius: 22px;
  overflow: hidden;
  border: 4px solid #FFE28A;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}
.celebration-frog-scene img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}
.celebration-sub {
  margin: 14px 0 18px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: #3D4A5C;
}
.celebration-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Parent Settings Card */
.parent-card {
  width: 100%;
  max-width: 580px;
  max-height: 90dvh;
  background: #FFFFFF;
  color: #253040;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}
.parent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: #FFF6DF;
  border-bottom: 2px solid #F0E4C4;
}
.parent-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
}
.parent-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.setting-row label {
  font-weight: 700;
  font-size: 16px;
  color: #2C3A4E;
}
.setting-row input[type="text"] {
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid #D4DDE8;
  font-size: 18px;
  font-weight: 600;
  color: #253040;
}
.setting-hint {
  margin: 0;
  font-size: 13px;
  color: #67768A;
  line-height: 1.4;
}

.seg-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg-group button {
  flex: 1;
  min-width: 105px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid #D7E0EB;
  background: #F7F9FC;
  font-size: 14px;
  font-weight: 600;
  color: #3A485C;
}
.seg-group button.active {
  background: #FF9F1C;
  border-color: #E08700;
  color: #FFFFFF;
}

/* Custom Parent Voice Recorder List */
.recorder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #F8FAFC;
  border: 2px solid #E4ECF5;
}
.rec-label {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}
.rec-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rec-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
}
.rec-record { background: #FFE6E7; color: #C9363B; }
.rec-record.recording { background: #FF595E; color: #FFF; animation: pulseDot 0.9s infinite; }
.rec-play { background: #E3F6E5; color: #2E7D32; }
.rec-del { background: #EFEFEF; color: #666; }
.rec-default-tag { font-size: 12px; color: #8796AA; padding-inline: 6px; }

.parent-footer {
  padding: 14px 22px;
  border-top: 2px solid #EEF2F7;
  display: flex;
  justify-content: center;
}

/* Toast Banner */
.toast-banner {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  max-width: 90vw;
  background: #253040;
  color: #FFFFFF;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

/* ==================== RESPONSIVE BREAKPOINTS (IPAD / PHONE) ==================== */
@media (max-width: 860px) {
  .home-hero {
    grid-template-columns: 88px 1fr 94px;
    padding: 12px 14px;
  }
  .hero-frog img { width: 84px; height: 94px; }

  .game-cards {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .game-card {
    flex-direction: row;
    min-height: 112px;
    padding: 14px 18px;
    text-align: right;
  }
  .card-art { width: 120px; height: 82px; flex-shrink: 0; }
  .card-text { flex: 1; }
  .card-badge { top: -10px; right: auto; left: 16px; }

  .learn-stage {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .count-layout {
    grid-template-columns: 1fr;
  }
  .count-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
  }
  .count-showcase-card {
    flex: 0 0 140px;
    padding: 12px 10px;
  }
  .count-big-badge { width: 78px; height: 78px; font-size: 50px; border-radius: 22px; }
  .count-word-text { font-size: 20px; }
  .pace-panel { flex: 1; min-width: 200px; }
  .count-scene-wrap { min-height: 360px; }

  .match-stage {
    grid-template-columns: minmax(92px, 128px) 1fr minmax(145px, 210px);
    padding: 16px 14px;
  }
  .match-card { min-height: 98px; }
  .match-group-item { width: 52px; height: 52px; }
  .match-group-card.count-of-4 .match-group-item,
  .match-group-card.count-of-5 .match-group-item { width: 42px; height: 42px; }
}

@media (max-width: 520px) {
  .app-shell { padding: 10px 10px 14px; }
  .home-hero {
    grid-template-columns: 70px 1fr 74px;
    gap: 6px;
  }
  .hero-frog img { width: 68px; height: 76px; }
  .theme-btn { padding: 8px 12px; font-size: 16px; }
  .subtab { padding: 8px 12px; font-size: 15px; }
  .mini-theme-btn { width: 34px; height: 34px; font-size: 18px; }
  .nav-home-btn { width: 46px; height: 46px; font-size: 22px; }
  .num-pick-btn { width: 50px; height: 50px; font-size: 28px; }
  .big-action-btn { padding: 12px 18px; font-size: 18px; }
  .book-arrow { width: 46px; height: 46px; font-size: 22px; }
}

/* ==================== MILESTONE 1 EXPANSION STYLES ==================== */

/* Sensory Calm & Reduced-Motion Support */
body.sensory-calm *,
body.sensory-calm *::before,
body.sensory-calm *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.12s !important;
}
@media (prefers-reduced-motion: reduce) {
  .hero-frog, .count-item.is-inviting .count-item-visual { animation: none !important; }
}

/* Global Family Co-Play Turn Banner */
.coplay-turn-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  margin-bottom: 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #FFF3C4, #FFE8A3);
  color: #3A2A0E;
  border: 3px solid #FF9F1C;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.14);
}
.coplay-turn-bar.turn-adult {
  background: linear-gradient(90deg, #E2D9FF, #D2F1FF);
  border-color: #8E54E9;
  color: #251B47;
}
.coplay-turn-bar.turn-companion {
  background: linear-gradient(135deg, #E3F6E0, #F3FBE6);
  border-color: #4CAF50;
}
.coplay-turn-btn {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.3vw, 22px);
  font-weight: 700;
  color: inherit;
}
.coplay-adv-pill {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

/* Stage Pill */
.stage-open-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: #FFF3C4;
  color: #3D2B07;
  border: 3px solid #FFCA3A;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 0 #D99B00;
}
.stage-open-pill:active { transform: translateY(2px); }

/* Family Co-Play Bar on Home */
.coplay-home-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-tint);
  border: 3px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  box-shadow: var(--shadow-card);
}
.coplay-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.coplay-pill-btn {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 2.5px solid var(--border-soft);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  transition: transform 0.14s ease, background 0.2s ease;
}
.coplay-pill-btn.active {
  background: #FFE58F;
  color: #3A2A0E;
  border-color: #FF9F1C;
  box-shadow: 0 3px 0 #D98200;
}
.adventure-launch-btn {
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #FF595E, #FF9F1C);
  color: #FFF;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 5px 0 #B83A18;
}
.adventure-launch-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #B83A18; }

/* Home Category Tabs */
.home-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.cat-tab {
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface-tint);
  border: 3px solid var(--border-soft);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.cat-tab.active {
  background: #4CAF50;
  color: #FFF;
  border-color: #2E7D32;
  box-shadow: 0 4px 0 #2E7D32;
}

.card-emoji-hero {
  font-size: 58px;
  line-height: 1.1;
  margin-top: 10px;
}

/* Shared Activity Prompt & Stage */
.prompt-banner-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px;
  border-radius: var(--radius-xl);
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}
.prompt-banner-text {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.8vw, 28px);
  font-weight: 700;
  text-align: center;
}
.activity-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card);
  min-height: 390px;
}

/* Real Labels under Planets / Dinosaurs / Tens Bundles */
.item-real-name, .scene-real-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 253, 244, 0.92);
  color: #253040;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}
.scene-real-tag {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
}
.ten-bundle-chip {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 22px;
  background: #FFF3C4;
  border: 3px solid #FF9F1C;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.ten-bundle-chip .item-svg, .ten-bundle-chip .item-img { width: 66px; height: 66px; object-fit: contain; }
.ten-badge {
  position: absolute;
  top: -10px;
  right: -8px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: #FF595E;
  color: #FFF;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}
.match-group-item.tiny-item { width: 42px; height: 42px; }
.match-tens-visual { text-align: center; padding: 6px; }
.match-word-big { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.match-tens-pills { display: flex; gap: 6px; justify-content: center; }
.ten-pill-mini, .one-pill-mini {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}
.ten-pill-mini { background: #FFE58F; color: #3D2B07; }
.one-pill-mini { background: #DFF2FF; color: #0E5887; }

/* ==================== GAME 1: SPACE ANIMAL RESCUE ==================== */
.rescue-planets-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}
.rescue-planet-card {
  position: relative;
  width: clamp(190px, 26vw, 250px);
  padding: 18px 14px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(35, 48, 102, 0.9), rgba(26, 35, 76, 0.95));
  color: #FFF9EB;
  border: 4px solid rgba(255, 224, 102, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}
.rescue-planet-card:active { transform: scale(0.95); }
.rescue-planet-bg { width: 120px; height: 105px; opacity: 0.9; }
.rescue-animal-on-planet { width: 105px; height: 105px; margin-top: -66px; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35)); }
.rescue-card-labels { display: flex; flex-direction: column; align-items: center; }
.rescue-animal-name { font-family: var(--font-display); font-size: 25px; }
.rescue-planet-sub { font-size: 15px; color: #FFE66D; font-weight: 600; }
.rescued-win { animation: winBounce 0.7s ease; outline: 6px solid #8AC926; }

.rescue-board-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 20px;
  touch-action: none;
}
.rescue-waiting-zone {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}
.rescue-wait-animal {
  width: 130px;
  padding: 12px;
  border-radius: 26px;
  background: var(--surface);
  border: 4px solid #FFE66D;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.14);
  touch-action: none;
}
.rescue-wait-animal .item-svg { width: 92px; height: 92px; }
.rescue-tap-chip { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.rescue-wait-animal.boarded-out { opacity: 0.2; transform: scale(0.75); pointer-events: none; }

.rescue-spaceship-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border-radius: 30px;
  background: radial-gradient(circle, rgba(76, 201, 240, 0.22), rgba(26, 35, 76, 0.55));
  border: 4px dashed #FFE66D;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.rescue-spaceship-zone.drop-highlight,
.feed-animal-zone.drop-highlight {
  transform: scale(1.04);
  border-color: #8AC926;
  background: rgba(138, 201, 38, 0.2);
}
.ship-cabin-svg { width: 170px; }
.ship-counter-pill {
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  background: #FF9F1C;
  color: #FFF;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}
.ship-passengers { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; min-height: 62px; }
.ship-passenger-mini { position: relative; width: 58px; height: 58px; }
.mini-num-tag {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFF;
}

.rescue-habitat-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.rescue-hero-animal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 28px;
  border-radius: 28px;
  background: var(--surface);
  border: 4px solid var(--border-soft);
}
.rescue-hero-animal .item-svg { width: 118px; height: 118px; }
.rescue-hero-animal strong { font-family: var(--font-display); font-size: 26px; }
.rescue-habitats-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.habitat-card {
  width: 190px;
  padding: 20px 14px;
  border-radius: 28px;
  color: #253040;
  border: 4px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.hab-emoji { font-size: 52px; }
.habitat-card strong { font-family: var(--font-display); font-size: 22px; }

/* ==================== GAME 2: FEED THE ANIMALS ==================== */
.feed-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 20px;
  touch-action: none;
}
.feed-animal-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-radius: 30px;
  background: var(--surface);
  border: 4px dashed #FF9F1C;
}
.feed-qty-target {
  position: absolute;
  top: -16px;
  right: 18px;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feed-animal-art { width: 145px; height: 145px; }
.feed-animal-art .item-svg, .feed-animal-art .item-img { width: 100%; height: 100%; object-fit: contain; }
.feed-animal-art.munch-anim { animation: itemHop 0.45s ease; }
.feed-animal-name { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.feed-bowl {
  width: 100%;
  padding: 10px 14px;
  border-radius: 20px;
  background: rgba(255, 159, 28, 0.14);
  text-align: center;
}
.bowl-label { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.bowl-items { display: flex; justify-content: center; gap: 10px; margin-top: 8px; min-height: 54px; }
.bowl-food-mini { position: relative; width: 52px; height: 52px; }

.feed-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}
.feed-food-item {
  width: 122px;
  padding: 12px 10px;
  border-radius: 24px;
  background: var(--surface);
  border: 4px solid var(--border-soft);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  touch-action: none;
}
.feed-food-item .item-svg { width: 78px; height: 78px; }
.feed-food-item span { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.feed-food-item.food-eaten { opacity: 0.18; transform: scale(0.75); pointer-events: none; }

/* ==================== GAME 3: BUILD A SPACESHIP ==================== */
.ship-color-bar {
  display: flex;
  gap: 10px;
  background: var(--surface-tint);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-soft);
}
.ship-color-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid #FFF;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}
.ship-color-dot.active { transform: scale(1.2); outline: 3px solid #FFE66D; }

.ship-builder-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 18px;
  background: var(--surface-tint);
  border: 4px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 20px;
  touch-action: none;
}
.ship-parts-tray {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-content: center;
}
.ship-part-btn {
  padding: 12px 8px;
  border-radius: 22px;
  background: var(--surface);
  border: 3px solid var(--border-soft);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  touch-action: none;
}
.ship-part-btn .part-icon { width: 72px; height: 64px; }
.ship-part-btn span { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.ship-part-btn.is-used { opacity: 0.25; pointer-events: none; }
/* The companion is drawing attention to this part (hint, or the part chosen on the companion's own turn). */
.ship-part-btn.companion-pick { outline: 5px solid #FFE66D; outline-offset: 3px; box-shadow: 0 0 0 10px rgba(255, 230, 109, 0.28); }

.ship-blueprint-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 45%, #30428A, #19224A);
  padding: 16px;
  overflow: hidden;
}
.ship-blueprint {
  position: relative;
  width: 240px;
  transition: transform 2.1s cubic-bezier(0.4, 0, 0.2, 1);
}
.ship-blueprint.launching { transform: translateY(-420px) scale(0.75); }
.ship-window-frogs {
  position: absolute;
  top: 41.5%;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  object-fit: contain;
}

/* ==================== GAME 4: SPACE MUSIC LABORATORY ==================== */
.music-planets-row {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  align-items: center;
  background: radial-gradient(circle at 50% 40%, #32438C, #1B234D);
  border: 4px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-xl);
  padding: 20px;
}
.music-planet-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.11);
  border: 3px solid rgba(255, 255, 255, 0.25);
  color: #FFF9EB;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.music-planet-pad:active,
.music-planet-pad.pad-lit {
  transform: scale(1.12) translateY(-6px);
  background: rgba(255, 230, 109, 0.34);
  border-color: #FFE66D;
  box-shadow: 0 0 28px rgba(255, 230, 109, 0.75);
}
.music-planet-art { width: 96px; height: 88px; }
.music-planet-name { font-family: var(--font-display); font-size: 19px; }
.music-note-tag {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.2);
  font-size: 14px;
  font-weight: 700;
}
.music-drums-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}
.cosmic-drum-btn {
  padding: 16px 28px;
  border-radius: var(--radius-pill);
  background: #FF595E;
  color: #FFF;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 6px 0 #C43237;
}
.cosmic-drum-btn.drum-bongo { background: #FF9F1C; box-shadow: 0 6px 0 #C47100; }
.cosmic-drum-btn.drum-star { background: #8E54E9; box-shadow: 0 6px 0 #5E2BB0; }
.cosmic-drum-btn:active, .cosmic-drum-btn.pad-lit { transform: translateY(4px) scale(1.04); }

/* ==================== GAME 5: HEBREW LETTER PLANET & TRACING ==================== */
.letter-hero-art { width: 190px; height: 190px; display: flex; align-items: center; justify-content: center; }
.letter-hero-art .item-svg, .letter-hero-art .item-img { width: 100%; height: 100%; object-fit: contain; }
.letters-picker-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; flex: 1; }
.letter-pick-chip {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  color: #FFF;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  opacity: 0.75;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}
.letter-pick-chip.active { opacity: 1; transform: scale(1.14) translateY(-3px); outline: 4px solid #FFF; }

.letter-find-card {
  width: clamp(160px, 24vw, 220px);
  padding: 18px 14px;
  border-radius: 34px;
  color: #FFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2);
}
.letter-find-glyph { font-family: var(--font-display); font-size: 86px; font-weight: 700; line-height: 1; }
.letter-find-mini-art { width: 72px; height: 72px; }
.letter-find-word { font-family: var(--font-display); font-size: 22px; font-weight: 700; }

.trace-body { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.trace-top-row { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.trace-board-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 520 / 360;
  border-radius: 34px;
  background: #FFFDF7;
  border: 6px solid #FFCA3A;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  touch-action: none;
}
.trace-glyph-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(180px, 28vw, 260px);
  font-weight: 700;
  color: rgba(45, 54, 66, 0.14);
  pointer-events: none;
  user-select: none;
}
.trace-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.trace-controls { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* Storybook & Stage Grid & Parent Dashboard Additions */
.book-heading { font-family: var(--font-display); font-size: clamp(22px, 3vw, 30px); color: #FF9F1C; margin-bottom: 4px; }
.book-text { font-size: clamp(17px, 2.2vw, 22px); line-height: 1.45; }

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.stage-cell {
  padding: 12px 8px;
  border-radius: 18px;
  background: #F6F8FC;
  border: 2.5px solid #D7E0EB;
  color: #253040;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: var(--font-display);
}
.stage-cell strong { font-size: 17px; }
.stage-cell span { font-size: 15px; color: #596778; }
.stage-cell.completed { background: #E9F9E6; border-color: #6BCB5B; }
.stage-cell.active { background: #FFF3C4; border-color: #FF9F1C; box-shadow: 0 4px 0 #D98200; }

.parent-info-box {
  padding: 12px 14px;
  border-radius: 16px;
  background: #EEF8EE;
  border: 2px solid #A8DDA8;
  font-size: 14px;
  line-height: 1.5;
}
.parent-summary-card {
  padding: 14px;
  border-radius: 16px;
  background: #FFF9E6;
  border: 2px solid #F5DC8C;
  font-size: 14px;
}
.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.parent-games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.game-toggle-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #F7F9FC;
  border: 1.5px solid #DCE4EE;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 820px) {
  .rescue-board-layout,
  .feed-layout,
  .ship-builder-layout {
    grid-template-columns: 1fr;
  }
  .parent-games-grid, .summary-stats { grid-template-columns: 1fr; }
}

/* Inline-style replacements (CSP: no 'unsafe-inline' for styles) */
.ship-replay-row { display: flex; gap: 8px; align-items: center; }
.header-spacer-44 { width: 44px; }
.settings-data-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.voice-health-warn { color: #C9363B; }
.match-big-digit.is-double { font-size: clamp(48px, 7vw, 68px); }
.find-digit.is-double { font-size: clamp(74px, 11vw, 110px); }

/* ==================== SOLAR SYSTEM PLANETS GAME ==================== */
.planets-levels { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 6px 12px; }
.planets-levels .soft-pill-btn.active { outline: 3px solid #FFCA3A; }
.planets-status { text-align: center; font-weight: 700; margin: 4px 12px 0; min-height: 1.4em; }
.planets-body { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 16px 28px; }
.planets-big-slot { min-height: 220px; width: 100%; display: flex; align-items: center; justify-content: center; }
.planet-big-hint { font-size: 1.6rem; font-weight: 700; opacity: 0.75; }
.planet-big { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: planetPop 0.45s ease-out; }
.planet-big-art svg { width: min(230px, 56vw); height: auto; }
.planet-big-name { font-family: 'NoamFredoka', sans-serif; font-size: clamp(2rem, 6vw, 3rem); font-weight: 700; }
.planet-big-order { font-size: 1.1rem; opacity: 0.8; }
.planet-sun { display: flex; flex-direction: column; align-items: center; }
.planet-sun-emoji { font-size: clamp(3.5rem, 10vw, 5rem); line-height: 1; }
.planet-sun-label { font-weight: 700; font-size: 1.05rem; }
.planets-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.planet-card, .dino-card, .dino-match-pic, .dino-match-name, .dino-mem-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 96px; padding: 10px 8px; border: 0; border-radius: 22px;
  background: rgba(255, 255, 255, 0.85); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  cursor: pointer; font: inherit; color: #2b2540; transition: transform 0.15s ease;
}
.planet-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }
.planet-card-art svg { width: 84px; height: auto; }
.planet-card-name { font-weight: 700; font-size: 1rem; }
.planet-card.is-counted, .planet-card.is-correct { background: #d8f5d0; }
.planet-card.is-correct { animation: planetPop 0.45s ease-out; }
.planet-shake { animation: planetShake 0.4s ease-in-out; }
.planets-progress { display: flex; gap: 8px; }
.planets-dot { width: 34px; height: 34px; border-radius: 50%; background: #eee; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.planets-dot.done { background: #FFCA3A; }
.planets-count-total { font-size: 1.5rem; font-weight: 700; min-height: 2em; }
.planets-question { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; justify-content: center; }
.planets-question-num { font-size: clamp(4rem, 14vw, 7rem); font-weight: 700; line-height: 1; color: #FF8C42; }
.planets-question-text { font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 700; }
@keyframes planetPop { 0% { transform: scale(0.8); opacity: 0.4; } 100% { transform: scale(1); opacity: 1; } }
@keyframes planetShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) {
  .planet-big, .planet-card.is-correct, .planet-shake { animation: none; }
}

/* ==================== DINOSAUR PICTURE GAME ==================== */
.dino-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; width: 100%; }
.dino-card-art svg { width: 110px; height: auto; }
.dino-card-name { font-weight: 700; font-size: 0.95rem; text-align: center; max-width: 150px; }
.dino-card.is-correct { background: #d8f5d0; }
.dino-big { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: planetPop 0.45s ease-out; }
.dino-big-slot { min-height: 260px; width: 100%; display: flex; align-items: center; justify-content: center; }
.dino-picture svg { width: min(300px, 70vw); height: auto; }
.dino-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.dino-match { display: flex; gap: 24px; justify-content: center; align-items: flex-start; width: 100%; }
.dino-match-pic { padding: 8px; border: 0; border-radius: 20px; background: rgba(255,255,255,0.85); box-shadow: 0 5px 0 rgba(0,0,0,0.12); cursor: pointer; color: #2b2540; font: inherit; }
.dino-match-pic svg { width: 110px; height: auto; }
.dino-match-name { padding: 12px 14px; border: 0; border-radius: 18px; background: #fff; box-shadow: 0 5px 0 rgba(0,0,0,0.12); cursor: pointer; color: #2b2540; font: inherit; font-weight: 700; min-width: 150px; }
.dino-match-pic.is-picked, .dino-match-name.is-picked { outline: 4px solid #FFCA3A; }
.dino-match-pic.is-correct, .dino-match-name.is-correct { background: #d8f5d0; }
.dino-memory { display: grid; gap: 10px; justify-content: center; width: 100%; max-width: 560px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dino-memory-4, .dino-memory-5, .dino-memory-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dino-mem-card { min-height: 110px; padding: 6px; border: 0; border-radius: 18px; background: #7a6fd0; box-shadow: 0 5px 0 rgba(0,0,0,0.15); cursor: pointer; color: #2b2540; font: inherit; }
.dino-mem-card .dino-mem-face { display: none; width: 100%; height: 100%; align-items: center; justify-content: center; }
.dino-mem-card.is-up .dino-mem-face, .dino-mem-card.is-correct .dino-mem-face { display: flex; background: #fff; border-radius: 14px; }
.dino-mem-card.is-up .dino-mem-face svg { width: 80px; height: auto; }
.dino-mem-text { font-weight: 700; font-size: 0.95rem; text-align: center; }
.dino-mem-card.is-correct { background: #d8f5d0; }
@media (max-width: 380px) { .dino-match { gap: 12px; } .dino-match-name { min-width: 120px; } }

/* Companion on screen: leave room under the content so the last row of cards can be scrolled clear of the figure. */
.has-companion .app-shell { padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + 128px); }

/* ==================== VOICE CHOICE (Beta 2.0) ==================== */
.voice-pill { gap: 6px; }
.voice-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.voice-option { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 10px; border-radius: 18px; background: #fffaf0; border: 3px solid #f1e3c8; }
.voice-option.selected { border-color: #4CAF50; background: #f0fbef; }
.voice-option.unavailable { opacity: 0.6; }
.voice-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 0; background: transparent; cursor: pointer; touch-action: manipulation; font: inherit; color: inherit; min-height: 44px; }
.voice-pick:disabled { cursor: not-allowed; }
.voice-avatar { width: 72px; height: 72px; object-fit: contain; }
.voice-avatar-icon { display: flex; align-items: center; justify-content: center; font-size: 46px; }
.voice-name { font-weight: 700; font-size: 18px; }
.voice-check { position: absolute; top: 2px; inset-inline-start: 4px; font-size: 22px; color: #2E7D32; font-weight: 800; }
.voice-desc { margin: 0; font-size: 13px; line-height: 1.35; color: #5a4a3a; }
.voice-preview { align-self: center; min-height: 44px; }
.voice-preview:disabled { opacity: 0.5; cursor: not-allowed; }
.voice-status { margin-top: 10px; }
.voice-volumes { display: grid; gap: 8px; }
.volume-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; }
.volume-row input[type="range"] { width: 100%; min-height: 32px; }
.app-version { text-align: center; font-size: 12px; color: #8a7a6a; margin: 14px 0 4px; }
.voice-card { max-width: 720px; }
.app-credits { text-align: center; font-size: 11px; color: #9a8a7a; margin: 0 0 12px; }
.app-credits a { color: inherit; }

/* Companion and narration choice: two separate groups in one sheet. */
.choice-heading { margin: 14px 4px 8px; font-size: 1.2rem; font-weight: 700; color: #2b2540; }
.choice-heading:first-child { margin-top: 2px; }
