/* ─── RESET & ROOT ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --green: #58CC02;
  --green-dark: #46A302;
  --green-light: #D7FFB8;
  --green-shadow: #4CAF00;
  --blue: #1CB0F6;
  --blue-dark: #0798D4;
  --blue-light: #DDF4FF;
  --red: #FF4B4B;
  --red-dark: #EA2B2B;
  --red-light: #FFDDDD;
  --gold: #FFD900;
  --gold-dark: #D5A800;
  --gold-light: #FFF4C2;
  --purple: #CE82FF;
  --purple-dark: #A560E8;
  --orange: #FF9600;
  --orange-light: #FFE0A8;
  --bg: #FFFFFF;
  --surface: #F7F7F7;
  --border: #E5E5E5;
  --text: #3C3C3C;
  --text-muted: #777777;
  --text-light: #AFAFAF;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 4px 0 0;
  --font: 'Nunito', 'Trebuchet MS', sans-serif;
}

body.dark {
  --bg: #131F24;
  --surface: #1B2930;
  --border: #33464F;
  --text: #F1F5F9;
  --text-muted: #AFBFC6;
  --text-light: #4F6C7B;
  --blue-light: #162C3A;
  --green-light: #182C15;
  --red-light: #321A1A;
  --gold-light: #2E2813;
  --purple-light: #2D1A39;
  --orange-light: #322315;
  
  --blue-dark: #35BFFF;
  --green-dark: #78E11E;
  --red-dark: #FF6666;
  --gold-dark: #FFE540;
  --purple-dark: #DC9BFF;
  --orange-dark: #FFAA33;
}

/* ─── TRANSITIONS FOR THEME SWITCHING ─── */
body, #app, .top-bar, .sidebar-left, .sidebar-right, .path-card, .lesson-row, .choice-btn, .sentence-display, .listen-card, .leaderboard-row, .mission-card, .fc-face, .feedback-banner, .lesson-bottom, .avatar-select-card, .story-card, .story-bubble {
  transition: background-color 0.25s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

html, body {
  height: 100%;
  background: var(--surface);
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── APP SHELL ─── */
#app {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ─── SCREEN TRANSITIONS ─── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeIn 0.25s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── TOP NAV / HEADER ─── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--green);
  letter-spacing: -0.5px;
}
.app-logo .bird { font-size: 1.5rem; }

/* ─── STATS BAR ─── */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text);
}
.stat-chip .icon { font-size: 1.1rem; }
.stat-chip span { color: var(--text); }

/* ─── HOME SCREEN ─── */
#home-screen { overflow-y: auto; }

.lang-selector {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.lang-selector::-webkit-scrollbar { display: none; }

.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.9rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.lang-btn.active {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue-dark);
}
.lang-btn .flag { font-size: 1.2rem; }
.lang-btn.soon { opacity: 0.4; cursor: not-allowed; }

.lang-label { font-size: 0.65rem; color: var(--text-light); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 0 1.25rem 0.5rem; margin-top: 0.5rem; }

/* ─── PATHS ─── */
.paths-container { padding: 1rem 1.25rem 2rem; display: flex; flex-direction: column; gap: 1.25rem; }

.path-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.path-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.4rem;
  cursor: pointer;
  user-select: none;
}

.path-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  flex-shrink: 0;
}

.path-info { flex: 1; }
.path-name { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.25rem; }
.path-progress-text { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.55rem; }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.path-chevron { font-size: 0.8rem; color: var(--text-light); transition: transform 0.2s; }
.path-card.open .path-chevron { transform: rotate(180deg); }

.lessons-list {
  display: none;
  padding: 0 1.25rem 1.5rem;
  flex-direction: column;
  gap: 0.7rem;
}
.path-card.open .lessons-list { display: flex; }

.lesson-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
  position: relative;
}
.lesson-row:hover:not(.locked) { border-color: var(--border); background: var(--bg); }
.lesson-row.locked { opacity: 0.5; cursor: not-allowed; }
.lesson-row.completed { background: var(--green-light); }
.lesson-row.current { border-color: var(--green); background: var(--bg); }

.lesson-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 900;
  flex-shrink: 0;
  background: var(--border);
  color: var(--text-muted);
}
.lesson-row.completed .lesson-num { background: var(--green); color: #fff; }
.lesson-row.current .lesson-num { background: var(--green); color: #fff; }

.lesson-info { flex: 1; }
.lesson-name { font-size: 1rem; font-weight: 800; color: var(--text); }
.lesson-meta { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; margin-top: 0.1rem; }

.lesson-lock { font-size: 0.9rem; color: var(--text-light); }

/* PATH COLORS */
.path-missionary .path-icon { background: #FFF3E0; }
.path-missionary .path-name { color: #E65100; }
.path-missionary .progress-fill { background: #FF9600; }
.path-missionary .lesson-row.current .lesson-num { background: #FF9600; }
.path-missionary .lesson-row.completed .lesson-num { background: #FF9600; }
.path-missionary .lesson-row.completed { background: #FFF3E0; }
.path-missionary .lesson-row.current { border-color: #FF9600; }

.path-daily .path-icon { background: #E3F2FD; }
.path-daily .path-name { color: #1565C0; }
.path-daily .progress-fill { background: var(--blue); }
.path-daily .lesson-row.current .lesson-num { background: var(--blue); }
.path-daily .lesson-row.completed .lesson-num { background: var(--blue); }
.path-daily .lesson-row.completed { background: #E3F2FD; }
.path-daily .lesson-row.current { border-color: var(--blue); }

.path-bible .path-icon { background: #F3E5F5; }
.path-bible .path-name { color: #6A1B9A; }
.path-bible .progress-fill { background: var(--purple); }
.path-bible .lesson-row.current .lesson-num { background: var(--purple); }
.path-bible .lesson-row.completed .lesson-num { background: var(--purple); }
.path-bible .lesson-row.completed { background: #F3E5F5; }
.path-bible .lesson-row.current { border-color: var(--purple); }

.path-culture .path-icon { background: var(--green-light); }
.path-culture .path-name { color: var(--green-dark); }
.path-culture .progress-fill { background: var(--green); }

/* ─── LESSON SCREEN ─── */
#lesson-screen { background: var(--bg); }

.lesson-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--border);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}
.btn-close:hover { color: var(--text); }

.btn-back {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--text); }

.lesson-progress-bar {
  flex: 1;
  height: 16px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hearts-display {
  display: flex;
  gap: 0.15rem;
  font-size: 1.1rem;
}

/* ─── EXERCISE AREA ─── */
.exercise-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
}

.exercise-type-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.ex-header .exercise-type-label { margin-bottom: 0; }

.exercise-question {
  margin-bottom: 1.5rem;
}

.swahili-word {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.word-pronunciation {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ─── CHOICES ─── */
.choices { display: flex; flex-direction: column; gap: 0.65rem; }

.choice-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
  width: 100%;
  box-shadow: var(--shadow) var(--border);
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-light);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 0 var(--blue);
}
.choice-btn.selected { border-color: var(--blue); background: var(--blue-light); box-shadow: var(--shadow) var(--blue); }
.choice-btn.correct { border-color: var(--green); background: var(--green-light); box-shadow: var(--shadow) var(--green-shadow); color: var(--green-dark); }
.choice-btn.wrong { border-color: var(--red); background: var(--red-light); box-shadow: var(--shadow) var(--red-dark); color: var(--red-dark); animation: shake 0.4s ease; }
.choice-btn:disabled { cursor: not-allowed; }

.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--text-muted);
  flex-shrink: 0;
}
.choice-btn.correct .choice-letter { background: var(--green); color: #fff; }
.choice-btn.wrong .choice-letter { background: var(--red); color: #fff; }
.choice-btn.selected .choice-letter { background: var(--blue); color: #fff; }

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

/* ─── TAP WORD TYPE ─── */
.sentence-display {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  margin-bottom: 1rem;
  line-height: 1.6;
}
.blank-slot {
  display: inline-block;
  min-width: 80px;
  border-bottom: 3px solid var(--blue);
  padding: 0 0.5rem;
  color: var(--blue);
  font-weight: 900;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.word-chip {
  padding: 0.55rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 99px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: 0 3px 0 0 var(--border);
  color: var(--text);
}
.word-chip:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-light); transform: translateY(-1px); box-shadow: 0 4px 0 0 var(--blue); }
.word-chip.selected-chip { border-color: var(--blue); background: var(--blue-light); color: var(--blue-dark); box-shadow: 0 3px 0 0 var(--blue); }
.word-chip.correct-chip { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.word-chip.wrong-chip { border-color: var(--red); background: var(--red-light); color: var(--red-dark); animation: shake 0.4s ease; }
.word-chip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── LISTEN TYPE ─── */
.listen-card {
  text-align: center;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 0.65rem 1.5rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: all 0.15s;
  box-shadow: 0 4px 0 0 var(--blue-dark);
}
.listen-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 0 var(--blue-dark); }
.listen-btn:active { transform: translateY(1px); box-shadow: 0 3px 0 0 var(--blue-dark); }
.listen-phrase { font-size: 1.8rem; font-weight: 900; color: var(--text); line-height: 1.3; }

/* ─── LEAGUE SCREEN ─── */
.league-tier-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
  background: var(--tier-bg);
  color: var(--tier-color);
}
.league-tier-badge.bronze { --tier-color: #cd7f32; --tier-bg: #fff8f2; }
.league-tier-badge.silver { --tier-color: #9aa7b5; --tier-bg: #f4f6f8; }
.league-tier-badge.gold { --tier-color: #d4a800; --tier-bg: #fffbe6; }
.league-tier-badge.diamond { --tier-color: #0094c6; --tier-bg: #e8f8ff; }
.league-tier-badge.elite { --tier-color: #7b2fbe; --tier-bg: #f5edff; }

body.dark .league-tier-badge.bronze { --tier-color: #ffd1a4; --tier-bg: #2b1f14; }
body.dark .league-tier-badge.silver { --tier-color: #cdd8e2; --tier-bg: #222c34; }
body.dark .league-tier-badge.gold { --tier-color: #ffe566; --tier-bg: #2d260c; }
body.dark .league-tier-badge.diamond { --tier-color: #6fd3ff; --tier-bg: #092635; }
body.dark .league-tier-badge.elite { --tier-color: #d19aff; --tier-bg: #221330; }

.league-tier-badge::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background: currentColor;
}
.league-tier-icon { font-size: 3rem; line-height: 1; }
.league-tier-name { font-size: 1.4rem; font-weight: 900; color: var(--tier-color); }
.league-tier-week { font-size: 0.78rem; font-weight: 700; opacity: 0.7; }
.league-xp-bar-wrap { width: 100%; background: rgba(255,255,255,0.3); border-radius: 99px; height: 8px; margin-top: 0.5rem; }
.league-xp-bar-fill { height: 100%; border-radius: 99px; background: var(--tier-color) !important; transition: width 0.4s ease; }
.league-tier-xp-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--tier-color);
  margin-top: 0.3rem;
}

.leaderboard { border-radius: var(--radius); overflow: hidden; border: 2px solid var(--border); margin-bottom: 1.25rem; }
.leaderboard-header { background: var(--surface); padding: 0.6rem 1rem; font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); display: grid; grid-template-columns: 2.2rem 1fr 4rem; }
.leaderboard-row { display: grid; grid-template-columns: 2.2rem 1fr 4rem; align-items: center; padding: 0.7rem 1rem; border-top: 1px solid var(--border); background: var(--bg); transition: background 0.15s; gap: 0.25rem; }
.leaderboard-row.me { background: var(--gold-light); }
.leaderboard-row.advance { border-left: 3px solid var(--green); }
.leaderboard-row.danger  { border-left: 3px solid var(--red); }
.lb-rank { font-size: 0.8rem; font-weight: 900; color: var(--text-muted); text-align: center; }
.lb-rank.top { color: var(--gold-dark); }
.lb-name { font-size: 0.88rem; font-weight: 800; color: var(--text); }
.lb-you-tag { font-size: 0.6rem; font-weight: 900; color: var(--green-dark); background: var(--green-light); border-radius: 99px; padding: 0.05rem 0.35rem; margin-left: 0.3rem; vertical-align: middle; }
.lb-xp { font-size: 0.82rem; font-weight: 900; color: var(--gold-dark); text-align: right; }

.league-legend { display: flex; gap: 1rem; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); margin-bottom: 1rem; justify-content: center; }
.league-legend span { display: flex; align-items: center; gap: 0.3rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* ─── MISSIONS SCREEN ─── */
.missions-section-title {
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.6rem;
}
.missions-section-title:first-child { margin-top: 0; }
.mission-card {
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg);
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.mission-card.done { opacity: 0.6; }
.mission-icon { font-size: 1.6rem; flex-shrink: 0; }
.mission-body { flex: 1; min-width: 0; }
.mission-name { font-size: 0.9rem; font-weight: 900; color: var(--text); margin-bottom: 0.2rem; }
.mission-desc { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; margin-bottom: 0.5rem; }
.mission-bar-wrap { background: var(--surface); border-radius: 99px; height: 6px; width: 100%; }
.mission-bar-fill { height: 100%; border-radius: 99px; background: var(--green); transition: width 0.4s ease; }
.mission-prog-label { font-size: 0.68rem; font-weight: 800; color: var(--text-muted); margin-top: 0.25rem; }
.mission-reward { flex-shrink: 0; }
.btn-claim {
  background: var(--gold);
  color: #7a5500;
  border: none;
  border-radius: 99px;
  padding: 0.35rem 0.8rem;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--gold-dark);
  transition: all 0.15s;
}
.btn-claim:hover { transform: translateY(-1px); }
.btn-claim:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--gold-dark); }
.btn-claim.claimed { background: var(--green-light); color: var(--green-dark); box-shadow: none; cursor: default; }
.btn-claim.locked { background: var(--surface); color: var(--text-muted); box-shadow: none; cursor: default; }

/* ─── PHONETICS ─── */
.phonetic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  margin-top: 0.4rem;
}
.phonetic-ipa {
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}
.phonetic-pt {
  font-size: 0.78rem;
  color: var(--blue);
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(28,176,246,0.09);
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
}

/* ─── FEEDBACK BANNER ─── */
.feedback-banner {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideUp 0.25s ease;
}
.feedback-banner.show { display: flex; }
.feedback-banner.correct-fb { background: var(--green-light); border-top: 3px solid var(--green); }
.feedback-banner.wrong-fb { background: var(--red-light); border-top: 3px solid var(--red); }

.fb-icon { font-size: 1.4rem; }
.fb-content { flex: 1; }
.fb-title { font-size: 1rem; font-weight: 900; margin-bottom: 0.2rem; }
.feedback-banner.correct-fb .fb-title { color: var(--green-dark); }
.feedback-banner.wrong-fb .fb-title { color: var(--red-dark); }
.fb-answer { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ─── BOTTOM ACTION ─── */
.lesson-bottom {
  padding: 1rem 1.25rem;
  background: var(--bg);
  border-top: 2px solid var(--border);
}

.btn-primary {
  width: 100%;
  padding: 0.95rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 4px 0 0 var(--green-shadow);
  letter-spacing: 0.02em;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 0 0 var(--green-shadow); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 0 var(--green-shadow); }
.btn-primary:disabled { background: var(--border); color: var(--text-light); box-shadow: 0 4px 0 0 #d0d0d0; cursor: not-allowed; transform: none; }

/* ─── COMPLETE SCREEN ─── */
#complete-screen {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
  text-align: center;
}

.complete-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin: 0 auto 1.5rem;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: 0 8px 0 0 var(--green-shadow);
}
@keyframes popIn {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.complete-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--green);
  margin-bottom: 0.4rem;
}
.complete-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 2rem;
}

.stars-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  font-size: 2.5rem;
}
.star { animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.star:nth-child(2) { animation-delay: 0.15s; }
.star:nth-child(3) { animation-delay: 0.3s; }
@keyframes starPop {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.xp-earned {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gold-light);
  border: 2px solid var(--gold);
  border-radius: 99px;
  padding: 0.6rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 900;
  color: #8B6900;
  margin-bottom: 2.5rem;
  animation: fadeIn 0.5s 0.4s both;
}

/* confetti */
.confetti-container {
  position: fixed;
  top: 0; left: 0; right: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
  height: 100vh;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ─── HEARTS EMPTY SCREEN ─── */
#hearts-screen {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: var(--bg);
}
.hearts-big { font-size: 4rem; margin-bottom: 1rem; animation: heartBeat 0.8s ease; }
@keyframes heartBeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.3); }
  28% { transform: scale(1); }
  42% { transform: scale(1.3); }
  70% { transform: scale(1); }
}
.hearts-title { font-size: 1.6rem; font-weight: 900; margin-bottom: 0.5rem; color: var(--red); }
.hearts-sub { font-size: 0.95rem; color: var(--text-muted); font-weight: 700; margin-bottom: 2rem; line-height: 1.5; }
.hearts-timer {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--orange);
  background: var(--orange-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 2px solid var(--orange);
}
.btn-secondary {
  width: 100%;
  padding: 0.9rem;
  background: var(--bg);
  color: var(--blue);
  border: 2px solid var(--blue);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 0.75rem;
}
.btn-secondary:hover { background: var(--blue-light); }

/* ─── CULTURAL NOTE ─── */
.cultural-note {
  background: var(--gold-light);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.cultural-note-title {
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-dark);
  margin-bottom: 0.4rem;
}
.cultural-note-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #5A4000;
  line-height: 1.5;
}

/* ─── VERSE CALLOUT ─── */
.verse-callout {
  background: #F3E5F5;
  border-left: 4px solid var(--purple);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-style: italic;
  font-size: 0.95rem;
  color: #4A1470;
  font-weight: 700;
}

/* ─── PATH SENTENCES COLOR ─── */
.path-sentences .path-icon { background: #E0F2F1; }
.path-sentences .path-name { color: #00695C; }
.path-sentences .progress-fill { background: #00897B; }
.path-sentences .lesson-row.current .lesson-num { background: #00897B; }
.path-sentences .lesson-row.completed .lesson-num { background: #00897B; }
.path-sentences .lesson-row.completed { background: #E0F2F1; }
.path-sentences .lesson-row.current { border-color: #00897B; }

/* ─── BUILD EXERCISE (Monte a frase) ─── */
.build-answer {
  min-height: 60px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1rem;
  transition: border-color 0.2s, background 0.2s;
}
.build-answer.has-words { border-style: solid; border-color: var(--blue); }
.build-answer.correct-build { border-color: var(--green); background: var(--green-light); }
.build-answer.wrong-build { border-color: var(--red); background: var(--red-light); animation: shake 0.35s ease; }
.build-placeholder { color: var(--text-light); font-size: 0.82rem; font-weight: 600; font-style: italic; }
.build-word {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  background: var(--blue-light);
  border: 2px solid var(--blue);
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--blue-dark);
  cursor: pointer;
  transition: all 0.12s;
}
.build-word:hover { background: var(--red-light); border-color: var(--red); color: var(--red-dark); }
.build-word .rm { font-size: 0.55rem; opacity: 0.6; }
.build-word.correct-w { background: var(--green-light); border-color: var(--green); color: var(--green-dark); cursor: default; }
.build-word.wrong-w   { background: var(--red-light);   border-color: var(--red);   color: var(--red-dark);   cursor: default; }

/* ─── FILL EXERCISE (Complete a frase) ─── */
.fill-sentence {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  padding: 1.2rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  margin-bottom: 1rem;
  line-height: 2;
}
.fill-slot {
  display: inline-block;
  min-width: 72px;
  padding: 0.1rem 0.5rem;
  border-bottom: 3px solid var(--border);
  color: var(--text-light);
  font-weight: 900;
  margin: 0 0.15rem;
  cursor: pointer;
  transition: all 0.15s;
  vertical-align: bottom;
  border-radius: 4px 4px 0 0;
}
.fill-slot.active { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.fill-slot.filled { border-color: var(--blue); color: var(--blue-dark); background: var(--blue-light); border-style: solid; border-width: 2px 2px 3px; }
.fill-slot.correct-s { border-color: var(--green); color: var(--green-dark); background: var(--green-light); }
.fill-slot.wrong-s   { border-color: var(--red);   color: var(--red-dark);   background: var(--red-light); }

/* ─── THEORY TABLE ─── */
.theory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 0.85rem;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--border);
}
.theory-table th {
  background: var(--blue);
  color: #fff;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}
.theory-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
}
.theory-table tr:last-child td { border-bottom: none; }
.theory-table tr:nth-child(even) td { background: var(--surface); }
.theory-table td:first-child { color: var(--blue-dark); }
.theory-table td em { color: var(--green-dark); font-style: normal; font-weight: 900; }

/* ─── THEORY CARD ─── */
.theory-card {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}
.theory-eyebrow {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 0.4rem;
}
.theory-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 1.2rem;
  line-height: 1.2;
}
.theory-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}
.theory-point {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--blue);
}
.theory-point-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }
.theory-point-text { font-size: 0.875rem; font-weight: 700; color: var(--text); line-height: 1.5; }
.theory-point-text em { color: var(--blue-dark); font-style: normal; font-weight: 900; }
.theory-example {
  background: var(--blue-light);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--blue-dark);
  line-height: 1.5;
}
.theory-example strong { display: block; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--blue); margin-bottom: 0.3rem; }

/* ─── MINI AUDIO BUTTON ─── */
.ex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.mini-audio-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.mini-audio-btn:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.mini-audio-btn:disabled { opacity: 0.4; cursor: default; }

/* ─── GLOSSED SWAHILI WORDS ─── */
.sw-word { cursor: default; }
.sw-word.has-gloss {
  cursor: pointer;
  border-bottom: 2px dotted var(--blue);
  padding-bottom: 1px;
  color: inherit;
}
.sw-word.has-gloss:hover { color: var(--blue-dark); border-bottom-style: solid; }

/* ─── GLOSS TOOLTIP ─── */
.gloss-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
  transition: opacity 0.15s;
  min-width: 140px;
  max-width: 240px;
}
.gloss-tooltip.hidden { display: none; }
.gloss-tooltip-text { flex: 1; line-height: 1.4; }
.gloss-tooltip .gloss-word { font-size: 0.9rem; font-weight: 900; display: block; }
.gloss-tooltip .gloss-def { font-size: 0.75rem; font-weight: 600; color: rgba(255,255,255,0.75); }
.gloss-tooltip .gloss-audio {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gloss-tooltip .gloss-audio:hover { background: rgba(255,255,255,0.3); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ═══════════════════════════════════════════════════════
   DESKTOP LAYOUT
═══════════════════════════════════════════════════════ */
#layout {
  display: flex;
  min-height: 100vh;
  background: var(--surface);
  justify-content: center;
}

/* ─── LEFT SIDEBAR ─── */
.sidebar-left {
  display: none;
}

/* ─── RIGHT SIDEBAR ─── */
.sidebar-right {
  display: none;
}

/* ─── MOBILE BOTTOM NAV ─── */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: 60px;
  background: var(--bg);
  border-top: 1.5px solid var(--border);
  display: flex;
  z-index: 100;
}
.mobile-bottom-nav .mnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text-muted);
  padding: 0;
  transition: color 0.15s;
  position: relative;
}
.mobile-bottom-nav .mnav-btn.active { color: var(--green); }
.mobile-bottom-nav .mnav-btn .mnav-label { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.mnav-due-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  margin: 0;
  padding: 0.05rem 0.35rem;
  font-size: 0.6rem;
  min-width: 16px;
  text-align: center;
}

/* Push content above bottom nav on mobile */
#app { padding-bottom: 60px; }

@media (min-width: 900px) {
  #layout {
    max-width: none;
    width: 100%;
    margin: 0;
    gap: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  #app {
    flex: 1;
    min-width: 0;
    max-width: none;
    padding-bottom: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    min-height: 100vh;
    background: var(--surface);
  }

  /* Home screen — full width top bar, centered paths container */
  #home-screen { background: var(--surface); }
  #home-screen .top-bar        { padding: 1.1rem 2rem; }
  #home-screen .lang-selector  { padding: 0.75rem 2rem 0; }
  #home-screen .paths-container {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem 1.25rem 3rem;
    gap: 1.5rem;
  }

  /* Lesson / exercise / complete / hearts — fills center column */
  #lesson-screen, #complete-screen, #hearts-screen {
    max-width: none;
    width: 100%;
    background: var(--bg);
    border-radius: 0;
    min-height: 100vh;
  }

  /* Constrain inner exercise content for readability */
  #lesson-screen .lesson-top,
  #lesson-screen .exercise-area,
  #lesson-screen .lesson-bottom,
  #lesson-screen .feedback-banner {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  /* Flashcard — slightly wider card area */
  #flashcard-screen .fc-area { max-width: 640px; margin: 0 auto; }
  #flashcard-screen .fc-top  { max-width: 640px; margin: 0 auto; width: 100%; }

  /* Profile, League, and Missions Screens desktop layout alignment */
  #profile-screen, #league-screen, #missions-screen {
    background: var(--bg);
    min-height: 100vh;
  }
  #profile-screen .top-bar,
  #profile-screen > div:nth-child(2),
  #league-screen .top-bar,
  #league-screen > div:nth-child(2),
  #missions-screen .top-bar,
  #missions-screen > div:nth-child(2) {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  .mobile-bottom-nav { display: none; }

  /* ─── LEFT SIDEBAR DESKTOP ─── */
  .sidebar-left {
    display: flex;
    flex-direction: column;
    width: 244px;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg);
  }
  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--green);
    letter-spacing: -0.01em;
  }
  .sidebar-logo .bird { font-size: 1.5rem; }
  .sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
  .sidebar-nav li { width: 100%; }
  .sidebar-nav .snav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    text-align: left;
  }
  .sidebar-nav .snav-btn:hover { background: var(--surface); color: var(--text); }
  .sidebar-nav .snav-btn.active { background: var(--green-light); color: var(--green-dark); }
  .sidebar-nav .snav-icon { font-size: 1.3rem; width: 1.6rem; text-align: center; flex-shrink: 0; }
  .sidebar-nav .snav-label { flex: 1; }

  /* ─── RIGHT SIDEBAR DESKTOP ─── */
  .sidebar-right {
    display: flex;
    flex-direction: column;
    width: 340px;
    gap: 1rem;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg);
  }
  .sb-stats-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
  }
  .sb-stat {
    flex: 1;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.5rem;
    text-align: center;
  }
  .sb-stat-icon { font-size: 1.3rem; display: block; margin-bottom: 0.2rem; }
  .sb-stat-value { font-size: 1.1rem; font-weight: 900; color: var(--text); display: block; }
  .sb-stat-label { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
  .sb-card {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1rem 1.1rem;
  }
  .sb-card-title {
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
  }
  .sb-card-headline {
    font-size: 1rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 0.35rem;
  }
  .sb-card-sub { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); line-height: 1.4; }
  .sb-mission { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
  .sb-mission:last-child { border-bottom: none; padding-bottom: 0; }
  .sb-mission-icon { font-size: 1.1rem; flex-shrink: 0; }
  .sb-mission-info { flex: 1; }
  .sb-mission-name { font-size: 0.78rem; font-weight: 800; color: var(--text); }
  .sb-mission-bar { height: 6px; background: var(--border); border-radius: 99px; margin-top: 4px; overflow: hidden; }
  .sb-mission-fill { height: 100%; background: var(--green); border-radius: 99px; transition: width 0.4s; }
  .sb-mission-count { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
  .sb-league-badge { font-size: 3rem; text-align: center; display: block; margin: 0.3rem 0 0.6rem; }
  .sb-league-name { font-size: 0.85rem; font-weight: 900; color: var(--text); text-align: center; margin-bottom: 0.25rem; }
  .sb-league-sub { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-align: center; }
}

/* ═══════════════════════════════════════════════════════
   VOICE TOGGLE
═══════════════════════════════════════════════════════ */
.voice-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.voice-toggle:hover { border-color: var(--blue); color: var(--blue); }
.voice-toggle .vt-icon { font-size: 0.85rem; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--blue); color: var(--blue); }
.theme-toggle .tt-icon { font-size: 0.85rem; }

/* ═══════════════════════════════════════════════════════
   FLASHCARD SCREEN
═══════════════════════════════════════════════════════ */
#flashcard-screen {
  background: var(--surface);
  align-items: stretch;
}
#fc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.fc-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.2rem 0.75rem;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
}
.fc-top-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 900;
  color: var(--text);
}
.fc-top-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}
.fc-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}
.fc-empty-icon { font-size: 3.5rem; }
.fc-empty-title { font-size: 1.1rem; font-weight: 900; color: var(--text); }
.fc-empty-sub { font-size: 0.85rem; font-weight: 600; line-height: 1.5; }
.fc-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.2rem;
  width: 100%;
  gap: 1.2rem;
}
.fc-progress-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.fc-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.fc-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.35s;
}
.fc-progress-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── The flip card ─── */
.fc-scene {
  width: 100%;
  max-width: 360px;
  height: 240px;
  perspective: 900px;
  cursor: pointer;
}
.fc-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius);
}
.fc-card.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}
.fc-front {
  background: var(--bg);
  border: 2px solid var(--border);
}
.fc-back {
  background: var(--green);
  transform: rotateY(180deg);
}
.fc-tap-hint {
  position: absolute;
  bottom: 0.7rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.45;
}
.fc-front .fc-tap-hint { color: var(--text-muted); }
.fc-back .fc-tap-hint { color: #fff; }
.fc-path-tag {
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-muted);
}
.fc-back .fc-path-tag { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.8); }
.fc-sw-text {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}
.fc-pt-text {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  text-align: center;
  line-height: 1.2;
}
.fc-audio-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
  flex-shrink: 0;
}
.fc-audio-btn:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.fc-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 360px;
  justify-content: space-between;
}
.fc-nav-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text);
}
.fc-nav-btn:hover:not(:disabled) { border-color: var(--green); color: var(--green); background: var(--green-light); }
.fc-nav-btn:disabled { opacity: 0.3; cursor: default; }
.fc-flip-btn {
  flex: 1;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--green);
  background: var(--green-light);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--green-dark);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fc-flip-btn:hover { background: var(--green); color: #fff; }
.fc-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 360px;
}
.fc-action-btn {
  flex: 1;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}
.fc-action-btn.know { border-color: var(--green); color: var(--green-dark); background: var(--green-light); }
.fc-action-btn.know:hover { background: var(--green); color: #fff; }
.fc-action-btn.again { border-color: var(--red); color: var(--red-dark); background: var(--red-light); }
.fc-action-btn.again:hover { background: var(--red); color: #fff; }

.fc-keyboard-legend {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
  margin-top: 0.5rem;
  opacity: 0.8;
}
.fc-keyboard-legend kbd {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 0 var(--border);
  padding: 0.1rem 0.35rem;
  font-family: inherit;
  font-size: 0.68rem;
  color: var(--text);
  margin: 0 0.1rem;
}
@media (max-width: 899px) {
  .fc-keyboard-legend { display: none; }
}

/* ─── TYPE EXERCISE ─── */
.type-input {
  width: 100%;
  padding: 0.9rem 1.1rem;
  font-size: 1.2rem;
  font-family: var(--font);
  font-weight: 700;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
  background: var(--bg);
  color: var(--text);
  margin-top: 0.5rem;
  text-align: center;
}
.type-input:focus { border-color: var(--blue); }
.type-input.correct-input { border-color: var(--green); background: var(--green-light); }
.type-input.wrong-input { border-color: var(--red); background: var(--red-light); }

/* ─── PROFILE SCREEN ─── */
.profile-avatar { font-size: 4rem; text-align: center; margin: 1rem 0 1.5rem; }
.profile-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.profile-stat-card { background: var(--surface); border-radius: var(--radius-sm); padding: 1rem; text-align: center; }
.profile-stat-value { font-size: 1.8rem; font-weight: 900; color: var(--green); }
.profile-stat-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; margin-top: 0.2rem; }
.profile-section-title { font-size: 0.75rem; font-weight: 900; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 1.5rem 0 0.75rem; }
.profile-lang-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.profile-lang-flag { font-size: 1.3rem; }
.profile-lang-bar-wrap { flex: 1; }
.profile-lang-name { font-size: 0.78rem; font-weight: 800; margin-bottom: 0.2rem; }
.profile-lang-pct { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; }
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.achievement-card { background: var(--surface); border-radius: var(--radius-sm); padding: 0.85rem 0.5rem; text-align: center; border: 2px solid transparent; }
.achievement-card.unlocked { background: var(--gold-light); border-color: var(--gold); }
.achievement-icon { font-size: 1.8rem; margin-bottom: 0.3rem; }
.achievement-name { font-size: 0.65rem; font-weight: 800; color: var(--text); line-height: 1.3; }
.achievement-card:not(.unlocked) { opacity: 0.4; filter: grayscale(1); }

/* ─── ACHIEVEMENT TOAST ─── */
.achievement-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; border-radius: var(--radius); padding: 0.85rem 1.25rem;
  display: flex; align-items: center; gap: 0.75rem; z-index: 9999;
  opacity: 0; transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1); min-width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.achievement-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.achievement-toast span { font-size: 2rem; }
.ach-toast-title { font-size: 0.65rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; }
.ach-toast-name { font-size: 0.9rem; font-weight: 800; }
@media (min-width: 900px) { .achievement-toast { bottom: 2rem; } }

/* ─── FC DUE BADGE ─── */
.fc-due-badge {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 900;
  padding: 0.15rem 0.55rem;
  margin-left: 0.4rem;
}
.fc-due-info {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.5rem 1.2rem 0;
}

/* ─── STORIES & AVATAR SELECTION ─── */
#avatar-select-screen, #stories-screen, #story-player-screen {
  font-family: var(--font);
}

.avatar-cards-container {
  display: flex;
  gap: 1.5rem;
  width: 100%;
  max-width: 500px;
  justify-content: center;
  margin-top: 1rem;
}

.avatar-select-card {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 0 0 var(--border);
}

.avatar-select-card:hover {
  transform: translateY(-2px);
  border-color: var(--green);
  box-shadow: 0 6px 0 0 var(--green-dark);
}

.avatar-select-card:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 0 var(--green-dark);
}

/* Story list styles */
.stories-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 650px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 2rem;
}

.story-card {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  gap: 1.25rem;
  transition: all 0.2s ease;
  position: relative;
  text-align: left;
  width: 100%;
}

.story-card.unlocked {
  cursor: pointer;
}

.story-card.unlocked:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.story-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface);
}

.story-card-number {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text-light);
  min-width: 45px;
  text-align: center;
}

.story-card.completed .story-card-number {
  color: var(--green);
}

.story-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.story-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.story-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.story-card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.story-arc-tag {
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

/* Tags dynamic colors */
.story-arc-tag.tag-chegada {
  background: var(--blue-light);
  color: var(--blue-dark);
}
.story-arc-tag.tag-cotidiano {
  background: var(--green-light);
  color: var(--green-dark);
}
.story-arc-tag.tag-conflito {
  background: var(--red-light);
  color: var(--red-dark);
}
.story-arc-tag.tag-resolucao {
  background: var(--gold-light);
  color: var(--gold-dark);
}

.story-card-status {
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.story-card-status.completed {
  color: var(--green);
}

.story-card-status.available {
  color: var(--blue);
}

.story-card-status.locked {
  color: var(--text-light);
}

/* Chat bubble styling */
.story-line {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  width: 100%;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 0.25rem;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.story-line.local {
  flex-direction: row;
}

.story-line.missionary {
  flex-direction: row-reverse;
}

.story-line.narrative-block {
  display: block;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 1rem auto;
  max-width: 550px;
}

.story-avatar {
  font-size: 2.25rem;
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 50%;
  user-select: none;
}

.story-bubble-wrapper {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.story-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  cursor: pointer;
  user-select: none;
}

.story-line.local .story-bubble {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.story-line.missionary .story-bubble {
  background: var(--blue-light);
  border: 2px solid var(--blue-dark);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.story-speaker-name {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.story-line.missionary .story-speaker-name {
  text-align: right;
}

.story-translation {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.35rem;
  display: none;
}

.story-bubble.show-translation .story-translation {
  display: block;
}

/* Audio play inline */
.story-bubble-audio-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.btn-story-audio {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 0.1rem;
  transition: opacity 0.2s, transform 0.1s;
  align-self: center;
}

.btn-story-audio:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* Challenge elements */
.story-challenge-option {
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.story-challenge-option:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.story-challenge-option.correct {
  border-color: var(--green) !important;
  background: var(--green-light) !important;
  color: var(--green-dark) !important;
}

.story-challenge-option.wrong {
  border-color: var(--red) !important;
  background: var(--red-light) !important;
  color: var(--red-dark) !important;
}

.story-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.story-chip-btn {
  padding: 0.5rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 0 0 var(--border);
}

.story-chip-btn:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.story-chip-btn.selected {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.story-bubble .has-gloss {
  border-bottom: 2px dashed var(--blue);
  cursor: help;
  font-weight: 700;
}

.story-bubble .has-gloss:hover {
  color: var(--blue-dark);
}

/* ════════════════════════════════════════════════════════
   Suporte a RTL para o Árabe (ativado por <body class="lang-ar">)
════════════════════════════════════════════════════════ */
body.lang-ar .swahili-word,
body.lang-ar .listen-phrase,
body.lang-ar .sentence-display,
body.lang-ar .word-chip,
body.lang-ar .choice-btn,
body.lang-ar .theory-example,
body.lang-ar .theory-point-text,
body.lang-ar .fc-sw-text {
  unicode-bidi: plaintext;
}
