:root {
  color-scheme: light;
  --bg: #fff8f2;
  --surface: #ffffff;
  --surface-soft: #ffe8da;
  --surface-mint: #d8fbf3;
  --surface-yellow: #fff2af;
  --primary: #ff6b6b;
  --primary-deep: #f25454;
  --secondary: #4ecdc4;
  --secondary-deep: #2ba99f;
  --ink: #24304b;
  --ink-soft: #54627d;
  --danger: #ff8f8f;
  --border: rgba(36, 48, 75, 0.08);
  --shadow-soft: 0 12px 28px rgba(255, 107, 107, 0.14);
  --shadow-card: 0 18px 40px rgba(36, 48, 75, 0.12);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --max-width: 480px;
  --font-display: "MathStarter Rounded", "Segoe UI", "Aptos", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 217, 61, 0.35), transparent 32%),
    radial-gradient(circle at top right, rgba(78, 205, 196, 0.18), transparent 24%),
    linear-gradient(180deg, #fffef9 0%, #fff6ef 100%);
  color: var(--ink);
  font-family: var(--font-display);
}

body {
  display: flex;
  justify-content: center;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  padding: 18px 16px 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-title {
  margin: 0;
  font-size: 1.45rem;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-pill,
.chip,
.ghost-button,
.chip-button {
  border-radius: 999px;
  border: 0;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-soft);
}

.ghost-button {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 1.3rem;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.icon-button.is-recording {
  background: linear-gradient(180deg, #ff8f8f 0%, #ff6b6b 100%);
  color: #fff;
}

.progress-shell {
  margin-bottom: 18px;
}

.progress-bar,
.mini-progress {
  overflow: hidden;
  border-radius: 999px;
  background: rgba(36, 48, 75, 0.08);
}

.progress-bar {
  height: 18px;
}

.progress-fill,
.mini-progress-fill {
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.3), transparent 40%),
    linear-gradient(90deg, #4ecdc4 0%, #69dfb1 100%);
  transition: width 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.screen-shell {
  display: grid;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 18px;
}

.card,
.hero-card {
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card {
  padding: 22px;
}

.hero-card {
  padding: 26px 22px;
  background:
    radial-gradient(circle at top right, rgba(255, 217, 61, 0.35), transparent 36%),
    linear-gradient(180deg, #ffffff 0%, #fff4ec 100%);
}

.center-card {
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
}

.status-dot {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(180deg, #4ecdc4 0%, #2ba99f 100%);
  box-shadow: 0 0 0 12px rgba(78, 205, 196, 0.14);
}

.hero-badge,
.chapter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-yellow);
  color: var(--ink);
  font-weight: 800;
}

.hero-title {
  margin: 14px 0 10px;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  line-height: 1.05;
}

.hero-copy,
.chapter-copy,
.helper-text,
.prompt-helper,
.learn-copy {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.hero-preview {
  display: grid;
  gap: 10px;
  margin: 18px 0 22px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
}

.hero-number,
.learn-number,
.prompt-number {
  font-size: clamp(4rem, 20vw, 6rem);
  font-weight: 900;
  line-height: 0.9;
}

.hero-word,
.learn-word,
.prompt-word {
  font-size: clamp(1.8rem, 8vw, 2.5rem);
  font-weight: 800;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 22px;
}

.mode-selector {
  display: grid;
  gap: 12px;
  margin: 18px 0 22px;
}

.mode-card {
  border: 2px solid rgba(36, 48, 75, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  text-align: left;
  color: var(--ink);
}

.mode-card strong {
  font-size: 1.05rem;
}

.mode-card span {
  color: var(--ink-soft);
  line-height: 1.4;
}

.mode-card.is-active {
  border-color: rgba(78, 205, 196, 0.65);
  background: linear-gradient(180deg, #ffffff 0%, #eefdf7 100%);
  box-shadow: var(--shadow-soft);
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 16px 12px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
}

.stat-card strong {
  font-size: 1.4rem;
}

.primary-button,
.secondary-button,
.answer-card {
  border: 0;
  cursor: pointer;
  transition:
    transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.primary-button,
.secondary-button {
  min-height: 64px;
  padding: 16px 20px;
  border-radius: 24px;
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #fff;
  box-shadow: 0 18px 28px rgba(242, 84, 84, 0.26);
}

.secondary-button {
  width: 100%;
  background: var(--surface-soft);
  color: var(--ink);
}

.primary-button:active,
.secondary-button:active,
.answer-card:active,
.ghost-button:active {
  transform: translateY(3px) scale(0.98);
}

.chapter-grid {
  display: grid;
  gap: 14px;
}

.chapter-card.is-current {
  outline: 3px solid rgba(78, 205, 196, 0.3);
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.chapter-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.mini-progress {
  height: 12px;
  margin: 14px 0 16px;
}

.learn-card,
.prompt-card {
  text-align: center;
}

.toddler-learn-card,
.toddler-prompt-card {
  overflow: hidden;
  min-height: 240px;
}

.quantity-panel {
  margin: 18px 0;
}

.quantity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 10px;
}

.quantity-bubble,
.quantity-empty {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff6d6 0%, #ffdd6a 100%);
  font-weight: 900;
  box-shadow: inset 0 -6px 0 rgba(255, 255, 255, 0.35);
}

.quantity-empty {
  background: linear-gradient(180deg, #d8fbf3 0%, #9ce8dd 100%);
  font-size: 1.8rem;
}

.quantity-bubble {
  position: relative;
}

.quantity-bubble::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(36, 48, 75, 0.9);
  box-shadow: 0 3px 0 rgba(255, 255, 255, 0.3);
}

.quantity-caption {
  margin-top: 8px;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip,
.chip-button {
  padding: 10px 14px;
  background: var(--surface-mint);
  color: var(--ink);
  font-weight: 700;
}

.chip-button {
  cursor: pointer;
}

.toddler-chip-row {
  justify-content: center;
}

.toddler-audio-chip {
  min-width: 132px;
}

.prompt-title {
  margin: 10px 0 8px;
  font-size: 1.6rem;
}

.prompt-emphasis {
  margin-top: 12px;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.toddler-answer-grid {
  gap: 18px;
}

.answer-card {
  min-height: 140px;
  padding: 18px 14px;
  border-radius: 28px;
  border: 0;
  background: linear-gradient(180deg, #ffffff 0%, #fff0e6 100%);
  box-shadow: var(--shadow-soft);
  display: grid;
  align-content: center;
  gap: 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, outline-color 180ms ease;
}

.answer-card:disabled {
  cursor: default;
  opacity: 1;
}

.answer-card.is-locked {
  pointer-events: none;
}

.answer-card.is-success {
  background: linear-gradient(180deg, #d8fbf3 0%, #a2eadc 100%);
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 0 0 4px rgba(78, 205, 196, 0.26), 0 22px 36px rgba(78, 205, 196, 0.22);
}

.answer-card.is-error {
  background: linear-gradient(180deg, #ffe4e4 0%, #ffbdbd 100%);
  animation: shake 250ms linear;
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.2), 0 20px 34px rgba(255, 107, 107, 0.2);
}

.answer-card.is-correct-hint {
  outline: 4px solid rgba(78, 205, 196, 0.55);
  box-shadow: 0 18px 34px rgba(78, 205, 196, 0.18);
}

.answer-label {
  font-size: 1.45rem;
  font-weight: 900;
}

.answer-meta {
  color: var(--ink-soft);
}

.toddler-answer-card {
  min-height: 220px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fff7df 100%);
}

.toddler-answer-card.is-success {
  background: linear-gradient(180deg, #e8fff8 0%, #baf5df 100%);
  box-shadow: 0 0 0 6px rgba(78, 205, 196, 0.36), 0 24px 40px rgba(78, 205, 196, 0.26);
}

.toddler-answer-card.is-error {
  background: linear-gradient(180deg, #fff0f0 0%, #ffcfcf 100%);
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.3), 0 24px 40px rgba(255, 107, 107, 0.24);
}

.toddler-answer-card.is-correct-hint {
  background: linear-gradient(180deg, #f7fffc 0%, #e7fbf3 100%);
  outline: 6px solid rgba(78, 205, 196, 0.48);
}

.toddler-control-row {
  display: grid;
  place-items: center;
  margin: 8px 0 4px;
}

.audio-orb-button {
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at top, #ffffff 0%, #d8fbf3 40%, #4ecdc4 100%);
  box-shadow: 0 22px 34px rgba(78, 205, 196, 0.24);
  font-size: 3rem;
  cursor: pointer;
}

.audio-orb-button.is-muted {
  opacity: 0.45;
  box-shadow: none;
}

.toddler-start-button {
  width: 104px;
  height: 104px;
  min-height: 104px;
  margin: 0 auto;
  border-radius: 50%;
  font-size: 2.8rem;
  padding: 0;
}

.toddler-card-symbol {
  display: grid;
  place-items: center;
}

.feedback-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.45rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 10px 18px rgba(36, 48, 75, 0.18);
}

.feedback-badge-success,
.feedback-badge-hint {
  background: linear-gradient(180deg, #4ecdc4 0%, #2ba99f 100%);
}

.feedback-badge-error {
  background: linear-gradient(180deg, #ff8f8f 0%, #f25454 100%);
}

.reward-card {
  text-align: center;
}

.toddler-reward-card {
  padding-top: 32px;
  gap: 24px;
}

.reward-burst {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at top, #fff9d6 0%, #ffd93d 55%, #ffb703 100%);
  box-shadow: 0 24px 38px rgba(255, 217, 61, 0.34);
  font-size: 2.8rem;
}

.audio-studio {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
}

.audio-studio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audio-status {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
}

.audio-status.is-ready {
  background: var(--surface-mint);
}

.audio-status.is-missing {
  background: var(--surface-yellow);
}

.audio-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.audio-action-button {
  flex: 1 1 180px;
}

.audio-error {
  margin: 0;
  color: #c13e3e;
  font-weight: 700;
}

.audio-uploading {
  font-weight: 700;
}

.studio-toggle {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.studio-tab {
  flex: 1 1 0;
  min-height: 52px;
  padding: 0 12px;
  border: 2px solid rgba(36, 48, 75, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-weight: 800;
  text-wrap: balance;
}

.studio-tab.is-active {
  border-color: rgba(78, 205, 196, 0.65);
  background: linear-gradient(180deg, #ffffff 0%, #eefdf7 100%);
}

.studio-list {
  display: grid;
  gap: 14px;
}

.studio-row {
  display: grid;
  gap: 12px;
}

.studio-row-main {
  display: flex;
  gap: 14px;
  align-items: center;
}

.studio-row-symbol {
  width: 88px;
  min-width: 88px;
  display: grid;
  place-items: center;
}

.studio-row-copy {
  display: grid;
  gap: 4px;
}

.studio-row-copy strong {
  font-size: 1rem;
}

.studio-row-copy span {
  color: var(--ink-soft);
}

.studio-row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.studio-prompt-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at top, #ffffff 0%, #d8fbf3 40%, #4ecdc4 100%);
  box-shadow: var(--shadow-soft);
  font-size: 2rem;
}

.recording-panel {
  display: grid;
  gap: 12px;
}

.recording-live {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  color: #c13e3e;
}

.recording-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ff5252;
  box-shadow: 0 0 0 8px rgba(255, 82, 82, 0.14);
  animation: pulse-record 1s infinite;
}

.caregiver-hint {
  display: inline-grid;
  gap: 4px;
  justify-items: center;
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.caregiver-hint strong {
  color: var(--ink);
  font-size: 1.15rem;
}

.toddler-stage {
  display: grid;
  place-items: center;
  margin: 18px 0 8px;
}

.symbol-cluster {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.symbol-card,
.symbol-hero,
.symbol-studio {
  width: 100%;
}

.symbol-single {
  width: 100%;
}

.symbol-hero.symbol-single {
  width: min(176px, 42vw);
}

.symbol-card.symbol-single {
  width: min(118px, 48%);
}

.symbol-studio.symbol-single {
  width: 72px;
}

.single-plate {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #fff0d7 100%);
  box-shadow: var(--shadow-soft);
}

.symbol-studio .single-plate {
  padding: 14px;
  border-radius: 18px;
}

.single-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(36, 48, 75, 0.96);
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.14);
}

.symbol-dice {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
  border-radius: 32px;
  background: linear-gradient(180deg, #ffffff 0%, #fff0d7 100%);
  box-shadow: var(--shadow-soft);
}

.symbol-hero.symbol-dice {
  width: min(280px, 72vw);
  min-height: 280px;
}

.symbol-card.symbol-dice {
  width: min(180px, 100%);
  min-height: 180px;
}

.symbol-studio.symbol-dice {
  width: 88px;
  min-height: 88px;
  padding: 10px;
  gap: 6px;
  border-radius: 20px;
}

.dice-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: transparent;
}

.dice-cell.is-filled {
  background: rgba(36, 48, 75, 0.96);
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.14);
}

.symbol-frames {
  width: 100%;
}

.symbol-hero.symbol-frames {
  width: min(320px, 82vw);
}

.symbol-card.symbol-frames {
  width: min(200px, 100%);
}

.symbol-studio.symbol-frames {
  width: 88px;
}

.pip-frame {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 14px;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #fff0d7 100%);
  box-shadow: var(--shadow-soft);
}

.pip-frame-10 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.pip-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(36, 48, 75, 0.08);
}

.pip-cell.is-filled {
  background: rgba(36, 48, 75, 0.96);
}

.symbol-empty {
  width: 100%;
}

.symbol-hero.symbol-empty {
  width: min(176px, 42vw);
}

.symbol-card.symbol-empty {
  width: min(118px, 48%);
}

.symbol-studio.symbol-empty {
  width: 88px;
}

.empty-tray {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 3.2;
  padding: 14px;
  border-radius: 34px;
  background: linear-gradient(180deg, #ffffff 0%, #fff0d7 100%);
  box-shadow: var(--shadow-soft);
}

.symbol-studio .empty-tray {
  width: 88px;
  padding: 8px;
  border-radius: 18px;
}

.empty-tray-surface {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.65) 34%, rgba(255, 255, 255, 0.25) 65%, transparent 66%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(240, 252, 249, 0.92) 100%);
  border: 3px dashed rgba(78, 205, 196, 0.42);
  box-shadow:
    inset 0 -12px 18px rgba(78, 205, 196, 0.08),
    inset 0 6px 10px rgba(255, 255, 255, 0.6);
}

.symbol-studio .empty-tray-surface {
  border-width: 2px;
  border-radius: 12px;
  box-shadow:
    inset 0 -6px 10px rgba(78, 205, 196, 0.08),
    inset 0 3px 6px rgba(255, 255, 255, 0.6);
}

@keyframes pulse-record {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.78;
  }
}

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

@media (max-width: 380px) {
  .answer-grid,
  .hero-stats {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-meta {
    width: 100%;
    justify-content: space-between;
  }

  .studio-row-main {
    align-items: flex-start;
  }
}
