:root {
  --bg: #fffaf4;
  --bg-soft: rgba(255, 255, 255, 0.76);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --line: rgba(125, 119, 255, 0.14);
  --line-strong: rgba(70, 74, 119, 0.12);
  --text: #2d3553;
  --muted: #68728f;
  --heading: #222c49;
  --primary: #7d77ff;
  --primary-strong: #635df0;
  --secondary: #4fc4c9;
  --mint: #90d7b1;
  --coral: #ff8f7d;
  --sun: #ffd46b;
  --danger: #e6657c;
  --success: #36b67d;
  --shadow: 0 22px 45px rgba(88, 94, 151, 0.16);
  --shadow-soft: 0 14px 28px rgba(88, 94, 151, 0.12);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --max-width: 980px;
  --transition: 220ms ease;
  --font-title: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(125, 119, 255, 0.2), transparent 34%),
    radial-gradient(circle at top right, rgba(79, 196, 201, 0.17), transparent 24%),
    linear-gradient(180deg, #fffaf4 0%, #fffefb 42%, #f9fbff 100%);
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.background-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.7;
  animation: drift 18s ease-in-out infinite alternate;
}

.orb-lilac {
  width: 280px;
  height: 280px;
  top: -34px;
  left: -72px;
  background: radial-gradient(circle, rgba(125, 119, 255, 0.34) 0%, rgba(125, 119, 255, 0) 72%);
}

.orb-coral {
  width: 240px;
  height: 240px;
  right: -58px;
  top: 140px;
  background: radial-gradient(circle, rgba(255, 143, 125, 0.32) 0%, rgba(255, 143, 125, 0) 74%);
  animation-delay: 1.8s;
}

.orb-mint {
  width: 320px;
  height: 320px;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(144, 215, 177, 0.22) 0%, rgba(144, 215, 177, 0) 72%);
  animation-delay: 2.6s;
}

.grid-glow {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(125, 119, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 119, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.46), transparent 82%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: 16px 16px calc(112px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0 16px;
  backdrop-filter: blur(14px);
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.brand-button:hover,
.brand-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(88, 94, 151, 0.14);
}

.brand-button:focus-visible,
.button-primary:focus-visible,
.button-secondary:focus-visible,
.pill-button:focus-visible,
.sound-toggle:focus-visible,
.mode-card:focus-visible,
.bottom-nav-button:focus-visible,
.choice-button:focus-visible,
.letter-button:focus-visible {
  outline: 3px solid rgba(125, 119, 255, 0.22);
  outline-offset: 2px;
}

.brand-mascot {
  width: 46px;
  height: 46px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.brand-copy strong {
  font-family: var(--font-title);
  color: var(--heading);
  font-size: 1rem;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.82rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.points-pill,
.sound-toggle,
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.pill-label,
.mini-label {
  display: block;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.points-pill strong {
  font-family: var(--font-title);
  color: var(--heading);
  font-size: 1.08rem;
}

.sound-toggle {
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  transform: translateY(-1px);
}

.sound-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(125, 119, 255, 0.15), rgba(79, 196, 201, 0.15));
}

.sound-icon::before {
  content: "♪";
  color: var(--primary-strong);
  font-size: 1rem;
  font-weight: 700;
}

.sound-toggle.is-muted .sound-icon::before {
  content: "×";
  color: var(--danger);
}

.sound-toggle span:last-child {
  font-size: 0.88rem;
  font-weight: 700;
}

.app-main {
  display: block;
}

.screen {
  display: none;
  animation: screenIn 320ms ease;
}

.screen.is-active {
  display: block;
}

.surface-card {
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.84));
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  display: grid;
  gap: 24px;
  padding: 24px;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: auto -12% -26% auto;
  width: 250px;
  height: 250px;
  border-radius: 46% 54% 50% 50%;
  background: radial-gradient(circle, rgba(255, 212, 107, 0.34) 0%, rgba(255, 212, 107, 0.02) 72%);
}

.hero-copy,
.hero-art,
.screen-header,
.progress-panel,
.challenge-card,
.feedback-card,
.mini-panel,
.help-card,
.medal-panel,
.progress-detail-panel {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(125, 119, 255, 0.1);
  color: var(--primary-strong);
  font-size: 0.85rem;
  font-weight: 700;
}

.hero-card h1,
.screen-header h2,
.feedback-card h2 {
  margin: 12px 0 10px;
  color: var(--heading);
  font-family: var(--font-title);
  line-height: 1.04;
}

.hero-card h1 {
  font-size: clamp(2.2rem, 6vw, 4rem);
}

.screen-header h2,
.feedback-card h2 {
  font-size: clamp(1.65rem, 4vw, 2.2rem);
}

.hero-subtitle,
.screen-description,
.mini-panel p,
.help-card p,
.feedback-card p,
.panel-headline p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 1rem;
}

.hero-highlight {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-top: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(125, 119, 255, 0.12), rgba(255, 255, 255, 0.68));
  border: 1px solid rgba(125, 119, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.hero-highlight strong {
  display: block;
  color: var(--heading);
  font-family: var(--font-title);
  font-size: 1.4rem;
}

.hero-highlight span:last-child {
  color: var(--muted);
  font-size: 0.94rem;
}

.hero-actions,
.hero-links,
.progress-actions,
.challenge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions {
  margin-top: 20px;
}

.hero-links {
  margin-top: 12px;
}

.button-primary,
.button-secondary,
.pill-button,
.mode-card,
.bottom-nav-button,
.choice-button,
.letter-button {
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.button-primary,
.button-secondary,
.pill-button {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.button-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  color: #ffffff;
  box-shadow: 0 18px 30px rgba(99, 93, 240, 0.28);
}

.button-primary:hover,
.button-primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 22px 34px rgba(99, 93, 240, 0.32);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(125, 119, 255, 0.12);
  color: var(--heading);
  box-shadow: var(--shadow-soft);
}

.button-secondary:hover,
.button-secondary:focus-visible,
.pill-button:hover,
.pill-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(88, 94, 151, 0.15);
}

.pill-button {
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(125, 119, 255, 0.12);
  color: var(--heading);
}

.button-large {
  min-height: 58px;
  padding-inline: 22px;
  font-size: 1rem;
}

.hero-art {
  position: relative;
  min-height: 320px;
}

.mascot-frame {
  width: min(100%, 370px);
  margin: 0 auto;
  padding: 20px;
  border-radius: 38px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.82)),
    linear-gradient(180deg, rgba(125, 119, 255, 0.12), rgba(79, 196, 201, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), var(--shadow-soft);
}

.mascot-frame img {
  margin: 0 auto;
  animation: floaty 4.6s ease-in-out infinite;
}

.floating-card {
  position: absolute;
  min-width: 134px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.floating-card strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-title);
  color: var(--heading);
  font-size: 1.25rem;
}

.score-card {
  left: 0;
  bottom: 16px;
}

.progress-card {
  right: 0;
  top: 18px;
}

.home-panels,
.stats-grid,
.help-grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.mini-panel,
.help-card,
.medal-panel,
.progress-detail-panel,
.feedback-card,
.progress-panel,
.challenge-card {
  padding: 22px;
}

.panel-headline {
  display: flex;
  align-items: center;
  gap: 14px;
}

.panel-headline h2,
.panel-headline h3,
.help-card h3 {
  margin: 0 0 4px;
  color: var(--heading);
  font-family: var(--font-title);
}

.panel-headline h2 {
  font-size: 1.15rem;
}

.panel-headline h3,
.help-card h3 {
  font-size: 1.05rem;
}

.mini-panel .button-secondary {
  margin-top: 16px;
}

.screen-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.screen-header.compact {
  align-items: center;
}

.mode-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 170px;
  padding: 22px 18px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.84));
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  text-align: left;
}

.mode-card strong {
  color: var(--heading);
  font-family: var(--font-title);
  font-size: 1.08rem;
}

.mode-card span {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 22px 34px rgba(88, 94, 151, 0.16);
}

.theme-word {
  background: linear-gradient(180deg, rgba(125, 119, 255, 0.14), rgba(255, 255, 255, 0.92));
}

.theme-initial {
  background: linear-gradient(180deg, rgba(255, 143, 125, 0.14), rgba(255, 255, 255, 0.92));
}

.theme-sum {
  background: linear-gradient(180deg, rgba(79, 196, 201, 0.14), rgba(255, 255, 255, 0.92));
}

.theme-subtract {
  background: linear-gradient(180deg, rgba(255, 212, 107, 0.16), rgba(255, 255, 255, 0.92));
}

.theme-count {
  background: linear-gradient(180deg, rgba(144, 215, 177, 0.18), rgba(255, 255, 255, 0.92));
}

.theme-mixed {
  background: linear-gradient(180deg, rgba(233, 150, 193, 0.16), rgba(255, 255, 255, 0.92));
}

.challenge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-chip {
  color: var(--heading);
  font-size: 0.92rem;
  font-weight: 700;
}

.progress-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.progress-copy {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.progress-copy strong {
  color: var(--heading);
  font-family: var(--font-title);
}

.progress-copy span {
  color: var(--muted);
}

.progress-bar {
  width: 100%;
  height: 14px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(125, 119, 255, 0.1);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  transition: width 300ms ease;
}

.challenge-card {
  display: grid;
  gap: 18px;
}

.challenge-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 14px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.56)),
    linear-gradient(180deg, rgba(125, 119, 255, 0.08), rgba(79, 196, 201, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.illustration-svg {
  width: min(100%, 240px);
  height: auto;
}

.figure-token .illustration-svg {
  width: 100%;
}

.challenge-question {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  line-height: 1.3;
  color: var(--heading);
  text-align: center;
}

.challenge-workspace {
  display: grid;
  gap: 16px;
}

.word-board,
.choice-board,
.math-board,
.count-board {
  display: grid;
  gap: 16px;
}

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

.letter-slot {
  min-height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(125, 119, 255, 0.08);
  border: 2px dashed rgba(125, 119, 255, 0.22);
  color: var(--heading);
  font-family: var(--font-title);
  font-size: 1.55rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.letter-slot.is-filled {
  border-style: solid;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(125, 119, 255, 0.08));
}

.letter-grid,
.choice-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.letter-button,
.choice-button {
  min-height: 66px;
  padding: 12px;
  border: 0;
  border-radius: 20px;
  cursor: pointer;
  color: var(--heading);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
  box-shadow: var(--shadow-soft);
}

.letter-button {
  font-family: var(--font-title);
  font-size: 1.5rem;
}

.letter-button:hover,
.choice-button:hover,
.letter-button:focus-visible,
.choice-button:focus-visible {
  transform: translateY(-1px);
}

.letter-button:disabled {
  opacity: 0.4;
  transform: none;
  cursor: default;
}

.choice-button {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.choice-button strong {
  font-family: var(--font-title);
  font-size: 1.45rem;
}

.choice-button small {
  color: var(--muted);
  font-size: 0.86rem;
}

.choice-button.is-correct {
  background: linear-gradient(180deg, rgba(54, 182, 125, 0.2), rgba(255, 255, 255, 0.92));
}

.choice-button.is-wrong {
  background: linear-gradient(180deg, rgba(230, 101, 124, 0.18), rgba(255, 255, 255, 0.92));
}

.choice-button.is-selected {
  border: 2px solid rgba(125, 119, 255, 0.32);
}

.choice-button:disabled {
  cursor: default;
}

.math-visual {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.math-operator {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: rgba(125, 119, 255, 0.12);
  color: var(--primary-strong);
  font-family: var(--font-title);
  font-size: 1.9rem;
}

.math-side,
.count-area {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.math-side span,
.count-area span {
  color: var(--muted);
  font-weight: 700;
}

.count-cluster,
.option-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.count-cluster {
  max-width: 320px;
}

.option-cluster {
  max-width: 110px;
}

.figure-token {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(125, 119, 255, 0.1);
  box-shadow: 0 10px 16px rgba(88, 94, 151, 0.08);
  display: grid;
  place-items: center;
  padding: 4px;
}

.figure-token.is-small {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  padding: 2px;
}

.figure-token.is-faded {
  opacity: 0.4;
  filter: grayscale(0.3);
}

.challenge-actions {
  justify-content: center;
}

.feedback-card {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 14px;
}

.feedback-badge {
  width: 90px;
  height: 90px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  box-shadow: var(--shadow-soft);
}

.feedback-badge.is-success {
  background: linear-gradient(180deg, rgba(54, 182, 125, 0.24), rgba(255, 255, 255, 0.9));
}

.feedback-badge.is-error {
  background: linear-gradient(180deg, rgba(230, 101, 124, 0.22), rgba(255, 255, 255, 0.9));
}

.feedback-stars {
  display: flex;
  gap: 8px;
  min-height: 28px;
}

.feedback-stars .star {
  width: 22px;
  height: 22px;
  clip-path: polygon(50% 0%, 61% 36%, 98% 36%, 68% 58%, 79% 94%, 50% 72%, 21% 94%, 32% 58%, 2% 36%, 39% 36%);
  background: rgba(125, 119, 255, 0.14);
}

.feedback-stars .star.is-on {
  background: linear-gradient(180deg, #ffd86c, #ffb43b);
  box-shadow: 0 6px 14px rgba(255, 180, 59, 0.28);
}

.feedback-answer,
.feedback-bonus {
  margin: 0;
  font-weight: 700;
}

.feedback-answer {
  color: var(--heading);
}

.feedback-bonus {
  color: var(--primary-strong);
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}

.stat-card {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.94);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.84));
  box-shadow: var(--shadow-soft);
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  color: var(--heading);
  font-family: var(--font-title);
  font-size: 1.65rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.94rem;
}

.medal-panel,
.progress-detail-panel {
  margin-top: 16px;
}

.medal-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.medal-step {
  padding: 14px 10px;
  border-radius: 18px;
  background: rgba(125, 119, 255, 0.06);
  text-align: center;
}

.medal-step strong {
  display: block;
  margin-top: 8px;
  color: var(--heading);
}

.medal-step span {
  color: var(--muted);
  font-size: 0.88rem;
}

.medal-dot {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.medal-step.is-earned {
  background: linear-gradient(180deg, rgba(255, 212, 107, 0.22), rgba(255, 255, 255, 0.92));
}

.mode-stats-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.mode-stat-item {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(125, 119, 255, 0.08);
}

.mode-stat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.mode-stat-head strong {
  color: var(--heading);
}

.mode-stat-head span {
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-stat-bar {
  width: 100%;
  height: 12px;
  background: rgba(125, 119, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.mode-stat-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
}

.mode-stat-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.help-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.help-card {
  display: grid;
  gap: 12px;
}

.progress-actions {
  margin-top: 18px;
}

.danger-button {
  color: #b44156;
  border-color: rgba(230, 101, 124, 0.2);
  background: rgba(255, 240, 244, 0.9);
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.94) 38%);
  backdrop-filter: blur(12px);
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(100%, 620px);
  margin: 0 auto;
}

.bottom-nav-button {
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-weight: 700;
}

.bottom-nav-button.is-active {
  background: linear-gradient(180deg, rgba(125, 119, 255, 0.18), rgba(255, 255, 255, 0.96));
  color: var(--primary-strong);
}

.toast-layer,
.reward-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.toast-layer {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 92px;
}

.toast {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(45, 53, 83, 0.92);
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  animation: toastIn 1.8s ease forwards;
}

.reward-spark {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: popSpark 900ms ease forwards;
}

body[data-active-mode="word"] .challenge-card {
  background:
    linear-gradient(180deg, rgba(125, 119, 255, 0.12), rgba(255, 255, 255, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
}

body[data-active-mode="initial"] .challenge-card {
  background:
    linear-gradient(180deg, rgba(255, 143, 125, 0.12), rgba(255, 255, 255, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
}

body[data-active-mode="sum"] .challenge-card {
  background:
    linear-gradient(180deg, rgba(79, 196, 201, 0.12), rgba(255, 255, 255, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
}

body[data-active-mode="subtract"] .challenge-card {
  background:
    linear-gradient(180deg, rgba(255, 212, 107, 0.16), rgba(255, 255, 255, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
}

body[data-active-mode="count"] .challenge-card {
  background:
    linear-gradient(180deg, rgba(144, 215, 177, 0.18), rgba(255, 255, 255, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
}

body[data-active-mode="mixed"] .challenge-card {
  background:
    linear-gradient(180deg, rgba(233, 150, 193, 0.16), rgba(255, 255, 255, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(18px, -12px, 0);
  }
}

@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }

  15%,
  70% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-18px) scale(0.96);
  }
}

@keyframes popSpark {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.2);
  }

  20% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--x, 0), var(--y, -50px), 0) scale(0.4);
  }
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 24px;
  }

  .hero-card {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
    padding: 32px;
  }

  .home-panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .challenge-card {
    padding: 28px;
  }

  .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 719px) {
  .app-header {
    align-items: stretch;
  }

  .brand-button {
    min-width: 0;
  }

  .brand-copy span {
    display: none;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    min-width: 118px;
  }

  .points-pill,
  .sound-toggle {
    justify-content: center;
  }

  .feedback-card,
  .medal-track {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 12px;
  }

  .hero-card,
  .mini-panel,
  .help-card,
  .medal-panel,
  .progress-detail-panel,
  .feedback-card,
  .progress-panel,
  .challenge-card {
    padding: 18px;
  }

  .bottom-nav {
    gap: 8px;
  }

  .bottom-nav-button {
    font-size: 0.9rem;
  }

  .letter-slots {
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  }

  .math-visual {
    grid-template-columns: 1fr;
  }

  .math-operator {
    margin: 0 auto;
  }

  .floating-card {
    position: static;
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
