@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Baloo+2:wght@400;600;700;800&display=swap');

:root {
  --sky: #6EC6F0;
  --sun: #FFD94A;
  --grass: #4ECB71;
  --coral: #FF7A5A;
  --purple: #A07BE5;
  --pink: #FF9FC8;
  --cream: #FFF9EE;
  --dark: #2D2A40;
  --shadow: 0 6px 24px rgba(45,42,64,0.10);
  --radius: 22px;
  --font-main: 'Nunito', sans-serif;
  --font-display: 'Baloo 2', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: linear-gradient(160deg, #e0f4ff 0%, #fff9ee 60%, #e8ffe6 100%);
  min-height: 100vh;
  color: var(--dark);
  overflow-x: hidden;
}

/* === OFFLINE BANNER === */
.offline-banner {
  display: none;
  background: var(--coral);
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
}
body.offline .offline-banner { display: block; }

/* === HEADER === */
.header {
  background: white;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 3px 16px rgba(0,0,0,0.07);
  position: sticky; top: 0; z-index: 100;
}
.logo-wrap {
  display: flex; flex-direction: column; gap: 1px;
}
.logo-svg {
  width: 110px; height: 36px;
  overflow: visible;
  cursor: pointer;
  transition: transform 0.2s;
}
.logo-svg:active { transform: scale(0.95); }
/* Tap animation — bounce on click */
.logo-svg.bounce {
  animation: logoBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes logoBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15) rotate(-3deg); }
  70%  { transform: scale(0.95) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.subtitle { font-size: 12px; color: #aaa; font-weight: 600; margin-top: 1px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.star-count {
  background: linear-gradient(135deg, var(--sun), #FFB347);
  color: white; font-weight: 800; font-size: 15px;
  padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(255,180,0,0.3);
}
.parent-btn {
  background: #f0eaff; border: none; border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 700;
  color: var(--purple); cursor: pointer; font-family: var(--font-main);
}

/* === SCREENS === */
.screen { display: none; padding: 20px 16px 100px; }
.screen.active { display: block; }
.parent-screen { display: none; padding: 20px 16px 100px; }
.parent-screen.active { display: block; }

/* === HOME === */
.welcome-card {
  background: linear-gradient(135deg, var(--sky) 0%, var(--purple) 100%);
  border-radius: var(--radius); padding: 22px 20px 18px;
  color: white; margin-bottom: 24px; position: relative; overflow: hidden;
}
.welcome-card::before {
  content: '🌟'; font-size: 80px;
  position: absolute; right: -10px; top: -10px; opacity: 0.18;
}
.welcome-name { font-family: var(--font-display); font-size: 28px; font-weight: 800; }
.welcome-sub { font-size: 14px; opacity: 0.88; margin-top: 4px; line-height: 1.5; }
.xp-bar-wrap { margin-top: 14px; }
.xp-label { font-size: 12px; opacity: 0.8; margin-bottom: 5px; }
.xp-bar { background: rgba(255,255,255,0.3); border-radius: 999px; height: 10px; }
.xp-fill { background: var(--sun); border-radius: 999px; height: 10px; transition: width 0.8s ease; }
.streak-pill {
  display: inline-block; margin-top: 12px;
  background: rgba(255,255,255,0.2); border-radius: 999px;
  padding: 4px 14px; font-size: 13px; font-weight: 700;
}

.section-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 800;
  margin-bottom: 14px; color: var(--dark);
}
.section-title span { font-size: 22px; margin-right: 6px; }

.modules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 28px; }
.module-card {
  background: white; border-radius: var(--radius);
  padding: 18px 14px 16px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform 0.18s;
  border: 3px solid transparent; text-align: center;
}
.module-card:active { transform: scale(0.96); }
.module-card.fr { border-color: var(--sky); }
.module-card.math { border-color: var(--grass); }
.module-card.memory { border-color: var(--purple); }
.module-card.reward { border-color: var(--sun); }
.module-card.oral { border-color: var(--coral); }
.module-card.lecture { border-color: var(--pink); }
.module-icon { font-size: 40px; margin-bottom: 6px; }
.module-name { font-family: var(--font-display); font-size: 16px; font-weight: 800; color: var(--dark); }
.module-sub { font-size: 11px; color: #999; margin-top: 2px; }

/* === ACTIVITY === */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: white; border: none; border-radius: 999px;
  padding: 10px 18px; font-size: 15px; font-weight: 700;
  color: var(--dark); cursor: pointer; box-shadow: var(--shadow);
  margin-bottom: 20px; font-family: var(--font-main);
}
.activity-header {
  background: white; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.activity-title { font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.progress-wrap { margin-top: 12px; }
.progress-label { font-size: 12px; color: #aaa; margin-bottom: 5px; font-weight: 600; }
.progress-bar { background: #EEE; border-radius: 999px; height: 10px; }
.progress-fill { background: linear-gradient(90deg, var(--sky), var(--purple)); border-radius: 999px; height: 10px; transition: width 0.5s; }

.question-card {
  background: white; border-radius: var(--radius);
  padding: 24px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.question-audio-btn {
  background: linear-gradient(135deg, var(--sky), var(--purple));
  color: white; border: none; border-radius: 999px;
  padding: 10px 20px; font-size: 15px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; font-family: var(--font-main);
  box-shadow: 0 4px 12px rgba(110,198,240,0.4); transition: transform 0.15s;
}
.question-audio-btn:active { transform: scale(0.95); }
.question-text { font-size: 22px; font-weight: 800; line-height: 1.4; margin-bottom: 6px; }
.question-hint {
  font-size: 13px; color: #aaa; background: #f7f7f7;
  border-radius: 12px; padding: 8px 12px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 6px;
}
.image-hint { font-size: 56px; text-align: center; margin: 10px 0 16px; }

.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer-btn {
  background: #f4f4f8; border: 3px solid #e0e0e0;
  border-radius: 16px; padding: 16px 12px;
  font-size: 17px; font-weight: 800; color: var(--dark);
  cursor: pointer; transition: all 0.18s; font-family: var(--font-main);
  text-align: center; min-height: 64px;
  display: flex; align-items: center; justify-content: center;
}
.answer-btn:active { transform: scale(0.95); }
.answer-btn.correct { background: #d4f8e0; border-color: var(--grass); color: #1d8a40; }
.answer-btn.wrong { background: #ffe0da; border-color: var(--coral); color: #c0392b; }
.answer-btn:disabled { cursor: default; }

.feedback-card {
  border-radius: var(--radius); padding: 20px;
  margin-top: 14px; text-align: center; display: none;
}
.feedback-card.show { display: block; }
.feedback-card.good { background: linear-gradient(135deg, #d4f8e0, #b8f0cd); border: 2px solid var(--grass); }
.feedback-card.bad { background: linear-gradient(135deg, #ffe0da, #ffc8bc); border: 2px solid var(--coral); }
.feedback-emoji { font-size: 48px; }
.feedback-text { font-size: 17px; font-weight: 800; margin-top: 8px; }
.feedback-explain { font-size: 14px; color: #666; margin-top: 6px; line-height: 1.5; }

.next-btn {
  width: 100%; background: linear-gradient(135deg, var(--grass), #2ecc71);
  color: white; border: none; border-radius: 999px;
  padding: 16px; font-size: 18px; font-weight: 800;
  cursor: pointer; margin-top: 16px; font-family: var(--font-main);
  box-shadow: 0 6px 20px rgba(78,203,113,0.35);
  transition: transform 0.15s; display: none;
}
.next-btn.show { display: block; }
.next-btn:active { transform: scale(0.97); }

/* === LECTURE === */
.story-card {
  background: linear-gradient(135deg, #fff9ee, #fff0f5);
  border-radius: var(--radius); padding: 22px 20px;
  border: 2px solid var(--pink); margin-bottom: 16px;
  font-size: 18px; line-height: 1.9; color: var(--dark);
  box-shadow: var(--shadow);
}
.story-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 800;
  margin-bottom: 12px; color: var(--purple);
}
.story-image { font-size: 56px; text-align: center; margin-bottom: 14px; }
.story-listen-btn {
  background: linear-gradient(135deg, var(--pink), var(--coral));
  color: white; border: none; border-radius: 999px;
  padding: 10px 20px; font-size: 15px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; font-family: var(--font-main);
  box-shadow: 0 4px 12px rgba(255,159,200,0.4);
}

/* === DICTÉE === */
.dictee-listen-btn {
  background: linear-gradient(135deg, var(--coral), #ff5733);
  color: white; border: none; border-radius: 999px;
  padding: 16px 28px; font-size: 18px; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; gap: 10px;
  margin: 0 auto 20px; font-family: var(--font-main);
  box-shadow: 0 6px 20px rgba(255,122,90,0.4); transition: transform 0.15s;
}
.dictee-listen-btn:active { transform: scale(0.95); }
.dictee-letters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0; }
.letter-btn {
  background: white; border: 3px solid #e0e0e0; border-radius: 12px;
  padding: 12px 16px; font-size: 22px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main); min-width: 48px;
  text-align: center; transition: all 0.15s;
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.letter-btn:active { transform: scale(0.9); background: #f0eaff; border-color: var(--purple); }
.letter-btn:disabled { opacity: 0.3; }
.dictee-answer-row {
  display: flex; gap: 8px; justify-content: center;
  min-height: 56px; margin: 16px 0; flex-wrap: wrap;
}
.letter-slot {
  width: 44px; height: 52px; border-bottom: 3px solid var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: var(--dark);
  cursor: pointer; border-radius: 8px 8px 0 0;
}
.dictee-controls { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.dictee-ctrl-btn {
  background: #f4f4f8; border: 2px solid #e0e0e0;
  border-radius: 12px; padding: 10px 18px;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font-main);
}
.dictee-ctrl-btn.validate {
  background: linear-gradient(135deg, var(--grass), #2ecc71);
  color: white; border-color: var(--grass);
}

/* === ORAL === */
.oral-record-zone { text-align: center; margin: 20px 0; }
.oral-record-btn {
  background: linear-gradient(135deg, var(--coral), #e74c3c);
  color: white; border: none; border-radius: 50%;
  width: 100px; height: 100px; font-size: 36px;
  cursor: pointer; margin: 0 auto 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(255,122,90,0.4); transition: all 0.2s;
  font-family: var(--font-main);
}
.oral-record-btn.recording {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  animation: pulse 1s infinite;
  box-shadow: 0 0 0 0 rgba(231,76,60,0.4);
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
  70% { box-shadow: 0 0 0 20px rgba(231,76,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
}
.oral-record-label { font-size: 11px; font-weight: 700; margin-top: 4px; }
.oral-transcript-box {
  background: #f7f7f7; border-radius: 14px;
  padding: 14px 16px; font-size: 16px; color: #666;
  min-height: 60px; line-height: 1.5;
  border: 2px dashed #ddd; margin-top: 10px;
}
.oral-transcript-box.has-text { color: var(--dark); border-color: var(--purple); background: #f5f0ff; }
.oral-model-answer {
  background: #e8f8ee; border-radius: 14px; padding: 14px 16px;
  border: 2px solid var(--grass); margin-top: 14px;
}
.oral-model-label { font-size: 13px; font-weight: 800; color: var(--grass); margin-bottom: 6px; }
.oral-model-text { font-size: 16px; line-height: 1.5; color: var(--dark); }

/* === MEMORY === */
.difficulty-selector { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.diff-label { font-size: 13px; font-weight: 700; color: #888; }
.diff-btn {
  background: #f4f4f8; border: 2px solid #e0e0e0;
  border-radius: 12px; padding: 8px 14px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: var(--font-main); transition: all 0.15s; line-height: 1.3;
}
.diff-btn.active { background: #f0eaff; border-color: var(--purple); color: var(--purple); }
.memory-grid { display: grid; gap: 10px; margin-top: 10px; }
.memory-grid.easy { grid-template-columns: repeat(4, 1fr); }
.memory-grid.medium { grid-template-columns: repeat(4, 1fr); }
.memory-grid.hard { grid-template-columns: repeat(4, 1fr); }
.mem-card {
  aspect-ratio: 1; border-radius: 14px;
  background: linear-gradient(135deg, var(--sky), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  border: 3px solid transparent; user-select: none;
  transition: transform 0.15s;
}
.mem-card:active { transform: scale(0.92); }
.mem-card.matched { border-color: var(--grass); opacity: 0.7; pointer-events: none; }

/* === REWARD === */
.reward-screen-inner { text-align: center; padding: 30px 20px; }
.reward-trophy { font-size: 90px; margin-bottom: 10px; }
.reward-title { font-family: var(--font-display); font-size: 32px; font-weight: 900; }
.reward-stars { font-size: 32px; letter-spacing: 8px; margin: 16px 0; }
.reward-msg { font-size: 16px; color: #666; line-height: 1.6; margin-bottom: 24px; }
.reward-btn {
  background: linear-gradient(135deg, var(--sun), #FFB347);
  color: white; border: none; border-radius: 999px;
  padding: 16px 40px; font-size: 18px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
  box-shadow: 0 6px 20px rgba(255,180,0,0.35);
}

/* === PARENT === */
.parent-lock {
  background: white; border-radius: var(--radius);
  padding: 30px 20px; text-align: center; box-shadow: var(--shadow);
}
.parent-lock-icon { font-size: 64px; margin-bottom: 12px; }
.parent-lock-title { font-family: var(--font-display); font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.parent-lock-sub { font-size: 14px; color: #888; margin-bottom: 20px; }
.pin-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.pin-dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--purple); background: transparent; transition: background 0.2s; }
.pin-dot.filled { background: var(--purple); }
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 240px; margin: 0 auto 16px; }
.pin-btn {
  background: #f4f4f8; border: 2px solid #e0e0e0;
  border-radius: 14px; padding: 16px; font-size: 22px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main); transition: background 0.15s;
}
.pin-btn:active { background: #e8e0ff; border-color: var(--purple); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 20px; text-align: center; box-shadow: var(--shadow);
}
.stat-icon { font-size: 36px; margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 32px; font-weight: 900; color: var(--purple); }
.stat-label { font-size: 13px; color: #888; font-weight: 600; margin-top: 2px; }

/* === CALENDAR === */
.calendar-card {
  background: white; border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.calendar-legend { font-size: 12px; color: #888; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; }
.cal-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #e0e0e0; }
.cal-dot.active { background: var(--purple); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  aspect-ratio: 1; border-radius: 8px; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #bbb;
}
.cal-day.active { background: var(--purple); color: white; }
.cal-day.today { border: 2px solid var(--purple); }

/* === MODULE STATS === */
.module-stats { margin-top: 0; }
.mod-stat-row {
  background: white; border-radius: 16px;
  padding: 14px 18px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}
.mod-stat-icon { font-size: 28px; }
.mod-stat-info { flex: 1; }
.mod-stat-name { font-weight: 800; font-size: 15px; }
.mod-stat-bar { background: #EEE; border-radius: 999px; height: 8px; margin-top: 4px; }
.mod-stat-fill { background: linear-gradient(90deg, var(--sky), var(--purple)); border-radius: 999px; height: 8px; }
.mod-stat-pct { font-size: 13px; font-weight: 700; color: var(--purple); }

.encouragement-card {
  background: linear-gradient(135deg, var(--grass), #2ecc71);
  border-radius: var(--radius); padding: 18px 20px; color: white;
  margin-top: 20px; box-shadow: var(--shadow);
}
.enc-title { font-family: var(--font-display); font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.enc-item { font-size: 14px; opacity: 0.92; margin-bottom: 4px; }

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: white;
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 0 16px; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); z-index: 200;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  padding: 6px 10px; border-radius: 16px;
  transition: background 0.15s; font-family: var(--font-main);
}
.nav-btn.active { background: #f0eaff; }
.nav-icon { font-size: 22px; }
.nav-label { font-size: 10px; font-weight: 700; color: #aaa; }
.nav-btn.active .nav-label { color: var(--purple); }

/* === CONFETTI === */
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.confetti-piece {
  position: fixed; top: -20px; font-size: 20px;
  animation: fall linear forwards; pointer-events: none; z-index: 999;
}

/* === TABLET === */
@media (min-width: 600px) {
  .modules-grid { grid-template-columns: repeat(5, 1fr); }
  .screen, .parent-screen { max-width: 700px; margin: 0 auto; }
  .question-text { font-size: 26px; }
  .answer-btn { font-size: 20px; padding: 20px; min-height: 76px; }
}

/* ===================== NIVEAUX & RÉVISION ===================== */

/* Badge de niveau sur les cartes modules */
.module-card { position: relative; }
.lvl-badge {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 0 0 18px 18px;
  font-size: 12px; font-weight: 900;
  padding: 5px 0;
  text-align: center;
  font-family: var(--font-main);
  letter-spacing: 0.5px;
  background: var(--purple);
  color: white;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.10);
}
/* Couleurs par niveau */
.module-card[data-key] .lvl-badge { background: var(--grass); }


/* Badge niveau sur la question en cours */
.level-badge {
  display: inline-block; font-size: 12px; font-weight: 800;
  padding: 4px 12px; border-radius: 999px; margin-top: 6px;
  font-family: var(--font-main);
}
.level-badge:empty { display: none; }
.lvl-1 { background: #e8f8ee; color: var(--grass); }
.lvl-2 { background: #fff0e0; color: #e67e22; }
.lvl-3 { background: #f0eaff; color: var(--purple); }
.lvl-rev { background: #ffe0da; color: var(--coral); }

/* Bannière révision sur l'accueil */
.revision-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fff0e0, #ffe8d0);
  border: 2px solid var(--coral); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 20px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform 0.15s;
}
.revision-banner:active { transform: scale(0.97); }
.rev-icon { font-size: 34px; }
.rev-title { font-family: var(--font-display); font-size: 17px; font-weight: 800; color: var(--coral); }
.rev-sub { font-size: 12px; color: #aaa; margin-top: 2px; }
.rev-arrow { margin-left: auto; font-size: 22px; color: var(--coral); font-weight: 900; }

/* Bouton révision sur l'écran de résultat */
.reward-btn-rev {
  display: block; width: 100%; max-width: 260px; margin: 12px auto 0;
  background: linear-gradient(135deg, var(--coral), #e74c3c);
  color: white; border: none; border-radius: 999px;
  padding: 14px 30px; font-size: 16px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
  box-shadow: 0 6px 20px rgba(255,122,90,0.35);
}

/* Grille niveaux dans le dashboard parents */
.levels-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px;
}
.level-card {
  background: white; border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
  display: flex; align-items: center; gap: 10px;
}
.level-card-icon { font-size: 24px; }
.level-card-info { flex: 1; }
.level-card-name { font-weight: 800; font-size: 13px; }
.level-card-lvl {
  font-size: 12px; font-weight: 700; margin-top: 2px;
  color: var(--purple);
}
.level-stars { font-size: 14px; letter-spacing: 1px; }

/* Liste erreurs dans dashboard */
.errors-list { margin-bottom: 4px; }
.error-row {
  background: white; border-radius: 14px;
  padding: 12px 16px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
  border-left: 4px solid var(--coral);
}
.error-count {
  background: var(--coral); color: white;
  font-size: 12px; font-weight: 800; min-width: 28px;
  height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.error-text { font-size: 13px; color: var(--dark); line-height: 1.4; }
.error-module { font-size: 11px; color: #aaa; margin-top: 2px; }
.errors-empty {
  text-align: center; color: var(--grass); font-weight: 700;
  padding: 16px; background: #e8f8ee; border-radius: 14px;
  font-size: 14px;
}

/* ===================== GÉO + CONJ ORAL + TABLE ===================== */

/* Couleurs nouvelles cartes */
.module-card.geo   { border-color: #2ecc71; }
.module-card.conj  { border-color: var(--coral); }
.module-card.table { border-color: var(--sun); }

/* ── Conjugaison orale ── */
.conj-verb-display {
  text-align: center; margin-bottom: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.conj-verb-name {
  font-family: var(--font-display);
  font-size: 38px; font-weight: 900;
  background: linear-gradient(135deg, var(--coral), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: 3px;
}
.conj-tense-badge {
  background: linear-gradient(135deg, var(--purple), var(--sky));
  color: white; font-size: 13px; font-weight: 800;
  padding: 4px 16px; border-radius: 999px;
  font-family: var(--font-main); letter-spacing: 1px;
}
.conj-prompt {
  font-size: 17px; font-weight: 700; color: var(--dark);
  text-align: center; margin-bottom: 14px; line-height: 1.5;
}
.conj-transcript {
  font-family: var(--font-display) !important;
  font-size: 15px !important; line-height: 1.7 !important;
}

/* ── Table de multiplication ── */
.table-selector {
  background: white; border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.table-selector-label {
  font-size: 13px; font-weight: 700; color: #888; margin-bottom: 10px;
}
.table-btns {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.table-btn {
  background: #f4f4f8; border: 2px solid #e0e0e0;
  border-radius: 12px; padding: 10px 14px;
  font-size: 16px; font-weight: 800;
  cursor: pointer; font-family: var(--font-display);
  transition: all 0.15s; min-width: 48px; text-align: center;
}
.table-btn:active { transform: scale(0.92); }
.table-btn.active {
  background: linear-gradient(135deg, var(--sun), #FFB347);
  border-color: var(--sun); color: white;
  box-shadow: 0 4px 12px rgba(255,180,0,0.35);
}

.table-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px;
}
.table-grid { display: flex; flex-direction: column; }
.table-row {
  display: flex; align-items: center; gap: 0;
  padding: 13px 20px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer; transition: background 0.15s;
}
.table-row:last-child { border-bottom: none; }
.table-row.even { background: #fafafa; }
.table-row:active, .table-row.highlight {
  background: #f0eaff !important;
  transform: scale(1.01);
  transition: all 0.1s;
}
.t-left {
  font-family: var(--font-display); font-size: 20px;
  font-weight: 700; color: var(--dark); min-width: 80px;
}
.t-eq {
  font-size: 20px; color: #bbb; margin: 0 10px; font-weight: 300;
}
.t-result {
  font-family: var(--font-display); font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), var(--sky));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  flex: 1;
}
.t-listen {
  background: none; border: none; font-size: 20px;
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
  transition: background 0.15s; flex-shrink: 0;
}
.t-listen:active { background: #f0f0f0; }

.table-quiz-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--sun), #FFB347);
  color: white; border: none; border-radius: 999px;
  padding: 16px; font-size: 18px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
  box-shadow: 0 6px 20px rgba(255,180,0,0.35);
  transition: transform 0.15s; margin-bottom: 16px;
}
.table-quiz-btn:active { transform: scale(0.97); }

/* Tablette */
@media (min-width: 600px) {
  .table-btns { gap: 10px; }
  .table-btn { padding: 12px 18px; font-size: 18px; }
  .t-left { font-size: 22px; min-width: 100px; }
  .t-result { font-size: 30px; }
  .conj-verb-name { font-size: 48px; }
}

/* === Mario reward trophy === */
.reward-trophy {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0; /* hide any leftover text */
  margin-bottom: 10px;
}
.reward-trophy svg {
  width: 110px;
  height: 110px;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.18));
  animation: marioEntrance 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes marioEntrance {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

/* ===================== LECTURE NIVEAUX 4 & 5 ===================== */

.story-meta-row {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 4px;
}
.story-lvl-badge {
  color: white; font-size: 11px; font-weight: 800;
  padding: 3px 12px; border-radius: 999px;
  font-family: var(--font-main);
}

/* Bandeau d'inférence — niveaux 4 & 5 */
.inference-banner {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  border: 2px solid #FF7A5A;
  border-radius: 14px; padding: 10px 14px;
  font-size: 13px; font-weight: 700; color: #c0392b;
  margin-bottom: 14px; line-height: 1.5;
  align-items: flex-start; gap: 8px;
}

/* Texte des histoires longues — police légèrement plus petite, interligne confort */
.story-card {
  font-size: 17px;
  line-height: 2;
}

/* Niveaux 4-5 : couleur de fond différente pour le texte */
.story-card.lvl-high {
  background: linear-gradient(135deg, #fff8f0, #fff3e0);
  border-color: #FF7A5A;
}

/* Badge de niveau dans l'activity header */
.level-badge.lvl-4 { background: #ffe0da; color: var(--coral); }
.level-badge.lvl-5 { background: #ffd6d6; color: #c0392b; }

/* ===================== NOUVELLES FEATURES ===================== */

/* ── Couleurs nouvelles cartes ── */
.module-card.flash       { border-color: #f39c12; }
.module-card.karaoke     { border-color: var(--coral); }
.module-card.puzzle-card { border-color: var(--purple); }
.module-card.defi        { border-color: var(--grass); position: relative; }
.module-card.badges-card { border-color: var(--sun); }

.defi-badge-dot {
  position: absolute; top: 8px; right: 8px;
  background: var(--coral); color: white;
  font-size: 9px; font-weight: 900; padding: 2px 7px;
  border-radius: 999px; letter-spacing: 0.5px;
}

/* ── FLASHCARDS ── */
.flash-study-card {
  text-align: center;
}
.flash-emoji {
  font-size: 72px; margin-bottom: 10px;
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.flash-word {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 900;
  color: var(--dark); margin-bottom: 12px;
}
.flash-def {
  font-size: 17px; color: #555; line-height: 1.6;
  background: #f7f7f7; border-radius: 14px;
  padding: 12px 16px; margin-bottom: 10px;
}
.flash-exemple {
  font-size: 14px; color: var(--purple); font-style: italic;
  background: #f5f0ff; border-radius: 12px; padding: 8px 14px;
  margin-bottom: 16px;
}
.flash-next-btn { margin-top: 14px; }

.flash-quiz-word {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 900;
  color: var(--dark); text-align: center;
  margin: 16px 0 8px;
}
.flash-quiz-prompt {
  text-align: center; font-size: 18px; color: #888;
  font-weight: 700; margin-bottom: 16px;
}
.flash-answer-reveal {
  background: #e8f8ee; border-radius: 14px;
  padding: 14px; font-size: 16px; color: var(--dark);
  border: 2px solid var(--grass); margin: 10px 0;
  text-align: center; line-height: 1.6;
}
.flash-rate-zone {
  flex-direction: column; align-items: center;
  margin-top: 16px; gap: 10px;
}
.flash-rate-label {
  font-size: 15px; font-weight: 700; color: var(--dark);
}
.flash-rate-btns { display: flex; gap: 16px; }
.flash-rate-btn {
  border: none; border-radius: 999px;
  padding: 14px 28px; font-size: 17px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
  transition: transform 0.15s;
}
.flash-rate-btn:active { transform: scale(0.93); }
.flash-rate-btn.bad  { background: #ffe0da; color: var(--coral); }
.flash-rate-btn.good { background: #d4f8e0; color: #1d8a40; }

.flash-box-badge {
  display: inline-block; font-size: 11px; font-weight: 800;
  padding: 3px 12px; border-radius: 999px;
  font-family: var(--font-main); margin-top: 6px;
}
.box-0 { background: #ffe0da; color: var(--coral); }
.box-1 { background: #fff3e0; color: #e67e22; }
.box-2 { background: #e8f4ff; color: var(--sky); }
.box-3 { background: #f0eaff; color: var(--purple); }
.box-4 { background: #d4f8e0; color: #1d8a40; }

/* ── KARAOKÉ ── */
.karaoke-theme-badge {
  display: inline-block; background: var(--coral);
  color: white; font-size: 11px; font-weight: 800;
  padding: 3px 12px; border-radius: 999px;
  font-family: var(--font-main); margin-bottom: 8px;
}
.karaoke-emoji {
  font-size: 56px; text-align: center; margin-bottom: 10px;
}
.karaoke-hint {
  text-align: center; font-size: 13px; color: #888;
  font-weight: 600; margin-bottom: 16px;
}
.karaoke-word-display {
  min-height: 60px; background: #f7f7f7;
  border-radius: 16px; padding: 14px 16px;
  font-size: 20px; line-height: 1.8;
  margin-bottom: 16px; text-align: center;
  font-weight: 700; color: var(--dark);
}
.karaoke-word { color: #ccc; transition: color 0.2s, transform 0.2s; }
.karaoke-word.done   { color: var(--grass); }
.karaoke-word.active {
  color: var(--coral); font-size: 26px;
  display: inline-block; transform: scale(1.2);
  background: #fff3e0; border-radius: 8px;
  padding: 0 4px;
}
.karaoke-controls {
  display: flex; justify-content: center;
  gap: 16px; margin-bottom: 14px;
}
.karaoke-listen-btn {
  background: linear-gradient(135deg, var(--sky), var(--purple));
  color: white; border: none; border-radius: 999px;
  padding: 14px 28px; font-size: 17px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
  box-shadow: 0 4px 14px rgba(110,198,240,0.4);
  transition: transform 0.15s;
}
.karaoke-listen-btn:active { transform: scale(0.95); }
.karaoke-record-btn {
  width: 80px; height: 80px; font-size: 28px;
}
.karaoke-transcript {
  min-height: 48px; margin-bottom: 14px;
  font-size: 15px; font-style: italic;
}

/* ── PUZZLE DE PHRASES ── */
.puzzle-label {
  font-size: 13px; font-weight: 800; color: #888;
  margin-bottom: 8px;
}
.puzzle-drop-zone {
  min-height: 56px; background: #f0eaff;
  border: 2px dashed var(--purple); border-radius: 16px;
  padding: 10px 12px; display: flex;
  flex-wrap: wrap; gap: 8px; align-items: center;
  transition: background 0.2s;
}
.puzzle-drop-zone:empty::after {
  content: 'Clique sur les mots pour les placer ici'; 
  color: #bbb; font-size: 13px; font-weight: 600;
}
.puzzle-word-bank {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 0;
}
.puzzle-word {
  background: white; border: 2px solid var(--sky);
  border-radius: 12px; padding: 10px 14px;
  font-size: 17px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
  transition: all 0.15s; user-select: none;
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.puzzle-word:active { transform: scale(0.93); }
.puzzle-word.placed {
  background: var(--purple); color: white;
  border-color: var(--purple);
  box-shadow: 0 3px 10px rgba(160,123,229,0.4);
}

/* ── BADGES ── */
.badges-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; padding: 0 0 20px;
}
.badge-card {
  background: white; border-radius: 18px;
  padding: 18px 14px; text-align: center;
  box-shadow: var(--shadow); transition: transform 0.15s;
}
.badge-card.earned { border: 2px solid var(--sun); }
.badge-card.locked { opacity: 0.55; border: 2px solid #e0e0e0; }
.badge-emoji { font-size: 38px; margin-bottom: 6px; }
.badge-label {
  font-family: var(--font-display); font-size: 14px;
  font-weight: 800; color: var(--dark); margin-bottom: 4px;
}
.badge-desc { font-size: 11px; color: #888; line-height: 1.4; }

/* Toast badge notification */
.badge-toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: white; border-radius: 18px;
  padding: 14px 18px; display: flex; gap: 14px;
  align-items: center; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  border: 2px solid var(--sun); z-index: 500;
  opacity: 0; transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  min-width: 260px; max-width: 340px;
}
.badge-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.badge-toast-icon { font-size: 40px; flex-shrink: 0; }
.badge-toast-title { font-size: 11px; font-weight: 800; color: var(--sun); }
.badge-toast-name  { font-family: var(--font-display); font-size: 16px; font-weight: 900; color: var(--dark); }
.badge-toast-desc  { font-size: 12px; color: #888; margin-top: 2px; line-height: 1.4; }

/* ── MILESTONE CELEBRATION ── */
.milestone-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0;
  transition: opacity 0.3s;
}
.milestone-overlay.show { opacity: 1; }
.milestone-card {
  background: white; border-radius: 28px;
  padding: 32px 24px; text-align: center;
  max-width: 320px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: marioEntrance 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
.milestone-chars svg { width: 100px; height: 100px; margin: 0 auto; }
.milestone-stars { font-size: 36px; margin: 10px 0; letter-spacing: 6px; }
.milestone-title {
  font-family: var(--font-display); font-size: 30px;
  font-weight: 900; color: var(--dark); margin-bottom: 8px;
}
.milestone-msg { font-size: 15px; color: #666; line-height: 1.6; margin-bottom: 20px; }
.milestone-btn {
  background: linear-gradient(135deg, var(--sun), #FFB347);
  color: white; border: none; border-radius: 999px;
  padding: 14px 32px; font-size: 18px; font-weight: 800;
  cursor: pointer; font-family: var(--font-main);
}

/* Tablet */
@media (min-width: 600px) {
  .badges-grid { grid-template-columns: repeat(3, 1fr); }
  .flash-emoji { font-size: 90px; }
  .flash-word  { font-size: 40px; }
}

/* ===================== SECTION REPÈRES ===================== */
.reperes-section {
  background: linear-gradient(135deg, #fff3e0, #ffe8cc);
  border: 2px solid var(--coral);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.reperes-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 900;
  color: var(--coral); margin-bottom: 3px;
}
.reperes-sub {
  font-size: 12px; color: #888; font-weight: 600;
}
.module-card.reperes {
  border-color: var(--coral);
  background: linear-gradient(160deg, #fff8f5, white);
}
.module-card.reperes .lvl-badge {
  background: var(--coral);
}
/* Ensure card has enough bottom padding for the badge */
.module-card {
  padding-bottom: 36px !important;
}
.reperes-grid {
  margin-bottom: 10px;
}

/* === INSTALL GUIDE (Ajouter à l'écran d'accueil) === */
#install-fab {
  position: fixed;
  right: 16px;
  bottom: 92px;
  z-index: 500;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sky), var(--purple));
  color: white;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s ease;
}
#install-fab:active { transform: scale(.92); }
#install-fab .install-dot {
  position: absolute; top: 2px; right: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--coral);
  border: 2px solid white;
  display: none;
}
#install-fab.has-dot .install-dot { display: block; }

#install-toast {
  position: fixed;
  left: 16px;
  bottom: 92px;
  z-index: 499;
  max-width: 230px;
  background: white;
  border-radius: 999px;
  padding: 9px 8px 9px 14px;
  display: flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow);
  font-size: 12px; font-weight: 700; color: var(--dark);
  font-family: var(--font-main);
  cursor: pointer;
  opacity: 0; transform: translateY(8px) scale(.96);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
#install-toast.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#install-toast .toast-close {
  background: none; border: none; color: #bbb;
  font-size: 14px; cursor: pointer; padding: 2px 4px; line-height: 1;
}

#install-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(45,42,64,0.45);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  padding: 20px;
}
#install-overlay.open { display: flex; }
#install-card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 26px 22px;
  max-width: 400px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow);
  position: relative;
  animation: popIn .3s ease;
}
@keyframes popIn { from { opacity:0; transform: translateY(14px) scale(.97); } to { opacity:1; transform: translateY(0) scale(1); } }
#install-card .close-x {
  position: absolute; top: 14px; right: 14px;
  background: rgba(45,42,64,0.08); border: none;
  border-radius: 10px; color: var(--dark);
  font-size: 16px; padding: 6px 10px; cursor: pointer;
  font-family: var(--font-main);
}
.install-hero { text-align: center; margin-bottom: 16px; }
.install-hero-icon { font-size: 34px; margin-bottom: 4px; }
.install-hero h3 {
  font-family: var(--font-display); font-size: 19px; font-weight: 800;
  color: var(--dark); margin-bottom: 6px;
}
.install-hero-sub { font-size: 12.5px; color: #888; line-height: 1.6; font-weight: 600; }
.install-os-tabs {
  display: flex; border-radius: 14px; overflow: hidden;
  margin-bottom: 16px; background: #f0eeff;
}
.install-os-tab {
  flex: 1; padding: 10px; text-align: center; font-size: 13px;
  font-weight: 700; color: #999; background: none; border: none; cursor: pointer;
  font-family: var(--font-main); transition: all .2s;
}
.install-os-tab.active { background: var(--purple); color: white; }
.install-steps { display: none; }
.install-steps.active { display: block; }
.install-step { display: flex; gap: 12px; margin-bottom: 13px; align-items: flex-start; }
.install-step-num {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: var(--sun); color: var(--dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; font-family: var(--font-display);
}
.install-step div:last-child { font-size: 13px; color: #555; line-height: 1.6; font-weight: 600; }
.install-step strong { color: var(--dark); }
.install-native-btn {
  display: block; width: 100%; padding: 12px; margin-top: 4px;
  background: linear-gradient(135deg, var(--grass), #3bb85f);
  border: none; border-radius: 14px; color: white;
  font-size: 14px; font-weight: 800; font-family: var(--font-display);
  cursor: pointer;
}
.install-native-btn:active { opacity: .85; }
.install-tip {
  margin-top: 14px; padding: 11px 13px; border-radius: 12px;
  background: #eafbf0; border: 1px solid #cdf2db;
  color: #2e9e54; font-size: 12px; line-height: 1.6; font-weight: 700;
  display: flex; gap: 8px; align-items: flex-start;
}
