@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS VARIABLES ─────────────────────────────────────── */
:root {
  --bg:        #0a0a0f;
  --bg2:       #13131a;
  --bg3:       #1c1c27;
  --card:      #1a1a24;
  --border:    #2a2a3a;
  --text:      #f0f0f8;
  --text2:     #9090b0;
  --text3:     #5a5a78;
  --accent:    #6c63ff;
  --accent2:   #8b84ff;
  --success:   #3dbfa8;
  --warning:   #f0a500;
  --danger:    #e55a5a;
  --nav-h:     64px;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --trans:     0.2s ease;
}

[data-theme="light"] {
  --bg:     #f5f5fa;
  --bg2:    #ebebf5;
  --bg3:    #ddddf0;
  --card:   #ffffff;
  --border: #d0d0e8;
  --text:   #0a0a1f;
  --text2:  #505070;
  --text3:  #9090b0;
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

/* ── RESET ─────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background:
    linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)),
    url('https://i.ibb.co/cKPMJn9Z/bg-png.png') center/cover fixed;
  color: var(--text);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── APP SHELL ─────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
}

/* ── TYPOGRAPHY ────────────────────────────────────────── */
h1,h2,h3,h4 { font-family: 'Syne', sans-serif; }
h1 { font-size: 1.8rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }

/* ── SCREENS ───────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 0 0 calc(var(--nav-h) + 8px);
  overflow-y: auto;
  animation: fadeIn 0.22s ease;
}
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

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

/* ── TOP BAR ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar-title { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 700; flex: 1; }
.btn-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--trans), transform var(--trans);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg3); }
.btn-icon:active { transform: scale(0.92); }

/* ── BOTTOM NAV ────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 520px;
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text3);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--trans);
  padding: 8px 0;
}
.nav-btn .nav-icon { font-size: 1.3rem; transition: transform var(--trans); }
.nav-btn.active { color: var(--accent2); }
.nav-btn.active .nav-icon { transform: scale(1.15); }

/* ── HOME SCREEN ───────────────────────────────────────── */
.home-hero {
  position: relative;
  padding: 36px 20px 30px;
  background: linear-gradient(162deg, rgba(17,14,46,0.55) 0%, rgba(28,18,69,0.45) 38%, rgba(17,15,48,0.40) 65%, rgba(10,10,15,0.20) 100%);
  overflow: hidden;
  border-bottom: 1px solid rgba(108,99,255,0.25);
  --hero-void: rgba(14,11,40,0.6);
}
.home-hero::before {
  content: '';
  position: absolute;
  top: -30%; left: 50%; transform: translateX(-50%);
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(108,99,255,0.18) 0%, transparent 68%);
  pointer-events: none;
}
[data-theme="light"] .home-hero {
  background: linear-gradient(162deg, rgba(237,232,255,0.72) 0%, rgba(243,238,255,0.65) 45%, rgba(245,245,250,0.40) 100%);
  border-bottom-color: rgba(108,99,255,0.2);
  --hero-void: rgba(234,228,255,0.7);
}
.hero-content {
  position: relative;
  z-index: 2;
  display: flex; flex-direction: column; gap: 5px;
}
.home-greeting { font-size: 0.88rem; color: rgba(190,185,255,0.75); letter-spacing: 0.01em; }
[data-theme="light"] .home-greeting { color: var(--text2); }
.home-title { font-size: 2.1rem; font-weight: 800; line-height: 1.1; color: #f0f0f8; }
[data-theme="light"] .home-title { color: var(--text); }
.home-title span {
  color: #a78bfa;
  text-shadow: 0 0 28px rgba(167,139,250,0.45);
}
/* Landmark silhouettes */
.hero-landmark {
  position: absolute;
  bottom: 0;
  color: rgba(108,99,255,0.20);
  z-index: 1;
  pointer-events: none;
}
[data-theme="light"] .hero-landmark { color: rgba(108,99,255,0.13); }
.hero-bigben   { left: 14px;   height: 128px; }
.hero-eiffel   { left: 64px;   height: 158px; }
.hero-sagrada  { right: 54px;  height: 148px; }
.hero-colosseum{ right: -6px;  width: 164px;  height: auto; }

.streak-banner {
  margin: 16px 20px 16px;
  background: linear-gradient(135deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.streak-icon { font-size: 1.8rem; }
.streak-info { flex: 1; }
.streak-count { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 800; }
.streak-label { font-size: 0.8rem; color: var(--text2); }
.xp-pill {
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.section-header {
  padding: 16px 20px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title { font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; }
.section-link { font-size: 0.8rem; color: var(--accent2); cursor: pointer; }

/* Language cards grid */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0 20px;
}
.lang-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.34,1.4,0.64,1),
              border-color 0.22s ease,
              box-shadow 0.28s ease;
  position: relative;
  overflow: hidden;
}
/* Top accent bar */
.lang-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--lang-accent, var(--accent));
  transition: height 0.22s ease;
}
/* Diagonal gradient glow */
.lang-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(138deg, transparent 35%, var(--lang-accent, var(--accent)) 140%);
  opacity: 0.07;
  border-radius: var(--radius);
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lang-card:hover {
  transform: translateY(-5px) scale(1.025);
  border-color: var(--lang-accent, var(--accent));
  box-shadow: 0 14px 40px rgba(0,0,0,0.5),
              0 0 0 1px var(--lang-accent, var(--accent)),
              0 4px 16px rgba(108,99,255,0.15);
}
.lang-card:hover::before { height: 4px; }
.lang-card:hover::after  { opacity: 0.15; }
.lang-card:active { transform: translateY(-2px) scale(1.01); transition-duration: 0.1s; }
.lang-flag { font-size: 2rem; margin-bottom: 8px; }
.lang-name { font-family: 'Syne', sans-serif; font-size: 0.95rem; font-weight: 700; }
.lang-native { font-size: 0.8rem; color: var(--text2); }
.lang-progress-bar {
  margin-top: 10px;
  height: 4px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}
.lang-progress-fill {
  height: 100%;
  background: var(--lang-accent, var(--accent));
  border-radius: 4px;
  transition: width 0.5s ease;
}
.lang-progress-text { font-size: 0.7rem; color: var(--text3); margin-top: 4px; }

/* ── LANGUAGE DETAIL ───────────────────────────────────── */
#screen-lang-detail .topbar { background: var(--bg); }

.lang-hero {
  padding: 0 20px 20px;
  display: flex; align-items: center; gap: 16px;
}
.lang-hero-flag { font-size: 3.5rem; }
.lang-hero-info {}
.lang-hero-name { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800; }
.lang-hero-native { font-size: 0.9rem; color: var(--text2); }
.lang-hero-stats { display: flex; gap: 16px; margin-top: 8px; }
.stat-pill {
  font-size: 0.75rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  color: var(--text2);
}
.stat-pill strong { color: var(--text); }

.chapters-list { padding: 0 20px; display: flex; flex-direction: column; gap: 10px; }
.chapter-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  transition: transform var(--trans), border-color var(--trans);
  position: relative;
}
.chapter-item:hover { transform: translateX(4px); border-color: var(--accent); }
.chapter-item.locked { opacity: 0.5; cursor: not-allowed; }
.chapter-item.locked:hover { transform: none; border-color: var(--border); }
.chapter-item.completed { border-color: var(--success); }
.chapter-icon { font-size: 1.5rem; width: 40px; text-align: center; flex-shrink: 0; }
.chapter-info { flex: 1; }
.chapter-num { font-size: 0.72rem; color: var(--text3); margin-bottom: 2px; }
.chapter-title { font-family: 'Syne', sans-serif; font-size: 0.95rem; font-weight: 700; }
.chapter-words { font-size: 0.75rem; color: var(--text2); }
.chapter-badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}
.chapter-badge.done { background: rgba(61,191,168,0.15); color: var(--success); }
.chapter-badge.locked { background: rgba(255,255,255,0.05); color: var(--text3); }
.chapter-badge.free { background: rgba(108,99,255,0.15); color: var(--accent2); }
.lock-icon { font-size: 1rem; color: var(--text3); }

/* ── FLASHCARD SCREEN ──────────────────────────────────── */
.flashcard-header {
  padding: 16px 20px 0;
  display: flex; flex-direction: column; gap: 10px;
}
.progress-track {
  height: 4px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.card-counter { font-size: 0.8rem; color: var(--text2); text-align: center; }

.card-stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  perspective: 1000px;
  min-height: 280px;
}
.flashcard {
  width: 100%;
  max-width: 420px;
  height: 260px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backface-visibility: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 24px;
  text-align: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.card-back { transform: rotateY(180deg); }
.card-emoji { font-size: 3rem; }
.card-word { font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.card-romanization { font-size: 0.9rem; color: var(--text2); font-style: italic; }
.card-translation { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--accent2); }
.card-example { font-size: 0.85rem; color: var(--text2); line-height: 1.5; }
.card-example-ua { font-size: 0.8rem; color: var(--text3); font-style: italic; }
.card-hint { font-size: 0.75rem; color: var(--text3); margin-top: auto; }

.card-audio-btn {
  background: rgba(108,99,255,0.15);
  border: 1px solid rgba(108,99,255,0.3);
  color: var(--accent2);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background var(--trans), transform var(--trans);
  flex-shrink: 0;
}
.card-audio-btn:hover { background: rgba(108,99,255,0.3); }
.card-audio-btn:active { transform: scale(0.9); }
.card-audio-btn.long-press { background: var(--accent); color: white; }

.card-nav {
  padding: 12px 20px 0;
  display: flex; align-items: center; gap: 12px;
}
.card-nav-btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans);
}
.card-nav-btn:hover { background: var(--bg3); }
.card-nav-btn:active { transform: scale(0.96); }
.card-flip-btn {
  flex: 2;
  padding: 13px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--trans), transform var(--trans);
}
.card-flip-btn:hover { opacity: 0.9; }
.card-flip-btn:active { transform: scale(0.96); }

.xp-toast {
  position: fixed;
  top: 80px;
  left: 50%; transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 200;
  animation: toastPop 1.6s ease forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes toastPop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.8); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.9); }
}

/* ── QUIZ SCREEN ───────────────────────────────────────── */
.quiz-header {
  padding: 16px 20px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.quiz-timer-row {
  display: flex; align-items: center; justify-content: space-between;
}
.quiz-timer {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent2);
  transition: color var(--trans);
  min-width: 36px;
  text-align: center;
}
.quiz-timer.urgent { color: var(--danger); }
.quiz-score-display { font-size: 0.85rem; color: var(--text2); }
.quiz-q-counter { font-size: 0.8rem; color: var(--text3); }

.quiz-question {
  padding: 24px 20px 16px;
  text-align: center;
}
.quiz-q-emoji { font-size: 3rem; margin-bottom: 12px; }
.quiz-q-word {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
}
.quiz-q-roman { font-size: 0.9rem; color: var(--text2); font-style: italic; margin-bottom: 12px; }
.quiz-q-prompt { font-size: 0.85rem; color: var(--text2); }

.quiz-options {
  padding: 0 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.quiz-option {
  padding: 14px 18px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--trans), background var(--trans), transform var(--trans);
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); background: var(--bg2); }
.quiz-option:active:not(:disabled) { transform: scale(0.98); }
.quiz-option.correct { border-color: var(--success); background: rgba(61,191,168,0.12); color: var(--success); }
.quiz-option.wrong   { border-color: var(--danger);  background: rgba(229,90,90,0.12);   color: var(--danger); }
.quiz-option:disabled { cursor: default; }

.quiz-feedback {
  padding: 12px 20px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 36px;
  color: var(--text2);
}
.quiz-feedback.correct { color: var(--success); }
.quiz-feedback.wrong   { color: var(--danger); }

/* Quiz results */
.quiz-results {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px;
  gap: 20px;
  text-align: center;
}
.results-emoji { font-size: 4rem; }
.results-title { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800; }
.results-score { font-size: 3rem; font-weight: 800; color: var(--accent2); font-family: 'Syne', sans-serif; }
.results-xp { font-size: 0.9rem; color: var(--text2); }
.results-btn {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--trans);
}
.results-btn:hover { opacity: 0.9; }
.results-btn.secondary {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ── CONFETTI ──────────────────────────────────────────── */
#confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* ── MY LESSONS SCREEN ─────────────────────────────────── */
.lessons-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 40px 20px;
  text-align: center;
}
.lessons-empty-icon { font-size: 4rem; opacity: 0.4; }
.lessons-empty-text { color: var(--text2); font-size: 0.9rem; }

.lessons-list { padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.lesson-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lesson-item-header {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
}
.lesson-item-flag { font-size: 1.5rem; }
.lesson-item-info { flex: 1; }
.lesson-item-name { font-family: 'Syne', sans-serif; font-size: 0.95rem; font-weight: 700; }
.lesson-item-sub { font-size: 0.75rem; color: var(--text2); }
.lesson-item-action {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── PROGRESS SCREEN ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 20px 16px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-card-icon { font-size: 1.4rem; margin-bottom: 2px; }
.stat-card-value { font-family: 'Syne', sans-serif; font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.stat-card-sub { font-size: 0.72rem; color: var(--text3); font-weight: 500; }
.stat-card-label { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }

/* XP Level card */
.xp-level-card {
  margin: 0 20px 16px;
  background: linear-gradient(135deg, var(--card), var(--bg3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.xp-level-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.xp-level-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
}
.xp-level-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(108,99,255,0.12);
  border-radius: 20px;
  padding: 3px 10px;
}
.xp-level-bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.xp-level-bar-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.8s cubic-bezier(0.22,1,0.36,1);
}
.xp-level-footer {
  display: flex; justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text2);
}
.xp-level-max {
  font-size: 0.72rem;
  color: var(--warning);
  font-weight: 600;
  width: 100%;
  text-align: center;
}

/* Language progress list */
.lang-prog-list {
  padding: 0 20px;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 4px;
}
.lang-prog-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.lang-prog-flag { font-size: 1.6rem; flex-shrink: 0; }
.lang-prog-body { flex: 1; min-width: 0; }
.lang-prog-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.lang-prog-name {
  font-family: 'Syne', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lang-prog-count {
  font-size: 0.72rem;
  color: var(--text2);
  font-weight: 600;
  flex-shrink: 0;
  margin-left: 8px;
}
.lang-prog-bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.lang-prog-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.8s cubic-bezier(0.22,1,0.36,1);
  min-width: 4px;
}

/* Weekly words chart */
.activity-chart { padding: 0 20px 16px; }
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 96px;
}
.chart-bar-wrap {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.chart-bar-value {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text2);
  height: 14px;
  line-height: 14px;
}
.chart-bar {
  width: 100%;
  border-radius: 5px 5px 0 0;
  background: var(--accent);
  min-height: 4px;
  transition: height 0.7s cubic-bezier(0.22,1,0.36,1);
  opacity: 0.55;
}
.chart-bar.today { opacity: 1; background: linear-gradient(0deg, var(--accent), var(--accent2)); }
.chart-bar-day {
  font-size: 0.62rem;
  color: var(--text3);
  font-weight: 500;
}
.chart-bar-day.today { color: var(--accent2); font-weight: 700; }

/* Achievements */
.achievements-list { padding: 0 20px; display: flex; flex-direction: column; gap: 10px; }
.achievement-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color var(--trans);
}
.achievement-item.unlocked { border-color: var(--warning); }
.achievement-icon { font-size: 1.8rem; filter: grayscale(1); opacity: 0.35; flex-shrink: 0; }
.achievement-item.unlocked .achievement-icon { filter: none; opacity: 1; }
.achievement-info { flex: 1; }
.achievement-name { font-family: 'Syne', sans-serif; font-size: 0.9rem; font-weight: 700; }
.achievement-desc { font-size: 0.75rem; color: var(--text2); }
.achievement-check { color: var(--warning); font-size: 1rem; font-weight: 700; flex-shrink: 0; }

/* ── SETTINGS SCREEN ───────────────────────────────────── */
.settings-section { padding: 0 20px; margin-bottom: 20px; }
.settings-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 10px;
}
.settings-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.settings-item-left { display: flex; align-items: center; gap: 12px; }
.settings-item-icon { font-size: 1.2rem; width: 24px; text-align: center; }
.settings-item-label { font-size: 0.9rem; font-weight: 500; }
.settings-item-sub { font-size: 0.75rem; color: var(--text2); }
a.settings-item { text-decoration: none; color: inherit; transition: background var(--trans), border-color var(--trans); }
a.settings-item:hover { background: var(--bg3); border-color: var(--accent); }

/* Toggle switch */
.toggle {
  width: 44px; height: 24px;
  background: var(--bg3);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--trans);
  border: none;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: var(--text3);
  border-radius: 50%;
  transition: transform var(--trans), background var(--trans);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(20px); background: white; }

/* ── UTILITY ───────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill-premium {
  background: linear-gradient(135deg, #f0a500, #f7d76f);
  color: #0a0a0f;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--trans), transform var(--trans);
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── PREMIUM LOCK OVERLAY ──────────────────────────────── */
.premium-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex; align-items: flex-end;
  animation: fadeIn 0.2s ease;
}
.premium-sheet {
  width: 100%; max-width: 520px;
  margin: 0 auto;
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 32px 24px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  text-align: center;
}
.premium-icon { font-size: 3rem; }
.premium-title { font-family: 'Syne', sans-serif; font-size: 1.4rem; font-weight: 800; }
.premium-desc { font-size: 0.9rem; color: var(--text2); line-height: 1.5; }
.premium-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--bg3); border: none; color: var(--text2);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 1rem; cursor: pointer;
}

/* ── INSTALL INSTRUCTIONS ──────────────────────────────── */
.install-steps {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; text-align: left;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.install-step {
  font-size: 0.9rem; color: var(--text2); line-height: 1.4;
}
.install-share-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--accent); color: #fff;
  border-radius: 5px; font-size: 0.8rem; font-weight: 700;
  vertical-align: middle;
}

/* ── SHARE / REFERRAL MODAL ────────────────────────────── */
.share-overlay { align-items: flex-end; }
.share-sheet {
  position: relative;
  width: 100%; max-width: 520px;
  margin: 0 auto;
  background: var(--bg2);
  border-radius: 28px 28px 0 0;
  padding: 32px 22px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: smSlideUp 0.45s cubic-bezier(0.22,1,0.36,1) both;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.35);
}
.share-header { text-align: center; }
.share-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.35rem; font-weight: 800;
}
.share-subtitle {
  font-size: 0.8rem; color: var(--text2); margin-top: 3px;
}
.share-qr-wrap {
  background: #fff;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.share-qr {
  display: block;
  width: 150px; height: 150px;
  border-radius: 8px;
}
.share-copy-btn {
  width: 100%;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans), border-color var(--trans);
}
.share-copy-btn:hover  { border-color: var(--accent); }
.share-copy-btn:active { transform: scale(0.97); }
.share-copy-fallback {
  width: 100%;
  margin-top: 8px;
}
.share-copy-fallback input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text1);
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  cursor: text;
  user-select: all;
}
.share-divider {
  font-size: 0.72rem; color: var(--text3);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
}
.share-messengers {
  display: flex; gap: 8px; width: 100%;
}
.share-msg-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px 10px;
  border-radius: var(--radius);
  text-decoration: none; color: #fff;
  font-size: 0.65rem; font-weight: 700; line-height: 1.2;
  transition: transform var(--trans), opacity var(--trans);
  text-align: center;
}
.share-msg-btn svg { width: 26px; height: 26px; flex-shrink: 0; }
.share-msg-btn:active { transform: scale(0.93); opacity: 0.88; }
.share-tg { background: #2AABEE; }
.share-wa { background: #25D366; }
.share-vb { background: #7360F2; }
.share-fb { background: #1877F2; }

/* ── LANGUAGE SELECTOR ─────────────────────────────────── */
.lang-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 4px 16px 14px;
}
.lang-sel-btn {
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--trans);
  font-family: 'DM Sans', sans-serif;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lang-sel-btn.active {
  border-color: var(--accent);
  background: rgba(108,99,255,0.12);
  color: var(--accent);
  font-weight: 600;
}
.lang-sel-btn:not(.active):hover {
  border-color: var(--text3);
  color: var(--text);
}

/* ── LANGUAGE PICKER (first launch) ──────────────────────── */
.lang-pick-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lang-pick-sheet {
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.lang-pick-logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.lang-pick-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}
.lang-pick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.lang-pick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: var(--trans);
}
.lang-pick-btn:hover {
  border-color: var(--accent);
  background: rgba(108,99,255,0.10);
  color: var(--accent);
}
.lang-pick-flag {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.lang-pick-name {
  font-weight: 500;
  text-align: left;
}

/* ── GRAMMAR SCREEN ────────────────────────────────────── */
.grammar-section-label {
  padding: 14px 20px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text3);
  text-transform: uppercase;
}
.grammar-pos-card {
  margin: 0 16px 16px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.grammar-pos-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.grammar-pos-emoji {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}
.grammar-pos-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.grammar-pos-title-ua {
  font-size: 0.82rem;
  color: var(--text3);
  margin-top: 1px;
}
.grammar-definition {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.grammar-def-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.grammar-def-en {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}
.grammar-def-ua {
  font-size: 0.82rem;
  color: var(--text3);
  margin-top: 4px;
  line-height: 1.4;
}
.grammar-examples-title {
  padding: 10px 16px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
}
.grammar-pronoun-wrap {
  padding-bottom: 4px;
}
.grammar-table-scroll {
  overflow-x: auto;
  padding: 0 16px 14px;
}
.grammar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 340px;
}
.grammar-table th {
  padding: 6px 8px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.grammar-table td {
  padding: 7px 8px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.grammar-table tbody tr:last-child td {
  border-bottom: none;
}
.grammar-table tbody tr:nth-child(even) {
  background: var(--bg);
}
.grammar-ex-num {
  color: var(--text3);
  font-size: 0.75rem;
  width: 20px;
  text-align: center;
}
.grammar-ex-word {
  white-space: nowrap;
  color: var(--accent);
}
.grammar-ex-trans {
  white-space: nowrap;
  color: var(--text2);
}
.grammar-ex-sentence {
  line-height: 1.5;
  color: var(--text);
}
.grammar-ex-sentence-ua {
  color: var(--text3);
  font-size: 0.78rem;
}
.grammar-table-note {
  white-space: nowrap;
  color: var(--text3);
  font-size: 0.75rem;
  font-style: italic;
}
.grammar-pronoun-table td {
  color: var(--text);
  font-size: 0.85rem;
}
.grammar-pronoun-table td strong {
  color: var(--accent2);
  font-weight: 700;
}

/* ── ALPHABET SCREEN ───────────────────────────────────── */
.alpha-intro {
  padding: 10px 20px 6px;
  font-size: 0.82rem;
  color: var(--text2);
}
.alpha-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 8px 16px calc(var(--nav-h) + 16px);
}
.alpha-card {
  aspect-ratio: 1;
  perspective: 700px;
  cursor: pointer;
}
.alpha-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
  border-radius: var(--radius-sm);
}
.alpha-card.flipped .alpha-card-inner {
  transform: rotateY(180deg);
}
.alpha-card-front,
.alpha-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
}
.alpha-card-back {
  transform: rotateY(180deg);
  padding: 5px 4px;
  justify-content: space-evenly;
  gap: 1px;
}
.alpha-letter-big {
  font-family: 'Syne', sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.alpha-letter-small {
  font-size: 1rem;
  color: var(--text2);
  margin-top: 2px;
}
.alpha-back-emoji { font-size: 1.1rem; line-height: 1; }
.alpha-back-name  { font-size: 0.62rem; font-weight: 700; color: var(--accent2); text-align: center; }
.alpha-back-pron  { font-size: 0.58rem; color: var(--text2); text-align: center; }
.alpha-back-word  { font-size: 0.6rem;  color: var(--text);  text-align: center; font-weight: 600; }
.alpha-back-trans { font-size: 0.55rem; color: var(--text3); text-align: center; }
.alpha-back-speak {
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (min-width: 520px) {
  #app { box-shadow: 0 0 60px rgba(0,0,0,0.5); }
  #bottom-nav { border-radius: var(--radius) var(--radius) 0 0; }
}

@media (max-height: 600px) {
  .flashcard { height: 210px; }
}

/* ── HOME ENTRY ANIMATIONS ─────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0);    }
}
#screen-home.active .home-hero {
  animation: slideUp 0.52s cubic-bezier(0.22,1,0.36,1) both;
}
#screen-home.active .streak-banner {
  animation: slideUp 0.45s 0.10s ease both;
}
#screen-home.active .section-header {
  animation: slideUp 0.42s 0.18s ease both;
}
#screen-home.active .lang-grid .lang-card:nth-child(1) { animation: slideUp 0.38s 0.22s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(2) { animation: slideUp 0.38s 0.26s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(3) { animation: slideUp 0.38s 0.30s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(4) { animation: slideUp 0.38s 0.34s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(5) { animation: slideUp 0.38s 0.38s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(6) { animation: slideUp 0.38s 0.42s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(7) { animation: slideUp 0.38s 0.46s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(8) { animation: slideUp 0.38s 0.50s ease both; }
#screen-home.active .lang-grid .lang-card:nth-child(9) { animation: slideUp 0.38s 0.54s ease both; }
#screen-home.active #home-achievements {
  animation: slideUp 0.38s 0.58s ease both;
}

/* ── STREAK BANNER ACTIVE STATE ────────────────────────── */
.streak-banner.streak-active {
  border-color: rgba(240,140,0,0.32);
  background: linear-gradient(135deg, rgba(240,100,0,0.09), rgba(108,99,255,0.06)) !important;
}
.streak-banner.streak-active .streak-icon {
  display: inline-block;
  animation: streakIconPulse 2.4s ease-in-out infinite;
}
@keyframes streakIconPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  40%       { transform: scale(1.18) rotate(-6deg); }
  60%       { transform: scale(1.18) rotate(6deg); }
}

/* ── STREAK MILESTONE MODAL ────────────────────────────── */
.streak-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  align-items: flex-end;
  justify-content: center;
}
.streak-modal.showing { display: flex; }

.streak-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  animation: smFadeIn 0.3s ease both;
}
.streak-modal.hiding .streak-modal-backdrop { animation: smFadeOut 0.35s ease both; }

@keyframes smFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes smFadeOut { from { opacity: 1; } to { opacity: 0; } }

.streak-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  background: linear-gradient(160deg, var(--bg2) 0%, var(--bg3) 100%);
  border: 1px solid rgba(240,140,0,0.28);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 36px 28px 48px;
  text-align: center;
  animation: smSlideUp 0.52s cubic-bezier(0.22,1,0.36,1) both;
  box-shadow: 0 -12px 60px rgba(240,100,0,0.18), 0 -4px 24px rgba(0,0,0,0.4);
}
.streak-modal.hiding .streak-modal-card { animation: smSlideDown 0.35s ease both; }

@keyframes smSlideUp {
  from { opacity: 0; transform: translateY(110%); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes smSlideDown {
  from { transform: translateY(0);   opacity: 1; }
  to   { transform: translateY(110%); opacity: 0; }
}

.streak-modal-fire-wrap {
  display: inline-block;
  margin-bottom: 4px;
}
.streak-modal-fire {
  display: block;
  font-size: 5rem;
  line-height: 1;
  animation: smFireBounce 0.85s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 18px rgba(255,120,0,0.55));
}
@keyframes smFireBounce {
  from { transform: scale(1)    rotate(-5deg) translateY(0); }
  to   { transform: scale(1.15) rotate(5deg)  translateY(-6px); }
}

.streak-modal-days {
  font-family: 'Syne', sans-serif;
  font-size: 5.5rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #f5c842, #ff6b35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 10px 0 4px;
}

.streak-modal-label {
  font-size: 0.8rem;
  color: var(--text2);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.streak-modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.2;
}

.streak-modal-msg {
  font-size: 0.95rem;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 30px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.streak-modal-btn {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  padding: 16px;
  background: linear-gradient(135deg, #f0a500, #ff6035);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--trans), opacity var(--trans);
  box-shadow: 0 4px 24px rgba(240,110,0,0.35);
}
.streak-modal-btn:active { transform: scale(0.97); opacity: 0.9; }

/* ── SW UPDATE BANNER ──────────────────────────────────── */
.sw-update-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 10px 12px 10px 16px;
  box-shadow: 0 4px 28px rgba(108,99,255,0.28), 0 2px 8px rgba(0,0,0,0.45);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.sw-update-banner.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.sw-update-text {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
}
.sw-update-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}
.sw-update-btn:hover  { opacity: 0.85; }
.sw-update-btn:active { transform: scale(0.95); }

/* ── ONBOARDING MODAL ──────────────────────────────────────── */
.onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.onboarding-modal.hidden {
  display: none;
}
.onboarding-slide {
  width: 100%;
  max-width: 420px;
  opacity: 0;
  transform: translateX(30px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  animation: none;
}
.onboarding-slide.onboarding-slide-active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.onboarding-slide.onboarding-slide-exit-left {
  animation: slideExitLeft 0.35s ease forwards;
}
.onboarding-slide.onboarding-slide-enter-left {
  animation: slideEnterLeft 0.35s ease forwards;
}
@keyframes slideExitLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-30px); }
}
@keyframes slideEnterLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}
.onboarding-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.onboarding-back {
  text-align: left;
  color: var(--text2);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: -12px;
  transition: color 0.2s ease;
}
.onboarding-back:hover {
  color: var(--accent);
}
.onboarding-emoji {
  font-size: 3.5rem;
  margin-bottom: 8px;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.onboarding-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}
.onboarding-slide-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 0 0 24px 0;
}
.onboarding-desc {
  font-size: 1rem;
  color: var(--text2);
  line-height: 1.6;
  margin: 0;
}
.onboarding-btn-next {
  align-self: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(108,99,255,0.3);
  margin-top: 16px;
}
.onboarding-btn-next:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(108,99,255,0.4);
  transform: translateY(-2px);
}
.onboarding-btn-next:active:not(:disabled) {
  transform: scale(0.95);
}
.onboarding-btn-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 2px 8px rgba(108,99,255,0.1);
}
.onboarding-lang-grid,
.onboarding-goals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
  max-height: 380px;
  overflow-y: auto;
}
.onboarding-lang-item,
.onboarding-goal-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.onboarding-lang-item:hover,
.onboarding-goal-item:hover {
  border-color: var(--accent);
  background: rgba(108,99,255,0.08);
}
.onboarding-lang-item.selected,
.onboarding-goal-item.selected {
  border-color: var(--accent);
  background: rgba(108,99,255,0.15);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}
.onboarding-lang-flag,
.onboarding-goal-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}
.onboarding-lang-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.onboarding-lang-native {
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 400;
}
.onboarding-goal-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.onboarding-goal-title {
  font-weight: 600;
  color: var(--text);
}
.onboarding-goal-subtitle {
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 400;
}
.onboarding-action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}
.onboarding-btn-skip {
  background: var(--bg2);
  color: var(--text2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.onboarding-btn-skip:hover {
  border-color: var(--text2);
  color: var(--text);
}
.onboarding-btn-confirm {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 32px;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(108,99,255,0.3);
}
.onboarding-btn-confirm:hover {
  box-shadow: 0 6px 20px rgba(108,99,255,0.4);
}
.onboarding-btn-confirm:active {
  transform: scale(0.95);
}
.onboarding-btn-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════════════
   ГЕЙМІФІКАЦІЯ: ЕНЕРГІЯ, АНІМАЦІЇ, ПРОГРЕС
   ═════════════════════════════════════════════════════════════ */

/* ── ЕНЕРГІЯ ⚡ ───────────────────────────────────────────── */
.energy-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(108, 99, 255, 0.15);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 6px 12px;
  font-weight: 600;
  color: var(--accent);
  animation: energyPulse 1.2s ease-in-out infinite;
}
.energy-display.energy-low {
  background: rgba(229, 90, 90, 0.15);
  border-color: var(--danger);
  color: var(--danger);
  animation: energyDangerPulse 0.6s ease-in-out infinite;
}
.energy-icon {
  font-size: 1.2rem;
  display: inline-block;
}
.energy-count {
  font-size: 1rem;
  min-width: 20px;
  text-align: center;
}

/* Пульс небезпеки при низькій енергії */
@keyframes energyDangerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Анімація пульсу енергії */
@keyframes energyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Анімація розряду енергії (震ак при помилці) */
.energy-display.energy-drain {
  animation: energyDrain 0.6s ease-out;
}
@keyframes energyDrain {
  0% { transform: scale(1.1); opacity: 1; }
  50% { transform: scale(0.95) rotate(2deg); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── ЕКРАН-СПАЛАХ (Correct Answer) ───────────────────────── */
.quiz-flash {
  animation: screenFlash 0.4s ease-out;
}
@keyframes screenFlash {
  0% { background-color: currentColor; opacity: 0.6; }
  100% { background-color: transparent; opacity: 0; }
}

/* ── ТРЯС ЕКРАНА (Wrong Answer) ───────────────────────────── */
.quiz-shake {
  animation: screenShake 0.5s cubic-bezier(0.36, 0, 0.66, -0.56);
}
@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-6px); }
  20% { transform: translateX(6px); }
  30% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  50% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
  90% { transform: translateX(-1px); }
}

/* ── ХВИЛЕВА АНІМАЦІЯ ПРОГРЕСА ──────────────────────────── */
.progress-track {
  position: relative;
  height: 4px;
  background: var(--bg2);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill.wave-animation {
  animation: waveFlow 2s ease-in-out infinite;
  background: linear-gradient(90deg,
    var(--accent) 0%,
    var(--accent2) 25%,
    var(--accent) 50%,
    var(--accent2) 75%,
    var(--accent) 100%);
  background-size: 200% 100%;
}
@keyframes waveFlow {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── XP АНІМАЦІЯ НА РЕЗУЛЬТАТАХ ────────────────────────── */
.results-xp {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  animation: xpPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes xpPop {
  0% { transform: scale(0) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ── ЕНЕРГІЯ ВИЧЕРПАНА ЕКРАН ────────────────────────────── */
.energy-exhausted {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 20px;
}
.energy-exhausted-icon {
  font-size: 4rem;
  animation: sadBounce 2s ease-in-out infinite;
}
@keyframes sadBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(-2deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(8px) rotate(2deg); }
}
.energy-exhausted-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.energy-exhausted-text {
  font-size: 1rem;
  color: var(--text2);
  margin: 0;
  line-height: 1.5;
}
.energy-exhausted-btn,
.energy-exhausted-btn.secondary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 28px;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.3);
}
.energy-exhausted-btn.secondary {
  background: var(--bg2);
  color: var(--text2);
  box-shadow: none;
  border: 1px solid var(--border);
}
.energy-exhausted-btn:hover {
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}
.energy-exhausted-btn.secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}
.energy-exhausted-btn:active {
  transform: scale(0.95);
}

/* ── ПРОГРЕС-БАР ПО РОЗДІЛАХ (Lessons) ────────────────── */
.lesson-progress-section {
  margin: 12px 0;
  padding: 16px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.lesson-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.lesson-progress-title {
  font-weight: 600;
  color: var(--text);
}
.lesson-progress-count {
  font-size: 0.9rem;
  color: var(--text2);
  font-weight: 500;
}
.lesson-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.5);
}

/* ── TOPBAR ENERGY RESPONSIVE ──────────────────────────── */
@media (max-width: 480px) {
  .energy-display {
    padding: 4px 10px;
    font-size: 0.9rem;
  }
  .energy-icon {
    font-size: 1rem;
  }
}

/* ── QUALITY SECTION ───────────────────────────────────── */
.quality-section {
  padding: 60px 20px;
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 40px 0;
  animation: fadeIn 0.8s ease-out;
}

.quality-section .container {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.quality-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
}

.quality-subtitle {
  font-size: 1rem;
  color: var(--text2);
  margin-bottom: 32px;
  line-height: 1.6;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .quality-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.quality-item {
  padding: 20px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.quality-item.perfect {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.05);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.2);
}

.quality-item.excellent {
  border-color: var(--success);
  background: rgba(61, 191, 168, 0.05);
  box-shadow: 0 0 16px rgba(61, 191, 168, 0.2);
}

.quality-item.good {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.05);
  box-shadow: 0 0 16px rgba(108, 99, 255, 0.2);
}

.quality-item:hover {
  transform: translateY(-4px);
}

.quality-item .flag {
  font-size: 2rem;
}

.quality-item .lang {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.quality-item .score {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent2);
}

.quality-footer {
  font-size: 0.95rem;
  color: var(--text2);
  line-height: 1.6;
}

/* ── WAITLIST SECTION ──────────────────────────────────– */
.waitlist-section {
  padding: 60px 20px;
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.1) 0%, rgba(61, 191, 168, 0.05) 100%);
  border-top: 1px solid var(--border);
  margin: 40px 0;
  animation: fadeIn 0.8s ease-out;
}

.waitlist-section .container {
  max-width: 600px;
  margin: 0 auto;
}

.waitlist-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
}

.waitlist-subtitle {
  font-size: 1rem;
  color: var(--text2);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}

.waitlist-benefits {
  list-style: none;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.waitlist-benefits li {
  color: var(--text);
  font-size: 0.95rem;
  padding: 8px 0;
}

.waitlist-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.waitlist-input {
  padding: 14px 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.waitlist-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(108, 99, 255, 0.3);
}

.waitlist-input::placeholder {
  color: var(--text3);
}

.language-picker {
  border: none;
  padding: 0;
}

.language-picker legend {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.language-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 480px) {
  .language-picker {
    grid-template-columns: repeat(2, 1fr);
  }
}

.language-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text2);
  font-size: 0.9rem;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.language-picker label:hover {
  background: var(--bg2);
  color: var(--text);
}

.language-picker input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.waitlist-button {
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.3);
}

.waitlist-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(108, 99, 255, 0.4);
}

.waitlist-button:active {
  transform: translateY(0);
}

.waitlist-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text3);
  margin-top: 12px;
}

.hidden {
  display: none;
}

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