/* ═══════════════════════════════════════════════════════════
   LinguaMax — Kid-Friendly English Learning Platform
   Modern, playful, gamified design system
   ═══════════════════════════════════════════════════════════ */



/* ── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  --bg: #F4F8FB;
  --bg-gradient: linear-gradient(135deg, #F4F8FB 0%, #FFFFFF 100%);
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;

  --primary: #4A8CFF; /* Bright vibrant blue */
  --primary-light: #8CB3FF;
  --primary-dark: #326CE5;
  --primary-glow: rgba(74, 140, 255, 0.3);

  --secondary: #FFB775; /* Soft pastel orange */
  --secondary-light: #FFD2A8;

  --accent: #FFB3CB; /* Soft pastel pink */
  --accent-light: #FFD9E5;

  --success: #34D399; /* Green */
  --success-light: #A7F3D0;

  --info: #38BDF8; /* Light blue */
  --info-light: #BAE6FD;

  --danger: #FB7185;
  --danger-light: #FECDD3;

  --warning: #FBBF24;
  --warning-light: #FDE68A;

  --text: #1E293B;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow: 0 8px 16px -4px rgba(74, 140, 255, 0.1);
  --shadow-lg: 0 16px 24px -8px rgba(74, 140, 255, 0.15);
  --shadow-xl: 0 24px 32px -12px rgba(74, 140, 255, 0.2);
  --shadow-glow: 0 0 20px var(--primary-glow);

  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  --radius-sm: 10px;

  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;

  --transition: all 0.3s ease;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ── ANIMATED BACKGROUND BUBBLES ───────────────────────────── */
.bg-bubbles {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.bg-bubbles span {
  position: absolute;
  border-radius: 50%;
  opacity: 0.06;
  animation: float-bubble 20s infinite;
}
.bg-bubbles span:nth-child(1) { width: 200px; height: 200px; background: var(--primary); top: 10%; left: -5%; animation-delay: 0s; }
.bg-bubbles span:nth-child(2) { width: 150px; height: 150px; background: var(--secondary); top: 60%; right: -3%; animation-delay: 4s; }
.bg-bubbles span:nth-child(3) { width: 250px; height: 250px; background: var(--accent); bottom: -5%; left: 40%; animation-delay: 8s; }
.bg-bubbles span:nth-child(4) { width: 100px; height: 100px; background: var(--success); top: 30%; right: 20%; animation-delay: 12s; }

@keyframes float-bubble {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  33% { transform: translateY(-30px) rotate(120deg) scale(1.1); }
  66% { transform: translateY(20px) rotate(240deg) scale(0.9); }
}

/* ── TYPOGRAPHY ────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; line-height: 1.3; }
h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
h2 { font-size: clamp(1.2rem, 4vw, 1.5rem); }
h3 { font-size: 1.1rem; font-weight: 700; }
a { color: var(--primary); text-decoration: none; }

/* ── UTILITY ───────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.relative { position: relative; }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  border: none; cursor: pointer; transition: var(--transition);
  text-decoration: none; white-space: nowrap; position: relative;
  overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--primary-glow); }

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), #E05580);
  color: #fff; box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #E8962E);
  color: #fff; box-shadow: 0 4px 15px rgba(255, 179, 71, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #1DB954);
  color: #fff; box-shadow: 0 4px 15px rgba(46, 213, 115, 0.3);
}

.btn-danger { background: var(--danger); color: #fff; }

.btn-outline {
  background: var(--surface); border: 2px solid var(--border);
  color: var(--text); box-shadow: var(--shadow-sm);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: none; border: none; color: var(--primary); padding: 8px; font-weight: 700; cursor: pointer; }
.btn-ghost:hover { background: var(--primary-light); border-radius: var(--radius-sm); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 16px 32px; font-size: 1.1rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-round { border-radius: var(--radius-full); }

.btn-icon {
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  border: 1px solid var(--border);
  transition: var(--transition);
  position: relative; overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-interactive { cursor: pointer; }
.card-interactive:hover { transform: translateY(-3px); }
.card-interactive:active { transform: translateY(0) scale(0.98); }

.card-gradient {
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
}
.card-gradient .stat-label,
.card-gradient .text-secondary { color: rgba(255,255,255,0.8); }

/* ── INPUT ─────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; color: var(--text-secondary); }
.input-field {
  padding: 14px 18px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 1rem; background: var(--surface);
  transition: var(--transition); outline: none; width: 100%;
}
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7185' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 0.75rem; font-weight: 700; font-family: var(--font-display);
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-secondary { background: var(--secondary-light); color: var(--secondary); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-danger { background: var(--danger-light); color: var(--danger); }

/* ── HEADER ────────────────────────────────────────────────── */
.header {
  background: rgba(255,255,255,0.9); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px; position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 900;
  color: var(--primary); display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.2rem; font-weight: 900;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Header Stats (XP, Coins, Streak) */
.header-stats {
  display: flex; align-items: center; gap: 12px;
}
.header-stat {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-full);
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
}
.stat-xp { background: var(--primary-light); color: var(--primary); }
.stat-coins { background: var(--accent-light); color: var(--accent); }
.stat-streak { background: var(--danger-light); color: var(--danger); }

.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; background: var(--primary-light);
  border-radius: var(--radius-full); font-size: 0.85rem;
  font-weight: 700; color: var(--primary);
  cursor: pointer; border: none; transition: var(--transition);
  font-family: var(--font-display);
}
.user-pill:hover { background: var(--primary); color: #fff; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800; color: #fff;
  font-family: var(--font-display);
}

/* ── DESKTOP NAV ───────────────────────────────────────────── */
.desktop-nav { display: flex; gap: 4px; }
.desktop-nav a {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-size: 0.9rem; font-weight: 700;
  color: var(--text-secondary); text-decoration: none;
  transition: var(--transition); display: flex; align-items: center; gap: 6px;
}
.desktop-nav a.active { background: var(--primary-light); color: var(--primary); }
.desktop-nav a:hover { color: var(--primary); background: var(--primary-light); }

/* ── BOTTOM NAV ────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 6px 0; padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 100; box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 8px; border: none; background: none;
  font-family: var(--font-display); font-size: 0.65rem; font-weight: 700;
  color: var(--text-secondary); cursor: pointer; transition: var(--transition);
  text-decoration: none; position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-item.active::before {
  content: ''; position: absolute; top: -6px; left: 50%;
  transform: translateX(-50%); width: 20px; height: 3px;
  background: var(--primary); border-radius: 0 0 3px 3px;
}
.nav-item .nav-icon { font-size: 1.3rem; }
.nav-item svg { width: 22px; height: 22px; }

/* ── PAGE LAYOUT ───────────────────────────────────────────── */
.page {
  padding: 16px 16px 100px; max-width: 1200px; margin: 0 auto;
  position: relative; z-index: 1;
}

/* ── STATS GRID ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-card { padding: 16px; text-align: center; }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px; font-size: 1.4rem;
}
.stat-card .stat-value {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 900;
}
.stat-card .stat-label {
  font-size: 0.75rem; color: var(--text-secondary); font-weight: 600;
}

/* ── PROGRESS BAR ──────────────────────────────────────────── */
.progress-bar {
  height: 10px; background: var(--border); border-radius: var(--radius-full);
  overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 0.8s var(--bounce);
  position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── XP BAR ────────────────────────────────────────────────── */
.xp-bar-wrapper {
  background: var(--border); border-radius: var(--radius-full);
  height: 8px; position: relative; overflow: hidden;
}
.xp-bar-fill {
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 1s var(--bounce);
}

/* ── STREAK DISPLAY ────────────────────────────────────────── */
.streak-card {
  background: linear-gradient(135deg, #FF6B35, #FF4757);
  border-radius: var(--radius-lg); padding: 20px;
  color: #fff; position: relative; overflow: hidden;
}
.streak-card::before {
  content: '🔥'; position: absolute; top: -10px; right: -10px;
  font-size: 80px; opacity: 0.15; transform: rotate(15deg);
}
.streak-number {
  font-family: var(--font-display); font-size: 3rem; font-weight: 900;
  line-height: 1;
}
.streak-days {
  display: flex; gap: 6px; margin-top: 12px;
}
.streak-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.2); display: flex;
  align-items: center; justify-content: center; font-size: 0.75rem;
}
.streak-dot.active { background: #FFD700; color: #333; }
.streak-dot.today { background: #fff; color: var(--danger); animation: pulse-dot 2s infinite; }

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── DAILY CHALLENGE CARD ──────────────────────────────────── */
.daily-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg); padding: 20px;
  color: #fff; border: none; position: relative; overflow: hidden;
}
.daily-card::before {
  content: '⭐'; position: absolute; top: -5px; right: 10px;
  font-size: 60px; opacity: 0.15; animation: spin-slow 10s linear infinite;
}
@keyframes spin-slow { 100% { transform: rotate(360deg); } }
.daily-card.completed { background: linear-gradient(135deg, var(--success), #1DB954); }

/* ── LESSON / ITEM LIST ────────────────────────────────────── */
.item-list { border-radius: var(--radius); overflow: hidden; }
.item-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: var(--transition); text-decoration: none; color: var(--text);
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--primary-light); }
.item-row:active { transform: scale(0.99); }

.item-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800; flex-shrink: 0;
  font-family: var(--font-display);
}
.item-icon-primary { background: var(--primary-light); color: var(--primary); }
.item-icon-secondary { background: var(--secondary-light); color: var(--secondary); }
.item-icon-accent { background: var(--accent-light); color: var(--accent); }
.item-icon-success { background: var(--success-light); color: var(--success); }
.item-icon-info { background: var(--info-light); color: var(--info); }

.item-info { flex: 1; min-width: 0; }
.item-title { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.item-desc { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding: 4px; background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; padding: 10px 18px; border: none; background: none;
  font-family: var(--font-display); font-size: 0.85rem; font-weight: 700;
  color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-sm); transition: var(--transition);
}
.tab-btn.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.tab-btn:hover:not(.active) { color: var(--primary); background: var(--primary-light); }

/* ── FLASHCARD ─────────────────────────────────────────────── */
.flashcard-container {
  perspective: 1200px; width: 100%; max-width: 400px; margin: 0 auto;
}
.flashcard {
  width: 100%; aspect-ratio: 3/4; position: relative;
  transform-style: preserve-3d; transition: transform 0.6s var(--bounce);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--radius-lg); padding: 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); border: 3px solid var(--border);
}
.flashcard-front {
  background: linear-gradient(145deg, #FFFFFF 0%, #F8F9FF 100%);
}
.flashcard-back {
  background: linear-gradient(145deg, var(--primary-light) 0%, #DDD8FF 100%);
  transform: rotateY(180deg);
}
.flashcard-word {
  font-family: var(--font-display); font-size: 2rem; font-weight: 900;
  color: var(--primary); margin-bottom: 8px;
}
.flashcard-pronunciation {
  font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 16px;
}
.flashcard-meaning {
  font-family: var(--font-display); font-size: 1.8rem; font-weight: 800;
  color: var(--text); margin-bottom: 8px;
}
.flashcard-example {
  font-size: 0.85rem; color: var(--text-secondary); text-align: center;
  font-style: italic;
}
.flashcard-counter {
  font-family: var(--font-display); font-weight: 700;
  color: var(--text-secondary); font-size: 0.9rem;
}

.sr-buttons {
  display: flex; gap: 8px; margin-top: 20px; width: 100%; max-width: 400px;
  margin-left: auto; margin-right: auto;
}
.sr-btn {
  flex: 1; padding: 14px 8px; border-radius: var(--radius-sm); border: none;
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
  cursor: pointer; transition: var(--transition);
}
.sr-btn:active { transform: scale(0.95); }
.sr-btn-hard { background: var(--danger-light); color: var(--danger); }
.sr-btn-good { background: var(--accent-light); color: var(--accent); }
.sr-btn-easy { background: var(--success-light); color: var(--success); }
.sr-btn-hard:hover { background: var(--danger); color: #fff; }
.sr-btn-good:hover { background: var(--accent); color: #fff; }
.sr-btn-easy:hover { background: var(--success); color: #fff; }

/* Speaker button */
.speak-btn {
  background: var(--primary-light); border: 2px solid var(--primary);
  width: 48px; height: 48px; border-radius: 50%; font-size: 1.3rem;
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.speak-btn:hover { background: var(--primary); color: #fff; transform: scale(1.1); }
.speak-btn:active { transform: scale(0.95); }
.speak-btn.speaking { animation: pulse-speak 1s infinite; }

@keyframes pulse-speak {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

/* ── GAMES ─────────────────────────────────────────────────── */
/* Match Pairs */
.game-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; max-width: 500px; margin: 0 auto;
}
.game-card {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.85rem; text-align: center; padding: 8px;
  cursor: pointer; transition: var(--transition);
  border: 2px solid var(--border); background: var(--surface);
  word-break: break-word;
}
.game-card:hover { border-color: var(--primary); transform: scale(1.03); }
.game-card:active { transform: scale(0.97); }
.game-card.flipped {
  background: var(--primary-light); border-color: var(--primary);
  color: var(--primary);
}
.game-card.matched {
  background: var(--success-light); border-color: var(--success);
  color: var(--success); pointer-events: none;
}
.game-card.wrong {
  background: var(--danger-light); border-color: var(--danger);
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Sentence Builder */
.sentence-area {
  min-height: 60px; padding: 12px; border-radius: var(--radius-sm);
  border: 2px dashed var(--border); display: flex; flex-wrap: wrap;
  gap: 8px; align-items: center; margin-bottom: 16px;
  background: var(--surface-2);
}
.word-chip {
  padding: 8px 16px; border-radius: var(--radius-full);
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.9rem; cursor: pointer; transition: var(--transition);
  user-select: none; border: 2px solid var(--border);
  background: var(--surface);
}
.word-chip:hover { border-color: var(--primary); background: var(--primary-light); }
.word-chip:active { transform: scale(0.95); }
.word-chip.placed {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.word-chip.correct { background: var(--success); color: #fff; border-color: var(--success); }
.word-chip.wrong { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Fill in the Blank */
.fill-text {
  font-size: 1.1rem; line-height: 2.2; padding: 16px;
}
.fill-blank {
  display: inline-block; min-width: 80px; padding: 4px 12px;
  border-bottom: 3px solid var(--primary); color: var(--primary);
  font-weight: 700; font-family: var(--font-display);
  text-align: center; cursor: pointer; transition: var(--transition);
  margin: 0 4px;
}
.fill-blank.filled { background: var(--primary-light); border-radius: var(--radius-sm); }
.fill-blank.correct { border-color: var(--success); color: var(--success); background: var(--success-light); }
.fill-blank.wrong { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }

.fill-options {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 16px;
}

/* ── GAME HUB ──────────────────────────────────────────────── */
.game-hub-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.game-hub-card {
  border-radius: var(--radius-lg); padding: 24px 16px;
  text-align: center; cursor: pointer; transition: var(--transition);
  border: 2px solid var(--border); text-decoration: none; color: var(--text);
}
.game-hub-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.game-hub-card .game-emoji { font-size: clamp(2rem, 8vw, 3rem); margin-bottom: 12px; display: block; }
.game-hub-card .game-name { font-family: var(--font-display); font-weight: 800; font-size: 1rem; }
.game-hub-card .game-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* ── READING ───────────────────────────────────────────────── */
.reading-content {
  font-size: 1.1rem; line-height: 2; padding: 24px;
}
.reading-content p { margin-bottom: 16px; }
.reading-word {
  cursor: pointer; transition: var(--transition);
  border-radius: 4px; padding: 1px 2px;
}
.reading-word:hover { background: var(--accent-light); color: var(--accent); }

/* ── LEADERBOARD ───────────────────────────────────────────── */
.leaderboard-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); transition: var(--transition);
}
.leaderboard-item:last-child { border-bottom: none; }
.leaderboard-rank {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 0.9rem;
  flex-shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #fff; box-shadow: 0 2px 8px rgba(255,215,0,0.4); }
.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #A0652E); color: #fff; }
.rank-other { background: var(--surface-2); color: var(--text-secondary); }
.leaderboard-me { background: var(--primary-light); border-radius: var(--radius-sm); }

/* ── ACHIEVEMENT GRID ──────────────────────────────────────── */
.achievement-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
}
.achievement-card {
  padding: 20px 12px; border-radius: var(--radius); text-align: center;
  border: 2px solid var(--border); transition: var(--transition);
  position: relative;
}
.achievement-card.earned {
  border-color: transparent;
  box-shadow: var(--shadow);
}
.achievement-card.locked { opacity: 0.5; filter: grayscale(0.8); }
.achievement-icon { font-size: 2.5rem; margin-bottom: 8px; display: block; }
.achievement-name { font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; }
.achievement-desc { font-size: 0.7rem; color: var(--text-secondary); margin-top: 4px; }
.achievement-stamp {
  position: absolute; top: 8px; right: 8px;
  font-size: 0.9rem;
}

/* ── EXAM INTERFACE ────────────────────────────────────────── */
.exam-header {
  background: rgba(255,255,255,0.95); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px; position: sticky; top: 0; z-index: 50;
}
.exam-timer {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 900;
  color: var(--danger);
}
.exam-progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; }
.exam-progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }

.question-card { margin-bottom: 16px; }
.question-num {
  font-family: var(--font-display); font-weight: 800; font-size: 0.85rem;
  color: var(--primary); margin-bottom: 8px;
}
.question-text {
  font-size: 1.05rem; font-weight: 600; margin-bottom: 16px; line-height: 1.8;
}
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice-btn {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: var(--transition);
  font-size: 0.95rem; text-align: left; font-family: var(--font-body);
}
.choice-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.choice-btn:active { transform: scale(0.98); }
.choice-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.choice-btn.correct { border-color: var(--success); background: var(--success-light); }
.choice-btn.wrong { border-color: var(--danger); background: var(--danger-light); }

.choice-letter {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 0.85rem;
  flex-shrink: 0; transition: var(--transition);
}
.choice-btn.selected .choice-letter { background: var(--primary); color: #fff; border-color: var(--primary); }
.choice-btn.correct .choice-letter { background: var(--success); color: #fff; border-color: var(--success); }
.choice-btn.wrong .choice-letter { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Answer Sheet */
.answer-sheet {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px; padding: 12px;
}
.answer-dot {
  width: 100%; aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 0.75rem; font-weight: 800;
  cursor: pointer; transition: var(--transition); background: var(--surface);
}
.answer-dot.answered { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.answer-dot.current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Score Result */
.score-circle {
  width: 150px; height: 150px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto 20px; position: relative;
  border: 8px solid var(--border);
}
.score-value { font-family: var(--font-display); font-size: 2.8rem; font-weight: 900; line-height: 1; }
.score-label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; }

/* ── ADMIN TABLE ───────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th {
  text-align: left; padding: 12px 14px; background: var(--surface-2);
  font-family: var(--font-display); font-weight: 700; font-size: 0.8rem;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.admin-table tr:hover td { background: var(--primary-light); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 500px; max-height: 85vh;
  overflow-y: auto; padding: 24px; animation: slideUp 0.3s var(--bounce);
}
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } }

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-content { border-radius: var(--radius-lg); max-height: 80vh; }
  .modal-handle { display: none; }
}

/* ── LOGIN PAGE ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.1) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255,255,255,0.08) 0%, transparent 50%);
}
.login-card {
  width: 100%; max-width: 420px; padding: 36px 28px;
  position: relative; z-index: 1;
  border: none; box-shadow: var(--shadow-xl);
}
.login-card h1 { color: var(--primary); margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 24px; }

.role-toggle {
  display: flex; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 4px; margin-bottom: 20px;
}
.role-btn {
  flex: 1; padding: 12px; border: none; background: none;
  border-radius: 8px; font-family: var(--font-display); font-weight: 700;
  cursor: pointer; transition: var(--transition); font-size: 0.9rem;
}
.role-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 2px 8px var(--primary-glow);
}

/* ── VOCAB GRID ────────────────────────────────────────────── */
.vocab-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin: 12px 0;
}
.vocab-card {
  padding: 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); text-align: center;
  cursor: pointer; transition: var(--transition);
}
.vocab-card:hover { border-color: var(--primary); background: var(--primary-light); }
.vocab-card:active { transform: scale(0.97); }
.vocab-en { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--primary); }
.vocab-th { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* ── DIALOGUE BOX ──────────────────────────────────────────── */
.dialogue-box {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 16px; border-left: 4px solid var(--primary);
  margin: 12px 0;
}
.dialogue-box p { margin-bottom: 8px; }
.dialogue-box p:last-child { margin-bottom: 0; }

/* ── LESSON CONTENT ────────────────────────────────────────── */
.lesson-content {
  line-height: 2; font-size: 1.05rem;
}
.lesson-content h3 { color: var(--primary); margin: 24px 0 12px; }
.lesson-content ul { padding-left: 24px; }
.lesson-content li { margin-bottom: 8px; }

/* ── NOTIFICATION TOAST ────────────────────────────────────── */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  padding: 16px 24px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg);
  font-family: var(--font-display); font-weight: 700;
  animation: slideInRight 0.4s var(--bounce), fadeOut 0.3s 2.7s forwards;
  display: flex; align-items: center; gap: 10px; max-width: 350px;
  border-left: 4px solid var(--primary);
}
.toast-badge { border-left-color: var(--accent); }

@keyframes slideInRight { from { transform: translateX(120%); } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100px); } }

/* ── CONFETTI ──────────────────────────────────────────────── */
.confetti-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 250; overflow: hidden;
}
.confetti-piece {
  position: absolute; width: 10px; height: 10px;
  top: -20px; animation: confetti-fall 3s linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── PROFILE ───────────────────────────────────────────────── */
.profile-header {
  text-align: center; padding: 30px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg); color: #fff; margin-bottom: 24px;
  position: relative; overflow: hidden;
}
.profile-header::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1), transparent 50%);
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 900; margin: 0 auto 12px;
  border: 4px solid rgba(255,255,255,0.3); position: relative;
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .page { padding: 24px 24px 40px; }
  .game-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
}
@media (min-width: 1025px) {
  .bottom-nav { display: none; }
  .desktop-nav { display: flex !important; }
  .header-stats { display: flex !important; }
}
@media (max-width: 1024px) {
  .desktop-nav { display: none !important; }
}
@media (max-width: 767px) {
  .header { display: none !important; }
  .page { padding-top: 0 !important; }
  .header-stats { display: none !important; }
  .game-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 400px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .game-card { font-size: 0.7rem; }
}

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-state .empty-emoji { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state .empty-title { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: var(--text); margin-bottom: 4px; }

/* ── ANIMATION UTILITIES ───────────────────────────────────── */
.animate-bounce { animation: bounce 2s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.animate-pulse { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.animate-fade-in { animation: fadeInUp 0.5s var(--bounce); }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-scale-in { animation: scaleIn 0.4s var(--bounce); }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ── SECTION TITLE ─────────────────────────────────────────── */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title h2 { display: flex; align-items: center; gap: 8px; }
.section-link {
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
  color: var(--primary); text-decoration: none;
}
.section-link:hover { text-decoration: underline; }

/* ── GAME TIMER / SCORE DISPLAY ────────────────────────────── */
.game-status {
  display: flex; justify-content: space-around; padding: 16px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.game-status-item { text-align: center; }
.game-status-value {
  font-family: var(--font-display); font-weight: 900;
  font-size: 1.5rem; color: var(--primary);
}
.game-status-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; }

/* ── INSTALL PAGE ──────────────────────────────────────────── */
.install-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg-gradient);
}
.install-card { width: 100%; max-width: 600px; }
.install-step { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.install-step:last-child { border-bottom: none; }
.install-step-icon { font-size: 1.3rem; flex-shrink: 0; }
.step-success { color: var(--success); }
.step-error { color: var(--danger); }
.step-pending { color: var(--text-secondary); }/* ── BOTTOM NAVIGATION (MOBILE) ───────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
  padding: 12px 16px;
  padding-bottom: env(safe-area-inset-bottom, 12px);
  z-index: 1000;
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 700;
  gap: 6px;
  transition: var(--transition);
}

.nav-item i {
  font-size: 1.4rem;
}

.nav-item.active {
  color: var(--primary);
}

@media (max-width: 1024px) {
  .bottom-nav { display: flex; flex-direction: row; justify-content: space-around; align-items: center; }
  body { padding-bottom: 80px; } /* Space for bottom nav */
  .sidebar { display: none; } /* Hide desktop sidebar if it exists */
}
