/* 閃電賽車英語樂園 — Offline Kid-Friendly Racing Theme CSS */
:root {
  --red: #ef4444;
  --red-dark: #b91c1c;
  --yellow: #fbbf24;
  --yellow-dark: #d97706;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --sky: #e0f2fe;
  --green: #16a34a;
  --green-dark: #15803d;
  --purple: #7c3aed;
  --purple-dark: #5b21b6;
  --orange: #f97316;
  --ink: #1e293b;
  --muted: #64748b;
  --bg: #fffbeb;
  --card: #ffffff;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-card: 0 8px 20px rgba(30, 41, 59, 0.1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button, .card, .choice-card, .mem-card, .tire-letter, .cat-card, .crew-card, .level-card, .game-card, .thumb-card {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Nunito", "Comic Sans MS", "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: radial-gradient(circle at top right, #fef3c7 0%, #fffbeb 45%, #e0f2fe 100%);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 70%, #b91c1c 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-badge {
  background: linear-gradient(135deg, #fde047, #f59e0b);
  color: #991b1b;
  font-weight: 900;
  font-size: 1.15rem;
  padding: 8px 11px;
  border-radius: 14px;
  border: 3px solid #fff;
  box-shadow: 0 3px 0 #b45309;
  transform: rotate(-4deg);
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 0 rgba(0,0,0,0.18);
}

.brand-sub {
  font-size: 0.78rem;
  opacity: 0.92;
  font-weight: 700;
}

.top-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
}

.star-pill { color: #b45309; }
.trophy-pill { color: #7c3aed; }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s;
}
.icon-btn:active { transform: scale(0.92); }

.checkered-strip {
  height: 10px;
  background-image: linear-gradient(45deg, #1e293b 25%, transparent 25%),
    linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%),
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: #ffffff;
  opacity: 0.9;
}

/* Main Content */
.app-main {
  flex: 1;
  padding: 18px 16px 24px;
}

/* Chunky 3D Kid Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 900;
  font-size: 1.05rem;
  padding: 12px 20px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
}

.btn:active {
  transform: translateY(3px);
}

.btn-red {
  background: linear-gradient(180deg, #ff5f5f, #ef4444);
  color: #fff;
  box-shadow: 0 5px 0 #b91c1c;
}
.btn-red:active { box-shadow: 0 2px 0 #b91c1c; }

.btn-yellow {
  background: linear-gradient(180deg, #fde047, #f59e0b);
  color: #78350f;
  box-shadow: 0 5px 0 #b45309;
}
.btn-yellow:active { box-shadow: 0 2px 0 #b45309; }

.btn-blue {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  color: #fff;
  box-shadow: 0 5px 0 #1d4ed8;
}
.btn-blue:active { box-shadow: 0 2px 0 #1d4ed8; }

.btn-green {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #fff;
  box-shadow: 0 5px 0 #15803d;
}
.btn-green:active { box-shadow: 0 2px 0 #15803d; }

.btn-purple {
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
  color: #fff;
  box-shadow: 0 5px 0 #5b21b6;
}
.btn-purple:active { box-shadow: 0 2px 0 #5b21b6; }

.btn-white {
  background: #ffffff;
  color: var(--ink);
  border: 2px solid #cbd5e1;
  box-shadow: 0 4px 0 #cbd5e1;
}
.btn-white:active { box-shadow: 0 1px 0 #cbd5e1; }

.btn-lg {
  font-size: 1.2rem;
  padding: 15px 26px;
  border-radius: 20px;
}

.btn-sm {
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 12px;
}

/* Hero Banner on Home */
.hero-card {
  background: linear-gradient(135deg, #fff1f2 0%, #fef9c3 60%, #e0f2fe 100%);
  border: 4px solid #ef4444;
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.hero-copy h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  color: #991b1b;
  font-weight: 900;
}

.hero-copy p {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #334155;
  font-weight: 700;
}

.hero-mascot {
  width: 175px;
  flex-shrink: 0;
  cursor: pointer;
  animation: carIdle 2.4s ease-in-out infinite;
}

.hero-mascot.zooming {
  animation: carZoom 0.7s ease-in-out;
}

@keyframes carIdle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-1deg); }
}

@keyframes carZoom {
  0% { transform: translateX(0) scale(1); }
  35% { transform: translateX(-14px) scale(0.95); }
  75% { transform: translateX(26px) scale(1.06); }
  100% { transform: translateX(0) scale(1); }
}

/* Section Titles */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 900;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Level Cards Grid */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.level-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 16px;
  border: 3px solid #e2e8f0;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.level-card:hover { transform: translateY(-3px); }

.level-card.selected {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2), var(--shadow-card);
}

.level-card.locked {
  opacity: 0.72;
  filter: grayscale(0.3);
}

.level-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.level-tag {
  font-weight: 900;
  font-size: 0.85rem;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
}

.level-badge {
  font-size: 1.5rem;
}

.level-name {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--ink);
}

.level-desc {
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 700;
}

.progress-track {
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fbbf24, #ef4444);
  transition: width 0.4s ease;
}

.level-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 800;
  color: #475569;
}

.lock-ribbon {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  border-radius: 21px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  gap: 4px;
  text-align: center;
  padding: 12px;
}

/* Game Launcher Cards */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.game-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 18px 16px;
  border: 3px solid transparent;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: transform 0.15s;
}
.game-card:hover { transform: translateY(-4px); }
.game-card:active { transform: scale(0.97); }

.game-card.g-learn { border-color: #38bdf8; background: linear-gradient(180deg, #f0f9ff, #ffffff); }
.game-card.g-race { border-color: #ef4444; background: linear-gradient(180deg, #fef2f2, #ffffff); }
.game-card.g-memory { border-color: #f59e0b; background: linear-gradient(180deg, #fffbeb, #ffffff); }
.game-card.g-pitstop { border-color: #10b981; background: linear-gradient(180deg, #ecfdf5, #ffffff); }
.game-card.g-sprint { border-color: #8b5cf6; background: linear-gradient(180deg, #f5f3ff, #ffffff); }

.game-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.game-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ink);
}

.game-en {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-desc {
  font-size: 0.88rem;
  color: #475569;
  font-weight: 700;
}

/* Subject Switcher Tabs (English / Chinese / Maths) */
.subject-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.subject-tab {
  background: #ffffff;
  border: 3px solid #cbd5e1;
  border-radius: 18px;
  padding: 12px 8px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 4px 0 #cbd5e1;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.subject-tab:active { transform: translateY(3px); }
.subject-tab .subj-icon { font-size: 1.75rem; line-height: 1.1; }
.subject-tab .subj-name { font-size: 1.02rem; font-weight: 900; color: var(--ink); }
.subject-tab .subj-sub { font-size: 0.75rem; font-weight: 800; color: var(--muted); }

.subject-tab.active-english {
  border-color: #2563eb;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  box-shadow: 0 5px 0 #1d4ed8;
}
.subject-tab.active-chinese {
  border-color: #ef4444;
  background: linear-gradient(180deg, #fef2f2, #fee2e2);
  box-shadow: 0 5px 0 #b91c1c;
}
.subject-tab.active-maths {
  border-color: #16a34a;
  background: linear-gradient(180deg, #f0fdf4, #dcfce7);
  box-shadow: 0 5px 0 #15803d;
}

/* Daily Exercise Banner & Hub */
.daily-banner {
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 55%, #ecfdf5 100%);
  border: 4px solid #f59e0b;
  border-radius: var(--radius-xl);
  padding: 15px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}

.daily-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.daily-chip {
  font-size: 0.85rem;
  font-weight: 900;
  padding: 4px 11px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  color: #475569;
}
.daily-chip.done {
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}

.daily-missions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.daily-mission-card {
  background: #ffffff;
  border: 3.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
}
.daily-mission-card.done {
  border-color: #16a34a;
  background: linear-gradient(180deg, #f0fdf4, #ffffff);
}

.daily-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.cal-day {
  background: #f8fafc;
  border: 2.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cal-day.today {
  border-color: #ef4444;
  background: #fef2f2;
}
.cal-day.crown {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fef9c3, #fffbeb);
}
.cal-date { font-size: 0.78rem; font-weight: 900; color: var(--ink); }
.cal-wk { font-size: 0.7rem; font-weight: 800; color: var(--muted); }
.cal-dots { display: flex; gap: 3px; justify-content: center; }
.cal-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  background: #e2e8f0;
  color: #94a3b8;
}
.cal-dot.on-e { background: #2563eb; color: #fff; }
.cal-dot.on-c { background: #ef4444; color: #fff; }
.cal-dot.on-m { background: #16a34a; color: #fff; }

/* Chinese HK Character Grid Box (田字格) */
.zh-char-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 112px;
  padding: 10px 22px;
  margin: 8px auto;
  border: 4px solid #ef4444;
  border-radius: 18px;
  background:
    linear-gradient(to right, transparent 49.2%, rgba(239, 68, 68, 0.22) 49.2%, rgba(239, 68, 68, 0.22) 50.8%, transparent 50.8%),
    linear-gradient(to bottom, transparent 49.2%, rgba(239, 68, 68, 0.22) 49.2%, rgba(239, 68, 68, 0.22) 50.8%, transparent 50.8%),
    #fffbeb;
  font-size: 3.6rem;
  font-weight: 900;
  color: #1e293b;
  letter-spacing: 6px;
}

.choice-zh-only {
  font-size: 2.2rem;
  font-weight: 900;
  color: #991b1b;
  padding: 16px 8px;
  letter-spacing: 3px;
}

/* Maths Visual Display */
.math-stage {
  background: #ffffff;
  border: 4px solid #16a34a;
  border-radius: var(--radius-xl);
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.math-prompt {
  font-size: 1.18rem;
  font-weight: 900;
  color: #14532d;
  margin-bottom: 12px;
  line-height: 1.4;
}

.math-big-eq {
  font-size: 2.5rem;
  font-weight: 900;
  color: #1e3a8a;
  margin: 10px 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.math-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 54px;
  padding: 0 10px;
  border: 3.5px dashed #ef4444;
  border-radius: 14px;
  background: #fef2f2;
  color: #ef4444;
}

.math-icon-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px auto;
  max-width: 440px;
}

.math-emoji {
  font-size: 2.1rem;
  line-height: 1.1;
  position: relative;
  display: inline-block;
}

.math-emoji.crossed {
  opacity: 0.35;
}
.math-emoji.crossed::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #dc2626;
  font-weight: 900;
  font-size: 1.8rem;
}

.math-choice-label {
  font-size: 1.95rem;
  font-weight: 900;
  color: #1e3a8a;
  padding: 14px 6px;
}

/* Category Theme Selector (7 HK K3/P1 Worlds) */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.cat-card {
  background: #fff;
  border: 3px solid #e2e8f0;
  border-radius: 18px;
  padding: 11px 8px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.08);
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}

.cat-card:hover { transform: translateY(-2px); }
.cat-card:active { transform: scale(0.96); }
.cat-card.selected {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.22), 0 6px 16px rgba(30, 41, 59, 0.12);
  transform: translateY(-2px);
}

.cat-icon {
  font-size: 2rem;
  line-height: 1.1;
}

.cat-title {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--ink);
}

.cat-en {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

.cat-prog {
  font-size: 0.74rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #334155;
  margin-top: 2px;
}

.cat-pills-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.cat-pills-bar::-webkit-scrollbar,
.level-tabs::-webkit-scrollbar {
  display: none;
}

.cat-pill-btn {
  flex-shrink: 0;
  padding: 8px 13px;
  border-radius: 999px;
  border: 2.5px solid #cbd5e1;
  background: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.9rem;
  color: #475569;
  cursor: pointer;
}

.cat-pill-btn.active {
  color: #fff;
  border-color: transparent;
}

/* Family Pit Crew Section (Papa Kenny, Mama Soki, Grandma Tracy) */
.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.crew-card {
  background: #fff;
  border: 3px solid #e2e8f0;
  border-radius: 20px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
  position: relative;
}

.crew-card:hover { transform: translateY(-3px); }
.crew-card:active { transform: scale(0.97); }
.crew-card.selected {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.22), var(--shadow-card);
}

.crew-avatar {
  width: 82px;
  height: 82px;
  transition: transform 0.2s;
}
.crew-avatar.cheer-bounce {
  animation: popBounce 0.55s ease;
}

.crew-name {
  font-size: 1.08rem;
  font-weight: 900;
  color: var(--ink);
}

.crew-role {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
}

.crew-pill {
  font-size: 0.78rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.crew-pill.active {
  background: #ef4444;
  color: #fff;
}

.crew-speech-box {
  background: #ffffff;
  border: 3px solid #fbbf24;
  border-radius: 18px;
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
  cursor: pointer;
}

.crew-mini-avatar {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.crew-speech-text {
  font-size: 0.98rem;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.35;
}

.crew-speech-sub {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 2px;
}

.victory-crew-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.victory-crew-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.victory-crew-chip .crew-mini-avatar {
  width: 68px;
  height: 68px;
}

.victory-crew-chip span {
  font-size: 0.82rem;
  font-weight: 900;
  color: #334155;
}

/* Weak Words Banner */
.weak-banner {
  margin-top: 18px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 3px dashed #d97706;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Flashcard Garage (Learn View) */
.level-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.level-tab {
  flex-shrink: 0;
  padding: 9px 15px;
  border-radius: 999px;
  border: 2.5px solid #cbd5e1;
  background: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.95rem;
  color: #475569;
  cursor: pointer;
}

.level-tab.active {
  background: #ef4444;
  color: #fff;
  border-color: #b91c1c;
}

.flashcard-stage {
  background: #fff;
  border: 4px solid #38bdf8;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card);
  text-align: center;
  margin-bottom: 18px;
}

.flashcard-svg {
  width: 240px;
  max-width: 80%;
  margin: 0 auto 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.flashcard-svg:active { transform: scale(1.08) rotate(-2deg); }
.flashcard-svg.bounce { animation: popBounce 0.55s ease; }

@keyframes popBounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.16) rotate(-3deg); }
  70% { transform: scale(0.95) rotate(2deg); }
  100% { transform: scale(1); }
}

.word-big {
  font-size: 2.7rem;
  font-weight: 900;
  color: #1e3a8a;
  letter-spacing: 2px;
  margin: 4px 0;
}

.word-phonics {
  display: inline-block;
  background: #fef3c7;
  color: #b45309;
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1rem;
  margin-bottom: 8px;
}

.word-zh {
  font-size: 1.4rem;
  font-weight: 900;
  color: #ef4444;
  margin-bottom: 10px;
}

.word-sentence {
  background: #f8fafc;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 10px auto 14px;
  max-width: 520px;
  border: 2px solid #e2e8f0;
}
.word-sentence .en { font-weight: 800; color: #1e293b; font-size: 1.05rem; }
.word-sentence .zh { font-weight: 700; color: #64748b; font-size: 0.92rem; margin-top: 2px; }

.flashcard-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.word-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.thumb-card {
  background: #fff;
  border: 3px solid #e2e8f0;
  border-radius: 18px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.thumb-card.active {
  border-color: #ef4444;
  background: #fef2f2;
  transform: scale(1.03);
}
.thumb-svg { width: 92px; height: 60px; margin: 0 auto; }
.thumb-en { font-weight: 900; font-size: 1rem; color: var(--ink); }
.thumb-zh { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.thumb-stars { font-size: 0.85rem; margin-top: 2px; }

/* Shared Game Shell */
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.game-badge {
  background: #1e293b;
  color: #fde047;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.95rem;
}

/* Game 1: Listen & Race Track */
.race-track-box {
  background: #334155;
  border: 4px solid #1e293b;
  border-radius: 20px;
  padding: 14px 18px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.race-lane {
  position: relative;
  height: 62px;
  border-top: 3px dashed rgba(255,255,255,0.45);
  border-bottom: 3px dashed rgba(255,255,255,0.45);
  display: flex;
  align-items: center;
}

.race-car-mover {
  position: absolute;
  left: 0%;
  width: 96px;
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 3;
}

.race-finish-flag {
  position: absolute;
  right: 6px;
  font-size: 2rem;
  z-index: 2;
}

.audio-prompt-card {
  background: linear-gradient(135deg, #fef2f2, #fffbeb);
  border: 4px solid #ef4444;
  border-radius: var(--radius-xl);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.big-speaker-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #1d4ed8, 0 10px 20px rgba(37, 99, 235, 0.3);
  transition: transform 0.12s;
  margin-bottom: 8px;
}
.big-speaker-btn:active { transform: scale(0.92); }

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

.choice-card {
  background: #fff;
  border: 4px solid #cbd5e1;
  border-radius: 22px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 0 #cbd5e1;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.choice-card:active { transform: translateY(3px); box-shadow: 0 2px 0 #cbd5e1; }
.choice-card.correct {
  border-color: #16a34a;
  background: #dcfce7;
  box-shadow: 0 6px 0 #15803d;
  animation: popBounce 0.5s ease;
}
.choice-card.wrong {
  border-color: #ef4444;
  background: #fee2e2;
  animation: shake 0.36s ease;
}

.choice-word-only {
  font-size: 1.75rem;
  font-weight: 900;
  color: #1e3a8a;
  padding: 18px 8px;
}

.choice-en-label {
  font-size: 1.45rem;
  font-weight: 900;
  color: #1e3a8a;
  margin-top: 6px;
  line-height: 1.15;
  word-break: break-word;
}

.choice-zh-sub {
  font-size: 0.9rem;
  font-weight: 800;
  color: #64748b;
  margin-top: 2px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Game 2: Memory Match */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 680px;
  margin: 0 auto;
}
.memory-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.mem-card {
  aspect-ratio: 4 / 3;
  perspective: 900px;
  cursor: pointer;
}

.mem-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s;
  transform-style: preserve-3d;
}

.mem-card.flipped .mem-inner,
.mem-card.matched .mem-inner {
  transform: rotateY(180deg);
}

.mem-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-shadow: 0 5px 0 rgba(30,41,59,0.16);
}

.mem-front {
  background: linear-gradient(135deg, #ef4444, #f97316);
  border: 4px solid #fde047;
  color: #fde047;
  font-size: 1.8rem;
  font-weight: 900;
}

.mem-back {
  background: #ffffff;
  border: 4px solid #38bdf8;
  transform: rotateY(180deg);
}

.mem-card.matched .mem-back {
  border-color: #16a34a;
  background: #dcfce7;
}

.mem-word {
  font-size: 1.35rem;
  font-weight: 900;
  color: #1e3a8a;
  text-align: center;
}

/* Game 3: Pit-Stop Tire Spelling */
.pitstop-stage {
  background: #fff;
  border: 4px solid #10b981;
  border-radius: var(--radius-xl);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.spell-slots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 22px;
}

.spell-slot {
  width: 54px;
  height: 62px;
  border-radius: 14px;
  border: 3.5px dashed #94a3b8;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  color: #1e3a8a;
  position: relative;
}

.spell-slot.space-slot {
  width: 20px;
  border: none;
  background: transparent;
}

.spell-slot.prefilled {
  border-style: solid;
  border-color: #cbd5e1;
  background: #e0f2fe;
  color: #0369a1;
}

.spell-slot.filled {
  border-style: solid;
  border-color: #16a34a;
  background: #dcfce7;
  color: #15803d;
  animation: popBounce 0.35s ease;
}

.spell-slot.active-slot {
  border-color: #ef4444;
  background: #fef2f2;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

.spell-slot .ghost-hint {
  opacity: 0.22;
  color: #ef4444;
}

.tire-bank {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.tire-letter {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 6px solid #1e293b;
  background: radial-gradient(circle, #fde047 0%, #f59e0b 65%, #ef4444 100%);
  color: #78350f;
  font-family: inherit;
  font-size: 1.85rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #0f172a;
  transition: transform 0.12s, opacity 0.2s;
  display: grid;
  place-items: center;
}
.tire-letter:active { transform: translateY(3px) scale(0.95); }
.tire-letter.used { opacity: 0.25; pointer-events: none; }
.tire-letter.hint-glow {
  box-shadow: 0 0 0 6px #38bdf8, 0 5px 0 #0f172a;
  animation: popBounce 0.6s infinite;
}

/* Victory Card */
.victory-card {
  background: linear-gradient(135deg, #fef9c3, #fffbeb 55%, #fef2f2);
  border: 4px solid #f59e0b;
  border-radius: var(--radius-xl);
  padding: 26px 20px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.victory-trophy { font-size: 4.5rem; animation: popBounce 0.9s infinite; }
.victory-title { font-size: 1.8rem; font-weight: 900; color: #b45309; margin: 6px 0; }
.victory-sub { font-size: 1.05rem; font-weight: 700; color: #475569; margin-bottom: 16px; }

/* Stickers & Garage */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
}

.sticker-card {
  background: #fff;
  border: 3px solid #fde047;
  border-radius: 20px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.sticker-card.locked {
  border-color: #cbd5e1;
  background: #f1f5f9;
  opacity: 0.65;
  filter: grayscale(1);
}
.sticker-icon { font-size: 2.8rem; margin-bottom: 6px; }
.sticker-name { font-weight: 900; font-size: 1rem; color: var(--ink); }
.sticker-desc { font-size: 0.82rem; color: var(--muted); font-weight: 700; margin-top: 3px; }

/* Parent Dashboard */
.parent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-box {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  border: 2.5px solid #e2e8f0;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.metric-val { font-size: 1.9rem; font-weight: 900; color: #2563eb; }
.metric-label { font-size: 0.85rem; font-weight: 800; color: var(--muted); }

.panel-card {
  background: #fff;
  border-radius: 20px;
  padding: 18px;
  border: 2.5px solid #e2e8f0;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  gap: 12px;
  flex-wrap: wrap;
}
.setting-row:last-child { border-bottom: none; }

.word-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.word-report-table th, .word-report-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
.word-report-table th { color: var(--muted); font-weight: 800; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 3px solid #ef4444;
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}

.nav-btn {
  flex: 1;
  max-width: 180px;
  border: none;
  background: transparent;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 14px;
  cursor: pointer;
  color: #64748b;
  font-weight: 800;
  transition: background 0.15s, color 0.15s;
}
.nav-btn.active {
  background: #fef2f2;
  color: #dc2626;
}
.nav-icon { font-size: 1.45rem; line-height: 1.1; }
.nav-label { font-size: 0.8rem; }

/* Toast & Confetti */
.toast-banner {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fde047;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1.05rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  z-index: 90;
  transition: opacity 0.25s, transform 0.25s;
  text-align: center;
  max-width: 90vw;
}
.toast-banner.hidden { opacity: 0; pointer-events: none; transform: translate(-50%, -14px); }

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 80;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: confettiFall 1.8s linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

input[type="text"], select {
  font-family: inherit;
  font-size: 16px; /* Prevents iOS Safari auto-zoom on focus */
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  font-weight: 700;
  user-select: text;
  -webkit-user-select: text;
}

.word-report-table {
  min-width: 520px;
}

@media (max-width: 600px) {
  .top-bar {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    gap: 8px;
  }
  .brand {
    gap: 8px;
    min-width: 0;
  }
  .brand-badge {
    font-size: 0.95rem;
    padding: 6px 8px;
    border-radius: 11px;
    flex-shrink: 0;
  }
  .brand-text {
    min-width: 0;
  }
  .brand-title {
    font-size: 0.96rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-sub {
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .top-stats {
    gap: 5px;
    flex-shrink: 0;
  }
  .stat-pill {
    padding: 5px 9px;
    font-size: 0.88rem;
    gap: 3px;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .app-main {
    padding: 14px 12px 20px;
  }
  .hero-card {
    flex-direction: column-reverse;
    text-align: center;
    padding: 16px 14px;
  }
  .hero-copy h1 { font-size: 1.3rem; }
  .hero-copy p { font-size: 0.92rem; }
  .hero-copy > div { justify-content: center !important; }
  .hero-mascot { width: 145px; }
  /* Compact 3-across Family Pit Crew on phones so Papa Kenny, Mama Soki & Grandma Tracy fit cleanly side-by-side */
  .crew-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .crew-card {
    padding: 10px 6px;
    border-radius: 16px;
    gap: 4px;
  }
  .crew-avatar { width: 58px; height: 58px; }
  .crew-name { font-size: 0.82rem; }
  .crew-role { font-size: 0.68rem; line-height: 1.2; }
  .crew-pill { font-size: 0.68rem; padding: 3px 7px; }
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .game-card { padding: 14px 10px; }
  .game-icon { font-size: 2.1rem; }
  .game-title { font-size: 1rem; }
  .game-desc { font-size: 0.8rem; }
  .word-big { font-size: 2.15rem; word-break: break-word; }
  .choice-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .choice-word-only { font-size: 1.35rem; padding: 14px 6px; }
  .choice-en-label { font-size: 1.15rem; }
  .choice-zh-sub { font-size: 0.8rem; }
  .memory-grid {
    gap: 8px;
  }
  .memory-grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .mem-card { aspect-ratio: 1 / 0.9; }
  .mem-word { font-size: 1.05rem; word-break: break-word; }
  .spell-slots { gap: 5px; }
  .spell-slot { width: 38px; height: 48px; font-size: 1.45rem; border-radius: 11px; }
  .tire-letter { width: 54px; height: 54px; font-size: 1.5rem; border-width: 5px; }
  .race-car-mover { width: 76px; }
  .btn-lg { font-size: 1.05rem; padding: 13px 18px; }
  .section-title { font-size: 1.1rem; }
  .subject-tab { padding: 9px 4px; border-radius: 14px; }
  .subject-tab .subj-icon { font-size: 1.45rem; }
  .subject-tab .subj-name { font-size: 0.88rem; }
  .subject-tab .subj-sub { font-size: 0.66rem; }
  .zh-char-box { font-size: 2.7rem; min-width: 96px; min-height: 92px; }
  .choice-zh-only { font-size: 1.7rem; padding: 12px 6px; }
  .math-big-eq { font-size: 1.95rem; }
  .math-emoji { font-size: 1.75rem; }
  .math-choice-label { font-size: 1.5rem; padding: 10px 4px; }
  .daily-calendar { gap: 4px; }
  .cal-day { padding: 6px 2px; border-radius: 10px; }
  .cal-dot { width: 14px; height: 14px; font-size: 0.54rem; }
  .nav-label { font-size: 0.72rem; }
}
