:root {
  --bg: #FFF9F0;
  --card: #FFFFFF;
  --math: #FF6B6B;
  --science: #4ECDC4;
  --english: #45B7D1;
  --success: #6BCB77;
  --warning: #FFD93D;
  --text: #2D3436;
  --text-light: #636e72;
  --shadow: 0 4px 20px rgba(0,0,0,0.10);
  --radius: 24px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Nunito', 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

/* ===== HOME ===== */
.home-header {
  text-align: center;
  padding: 40px 20px 20px;
}
.home-header h1 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 900; color: var(--text); }
.home-header p { font-size: clamp(1rem, 3vw, 1.3rem); color: var(--text-light); margin-top: 8px; }

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 20px 24px 40px;
  max-width: 900px;
  margin: 0 auto;
}

.subject-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 30px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  display: block;
  border: 3px solid transparent;
}
.subject-card:active { transform: scale(0.96); }
.subject-card:hover { transform: translateY(-4px); box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.subject-card .emoji { font-size: 108px; display: block; margin-bottom: 16px; }
.subject-card h2 { font-size: 1.8rem; font-weight: 900; }
.subject-card p { font-size: 1rem; color: var(--text-light); margin-top: 6px; }
.subject-card.math { border-color: var(--math); }
.subject-card.science { border-color: var(--science); }
.subject-card.english { border-color: var(--english); }

.parent-btn {
  display: block;
  margin: 0 auto 40px;
  padding: 14px 36px;
  background: #f0f0f0;
  border: none;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: none;
  width: fit-content;
  transition: background 0.15s;
}
.parent-btn:hover { background: #e0e0e0; }

/* ===== LESSONS LIST ===== */
.page-header {
  display: flex;
  align-items: center;
  padding: 24px 24px 12px;
  gap: 14px;
}
.back-btn {
  font-size: 2rem;
  background: var(--card);
  border: none;
  border-radius: 50%;
  width: 52px; height: 52px;
  cursor: pointer;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: transform 0.1s;
}
.back-btn:active { transform: scale(0.9); }
.page-header h2 { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 900; }

.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 12px 24px 40px;
  max-width: 900px;
  margin: 0 auto;
}

.lesson-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: transform 0.15s;
  position: relative;
}
.lesson-card:active { transform: scale(0.95); }
.lesson-card .emoji { font-size: 78px; display: block; margin-bottom: 12px; }
.lesson-card h3 { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.lesson-card .subtitle { font-size: 0.9rem; color: var(--text-light); margin-top: 4px; }
.stars-badge {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 1rem;
}
.game-btns {
  display: flex; gap: 8px; justify-content: center;
  margin-top: 12px; flex-wrap: wrap;
}
.game-btn {
  padding: 7px 16px; border-radius: 50px;
  font-size: 0.82rem; font-weight: 900;
  text-decoration: none; display: inline-block;
  transition: transform 0.15s, opacity 0.15s;
}
.game-btn:active { transform: scale(0.93); opacity: 0.8; }
.game-btn.memory { background: #764ba2; color: white; }
.game-btn.bubble { background: #203a43; color: white; }

/* ===== QUIZ / LESSON ===== */
.lesson-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.progress-bar-wrap {
  background: #e9ecef;
  border-radius: 50px;
  height: 12px;
  margin: 12px 24px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 50px;
  background: var(--success);
  transition: width 0.4s ease;
}

.question-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 28px;
  margin: 16px 0;
  text-align: center;
  box-shadow: var(--shadow);
}
.question-emoji { font-size: 96px; margin-bottom: 16px; display: block; }
.question-text { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 800; line-height: 1.4; }
.question-visual { font-size: 3.3rem; margin: 12px 0; letter-spacing: 4px; }
.hint-text { font-size: 1rem; color: var(--text-light); margin-top: 10px; font-style: italic; }

.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.choice-btn {
  background: var(--card);
  border: 3px solid #e9ecef;
  border-radius: var(--radius-sm);
  padding: 20px 14px;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  min-height: 80px;
}
.choice-btn:active { transform: scale(0.93); }
.choice-btn.correct { background: var(--success); border-color: var(--success); color: white; animation: bounceIn 0.3s; }
.choice-btn.wrong { background: #FF6B6B; border-color: #FF6B6B; color: white; animation: shake 0.3s; }

@keyframes bounceIn {
  0% { transform: scale(0.9); } 50% { transform: scale(1.08); } 100% { transform: scale(1); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); }
}

.result-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-top: 20px;
}
.result-stars { font-size: 3.5rem; }
.result-score { font-size: 2.5rem; font-weight: 900; margin: 12px 0; }
.result-msg { font-size: 1.3rem; color: var(--text-light); }
.result-fact {
  background: #FFF9F0; border-radius: 12px; padding: 16px;
  margin-top: 20px; font-size: 1rem; color: var(--text); font-weight: 600;
}

.action-btn {
  display: inline-block;
  padding: 18px 40px;
  border-radius: 50px;
  border: none;
  font-size: 1.3rem;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  margin-top: 20px;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  text-decoration: none;
}
.action-btn:active { transform: scale(0.95); }
.action-btn.primary { background: var(--success); color: white; }
.action-btn.secondary { background: #e9ecef; color: var(--text); }

/* ===== ALPHABET ===== */
.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  padding: 12px 0;
}
.alpha-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 20px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}
.alpha-card:active { transform: scale(0.92); }
.alpha-card .letter { font-size: 4.5rem; font-weight: 900; line-height: 1; }
.alpha-card .word-emoji { font-size: 3.3rem; margin: 6px 0; }
.alpha-card .word { font-size: 1rem; font-weight: 700; }
.alpha-card .thai { font-size: 0.85rem; color: var(--text-light); }

/* ===== VOCAB CARDS ===== */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 12px 0;
}
.vocab-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 24px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}
.vocab-card:active { transform: scale(0.92); }
.vocab-card .v-emoji { font-size: 4.5rem; margin-bottom: 8px; }
.vocab-card .v-word { font-size: 1.3rem; font-weight: 900; }
.vocab-card .v-thai { font-size: 0.95rem; color: var(--text-light); margin-top: 4px; }

/* ===== PARENT DASHBOARD ===== */
.dashboard-container { max-width: 800px; margin: 0 auto; padding: 0 20px 60px; }
.child-selector { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 0; }
.child-chip {
  padding: 10px 22px; border-radius: 50px; border: 2px solid #e9ecef;
  font-size: 1rem; font-weight: 700; font-family: inherit; cursor: pointer;
  background: var(--card); transition: all 0.15s;
}
.child-chip.active { background: var(--text); color: white; border-color: var(--text); }
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
.summary-card {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 20px 14px; text-align: center; box-shadow: var(--shadow);
}
.summary-card .s-emoji { font-size: 2rem; }
.summary-card .s-score { font-size: 2rem; font-weight: 900; margin: 6px 0; }
.summary-card .s-label { font-size: 0.85rem; color: var(--text-light); }
.recent-list { list-style: none; }
.recent-item {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 18px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.recent-item .r-subject { font-size: 1.5rem; }
.recent-item .r-info { flex: 1; }
.recent-item .r-lesson { font-weight: 700; font-size: 0.95rem; }
.recent-item .r-date { font-size: 0.8rem; color: var(--text-light); }
.recent-item .r-score { font-size: 1.2rem; font-weight: 900; }

/* ===== CELEBRATION OVERLAY ===== */
.celebration {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.celebration-emoji {
  font-size: 120px;
  animation: popIn 0.5s ease forwards;
  opacity: 0;
}
@keyframes popIn {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== SPEAK BTN ===== */
.speak-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.6rem; padding: 6px; border-radius: 50%;
  transition: transform 0.1s;
}
.speak-btn:active { transform: scale(0.85); }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .summary-cards { grid-template-columns: repeat(3, 1fr); }
  .choices-grid { grid-template-columns: 1fr 1fr; }
  .question-card { padding: 24px 16px; }
}
