/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --secondary: #FF6B6B;
  --success: #51CF66;
  --success-dark: #40C057;
  --danger: #FF5252;
  --warning: #FFD43B;
  --info: #4DABF7;
  --bg: #F3F0FF;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-light: #636E72;
  --border: #E9ECEF;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 24px rgba(108,99,255,0.12);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 2rem; font-weight: 900; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; }
p  { line-height: 1.6; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 50px;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-primary  { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(108,99,255,0.4); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 16px rgba(108,99,255,0.5); }
.btn-success  { background: var(--success); color: white; box-shadow: 0 4px 12px rgba(81,207,102,0.4); }
.btn-danger   { background: var(--danger); color: white; }
.btn-ghost    { background: white; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost:hover { background: var(--primary); color: white; }
.btn-sm { padding: 8px 18px; font-size: 0.9rem; }
.btn-lg { padding: 18px 36px; font-size: 1.15rem; }
.btn-block { width: 100%; display: flex; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== HEADER ===== */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.back-btn {
  background: white;
  border: none;
  border-radius: 50%;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  transition: all 0.15s;
}
.back-btn:hover { background: var(--primary); color: white; }
.screen-title { font-size: 1.4rem; font-weight: 900; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.card-hover { cursor: pointer; transition: all 0.2s; }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

/* ===== HOME SCREEN ===== */
.home-header {
  text-align: center;
  padding: 32px 0 24px;
}
.home-logo { font-size: 4rem; display: block; margin-bottom: 8px; animation: pulse 2s infinite; }
.home-title { font-size: 2.2rem; font-weight: 900; color: var(--primary); }
.home-subtitle { color: var(--text-light); font-size: 1rem; margin-top: 4px; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.profiles-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 16px;
  text-align: center;
}

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.profile-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}
.profile-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.profile-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: var(--kid-color);
}
.profile-avatar { font-size: 3.5rem; margin-bottom: 10px; display: block; }
.profile-name { font-size: 1.3rem; font-weight: 900; }
.profile-age { font-size: 0.85rem; color: var(--text-light); font-weight: 600; margin-top: 2px; }
.profile-stars { font-size: 0.9rem; margin-top: 8px; font-weight: 700; }

.ouder-btn { width: 100%; text-align: center; margin-top: 8px; }

/* ===== KID MENU ===== */
.kid-header {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border-left: 6px solid var(--kid-color);
}
.kid-header-avatar { font-size: 3rem; }
.kid-header-info { flex: 1; }
.kid-header-name { font-size: 1.4rem; font-weight: 900; }
.kid-header-stars { font-size: 0.95rem; color: var(--text-light); font-weight: 600; margin-top: 2px; }

.streak-badge {
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  color: white;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 800;
}

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.menu-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  border: 3px solid transparent;
}
.menu-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--kid-color); }
.menu-card-icon { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.menu-card-title { font-size: 1rem; font-weight: 800; }
.menu-card-desc { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }

/* ===== TOPIC SELECTION ===== */
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.topic-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  border: 3px solid transparent;
}
.topic-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.topic-card.selected { border-color: var(--primary); background: #F0EEFF; }
.topic-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.topic-name { font-size: 0.95rem; font-weight: 800; }
.topic-score { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; }
.topic-bar { height: 4px; background: #eee; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.topic-bar-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }
.topic-card.weak .topic-bar-fill { background: var(--danger); }

.mix-card {
  background: linear-gradient(135deg, var(--primary), #9B59B6);
  color: white;
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  grid-column: 1 / -1;
  transition: all 0.2s;
}
.mix-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(108,99,255,0.4); }

/* ===== LEARNING SESSION ===== */
.learn-explanation {
  background: linear-gradient(135deg, #F0EEFF, #E8F5FF);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  border-left: 5px solid var(--primary);
}
.learn-title { font-size: 1.3rem; font-weight: 900; color: var(--primary); margin-bottom: 12px; }
.learn-text { font-size: 0.95rem; line-height: 1.7; }
.learn-examples { margin-top: 16px; }
.learn-example {
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.learn-example .ex-icon { font-size: 1.3rem; }

/* ===== QUIZ / TEST ===== */
.progress-bar-wrap {
  background: #E9ECEF;
  border-radius: 50px;
  height: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #9B59B6);
  border-radius: 50px;
  transition: width 0.4s ease;
}

.quiz-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-light);
}
.quiz-score-live {
  background: var(--primary);
  color: white;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: 800;
}

.question-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.question-number { font-size: 0.85rem; color: var(--text-light); font-weight: 700; margin-bottom: 12px; }
.question-text {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.4;
  color: var(--text);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.question-hint { font-size: 0.85rem; color: var(--text-light); margin-top: 12px; font-style: italic; }

.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.choice-btn {
  background: white;
  border: 3px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.choice-btn:hover:not(:disabled) { border-color: var(--primary); background: #F0EEFF; transform: scale(1.02); }
.choice-btn.correct { border-color: var(--success); background: #EBFBEE; color: var(--success-dark); }
.choice-btn.wrong { border-color: var(--danger); background: #FFF5F5; color: var(--danger); }
.choice-btn.reveal-correct { border-color: var(--success); background: #EBFBEE; animation: flash-correct 0.5s; }
.choice-btn:disabled { cursor: not-allowed; }

@keyframes flash-correct {
  0%, 100% { background: #EBFBEE; }
  50% { background: #B2F2BB; }
}

.feedback-message {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  margin-bottom: 16px;
  animation: fadeInUp 0.2s ease;
}
.feedback-correct { background: #EBFBEE; color: var(--success-dark); }
.feedback-wrong { background: #FFF5F5; color: var(--danger); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.timer-display {
  background: white;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-weight: 900;
  font-size: 1.3rem;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.timer-display.warning { color: var(--danger); animation: timer-pulse 1s infinite; }
@keyframes timer-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== RESULTS SCREEN ===== */
.results-hero {
  background: linear-gradient(135deg, var(--primary), #9B59B6);
  color: white;
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(108,99,255,0.3);
}
.results-emoji { font-size: 4rem; display: block; margin-bottom: 12px; }
.results-score { font-size: 3rem; font-weight: 900; }
.results-label { font-size: 1rem; opacity: 0.85; }
.results-stars { font-size: 2.5rem; margin-top: 16px; letter-spacing: 4px; }

.results-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.results-stat {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.results-stat-num { font-size: 1.8rem; font-weight: 900; }
.results-stat-label { font-size: 0.75rem; color: var(--text-light); font-weight: 600; margin-top: 2px; }
.results-stat.green .results-stat-num { color: var(--success-dark); }
.results-stat.red .results-stat-num { color: var(--danger); }

.new-badges-section { margin-bottom: 16px; }
.new-badges-title { font-size: 1rem; font-weight: 800; margin-bottom: 10px; }
.new-badge-card {
  background: linear-gradient(135deg, #FFD43B, #FF8E53);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  animation: badge-appear 0.5s ease;
}
@keyframes badge-appear {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}
.new-badge-emoji { font-size: 2rem; }
.new-badge-info { color: white; }
.new-badge-name { font-weight: 900; }
.new-badge-desc { font-size: 0.8rem; opacity: 0.9; margin-top: 2px; }

/* ===== BADGES SCREEN ===== */
.badges-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.badge-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.badge-card.locked { opacity: 0.4; filter: grayscale(1); }
.badge-card.earned { border: 3px solid var(--warning); }
.badge-card.earned:hover { transform: translateY(-2px); }
.badge-emoji { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.badge-name { font-size: 0.9rem; font-weight: 800; }
.badge-desc { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; }
.badge-earned-date { font-size: 0.7rem; color: var(--primary); font-weight: 700; margin-top: 6px; }

/* ===== PARENT DASHBOARD ===== */
.dashboard-kid-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border-left: 6px solid var(--kid-color);
}
.dashboard-kid-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.dashboard-kid-header .avatar { font-size: 2.2rem; }
.dashboard-kid-header h3 { font-size: 1.1rem; }
.dashboard-kid-header .meta { font-size: 0.85rem; color: var(--text-light); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-box { background: var(--bg); border-radius: 12px; padding: 12px; text-align: center; }
.stat-box-num { font-size: 1.5rem; font-weight: 900; color: var(--primary); }
.stat-box-label { font-size: 0.7rem; color: var(--text-light); font-weight: 600; }

.topic-progress-list { }
.topic-progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.topic-progress-name { font-size: 0.85rem; font-weight: 700; width: 130px; flex-shrink: 0; }
.topic-progress-bar { flex: 1; height: 10px; background: #eee; border-radius: 5px; overflow: hidden; }
.topic-progress-fill { height: 100%; border-radius: 5px; transition: width 0.5s; }
.topic-progress-fill.good { background: var(--success); }
.topic-progress-fill.ok { background: var(--warning); }
.topic-progress-fill.weak { background: var(--danger); }
.topic-progress-pct { font-size: 0.8rem; font-weight: 800; width: 36px; text-align: right; }

.weak-topics-section {
  background: #FFF5F5;
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
}
.weak-topics-title { font-size: 0.85rem; font-weight: 800; color: var(--danger); margin-bottom: 8px; }
.weak-topic-chip {
  display: inline-block;
  background: var(--danger);
  color: white;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 3px;
}

.sessions-list { }
.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.session-item:last-child { border-bottom: none; }
.session-type-badge {
  display: inline-block;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}
.session-item .score { font-weight: 800; }
.session-item .date { color: var(--text-light); font-size: 0.78rem; }

/* ===== PIN MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; }
.modal-overlay.hidden { display: none; }
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  z-index: 101;
  width: min(400px, 90vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}
.modal.hidden { display: none; }
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--text-light); margin-bottom: 24px; font-size: 0.95rem; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 24px; }
.pin-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid var(--border);
  transition: all 0.2s;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 220px; margin: 0 auto 16px; }
.pin-key {
  background: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}
.pin-key:hover { background: var(--primary); color: white; }
.pin-key:active { transform: scale(0.93); }
.pin-error { color: var(--danger); font-size: 0.85rem; font-weight: 700; min-height: 20px; }

/* ===== RIDDLES ===== */
.riddle-card {
  background: linear-gradient(135deg, #FFF9DB, #FFF3BF);
  border-radius: var(--radius);
  padding: 24px;
  border: 2px dashed var(--warning);
  margin-bottom: 20px;
}
.riddle-label { font-size: 0.8rem; font-weight: 800; color: #B8860B; margin-bottom: 10px; letter-spacing: 1px; text-transform: uppercase; }
.riddle-text { font-size: 1.15rem; font-weight: 700; line-height: 1.6; }

.pattern-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 1.5rem;
  font-weight: 900;
  margin: 12px 0;
}
.pattern-blank {
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 4px 14px;
  min-width: 44px;
  text-align: center;
}

/* ===== LEARN SCREEN ===== */
.practice-mode-tag {
  background: var(--primary);
  color: white;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 800;
  display: inline-block;
  margin-bottom: 12px;
}

/* ===== ANIMATIONS ===== */
.screen-enter { animation: slideUp 0.25s ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.confetti-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 200;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ===== EMPTY STATES ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-state-icon { font-size: 3rem; display: block; margin-bottom: 12px; }

/* ===== UTILS ===== */
.text-center { text-align: center; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.gap-row { display: flex; gap: 10px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

.section-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .question-text { font-size: 1.2rem; }
  .choice-btn { font-size: 1rem; padding: 14px 8px; }
  .results-breakdown { grid-template-columns: 1fr 1fr 1fr; }
}
