:root {
  --primary: #2563EB;
  --primary-dark: #1E40AF;
  --accent: #F59E0B;
  --accent-dark: #D97706;
  --green: #10B981;
  --red: #EF4444;
  --purple: #8B5CF6;
  --bg: #F0F9FF;
  --card: #FFFFFF;
  --text: #1E293B;
  --muted: #64748B;
  --border: #E2E8F0;
  --uyghur-font-size: 1.5rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Navigation ── */
nav {
  background: var(--primary);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 0.5rem;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}


.hamburger-btn {
  display: none;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.28); }

.nav-logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  padding: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-techcircle {
  display: flex;
  align-items: center;
  padding: 0.4rem;
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-left: auto;
}
.nav-techcircle:hover { background: rgba(255,255,255,0.12); }
.nav-techcircle-logo {
  height: 64px;
  width: 64px;
  object-fit: contain;
  border-radius: 8px;
}

.nav-logo .uyghur-logo {
  font-size: 1.6rem;
  direction: rtl;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  padding: 0.4rem 1rem 0.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.nav-links button {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.3);
  color: white;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.nav-links button:hover,
.nav-links button.active {
  background: rgba(255,255,255,0.25);
  border-color: white;
}

@media (max-width: 768px) {
  .nav-logo { padding: 0.5rem 0; font-size: 1.1rem; }
  .nav-techcircle-logo { height: 36px !important; width: 36px !important; }
  .hamburger-btn { display: flex; }
  .nav-links {
    display: none !important;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 1rem 0.75rem;
    gap: 0.3rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    flex-wrap: nowrap;
  }
  .nav-links.open { display: flex !important; }
  .nav-links button {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    border-radius: 10px;
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
  }
  .nav-links button:hover,
  .nav-links button.active-nav { background: rgba(255,255,255,0.25); }
  .nav-level-badge {
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    color: rgba(255,255,255,0.95);
  }
  .nav-xp { font-size: 0.8rem; padding: 0.2rem 1rem; color: rgba(255,255,255,0.7); }
}

/* ── Page container ── */
.page { display: none; }
.page.active { display: block; overflow-x: hidden; }

/* ── Section wrapper ── */
.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.section-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
  color: var(--primary);
}

.section-sub {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #1E40AF 0%, #2563EB 50%, #3B82F6 100%);
  color: white;
  text-align: center;
  padding: 4rem 1rem;
}

.hero-uyghur {
  font-size: 3.5rem;
  direction: rtl;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  line-height: 1.3;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.hero p {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.75rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
}

.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 2px solid white;
  color: white;
}

.btn-outline:hover { background: rgba(255,255,255,0.15); transform: translateY(-1px); }

/* ── Feature cards (home) ── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1rem;
}

.feature-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(37,99,235,0.15);
}

.feature-card .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.35rem; }
.feature-card p { font-size: 0.875rem; color: var(--muted); line-height: 1.5; }

/* ── Alphabet grid ── */
.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.letter-card {
  border-radius: 18px;
  padding: 0.75rem 0.6rem 0.8rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  border: none;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}

.letter-card:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 10px 28px rgba(0,0,0,0.25);
}

.letter-card:active {
  transform: scale(0.96);
}

.letter-card-emoji {
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.85;
}

.letter-card .letter-main {
  font-size: 3.4rem;
  direction: rtl;
  color: white;
  line-height: 1;
  text-shadow: 0 3px 10px rgba(0,0,0,0.3);
  font-weight: 700;
}

.letter-card .letter-name {
  font-weight: 800;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.98);
  letter-spacing: 0.04em;
}

.letter-card .letter-latin {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.72);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.letter-card-number {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
}

/* ── Letter detail modal ── */
.letter-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.letter-modal-box {
  background: white;
  border-radius: 28px;
  padding: 2rem 2rem 1.75rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  position: relative;
  animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.letter-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: #F1F5F9;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  transition: background 0.15s;
}
.letter-modal-close:hover { background: #E2E8F0; }

.letter-modal-color-bar {
  height: 6px;
  border-radius: 99px;
  margin: 0 auto 1.25rem;
  width: 60px;
}

.letter-modal-emoji-big {
  font-size: 5rem;
  line-height: 1;
  margin-bottom: 0.5rem;
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.letter-modal-letter-big {
  font-size: 5rem;
  font-weight: 900;
  direction: rtl;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.letter-modal-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1E293B;
  direction: rtl;
}

.letter-modal-type-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 99px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.letter-modal-romanization {
  font-size: 1rem;
  color: #64748B;
  margin-bottom: .25rem;
  font-style: italic;
}

.letter-modal-ipa {
  font-size: .95rem;
  color: #475569;
  margin-bottom: 1rem;
  font-family: monospace;
  background: #F1F5F9;
  display: inline-block;
  padding: .15rem .6rem;
  border-radius: 6px;
  letter-spacing: .06em;
}

.letter-modal-example-box {
  background: #F8FAFC;
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
  border: 1.5px solid #E2E8F0;
}

.letter-modal-example-uyghur {
  font-size: 1.8rem;
  direction: rtl;
  font-weight: 700;
  color: #1E293B;
  margin-bottom: 0.2rem;
}

.letter-modal-example-latin {
  font-size: 1rem;
  color: #475569;
  font-style: italic;
}

.letter-modal-example-en {
  font-size: 0.9rem;
  color: #64748B;
  margin-top: 0.1rem;
}

.letter-modal-nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.25rem;
}

.letter-modal-listen-btn {
  border: none;
  border-radius: 99px;
  padding: 0.6rem 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  margin-bottom: 0.75rem;
}
.letter-modal-listen-btn:hover { opacity: 0.88; }
.letter-modal-listen-btn:active { transform: scale(0.96); }

.letter-modal-arrow {
  background: #F1F5F9;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  transition: background 0.15s;
}
.letter-modal-arrow:hover { background: #E2E8F0; }

/* ── Vocab tabs ── */
.tab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.tab-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 30px;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
}

.tab-btn.active, .tab-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Excel-style vocab grid ── */
.vocab-table-wrap {
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
  max-width: 100%;
}

.vocab-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  background: white;
}

.vocab-table thead {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.vocab-table thead th {
  padding: 0.9rem 1rem;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.vocab-table thead th.rtl-col { text-align: right; }

.vocab-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: pointer;
}

.vocab-table tbody tr:last-child { border-bottom: none; }
.vocab-table tbody tr:hover { background: #EFF6FF; }
.vocab-table tbody tr.mastered { background: #ECFDF5; }

.vocab-table td {
  padding: 0.8rem 1rem;
  font-size: 1rem;
}

.vocab-table td.uyghur-cell {
  font-size: var(--uyghur-font-size);
  direction: rtl;
  text-align: right;
  color: var(--primary-dark);
  font-weight: 600;
}

.vocab-table td.latin-cell {
  font-style: italic;
  color: var(--primary);
}

.vocab-table td.english-cell { font-weight: 600; }

.vocab-table td.tip-cell {
  color: var(--muted);
  font-size: 0.875rem;
}

.row-num {
  color: var(--muted);
  font-size: 0.85rem;
  width: 40px;
  text-align: center;
}

.star-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: transform 0.2s;
}

.star-btn:hover { transform: scale(1.3); }

/* ── Game cards ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.game-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  border: 2px solid var(--border);
  text-align: center;
}

.game-card .icon { font-size: 3rem; margin-bottom: 0.75rem; }
.game-card h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-card p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; line-height: 1.5; }

/* ── Flashcard ── */
#flashcard-area {
  display: none;
  max-width: 500px;
  margin: 0 auto;
}

.flashcard {
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 3rem 2rem;
  text-align: center;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
  border: 2px solid var(--border);
}

.flashcard:hover { transform: scale(1.01); }

.flashcard-uyghur {
  font-size: 3.5rem;
  direction: rtl;
  color: var(--primary);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.flashcard-latin {
  font-size: 1.2rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.5rem;
}

.flashcard-answer {
  font-size: 2rem;
  font-weight: 800;
  color: var(--green);
  margin-top: 0.5rem;
}

.flashcard-tip {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.card-hint { font-size: 0.85rem; color: var(--muted); margin-top: 1rem; }

.flashcard-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.fc-counter {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── Quiz game ── */
#quiz-area {
  display: none;
  max-width: 600px;
  margin: 0 auto;
}

.quiz-question {
  background: white;
  border-radius: 16px;
  padding: 2.5rem 2rem 2rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  text-align: center;
  margin-bottom: 1.25rem;
}

.quiz-word {
  font-size: 3rem;
  direction: rtl;
  color: var(--primary);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.quiz-latin {
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.quiz-opt {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-opt:hover { border-color: var(--primary); background: #EFF6FF; }
.quiz-opt.correct { background: #ECFDF5; border-color: var(--green); color: var(--green); }
.quiz-opt.wrong { background: #FEF2F2; border-color: var(--red); color: var(--red); }

.quiz-score {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* ── Matching game ── */
#match-area {
  display: none;
  max-width: 800px;
  margin: 0 auto;
}

.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.match-column {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.match-column h4 {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.match-tile {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}

.match-tile.uyghur-tile {
  font-size: 1.5rem;
  direction: rtl;
  color: var(--primary-dark);
}

.match-tile:hover { border-color: var(--primary); background: #EFF6FF; }
.match-tile.selected { background: #DBEAFE; border-color: var(--primary); }
.match-tile.matched { background: #ECFDF5; border-color: var(--green); color: var(--green); pointer-events: none; }
.match-tile.wrong { background: #FEF2F2; border-color: var(--red); }

.match-score {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* ── Progress bar ── */
.progress-bar {
  background: var(--border);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  background: linear-gradient(90deg, var(--primary), var(--green));
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── About / phrases ── */
.phrases-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.phrase-card {
  background: white;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-left: 4px solid var(--primary);
}

.phrase-uyghur {
  font-size: 1.5rem;
  direction: rtl;
  text-align: right;
  color: var(--primary-dark);
  font-weight: 700;
  line-height: 1.3;
}

.phrase-info { display: flex; flex-direction: column; gap: 0.1rem; }
.phrase-latin { font-style: italic; color: var(--primary); font-size: 0.9rem; }
.phrase-english { font-weight: 700; color: var(--text); font-size: 0.95rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-new { background: #DBEAFE; color: var(--primary); }
.badge-mastered { background: #ECFDF5; color: var(--green); }

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1E293B;
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  z-index: 9999;
  transition: transform 0.3s ease;
  white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Level badge (nav) ── */
.nav-level-badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  background: #10B981;
}
.nav-xp {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}

/* ── XP bar ── */
.xp-bar-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.xp-bar-track {
  flex: 1;
  background: var(--border);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  min-width: 120px;
}
.xp-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease, background 0.3s;
}
.xp-bar-label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Level cards ── */
.level-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.level-card {
  background: white;
  border-radius: 14px;
  padding: 1.25rem 1rem;
  text-align: center;
  border: 2px solid var(--border);
  transition: all 0.2s;
}
.level-card-current { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.level-card-locked { opacity: 0.45; }
.level-card-emoji { font-size: 2rem; margin-bottom: 0.4rem; }
.level-card-name { font-weight: 800; font-size: 1rem; margin-bottom: 0.2rem; }
.level-card-uyghur { font-size: 1rem; direction: rtl; color: var(--muted); margin-bottom: 0.4rem; }
.level-card-xp { font-size: 0.78rem; color: var(--muted); font-weight: 600; }

/* ── Level pip in vocab table ── */
.level-pip {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.85rem;
  line-height: 28px;
  text-align: center;
  cursor: default;
}

/* ── Game level select row ── */
.game-config-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  justify-content: center;
}
.game-config-row label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.game-config-row select {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  background: white;
}

/* ── Level-up overlay ── */
.levelup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}
.levelup-overlay.hidden { display: none; }
.levelup-box {
  background: white;
  border-radius: 24px;
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 360px;
  width: 90%;
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.levelup-emoji { font-size: 5rem; margin-bottom: 0.5rem; }
.levelup-title { font-size: 1.1rem; color: var(--muted); margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.08em; }
.levelup-name { font-size: 2.2rem; font-weight: 800; color: var(--primary); margin-bottom: 0.25rem; }
.levelup-uyghur { font-size: 1.5rem; direction: rtl; color: var(--muted); margin-bottom: 0.5rem; }
.levelup-desc { font-size: 0.95rem; color: var(--muted); }

@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
@keyframes popIn  { from { transform:scale(0.6); opacity:0 } to { transform:scale(1); opacity:1 } }

/* ── FC level pill ── */
.fc-level-pip {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* ── Footer ── */
footer {
  background: #1E293B;
  color: #94A3B8;
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 3rem;
}

footer strong { color: white; }
footer a { color: #60A5FA; text-decoration: none; }

/* ── Responsiveness ── */
@media (max-width: 600px) {
  .hero-uyghur { font-size: 2.5rem; }
  .hero h1 { font-size: 1.6rem; }
  .quiz-options { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr; }
  .phrase-uyghur { font-size: 1.25rem; }
  :root { --uyghur-font-size: 1.3rem; }

  /* Vocabulary table — mobile */
  .vocab-table { min-width: 340px; }
  .vocab-table td, .vocab-table th { padding: 0.55rem 0.5rem; font-size: 0.85rem; }
  .vocab-table td.uyghur-cell { font-size: 1.2rem; }
  .vocab-table .tip-cell, .vocab-table th:last-of-type { display: none; }
  .tab-bar { gap: 0.3rem; }
  .tab-btn { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
}

.hidden { display: none !important; }

/* ── Letter modal pronunciation ── */
.letter-modal-howto {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding: .4rem .9rem;
  background: #F8FAFC;
  border-radius: 99px;
  display: inline-block;
}

/* ── Pronunciation guide section ── */
.pronun-guide-bar {
  margin-bottom: 1rem;
}
.pronun-toggle-btn {
  border-color: var(--primary);
  color: var(--primary);
  font-size: .9rem;
}

.pronun-guide {
  background: white;
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.pronun-guide h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: .75rem;
}

.pronun-row {
  display: grid;
  grid-template-columns: 2.5rem 3rem 2.5rem 5rem 4.5rem 1fr;
  align-items: center;
  gap: .5rem;
  padding: .45rem .5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  font-size: .9rem;
}
.pronun-row:hover { background: #EFF6FF; }
.pronun-row:nth-child(even) { background: #F8FAFC; }
.pronun-row:nth-child(even):hover { background: #EFF6FF; }

.pronun-arabic   { font-size: 1.4rem; direction: rtl; color: var(--primary); font-weight: 700; }
.pronun-name-col  { font-size: 1.05rem; color: var(--primary); font-weight: 700; }
.pronun-latin-col { font-weight: 700; color: #475569; }
.pronun-ipa-col   { font-family: monospace; color: #7C3AED; font-size: .85rem; background: #F5F3FF; padding: .1rem .4rem; border-radius: 4px; }
.pronun-type-col  { min-width: 70px; }
.pronun-how-col   { color: #1E293B; font-style: italic; }

/* ── Level test button & info ── */
.level-up-info {
  background: #F8FAFC;
  border-radius: 12px;
  padding: .85rem 1rem;
  margin-top: .75rem;
  font-size: .85rem;
}
.level-up-info-row { color: #475569; margin-bottom: .5rem; font-weight: 600; }
.level-up-xp-list  { display: flex; flex-wrap: wrap; gap: .5rem .75rem; color: #64748B; }

.level-test-btn {
  font-size: 1.05rem;
  padding: .75rem 2rem;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(37,99,235,.25);
}
.level-test-hint {
  font-size: .82rem;
  color: #64748B;
  margin-top: .5rem;
  min-height: 1.2em;
}

/* ════════════════════════════════════════════
   VOCABULARY BUILDER
════════════════════════════════════════════ */

/* Category grid */
.study-cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.study-cat-card {
  background: white;
  border-radius: 16px;
  padding: 1.25rem 1.1rem 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.study-cat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.13);
}

.study-cat-top {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.study-cat-emoji { font-size: 1.6rem; }
.study-cat-name  { font-weight: 800; font-size: 1rem; color: var(--text); }
.study-cat-stats { font-size: .82rem; color: var(--muted); }

.study-cat-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.study-cat-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}

.study-cat-btn {
  border: none;
  border-radius: 99px;
  padding: .45rem .9rem;
  color: white;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  margin-top: .25rem;
  transition: opacity .15s;
  align-self: flex-start;
}
.study-cat-btn:hover { opacity: .85; }

/* Session header */
.study-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.study-cat-badge {
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 99px;
  color: white;
  font-size: .8rem;
  font-weight: 700;
}
.study-counter {
  font-weight: 700;
  color: var(--muted);
  font-size: .9rem;
}

/* Progress track */
.study-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.study-track-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .4s ease;
}

/* Flip card */
.study-card-wrap {
  perspective: 1000px;
  cursor: pointer;
  margin-bottom: 1.25rem;
  user-select: none;
}

.study-card-inner {
  position: relative;
  width: 100%;
  height: 300px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.4,0,.2,1);
  border-radius: 24px;
}
.study-card-inner.flipped {
  transform: rotateY(180deg);
}

.study-face {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 2rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.15);
}

.study-front {
  background: linear-gradient(135deg, #3B82F6, #6366F1);
}
.study-back {
  background: linear-gradient(135deg, #10B981, #059669);
  transform: rotateY(180deg);
}

.study-level-pill {
  padding: .2rem .65rem;
  border-radius: 99px;
  color: white;
  font-size: .75rem;
  font-weight: 700;
  opacity: .9;
}

.study-uyghur {
  font-size: 3.2rem;
  direction: rtl;
  color: white;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
  line-height: 1.2;
  text-align: center;
}
.study-tap-hint {
  font-size: .85rem;
  color: rgba(255,255,255,.75);
  margin-top: .25rem;
}

.study-english {
  font-size: 2rem;
  font-weight: 800;
  color: white;
  text-align: center;
}
.study-latin {
  font-size: 1.15rem;
  color: rgba(255,255,255,.88);
  font-style: italic;
}
.study-tip-text {
  font-size: .82rem;
  color: rgba(255,255,255,.72);
  text-align: center;
  max-width: 260px;
}

/* Action buttons */
.study-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.study-btn-learning, .study-btn-known {
  border: none;
  border-radius: 14px;
  padding: .9rem 1.6rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, opacity .12s;
  flex: 1;
  max-width: 220px;
}
.study-btn-learning:hover, .study-btn-known:hover { opacity: .88; }
.study-btn-learning:active, .study-btn-known:active { transform: scale(.96); }

.study-btn-learning {
  background: #FEF3C7;
  color: #92400E;
}
.study-btn-known {
  background: #D1FAE5;
  color: #065F46;
}

/* Prev / Next navigation */
.study-nav-row {
  display: flex;
  justify-content: center;
  gap: .75rem;
  margin: .5rem 0 .25rem;
}
.study-nav-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: .4rem 1.4rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
  min-width: 90px;
}
.study-nav-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}
.study-nav-btn:disabled {
  opacity: .3;
  cursor: default;
}

/* Speak button */
.study-speak-row {
  text-align: center;
  margin-top: .25rem;
}
.study-speak-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: .35rem 1rem;
  font-size: .9rem;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s;
}
.study-speak-btn:hover { background: var(--border); }

/* Mic / Pronunciation button */
.study-mic-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: .35rem 1.1rem;
  font-size: .9rem;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, border-color .2s, color .2s;
  margin-left: .5rem;
}
.study-mic-btn:hover:not(:disabled) { background: var(--border); }
.study-mic-btn:disabled { opacity: .6; cursor: default; }
.study-mic-btn.recording {
  background: #EF4444;
  border-color: #EF4444;
  color: #fff;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .75; transform: scale(.97); }
}

/* ASR feedback strip */
.study-asr-feedback {
  text-align: center;
  min-height: 1.9rem;
  margin: .3rem .5rem 0;
  font-size: .88rem;
  line-height: 1.45;
  padding: .2rem .75rem;
  border-radius: 10px;
  transition: opacity .25s;
}
.study-asr-feedback:empty { min-height: 0; }

/* Groq key setup form inside the feedback strip */
.asr-key-form { padding: .6rem .25rem; }
.asr-key-title { margin: 0 0 .5rem; font-size: .85rem; color: var(--text); }
.asr-key-row   { display: flex; gap: .4rem; justify-content: center; margin-bottom: .45rem; }
.asr-key-input {
  flex: 1; max-width: 280px;
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: .35rem .6rem; font-size: .85rem;
  background: white; color: var(--text);
  outline: none; font-family: monospace;
}
.asr-key-input:focus { border-color: #6366F1; }
.asr-key-save {
  background: #6366F1; color: white;
  border: none; border-radius: 8px;
  padding: .35rem .9rem; font-size: .85rem;
  cursor: pointer; font-weight: 600;
}
.asr-key-save:hover { background: #4F46E5; }
.asr-key-link { font-size: .78rem; color: #6366F1; text-decoration: none; }
.asr-key-link:hover { text-decoration: underline; }

/* Session complete */
.study-complete-box {
  background: white;
  border-radius: 24px;
  padding: 3rem 2rem 2.5rem;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
}
.study-done-emoji { font-size: 4rem; margin-bottom: .5rem; }
.study-done-title { font-size: 1.75rem; font-weight: 800; margin-bottom: 1.5rem; }

.study-done-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}
.study-done-stat { text-align: center; }
.stat-num { font-size: 2.5rem; font-weight: 900; }
.stat-lbl { font-size: .82rem; color: var(--muted); font-weight: 600; margin-top: .1rem; }

.study-done-btns {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .study-cats-grid { grid-template-columns: 1fr 1fr; }
  .study-card-inner { height: 260px; }
  .study-uyghur { font-size: 2.4rem; }
  .study-english { font-size: 1.6rem; }
  .study-btn-learning, .study-btn-known { padding: .75rem 1rem; font-size: .95rem; }
  .study-done-stats { gap: 1rem; }
}

/* ── Phrase Groups ── */
.phrase-group {
  background: white;
  border-radius: 16px;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  overflow: hidden;
}

.phrase-group-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  background: white;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.phrase-group-header:hover { background: #F8FAFC; }

.phrase-group-emoji { font-size: 1.5rem; }
.phrase-group-name  { font-size: 1.1rem; font-weight: 700; flex: 1; }
.phrase-group-count { font-size: .8rem; color: var(--muted); background: var(--bg); padding: .25rem .6rem; border-radius: 20px; font-weight: 600; }
.phrase-group-arrow { font-size: .8rem; color: var(--muted); transition: transform .2s; }

.phrase-group-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: .75rem;
  padding: 1rem;
}
.phrase-group-body.collapsed { display: none; }

/* phrase cards inside groups */
.phrase-group .phrase-card {
  margin: 0;
  box-shadow: none;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
}

/* ── Level number badge in nav ── */
.nav-level-badge {
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .02em;
}

/* ── Level cards grid (10 levels) ── */
.level-cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .6rem;
  margin-bottom: 1rem;
}
@media (max-width: 700px) {
  .level-cards-grid { grid-template-columns: repeat(3, 1fr); }
  .phrase-group-body { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .level-cards-grid { grid-template-columns: repeat(2, 1fr); }
}
.level-card-num {
  font-size: .65rem;
  font-weight: 900;
  letter-spacing: .06em;
  margin-bottom: .15rem;
}
