/* ============================================================
   TYPING KID — MAIN STYLESHEET
   Space Adventure Theme
   ============================================================ */

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

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  /* Colors */
  --bg-void:       #020710;
  --bg-deep:       #050a1a;
  --bg-space:      #0a1628;
  --bg-card:       rgba(255,255,255,0.06);
  --bg-card-hover: rgba(255,255,255,0.10);
  --bg-card-glow:  rgba(0,212,255,0.08);

  --cyan:   #00d4ff;
  --pink:   #ff2d9b;
  --lime:   #a8ff3e;
  --gold:   #ffd700;
  --violet: #b57ef7;
  --orange: #ff6b35;

  --text-primary:   #ffffff;
  --text-secondary: #94a3b8;
  --text-muted:     #3d5068;

  --correct: #00ff88;
  --wrong:   #ff4444;
  --cursor:  #ffd700;
  --pending: rgba(255,255,255,0.3);

  /* Finger Colors (typing) */
  --f-lp: #ff6b6b; /* left pinky */
  --f-lr: #ffa06b; /* left ring */
  --f-lm: #ffd76b; /* left middle */
  --f-li: #6bffb8; /* left index */
  --f-ri: #6bd4ff; /* right index */
  --f-rm: #6b8fff; /* right middle */
  --f-rr: #a06bff; /* right ring */
  --f-rp: #ff6bda; /* right pinky */
  --f-th: rgba(255,255,255,0.4); /* thumbs */

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  40px;
  --sp-xxl: 64px;

  /* Border Radius */
  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-full: 9999px;

  /* Transitions */
  --t-fast:   120ms ease;
  --t-normal: 250ms cubic-bezier(0.34,1.56,0.64,1);
  --t-slow:   450ms cubic-bezier(0.34,1.56,0.64,1);

  /* Shadows */
  --shadow-cyan:   0 0 24px rgba(0,212,255,0.4);
  --shadow-pink:   0 0 24px rgba(255,45,155,0.4);
  --shadow-card:   0 8px 32px rgba(0,0,0,0.4);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  height: 100%;
  font-family: 'Plus Jakarta Sans', 'Noto Sans Khmer', system-ui, sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; }
input, textarea { font-family: inherit; outline: none; border: none; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }

/* ─── Star Field ─────────────────────────────────────────── */
#star-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ─── Nebula Background ─────────────────────────────────── */
.nebula-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 15% 40%, rgba(120,0,220,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 20%, rgba(0,100,255,0.14) 0%, transparent 70%),
    radial-gradient(ellipse 40% 50% at 65% 75%, rgba(0,200,150,0.10) 0%, transparent 70%),
    var(--bg-void);
}

/* ─── App Shell ─────────────────────────────────────────── */
#app {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* ─── Screens ────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--sp-lg);
  animation: fadeSlideIn 0.35s cubic-bezier(0.34,1.2,0.64,1) both;
}
.screen.active { display: flex; }

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

/* ─── Glass Card ─────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  padding: var(--sp-lg);
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.card:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(0,212,255,0.15);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 12px 28px;
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 1rem;
  transition: transform var(--t-normal), box-shadow var(--t-normal), filter var(--t-fast);
}
.btn:active { transform: scale(0.95) !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0066cc);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,212,255,0.45);
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 30px rgba(0,212,255,0.6);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--pink), #cc0066);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255,45,155,0.45);
}
.btn-secondary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 30px rgba(255,45,155,0.6);
}

.btn-success {
  background: linear-gradient(135deg, var(--lime), #44cc00);
  color: #0a2200;
  box-shadow: 0 4px 20px rgba(168,255,62,0.4);
}
.btn-success:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 30px rgba(168,255,62,0.6);
}

.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.12);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.14);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-icon {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: var(--r-md);
  font-size: 1.2rem;
}

/* ─── Language Selector Buttons ─────────────────────────── */
.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-lg) var(--sp-xl);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.08);
  transition: all var(--t-normal);
  cursor: pointer;
  flex: 1;
  min-width: 140px;
}
.lang-btn:hover {
  border-color: var(--cyan);
  background: var(--bg-card-glow);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,212,255,0.3);
}
.lang-btn.selected {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.12);
  box-shadow: 0 0 0 4px rgba(0,212,255,0.15), var(--shadow-cyan);
}
.lang-btn .lang-flag { font-size: 3rem; line-height: 1; }
.lang-btn .lang-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.lang-btn .lang-sub  { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── Level Grid ─────────────────────────────────────────── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-md);
  width: 100%;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-lg) var(--sp-md);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.07);
  cursor: pointer;
  transition: all var(--t-normal);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.level-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.03));
  pointer-events: none;
}
.level-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--cyan);
  box-shadow: 0 16px 48px rgba(0,212,255,0.25), 0 0 0 1px rgba(0,212,255,0.2);
}
.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.3);
}
.level-card.locked:hover { transform: none; box-shadow: none; border-color: rgba(255,255,255,0.07); }
.level-card.completed { border-color: rgba(168,255,62,0.3); }
.level-card .level-icon  { font-size: 2.5rem; line-height: 1; }
.level-card .level-planet { font-size: 1.4rem; position: absolute; top: 10px; right: 12px; opacity: 0.6; }
.level-card .level-name  { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.level-card .level-desc  { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.3; }
.level-card .level-diff  {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
  padding: 2px 10px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.08); color: var(--text-secondary);
  text-transform: uppercase;
}
.level-card .level-diff.beginner { background: rgba(0,255,136,0.15); color: var(--correct); }
.level-card .level-diff.medium   { background: rgba(255,215,0,0.15);  color: var(--gold); }
.level-card .level-diff.hard     { background: rgba(255,45,155,0.15); color: var(--pink); }

/* Stars display */
.level-stars { display: flex; gap: 3px; }
.star { font-size: 1.1rem; filter: grayscale(1) brightness(0.5); transition: filter var(--t-fast); }
.star.earned { filter: grayscale(0) brightness(1); }

/* ─── Lesson Screen ──────────────────────────────────────── */
.lesson-header {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}
.lesson-title {
  flex: 1;
  font-size: 1.4rem;
  font-weight: 800;
}
.lesson-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--sp-sm);
  min-height: 1.2em;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: var(--sp-md);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-lg);
}
.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 20px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  min-width: 80px;
}
.stat-badge .stat-val { font-size: 1.6rem; font-weight: 900; line-height: 1; }
.stat-badge .stat-lbl { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); }
.stat-badge.wpm    .stat-val { color: var(--cyan); }
.stat-badge.acc    .stat-val { color: var(--lime); }
.stat-badge.timer  .stat-val { color: var(--gold); }

/* Exercise Progress */
.exercise-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: var(--sp-md);
}
.ex-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--t-normal);
}
.ex-dot.active   { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transform: scale(1.3); }
.ex-dot.done     { background: var(--correct); }

/* ─── Lesson Screen Layout & Spacing ─────────────────────── */
.lesson-screen {
  padding: 20px 24px !important;
  gap: 14px !important;
  min-height: 100vh;
  justify-content: flex-start;
}

.compact-lesson-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding-right: 56px; /* Space for top-right hamburger button */
}

.compact-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.compact-level-title {
  font-size: 1.25rem;
  font-weight: 800;
  white-space: nowrap;
  font-family: 'Plus Jakarta Sans', 'Noto Sans Khmer', sans-serif !important;
}

.compact-lesson-bar .exercise-progress {
  margin-bottom: 0;
  gap: 6px;
}

.compact-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 5px 14px;
  border-radius: var(--r-full);
}
.c-stat-time strong { color: var(--gold); }
.c-stat-wpm strong { color: var(--cyan); }
.c-stat-acc strong { color: var(--lime); }
.c-stat-sep { color: var(--text-muted); }

/* Mascot & Hint Bar */
.mascot-hint-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-md);
  padding: 6px 14px;
  font-size: 0.85rem;
  font-family: 'Plus Jakarta Sans', 'Noto Sans Khmer', sans-serif !important;
}
.mascot-mini { font-size: 1.3rem; line-height: 1; }
.mascot-speech-mini { font-weight: 700; color: var(--cyan); white-space: nowrap; }
.hint-mini { color: var(--text-secondary); opacity: 0.85; margin-left: auto; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.compact-pbar {
  height: 5px;
  margin-bottom: 4px;
}

/* ─── 2-Row Typing Display Layout ───────────────────────── */
.typing-display {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-xl);
  padding: 16px 22px;
  margin-bottom: 8px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: text;
  transition: border-color var(--t-fast);
  position: relative;
  box-shadow: var(--shadow-card);
}
.typing-display.focused { border-color: rgba(0,212,255,0.4); box-shadow: 0 0 0 3px rgba(0,212,255,0.1); }

.row-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.row-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.target-block .row-label { color: var(--cyan); }
.user-block .row-label   { color: var(--violet); }

.row-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

.row-chars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1.8;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-height: 48px;
}
.typing-display.khmer .row-chars {
  font-family: 'Noto Sans Khmer', 'Kantumruy Pro', 'Plus Jakarta Sans', sans-serif !important;
  font-size: 1.85rem;
}

/* Target Row Character States */
.target-char {
  display: inline-block;
  padding: 0 4px;
  color: var(--text-secondary);
  opacity: 0.65;
  transition: all var(--t-fast);
  font-family: 'Noto Sans Khmer', 'Plus Jakarta Sans', sans-serif !important;
}
.target-char.done {
  color: rgba(255,255,255,0.25);
  opacity: 0.35;
}
.target-char.active-target {
  color: var(--gold);
  opacity: 1;
  transform: scale(1.15);
  font-weight: 900;
  text-shadow: 0 0 16px rgba(255,215,0,0.8);
  position: relative;
}
.target-char.active-target::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--gold);
  animation: blink 0.9s step-end infinite;
}

/* User Row Character States */
.user-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0.6em;
  padding: 0 4px;
  margin: 0 2px;
  border-radius: 6px;
  position: relative;
  font-family: 'Noto Sans Khmer', 'Plus Jakarta Sans', sans-serif !important;
}
.user-char.correct {
  color: var(--correct);
  background: rgba(0, 255, 136, 0.12);
  border: 1px solid rgba(0, 255, 136, 0.3);
}
.user-char.wrong {
  color: #ff4444;
  background: rgba(255, 68, 68, 0.22);
  border: 1.5px dashed rgba(255, 68, 68, 0.8);
  text-decoration: line-through;
  font-weight: 800;
}
.user-char.active-caret {
  min-width: 14px;
  height: 32px;
  border-left: 3px solid var(--cyan);
  animation: blink 0.9s step-end infinite;
  box-shadow: -2px 0 10px var(--cyan);
}
.user-char.placeholder {
  color: rgba(255,255,255,0.15);
  font-size: 1.2rem;
}

/* Expected Badge Popup on Wrong Character */
.expected-badge {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 800;
  background: #ff4444;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(255, 68, 68, 0.4);
  text-decoration: none;
  pointer-events: none;
  font-family: 'Noto Sans Khmer', 'Plus Jakarta Sans', sans-serif !important;
  z-index: 10;
}
.expected-badge::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: #ff4444 transparent transparent;
}
.char.cursor  { color: var(--cursor); }
.char.cursor::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--cursor);
  border-radius: 2px;
  animation: blink 1s step-end infinite;
}
.char.pending { color: var(--pending); }
.char.space   { display: inline-block; width: 0.4em; }

@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Hidden input */
#typing-input {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px; height: 1px;
  opacity: 0;
}

/* ─── Progress Bar ───────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: var(--sp-lg);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: var(--r-full);
  transition: width 0.4s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute;
  right: 0; top: 0;
  width: 16px; height: 100%;
  background: white;
  border-radius: var(--r-full);
  opacity: 0.6;
  filter: blur(4px);
}

/* ─── Mascot ─────────────────────────────────────────────── */
.mascot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}
.mascot {
  font-size: 4rem;
  line-height: 1;
  display: inline-block;
  animation: mascotFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(0,212,255,0.6));
  cursor: default;
  user-select: none;
}
.mascot.celebrate { animation: mascotCelebrate 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards; }
.mascot-speech {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-lg);
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  max-width: 260px;
  transition: all var(--t-normal);
}

/* ─── Home Screen Layout & Spacing ───────────────────────── */
#screen-home, .home-screen {
  align-items: center;
  justify-content: center;
  gap: 20px !important;
  text-align: center;
  padding: 24px var(--sp-lg) !important;
  min-height: 100vh;
}

.home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.mascot-home-badge {
  font-size: 2.8rem;
  line-height: 1;
  animation: mascotFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(0,212,255,0.6));
}

.home-title {
  font-size: clamp(2.4rem, 6.5vw, 3.8rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 50%, var(--pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

.home-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}

@keyframes titleGlow {
  from { filter: brightness(1); }
  to   { filter: brightness(1.2) saturate(1.3); }
}

.home-section-block {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compact-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.lang-row {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  justify-content: center;
}

.lang-btn {
  padding: 16px 20px !important;
  border-radius: 18px !important;
  gap: 8px !important;
}

.profile-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}

.input-group, .avatar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.compact-input {
  width: 100%;
  background: var(--bg-card);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.compact-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.15);
}
.compact-input::placeholder { color: var(--text-muted); }

.compact-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.compact-grid .avatar-opt {
  font-size: 1.4rem;
  padding: 6px;
  border-radius: 10px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t-normal);
}
.compact-grid .avatar-opt:hover { transform: scale(1.15); border-color: rgba(255,255,255,0.2); }
.compact-grid .avatar-opt.active {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.15);
  box-shadow: 0 0 10px rgba(0,212,255,0.3);
  transform: scale(1.1);
}

.start-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.compact-btn-start {
  min-width: 200px;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 14px 44px !important;
  border-radius: var(--r-full);
}

.offline-note {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.avatar-opt.picked  { border-color: var(--cyan); background: rgba(0,212,255,0.12); transform: scale(1.15); }

/* ─── Lesson Menu ─────────────────────────────────────────── */
#screen-menu { padding: var(--sp-lg); gap: var(--sp-lg); }
.menu-header { display: flex; align-items: center; gap: var(--sp-md); margin-bottom: var(--sp-sm); }
.menu-title  { font-size: 1.8rem; font-weight: 900; flex: 1; }
.lang-badge  {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px;
  border-radius: var(--r-full);
  background: rgba(0,212,255,0.12);
  border: 1px solid rgba(0,212,255,0.3);
  font-size: 0.85rem; font-weight: 700; color: var(--cyan);
}

/* ─── Results Overlay ─────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,7,16,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.result-card {
  background: var(--bg-space);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-xl);
  padding: var(--sp-xl);
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
  box-shadow: 0 0 80px rgba(0,212,255,0.15);
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.result-title { font-size: 2.2rem; font-weight: 900; margin: var(--sp-md) 0; }
.result-stars { font-size: 2.5rem; gap: 8px; display: flex; justify-content: center; margin: var(--sp-md) 0; }
.result-star { opacity: 0.2; transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.result-star.lit { opacity: 1; filter: drop-shadow(0 0 12px gold); transform: scale(1.2); }
.result-stats { display: flex; gap: var(--sp-md); justify-content: center; margin: var(--sp-lg) 0; }
.result-stat { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.result-stat .val { font-size: 2rem; font-weight: 900; }
.result-stat .lbl { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.result-btns { display: flex; gap: var(--sp-md); justify-content: center; flex-wrap: wrap; }

/* ─── Progress Screen ─────────────────────────────────────── */
#screen-progress { gap: var(--sp-lg); }
.progress-header { display: flex; align-items: center; gap: var(--sp-md); }
.progress-title  { font-size: 1.8rem; font-weight: 900; flex: 1; }

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--sp-md);
}
.achievement {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: var(--sp-md);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.07);
  text-align: center;
  transition: all var(--t-normal);
}
.achievement.earned {
  border-color: rgba(255,215,0,0.3);
  background: rgba(255,215,0,0.06);
}
.achievement.locked { filter: grayscale(1) brightness(0.4); }
.achievement .badge-icon { font-size: 2.2rem; }
.achievement .badge-name { font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); }

/* WPM Chart */
.wpm-chart {
  width: 100%;
  height: 120px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
}
.wpm-chart canvas { width: 100%; height: 100%; }

/* ─── Hamburger Floating Button ───────────────────────────── */
.btn-hamburger {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(10, 22, 40, 0.85);
  border: 1.5px solid rgba(0, 212, 255, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 212, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--cyan);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  transition: all var(--t-normal);
}
.btn-hamburger:hover {
  transform: scale(1.08);
  border-color: var(--cyan);
  box-shadow: 0 6px 25px rgba(0, 212, 255, 0.4);
}
.btn-hamburger:active {
  transform: scale(0.95);
}

/* ─── Drawer Backdrop ────────────────────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 7, 16, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

/* ─── Drawer Slide-Over Panel ────────────────────────────── */
.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: rgba(8, 16, 32, 0.95);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 101;
  display: flex;
  flex-direction: column;
  padding: var(--sp-lg);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.nav-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: var(--sp-md);
}
.drawer-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--cyan);
}

.drawer-profile {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-lg);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  flex: 1;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
}
.drawer-item .drawer-icon {
  font-size: 1.4rem;
}
.drawer-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}
.drawer-item.active {
  background: rgba(0, 212, 255, 0.12);
  border-color: rgba(0, 212, 255, 0.3);
  color: var(--cyan);
}

.drawer-footer {
  padding-top: var(--sp-md);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Screen Padding without bottom nav */
.has-nav { padding-bottom: var(--sp-lg); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .screen { padding: var(--sp-md); }
  .typing-display { font-size: 1.5rem; padding: var(--sp-md); }
  .home-title { font-size: 2.5rem; }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .avatar-grid { grid-template-columns: repeat(5, 1fr); }
  .stats-bar .stat-badge { padding: 8px 14px; min-width: 64px; }
  .stats-bar .stat-badge .stat-val { font-size: 1.3rem; }
  .lang-btn { padding: var(--sp-md); min-width: 120px; }
}
@media (min-width: 768px) {
  .screen { padding: var(--sp-xl); max-width: 860px; margin: 0 auto; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .typing-display { font-size: 2.2rem; }
  .home-title { font-size: 5rem; }
}
@media (min-width: 1024px) {
  .screen { max-width: 960px; }
  .typing-display { font-size: 2.4rem; }
}

/* ─── Khmer Font Override ─────────────────────────────────── */
.khmer-text, .khmer * { font-family: 'Noto Serif Khmer', serif; }

/* ─── Utility ────────────────────────────────────────────── */
.text-center { text-align: center; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-sm   { gap: var(--sp-sm); }
.gap-md   { gap: var(--sp-md); }
.gap-lg   { gap: var(--sp-lg); }
.mt-sm    { margin-top: var(--sp-sm); }
.mt-md    { margin-top: var(--sp-md); }
.mt-lg    { margin-top: var(--sp-lg); }
.mb-md    { margin-bottom: var(--sp-md); }
.mb-lg    { margin-bottom: var(--sp-lg); }
.w-full   { width: 100%; }
.hidden   { display: none !important; }
.muted    { color: var(--text-secondary); }
.section-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-secondary); margin-bottom: var(--sp-sm);
}
