:root {
  --primary: #FF6B35;
  --primary-light: #FF8C5A;
  --primary-dark: #E55520;
  --teal: #4ECDC4;
  --teal-dark: #3AB5AC;
  --yellow: #FFE66D;
  --yellow-dark: #F5D93A;
  --bg: #FFF9F5;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-muted: #7F8C8D;
  --success: #27AE60;
  --danger: #E74C3C;
  --math: #3498DB;
  --math-light: #5DADE2;
  --english: #27AE60;
  --english-light: #58D68D;
  --science: #9B59B6;
  --science-light: #BB8FCE;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 680px;
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: center;
  padding: 24px 0 16px;
}

.logo {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -1px;
}

.logo span {
  color: var(--teal);
}

.tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 12px 0;
  flex-wrap: wrap;
}

.stat-chip {
  background: white;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip .icon { font-size: 1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 50px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  min-height: 52px;
  min-width: 52px;
  text-decoration: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 0 var(--primary-dark);
}

.btn-primary:hover { background: var(--primary-light); }

.btn-teal {
  background: var(--teal);
  color: white;
  box-shadow: 0 4px 0 var(--teal-dark);
}

.btn-yellow {
  background: var(--yellow);
  color: var(--text);
  box-shadow: 0 4px 0 var(--yellow-dark);
}

.btn-ghost {
  background: white;
  color: var(--text);
  border: 2px solid #E0E0E0;
  box-shadow: none;
}

.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm {
  padding: 10px 20px;
  font-size: 0.9rem;
  min-height: 44px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Subject cards */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px 0;
}

.subject-card {
  border: none;
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 100px;
}

.subject-card:active { transform: scale(0.95); }

.subject-card .emoji { font-size: 2.2rem; }

.subject-card.math { background: var(--math); color: white; box-shadow: 0 4px 0 #2980B9; }
.subject-card.english { background: var(--english); color: white; box-shadow: 0 4px 0 #1E8449; }
.subject-card.science { background: var(--science); color: white; box-shadow: 0 4px 0 #7D3C98; }

/* Level grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0;
}

.level-btn {
  border: 3px solid #E8E8E8;
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  background: white;
  transition: all 0.15s;
  min-height: 52px;
}

.level-btn:active { transform: scale(0.95); }
.level-btn.k { border-color: var(--teal); color: var(--teal); }
.level-btn.p { border-color: var(--math); color: var(--math); }
.level-btn.s { border-color: var(--science); color: var(--science); }
.level-btn.k:hover { background: var(--teal); color: white; }
.level-btn.p:hover { background: var(--math); color: white; }
.level-btn.s:hover { background: var(--science); color: white; }

/* Game type cards */
.gametype-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 8px 0;
}

.gametype-card {
  border: 3px solid #E8E8E8;
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  background: white;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.gametype-card:active { transform: scale(0.98); }
.gametype-card:hover { border-color: var(--primary); background: #FFF5F1; }
.gametype-card .gt-emoji { font-size: 2rem; }
.gametype-card .gt-title { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.gametype-card .gt-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* Progress */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.progress-bar-wrap {
  flex: 1;
  height: 12px;
  background: #E8E8E8;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--primary));
  border-radius: 6px;
  transition: width 0.4s ease;
}

.progress-label {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Score / streak chips */
.game-stats {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chip {
  background: white;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip.streak { background: var(--yellow); }
.chip.score { background: var(--teal); color: white; }

/* Question card */
.question-text {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 20px;
}

.question-number {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

/* MCQ options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  width: 100%;
  background: white;
  border: 2.5px solid #E8E8E8;
  border-radius: 12px;
  padding: 14px 18px;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.option-btn:hover:not(:disabled) { border-color: var(--primary); background: #FFF5F1; }
.option-btn .option-label {
  background: #F0F0F0;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.option-btn.correct { border-color: var(--success); background: #EAFAF1; }
.option-btn.correct .option-label { background: var(--success); color: white; }
.option-btn.wrong { border-color: var(--danger); background: #FDEDEC; }
.option-btn.wrong .option-label { background: var(--danger); color: white; }
.option-btn:disabled { cursor: default; }

/* Fill blank */
.fill-sentence {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.7;
  margin-bottom: 20px;
  text-align: center;
}

.fill-input-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.fill-input {
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  border: 3px solid #E8E8E8;
  border-radius: 12px;
  padding: 12px 18px;
  width: 220px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.fill-input:focus { border-color: var(--primary); }
.fill-input.correct { border-color: var(--success); background: #EAFAF1; }
.fill-input.wrong { border-color: var(--danger); background: #FDEDEC; }

/* Matching game */
.matching-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-item {
  border: 2.5px solid #E8E8E8;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
}

.match-item:hover { border-color: var(--primary); background: #FFF5F1; }
.match-item.selected { border-color: var(--primary); background: var(--primary); color: white; }
.match-item.matched-ok { border-color: var(--success); background: #EAFAF1; color: var(--success); cursor: default; }
.match-item.matched-err { border-color: var(--danger); background: #FDEDEC; color: var(--danger); }

.match-score { text-align: center; font-weight: 700; color: var(--text-muted); font-size: 0.9rem; }

/* Result overlay */
.result-banner {
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin: 12px 0;
}

.result-banner.correct { background: linear-gradient(135deg, #EAFAF1, #D5F5E3); border: 2px solid var(--success); }
.result-banner.wrong { background: linear-gradient(135deg, #FDEDEC, #FADBD8); border: 2px solid var(--danger); }

.result-emoji { font-size: 3rem; margin-bottom: 8px; }
.result-title { font-size: 1.4rem; font-weight: 900; margin-bottom: 8px; }
.result-points { font-size: 1rem; font-weight: 700; color: var(--text-muted); }
.result-explanation { font-size: 0.95rem; line-height: 1.5; margin-top: 12px; color: var(--text); }
.fun-fact { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; font-style: italic; }

/* Summary */
.summary-card {
  text-align: center;
  padding: 32px 24px;
}

.summary-score {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--primary);
}

.summary-label { font-size: 1rem; color: var(--text-muted); margin-bottom: 24px; }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.summary-stat {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
}

.summary-stat .val { font-size: 1.8rem; font-weight: 900; }
.summary-stat .key { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

.star-row { font-size: 2rem; margin: 8px 0; }

/* Loading */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 16px;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 6px solid #F0F0F0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Hint / action bar */
.action-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Section label */
.section-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.breadcrumb .crumb {
  background: white;
  border-radius: 20px;
  padding: 4px 12px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.breadcrumb .crumb.math { color: var(--math); }
.breadcrumb .crumb.english { color: var(--english); }
.breadcrumb .crumb.science { color: var(--science); }

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

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

@keyframes popIn {
  0% { transform: scale(0.7); opacity: 0; }
  80% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.bounce { animation: bounce 0.6s ease; }
.shake { animation: shake 0.5s ease; }
.pop-in { animation: popIn 0.4s ease forwards; }

/* Divider */
.divider {
  height: 1px;
  background: #F0F0F0;
  margin: 12px 0;
}

/* Section title */
.section-title {
  font-size: 1.3rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.section-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Back link */
.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  margin-bottom: 8px;
}

.back-btn:hover { color: var(--primary); }

/* Responsive */
@media (max-width: 400px) {
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .subject-grid { grid-template-columns: 1fr; }
  .fill-input { width: 100%; }
}

.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.w-full { width: 100%; }
