/* ===== English Study - Cartoon Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #4F9CF7;
  --primary-light: #E3F2FD;
  --secondary: #FF6B9D;
  --accent-yellow: #FFD93D;
  --accent-green: #6BCB77;
  --accent-purple: #9B59B6;
  --accent-orange: #FF8C42;
  --bg: #F8FBFF;
  --card-bg: #FFFFFF;
  --text: #2D3748;
  --text-light: #718096;
  --text-lighter: #A0AEC0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(79, 156, 247, 0.08);
  --shadow-hover: 0 8px 30px rgba(79, 156, 247, 0.15);
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ===== Layout ===== */
.app-container {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #4F9CF7 0%, #667eea 100%);
  padding: 20px 20px 24px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  border-radius: 0 0 24px 24px;
}
.header-top { display: flex; align-items: center; justify-content: space-between; }
.header-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.5px; }
.header-subtitle { font-size: 0.8rem; opacity: 0.85; margin-top: 2px; }
.header-back {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s;
}
.header-back:hover { background: rgba(255,255,255,0.35); }
.header-logo {
  display: flex; align-items: center; gap: 10px;
}
.header-logo-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.streak-badge {
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}

.app-container { padding-bottom: 20px; }

/* ===== Header Home Button ===== */
.header-home-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s;
  flex-shrink: 0;
}
.header-home-btn:hover { background: rgba(255,255,255,0.35); }

/* ===== Header Avatar Button ===== */
.header-avatar-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.header-avatar-btn:hover { background: rgba(255,255,255,0.35); }

/* ===== Page Content ===== */
.page-content { padding: 20px; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

/* ===== Daily Sentence Card ===== */
.daily-sentence {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.daily-sentence::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  background: rgba(255, 152, 0, 0.1);
  border-radius: 50%;
}
.daily-sentence-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-orange);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.daily-sentence-en {
  font-size: 1.15rem;
  font-weight: 700;
  color: #E65100;
  margin-bottom: 6px;
}
.daily-sentence-cn {
  font-size: 0.85rem;
  color: #BF360C;
  opacity: 0.8;
}

/* ===== Scenario Cards ===== */
.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 14px;
  color: var(--text);
}
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
.scenario-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
  transition: all 0.25s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}
.scenario-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
  border-color: var(--primary);
}
.scenario-card:active { transform: translateY(-1px) scale(0.98); }
.scenario-emoji {
  font-size: 2.2rem;
  margin-bottom: 10px;
  display: block;
}
.scenario-title { font-size: 1rem; font-weight: 800; margin-bottom: 3px; }
.scenario-subtitle { font-size: 0.75rem; color: var(--text-light); font-weight: 600; }
.scenario-age {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
}
.scenario-card[data-color="blue"] { border-left: 4px solid var(--primary); }
.scenario-card[data-color="yellow"] { border-left: 4px solid var(--accent-yellow); }
.scenario-card[data-color="green"] { border-left: 4px solid var(--accent-green); }
.scenario-card[data-color="purple"] { border-left: 4px solid var(--accent-purple); }

/* ===== Lesson List ===== */
.lesson-list { display: flex; flex-direction: column; gap: 12px; }

/* ===== Grade Grid ===== */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 768px) {
  .grade-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (min-width: 1024px) {
  .grade-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
}
.lesson-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
}
.lesson-card:hover { box-shadow: var(--shadow-hover); border-color: var(--primary); }
.lesson-emoji {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.lesson-info { flex: 1; }
.lesson-title { font-size: 0.95rem; font-weight: 700; }
.lesson-title-en { font-size: 0.8rem; color: var(--text-light); font-weight: 500; }
.lesson-arrow { color: var(--text-lighter); font-size: 1.2rem; }

/* ===== Learn Page (Tabs) ===== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: white;
  padding: 6px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.tab-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(79, 156, 247, 0.35);
}
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

/* ===== Flashcard ===== */
.flashcard-container { perspective: 1000px; margin-bottom: 20px; }
.flashcard {
  width: 100%;
  min-height: 220px;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  background: var(--card-bg);
  box-shadow: var(--shadow-hover);
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.flashcard-front { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.flashcard-back { background: white; transform: rotateY(180deg); }
.flashcard-word { font-size: 2rem; font-weight: 800; margin-bottom: 8px; }
.flashcard-phonetic { font-size: 0.9rem; opacity: 0.85; }
.flashcard-meaning { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.flashcard-example { font-size: 0.85rem; color: var(--text-light); font-style: italic; line-height: 1.5; }
.flashcard-hint { font-size: 0.75rem; opacity: 0.7; margin-top: 16px; }

.flashcard-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}
.flashcard-nav-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: white;
  color: var(--primary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  font-family: var(--font);
}
.flashcard-nav-btn:hover { background: var(--primary); color: white; }
.flashcard-counter { font-size: 0.9rem; font-weight: 700; color: var(--text-light); }

/* ===== Dialogue ===== */
.dialogue-header {
  background: linear-gradient(135deg, #4F9CF7 0%, #667eea 100%);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: white;
  margin-bottom: 16px;
}
.dialogue-title { font-size: 1.1rem; font-weight: 800; }
.dialogue-title-en { font-size: 0.85rem; opacity: 0.85; }

.dialogue-bubble {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.dialogue-bubble.right { flex-direction: row-reverse; }
.dialogue-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.dialogue-content { max-width: 75%; }
.dialogue-name { font-size: 0.72rem; font-weight: 700; color: var(--text-light); margin-bottom: 4px; }
.dialogue-text {
  background: white;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  color: var(--text);
}
.dialogue-text-cn {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 4px;
  padding: 0 4px;
}
.dialogue-bubble.right .dialogue-text {
  background: var(--primary-light);
}
.dialogue-bubble.right .dialogue-name { text-align: right; }

/* ===== Quiz ===== */
.quiz-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.quiz-dot {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #E2E8F0;
  transition: background 0.3s;
}
.quiz-dot.done { background: var(--accent-green); }
.quiz-dot.current { background: var(--primary); }
.quiz-dot.wrong { background: #FC8181; }

.quiz-question-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.quiz-q-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.quiz-question {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.quiz-option {
  background: white;
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}
.quiz-option:hover:not(.disabled) { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.correct { border-color: var(--accent-green); background: #F0FFF4; }
.quiz-option.wrong { border-color: #FC8181; background: #FFF5F5; }
.quiz-option.disabled { cursor: default; opacity: 0.7; }
.quiz-option-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #F7FAFC;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, #4F9CF7 0%, #667eea 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(79, 156, 247, 0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79, 156, 247, 0.5); }
.btn-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-block { width: 100%; }

/* ===== Result Screen ===== */
.result-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-hover);
}
.result-emoji { font-size: 4rem; margin-bottom: 16px; }
.result-score { font-size: 3rem; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.result-label { font-size: 1rem; color: var(--text-light); font-weight: 600; margin-bottom: 24px; }
.result-stars { font-size: 2rem; margin-bottom: 20px; letter-spacing: 4px; }
.result-buttons { display: flex; flex-direction: column; gap: 10px; }

/* ===== Progress Bar ===== */
.progress-bar {
  height: 8px;
  background: #E2E8F0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-green));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ===== Scenario Header ===== */
.scenario-hero {
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 20px;
  color: white;
  position: relative;
  overflow: hidden;
}
.scenario-hero::after {
  content: '';
  position: absolute;
  bottom: -30px; right: -30px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}
.scenario-hero-emoji { font-size: 2.5rem; margin-bottom: 10px; }
.scenario-hero-title { font-size: 1.4rem; font-weight: 800; }
.scenario-hero-subtitle { font-size: 0.85rem; opacity: 0.9; }
.scenario-hero-desc { font-size: 0.8rem; opacity: 0.85; margin-top: 8px; line-height: 1.5; }

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bounceIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade { animation: fadeIn 0.3s ease; }
.animate-bounce { animation: bounceIn 0.4s ease; }
.animate-slide { animation: slideUp 0.4s ease; }

/* ===== Responsive Design - Multi-Device ===== */

/* -- Small phones (iPhone SE, ≤374px) -- */
@media (max-width: 374px) {
  html { font-size: 14px; }
  .header { padding: 14px 14px 18px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); border-radius: 0 0 18px 18px; }
  .header-title { font-size: 1.1rem; }
  .header-logo-icon { width: 34px; height: 34px; font-size: 1.2rem; }
  .streak-badge { padding: 4px 10px; font-size: 0.78rem; }
  .page-content { padding: 14px; }
  .daily-sentence { padding: 14px; margin-bottom: 18px; }
  .daily-sentence-en { font-size: 1rem; }
  .scenario-grid { gap: 10px; }
  .scenario-card { padding: 14px 12px; }
  .scenario-emoji { font-size: 1.8rem; margin-bottom: 6px; }
  .scenario-title { font-size: 0.9rem; }
  .scenario-subtitle { font-size: 0.7rem; }
  .lesson-card { padding: 12px; gap: 10px; }
  .lesson-emoji { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; }
  .lesson-title { font-size: 0.88rem; }
  .lesson-title-en { font-size: 0.72rem; }
  .flashcard { min-height: 180px; }
  .flashcard-word { font-size: 1.6rem; }
  .flashcard-meaning { font-size: 1.2rem; }
  .flashcard-face { padding: 24px 18px; }
  .quiz-question-card { padding: 18px 14px; }
  .quiz-option { padding: 12px; font-size: 0.85rem; }
  .dialogue-content { max-width: 80%; }
  .modal { padding: 22px 18px; max-width: 320px; }
  .scenario-hero { padding: 18px 14px; }
  .scenario-hero-title { font-size: 1.2rem; }
  .result-card { padding: 24px 18px; }
  .btn { padding: 12px 20px; font-size: 0.88rem; }
  .profile-avatar { width: 64px; height: 64px; font-size: 2rem; }
}

/* -- Standard phones (375px - 428px, most iPhones & Android) -- */
@media (min-width: 375px) and (max-width: 428px) {
  .page-content { padding: 18px; }
  .scenario-card { padding: 16px 14px; }
}

/* -- Large phones (429px - 560px, iPhone Pro Max, large Android) -- */
@media (min-width: 429px) and (max-width: 560px) {
  .page-content { padding: 22px; }
  .scenario-grid { gap: 16px; }
}

/* -- Tablets portrait (iPad, 768px - 1023px) -- */
@media (min-width: 768px) {
  .app-container { max-width: 720px; }
  .page-content { padding: 28px; }
  .header { padding: 24px 28px 28px; border-radius: 0 0 28px 28px; }
  .header-title { font-size: 1.4rem; }
  .header-logo-icon { width: 46px; height: 46px; font-size: 1.5rem; }
  .scenario-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
  .scenario-card { padding: 22px 20px; }
  .scenario-emoji { font-size: 2.5rem; }
  .scenario-title { font-size: 1.1rem; }
  .lesson-card { padding: 18px; gap: 16px; }
  .lesson-emoji { width: 56px; height: 56px; font-size: 1.7rem; }
  .lesson-title { font-size: 1.05rem; }
  .lesson-title-en { font-size: 0.85rem; }
  .flashcard { min-height: 260px; }
  .flashcard-word { font-size: 2.4rem; }
  .flashcard-meaning { font-size: 1.6rem; }
  .flashcard-face { padding: 36px 30px; }
  .quiz-question-card { padding: 28px 24px; }
  .quiz-option { padding: 16px 20px; font-size: 1rem; }
  .dialogue-text { font-size: 0.95rem; }
  .section-title { font-size: 1.25rem; margin-bottom: 18px; }
  .daily-sentence { padding: 24px; }
  .daily-sentence-en { font-size: 1.3rem; }
  .scenario-hero { padding: 30px 26px; }
  .scenario-hero-title { font-size: 1.6rem; }
  .scenario-hero-desc { font-size: 0.9rem; }
  .modal { max-width: 440px; padding: 32px 28px; }
  .btn { padding: 16px 32px; font-size: 1rem; }
  .result-emoji { font-size: 4.5rem; }
  .result-score { font-size: 3.5rem; }
  .profile-avatar { width: 96px; height: 96px; font-size: 3rem; }
  .profile-name { font-size: 1.35rem; }
}

/* -- Tablets landscape & desktop (≥1024px) -- */
@media (min-width: 1024px) {
  .app-container { max-width: 800px; }
  .page-content { padding: 32px; }
  .header { padding: 28px 32px 32px; border-radius: 0 0 32px 32px; }
  .header-title { font-size: 1.5rem; }
  .scenario-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
  .scenario-card { padding: 24px; text-align: center; }
  .scenario-card:hover { transform: translateY(-5px); }
  .flashcard { min-height: 280px; }
  .scenario-hero-emoji { font-size: 3rem; }
  .scenario-hero-title { font-size: 1.8rem; }
}

/* -- Very large screens (≥1280px) -- */
@media (min-width: 1280px) {
  .app-container { max-width: 880px; }
}

/* -- Landscape orientation on phones -- */
@media (max-height: 500px) and (orientation: landscape) {
  .header { padding: 10px 20px 12px; border-radius: 0 0 16px 16px; }
  .header-logo-icon { width: 32px; height: 32px; font-size: 1.1rem; }
  .header-title { font-size: 1rem; }
  .header-subtitle { display: none; }
  .flashcard { min-height: 160px; }
  .flashcard-face { padding: 18px 16px; }
  .flashcard-word { font-size: 1.6rem; }
  .scenario-hero { padding: 16px; }
  .app-container { padding-bottom: 10px; }
}

/* -- High-DPI / Retina optimization -- */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .scenario-card, .lesson-card, .quiz-option {
    border-width: 1.5px;
  }
}

/* -- Reduced motion for accessibility -- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* -- Dark mode hint (future enhancement) -- */
@media (prefers-color-scheme: dark) {
  /* Reserved for future dark mode support */
}

/* -- Print optimization -- */
@media print {
  .header { display: none; }
  .app-container { max-width: 100%; padding: 0; }
  .page { display: block !important; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 2px; }
/* Hide scrollbar on mobile for cleaner look */
@media (max-width: 767px) {
  body::-webkit-scrollbar { display: none; }
  body { -ms-overflow-style: none; scrollbar-width: none; }
}

/* ===== Pronunciation Button ===== */
.pron-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
  margin-top: 12px;
}
.pron-btn:hover { background: rgba(255,255,255,0.4); transform: scale(1.05); }
.pron-btn-dark {
  background: var(--primary-light);
  color: var(--primary);
}
.pron-btn-dark:hover { background: #BBDEFB; }
.pron-btn-sm {
  padding: 4px 10px;
  font-size: 0.72rem;
  border-radius: 12px;
  margin-top: 4px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  animation: fadeIn 0.2s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal {
  background: white;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  -webkit-overflow-scrolling: touch;
}
.modal-title { font-size: 1.3rem; font-weight: 800; text-align: center; margin-bottom: 6px; }
.modal-subtitle { font-size: 0.85rem; color: var(--text-light); text-align: center; margin-bottom: 20px; }
.modal-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}
.modal-input:focus { border-color: var(--primary); }
.modal-label { font-size: 0.8rem; font-weight: 700; color: var(--text-light); margin-bottom: 6px; display: block; }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border: none;
  border-radius: 50%;
  background: #F7FAFC;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Avatar Picker ===== */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.avatar-option {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  background: #F7FAFC;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}
.avatar-option:hover { transform: scale(1.1); }
.avatar-option.selected { border-color: var(--primary); background: var(--primary-light); }

/* ===== Leaderboard ===== */
.leaderboard-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.leaderboard-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.leaderboard-header-icon { font-size: 1.5rem; }
.leaderboard-header-title { font-size: 1rem; font-weight: 800; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #F0F0F0;
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
  background: #F7FAFC;
  color: var(--text-light);
}
.leaderboard-rank.gold { background: linear-gradient(135deg, #FFD93D, #FFA726); color: white; }
.leaderboard-rank.silver { background: linear-gradient(135deg, #E2E8F0, #CBD5E0); color: white; }
.leaderboard-rank.bronze { background: linear-gradient(135deg, #CD7F32, #A0522D); color: white; }
.leaderboard-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  background: var(--primary-light);
  flex-shrink: 0;
}
.leaderboard-name { flex: 1; font-size: 0.88rem; font-weight: 700; }
.leaderboard-score { font-size: 0.85rem; font-weight: 800; color: var(--primary); }

/* ===== Daily Sentence Enhanced ===== */
.daily-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.daily-tab {
  flex: 1; padding: 10px 8px;
  border: 2px solid #E2E8F0;
  border-radius: 10px;
  background: white;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.daily-tab.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ===== Quiz Attempts ===== */
.quiz-attempts {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 12px;
  font-size: 0.8rem; color: var(--text-light);
}
.quiz-attempt-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #E2E8F0;
  transition: background 0.2s;
}
.quiz-attempt-dot.used { background: #FC8181; }
.quiz-attempt-dot.success { background: var(--accent-green); }

/* ===== Touch Optimization ===== */
@media (pointer: coarse) {
  .quiz-option { min-height: 48px; }
  .header-home-btn { width: 40px; height: 40px; }
  .flashcard-nav-btn { width: 52px; height: 52px; }
  .btn { min-height: 48px; }
  .tab-btn { min-height: 44px; }
  .daily-tab { min-height: 44px; }
  .avatar-option { min-width: 44px; min-height: 44px; }
  .header-back { width: 40px; height: 40px; }
  .modal-close { width: 36px; height: 36px; }
}

/* ===== User Profile ===== */
.profile-card {
  background: linear-gradient(135deg, #4F9CF7 0%, #667eea 100%);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  color: white;
  margin-bottom: 20px;
}
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 12px;
  background: rgba(255,255,255,0.15);
}
.profile-name { font-size: 1.2rem; font-weight: 800; }
.profile-stats {
  display: flex; justify-content: space-around;
  margin-top: 16px;
}
.profile-stat { text-align: center; }
.profile-stat-num { font-size: 1.3rem; font-weight: 800; }
.profile-stat-label { font-size: 0.7rem; opacity: 0.85; }
