/* ============================================================
   Elsa's English - Frozen Ice Castle Theme v3
   Optimized for tablet touch interface with Chinese guidance
   ============================================================ */

/* ===== Import Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&display=swap');

/* ===== CSS Variables ===== */
:root {
  --primary: #2196F3;
  --primary-light: #BBDEFB;
  --primary-dark: #0D47A1;
  --secondary: #5C6BC0;
  --secondary-light: #C5CAE9;
  --accent: #FFD54F;
  --accent-light: #FFF9C4;
  --accent-dark: #F57F17;
  --bg-main: #E3F2FD;
  --bg-card: #FFFFFF;
  --bg-soft: #E3F2FD;
  --bg-soft-2: #E8EAF6;
  --text-main: #1A237E;
  --text-light: #5C6BC0;
  --text-white: #FFFFFF;
  --success: #66BB6A;
  --success-light: #C8E6C9;
  --success-dark: #2E7D32;
  --warning: #FFA726;
  --error: #EF5350;
  --error-light: #FFCDD2;
  --gold: #FFD700;
  --purple: #7B68EE;
  --teal: #00BCD4;
  --ice: #B3E5FC;
  --ice-dark: #4FC3F7;
  --shadow: 0 4px 20px rgba(33, 150, 243, 0.12);
  --shadow-lg: 0 8px 30px rgba(33, 150, 243, 0.22);
  --shadow-xl: 0 12px 40px rgba(33, 150, 243, 0.3);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 30px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Fredoka', 'Noto Sans SC', 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 25%, #E8EAF6 50%, #B3E5FC 75%, #E1F5FE 100%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== Floating Background Decorations ===== */
.bg-decoration {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  opacity: 0.06;
  font-size: 60px;
  animation: floatBg 15s ease-in-out infinite;
  color: var(--ice-dark);
}
.bg-decoration:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; }
.bg-decoration:nth-child(2) { top: 30%; right: 8%; animation-delay: 2s; font-size: 50px; }
.bg-decoration:nth-child(3) { top: 60%; left: 3%; animation-delay: 4s; font-size: 70px; }
.bg-decoration:nth-child(4) { top: 80%; right: 5%; animation-delay: 6s; font-size: 45px; }

@keyframes floatBg {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33% { transform: translateY(-20px) rotate(10deg); }
  66% { transform: translateY(15px) rotate(-10deg); }
}

/* ===== Sparkle decorations ===== */
.sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  animation: sparkle 3s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100% { opacity: 0.3; transform: scale(1) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
}

/* ===== App Container ===== */
#app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  z-index: 10;
}

/* ===== Top Navigation Bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--primary-light), var(--secondary-light), var(--primary-light)) 1;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.topbar-logo .crown {
  font-size: 30px;
  animation: crownBounce 2s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.4));
}
@keyframes crownBounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-5px) rotate(5deg); }
}

.topbar-logo .title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  text-shadow: 1px 1px 2px rgba(255, 215, 0, 0.3);
  letter-spacing: 0.5px;
}

.topbar-logo .title-zh {
  font-size: 12px;
  color: var(--text-light);
  display: block;
  margin-top: -2px;
}

.topbar-stats {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--bg-soft), var(--bg-soft-2));
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.08);
}

.stat-pill:hover { transform: scale(1.05); box-shadow: var(--shadow); }
.stat-pill .icon { font-size: 16px; }

/* ===== View System ===== */
.view {
  display: none;
  padding: 14px 18px 85px;
  animation: fadeIn 0.4s ease;
}
.view.active { display: block; }

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

/* ===== Chinese Guide Banner ===== */
.guide-banner {
  background: linear-gradient(135deg, #E3F2FD, #E8F5E9);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #37474F;
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(38, 166, 154, 0.1);
}

.guide-banner .guide-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.guide-banner .guide-text {
  flex: 1;
}

.guide-banner .guide-text strong {
  color: var(--teal);
  font-weight: 700;
}

/* ===== Home View ===== */
.welcome-banner {
  background: linear-gradient(135deg, #0D47A1 0%, #1976D2 30%, #42A5F5 60%, #81D4FA 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  color: white;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* 欢迎横幅 + 成长树融合布局 */
.welcome-with-tree {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  text-align: left;
}
.welcome-left {
  flex: 1;
  min-width: 0;
}
.welcome-left .princess-avatar {
  display: inline-block;
  font-size: 42px;
  margin-bottom: 4px;
  animation: floatAvatar 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.welcome-left h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}
.welcome-left .welcome-zh {
  font-size: 14px;
  opacity: 0.95;
  margin-bottom: 2px;
}
.welcome-left p {
  font-size: 13px;
  opacity: 0.88;
  margin-bottom: 2px;
}
.welcome-left .welcome-zh-hint {
  font-size: 12px;
  opacity: 0.82;
  margin-top: 4px;
  background: rgba(255,255,255,0.16);
  border-radius: 10px;
  padding: 3px 10px;
  display: inline-block;
}

/* 成长树区域（融合在横幅右侧） */
.welcome-tree {
  flex-shrink: 0;
  text-align: center;
  background: rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 12px 18px;
  backdrop-filter: blur(4px);
  min-width: 130px;
}
.welcome-tree .tree-visual {
  font-size: 48px;
  line-height: 1;
  margin: 2px 0 4px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.15));
}
.welcome-tree .tree-level {
  font-size: 13px;
  font-weight: 700;
  color: #E8F5E9;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.welcome-tree .tree-progress {
  margin: 6px auto 3px;
  width: 90%;
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}
.welcome-tree .tree-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #A5D6A7, #66BB6A, #4CAF50);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.welcome-tree .tree-exp {
  font-size: 11px;
  opacity: 0.85;
}

/* 手机竖屏时上下排列 */
@media (max-width: 520px) {
  .welcome-with-tree {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
  }
  .welcome-left { text-align: center; }
  .welcome-left .welcome-zh-hint { display: inline-block; }
  .welcome-tree {
    width: 100%;
    max-width: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
  }
  .welcome-tree .tree-visual { font-size: 40px; }
}

@keyframes floatAvatar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.daily-tasks {
  margin-bottom: 22px;
}

.course-banner {
  background: linear-gradient(135deg, #E3F2FD, #F3E5F5);
  border: 1px solid #CE93D8;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 15px;
  color: #4A148C;
  line-height: 1.5;
}
.course-banner b { color: #AD1457; }
.course-hint { font-size: 12px; color: #6A1B9A; opacity: 0.8; margin-top: 4px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.section-title-zh {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
  margin-left: 2px;
}

.section-title .line {
  flex: 1;
  height: 3px;
  background: linear-gradient(90deg, var(--ice-dark), var(--primary-light), transparent);
  border-radius: 2px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.task-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 14px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  border: 3px solid transparent;
}

.task-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.task-card:active { transform: scale(0.97); }
.task-card:hover { border-color: var(--primary-light); transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.task-card .task-icon {
  font-size: 34px;
  margin-bottom: 6px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.task-card .task-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.task-card .task-title-zh {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.task-card .task-desc {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.4;
}

.task-card .task-progress {
  margin-top: 8px;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
}

.task-card .task-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.task-card .completed-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(102, 187, 106, 0.4);
}

/* ===== Category Cards ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.category-card {
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: var(--transition);
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.category-card:active { transform: scale(0.97); }
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.category-card::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
}

.category-card::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 50px;
  height: 50px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.category-card .cat-icon {
  font-size: 36px;
  margin-bottom: 6px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
  position: relative;
  z-index: 1;
}

.category-card .cat-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
  position: relative;
  z-index: 1;
}

.category-card .cat-name-zh {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 3px;
  position: relative;
  z-index: 1;
}

.category-card .cat-desc {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

/* ===== Scene Grid ===== */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.scene-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  border: 3px solid transparent;
  text-align: center;
  position: relative;
}

.scene-card:active { transform: scale(0.97); }
.scene-card:hover { border-color: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.scene-card .scene-icon {
  font-size: 38px;
  margin-bottom: 6px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.scene-card .scene-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.scene-card .scene-zh {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.scene-card .scene-meta {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-light);
  flex-wrap: wrap;
}

.scene-card .scene-meta span {
  background: var(--bg-soft);
  padding: 2px 7px;
  border-radius: 8px;
}

.scene-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.scene-card.locked .scene-icon::after {
  content: '🔒';
}

/* ===== Back Button ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  box-shadow: var(--shadow);
  transition: var(--transition);
  margin-bottom: 14px;
  border: none;
  font-family: inherit;
}

.back-btn:active { transform: scale(0.95); }
.back-btn:hover { background: var(--primary-light); transform: translateX(-2px); }

/* ===== Word Learning Module ===== */
.flashcard {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
  position: relative;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  perspective: 1000px;
  border: 2px solid var(--primary-light);
  overflow: hidden;
}

.flashcard::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--ice-dark), var(--primary), var(--secondary));
}

.flashcard-inner {
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.word-display {
  font-size: 40px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
  text-shadow: 0 2px 4px rgba(33, 150, 243, 0.1);
}

.word-phonetic {
  font-size: 18px;
  color: var(--purple);
  margin-bottom: 16px;
  font-style: italic;
}

.word-meaning {
  font-size: 26px;
  color: var(--text-main);
  margin-bottom: 12px;
  font-weight: 700;
}

.word-example {
  font-size: 15px;
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 6px;
  font-style: italic;
}

.word-example-zh {
  font-size: 13px;
  color: var(--text-light);
}

.speak-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 22px;
  cursor: pointer;
  margin: 10px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.speak-btn:active { transform: scale(0.9); }
.speak-btn:hover { box-shadow: var(--shadow-lg); transform: scale(1.05); }
.speak-btn.speaking { animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow); }
  50% { transform: scale(1.1); box-shadow: 0 0 25px var(--primary-light); }
}

.word-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

.word-nav-btn {
  background: var(--bg-soft);
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 700;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.08);
}

.word-nav-btn:active { transform: scale(0.92); }
.word-nav-btn:hover { background: var(--primary-light); box-shadow: var(--shadow); }
.word-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.word-counter {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 700;
}

/* ===== Pronunciation Practice ===== */
.pronunciation-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border: 2px solid var(--success-light);
}

.mic-btn {
  background: linear-gradient(135deg, var(--success), #4CAF50);
  color: white;
  border: none;
  border-radius: 50%;
  width: 66px;
  height: 66px;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
  transition: var(--transition);
  margin: 8px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-btn:active { transform: scale(0.9); }
.mic-btn:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5); }
.mic-btn.recording { background: var(--error); animation: pulse 0.8s infinite; }

.pron-score {
  font-size: 34px;
  font-weight: 700;
  margin: 8px 0;
}

.pron-score.high { color: var(--success); }
.pron-score.mid { color: var(--warning); }
.pron-score.low { color: var(--error); }

.pron-feedback {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.recognized-text {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 15px;
  color: var(--text-main);
  min-height: 24px;
}

/* ===== Dialogue Module ===== */
.dialogue-stage {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 14px;
}

.dialogue-header {
  padding: 14px 20px;
  color: white;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.dialogue-header::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.dialogue-header h3 {
  font-size: 17px;
  margin-bottom: 3px;
  position: relative;
  z-index: 1;
}

.dialogue-header p {
  font-size: 12px;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.dialogue-setting {
  padding: 12px 18px;
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--text-light);
  text-align: center;
  border-bottom: 1px solid var(--primary-light);
  line-height: 1.5;
}

.dialogue-messages {
  padding: 14px;
  max-height: 280px;
  overflow-y: auto;
}

.msg {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.msg .avatar {
  font-size: 30px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.msg .bubble {
  background: var(--bg-soft);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  max-width: 75%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.msg .bubble .text {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.5;
}

.msg .bubble .translation {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(0,0,0,0.05);
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: 16px 16px 4px 16px;
  box-shadow: var(--shadow);
}

.msg.user .bubble .text { color: white; }

.msg .speak-mini {
  font-size: 15px;
  cursor: pointer;
  opacity: 0.6;
  transition: var(--transition);
  margin-top: 4px;
  display: inline-block;
}

.msg .speak-mini:hover { opacity: 1; transform: scale(1.2); }

.choices-area {
  padding: 14px;
  border-top: 2px solid var(--bg-soft);
  background: linear-gradient(180deg, transparent, var(--bg-soft));
}

.choices-area .prompt {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
  text-align: center;
}

.choices-area .prompt-zh {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 10px;
  text-align: center;
  opacity: 0.8;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 2px solid var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.06);
}

.choice-btn:active { transform: scale(0.97); }
.choice-btn:hover { border-color: var(--primary); background: var(--bg-soft); transform: translateX(3px); }

.choice-btn.correct {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success-dark);
}

.choice-btn.incorrect {
  background: var(--error-light);
  border-color: var(--error);
  color: #C62828;
}

.choice-btn .choice-feedback {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.85;
  font-style: italic;
}

/* ===== Reading Module ===== */
.reading-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border-top: 4px solid var(--secondary);
}

.reading-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 10px;
  text-align: center;
}

.reading-text {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-main);
  margin-bottom: 14px;
  text-align: justify;
}

.reading-text .highlight-word {
  background: var(--accent-light);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: pointer;
  font-weight: 700;
  transition: var(--transition);
}

.reading-text .highlight-word:hover {
  background: var(--accent);
  color: white;
}

.reading-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.reading-btn {
  background: var(--bg-soft);
  border: none;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 700;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.06);
}

.reading-btn:active { transform: scale(0.95); }
.reading-btn:hover { background: var(--primary-light); }

.comprehension-q {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--secondary);
}

.comprehension-q .q-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
  line-height: 1.5;
}

.comprehension-q .options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.q-option {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
  text-align: left;
  font-family: inherit;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.q-option:active { transform: scale(0.97); }
.q-option:hover { border-color: var(--primary-light); }
.q-option.correct { background: var(--success-light); border-color: var(--success); }
.q-option.wrong { background: var(--error-light); border-color: var(--error); }
.q-option:disabled { cursor: default; }

/* ===== Writing Module ===== */
.writing-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border-top: 4px solid var(--accent);
}

.writing-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.writing-instruction {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 14px;
  line-height: 1.5;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.word-chip {
  background: var(--bg-soft);
  border: 2px solid var(--primary-light);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
  font-family: inherit;
  font-weight: 500;
}

.word-chip:active { transform: scale(0.93); }
.word-chip:hover { border-color: var(--primary); background: var(--primary-light); color: white; }
.word-chip.used { opacity: 0.3; cursor: default; }

.sentence-build-area {
  min-height: 60px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border: 2px dashed var(--primary-light);
}

.sentence-build-area .placeholder {
  color: var(--text-light);
  font-size: 13px;
}

.built-word {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.writing-textarea {
  width: 100%;
  min-height: 110px;
  border: 2px solid var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: var(--transition);
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-card);
}

.writing-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.fill-blank-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.fill-blank-options .q-option {
  flex: 1;
  min-width: 120px;
  text-align: center;
}

.writing-feedback {
  background: var(--success-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--success-dark);
  display: none;
}

.writing-feedback.show { display: block; animation: fadeIn 0.3s; }

.writing-feedback .label {
  font-weight: 700;
  margin-bottom: 4px;
}

.model-answer {
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
  border-left: 3px solid var(--accent-dark);
}

/* ===== Listening Module ===== */
.listen-player {
  background: linear-gradient(135deg, #0D47A1, #1976D2, #42A5F5);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: white;
  margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.listen-player::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.listen-player .play-btn {
  background: white;
  color: var(--primary-dark);
  border: none;
  border-radius: 50%;
  width: 66px;
  height: 66px;
  font-size: 26px;
  cursor: pointer;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.listen-player .play-btn:active { transform: scale(0.9); }
.listen-player .play-btn:hover { transform: scale(1.05); }
.listen-player .play-btn.playing { animation: pulse 1s infinite; }

.listen-player .play-label {
  font-size: 14px;
  opacity: 0.9;
}

.listen-speed {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.speed-btn {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 15px;
  padding: 5px 14px;
  font-size: 12px;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  font-weight: 500;
}

.speed-btn.active { background: rgba(255,255,255,0.8); color: var(--primary-dark); font-weight: 700; }

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 900px;
  display: flex;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 20px rgba(33, 150, 243, 0.1);
  z-index: 100;
  padding: 6px 0;
  border-top: 1px solid rgba(33, 150, 243, 0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-light);
  border: none;
  background: none;
  font-family: inherit;
  border-radius: 12px;
  margin: 0 4px;
}

.nav-item:active { transform: scale(0.9); }
.nav-item.active { color: var(--primary); background: var(--bg-soft); }
.nav-item.active .nav-icon { transform: scale(1.15); }

.nav-icon { font-size: 22px; transition: var(--transition); }
.nav-label { font-size: 10px; font-weight: 700; }
.nav-label-zh { font-size: 9px; color: var(--text-light); opacity: 0.7; }

/* ===== Achievement System ===== */
.achievement-banner {
  background: linear-gradient(135deg, var(--gold), var(--accent));
  border-radius: var(--radius);
  padding: 16px 20px;
  color: #5D4037;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.achievement-banner .badge-icon {
  font-size: 36px;
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.achievement-banner .badge-info h4 {
  font-size: 16px;
  margin-bottom: 2px;
}

.achievement-banner .badge-info p {
  font-size: 13px;
  opacity: 0.8;
}

/* ===== Growth Tree ===== */
.growth-tree {
  background: linear-gradient(180deg, #E8F5E9, #C8E6C9);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  min-height: 180px;
  box-shadow: var(--shadow);
}

.growth-tree::before {
  content: '☁️';
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 30px;
  opacity: 0.5;
}

.growth-tree::after {
  content: '🌸';
  position: absolute;
  bottom: 10px;
  left: 20px;
  font-size: 20px;
  opacity: 0.5;
}

.tree-visual {
  font-size: 72px;
  line-height: 1;
  margin: 8px 0;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.tree-level {
  font-size: 15px;
  font-weight: 700;
  color: #2E7D32;
}

.tree-progress {
  margin: 10px auto;
  width: 80%;
  height: 8px;
  background: rgba(255,255,255,0.5);
  border-radius: 4px;
  overflow: hidden;
}

.tree-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #66BB6A, #4CAF50);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ===== Badge Grid ===== */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.badge-item {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.badge-item.earned { border: 2px solid var(--gold); }
.badge-item.earned .badge-emoji { animation: bounce 0.5s ease; }
.badge-item.locked { opacity: 0.4; filter: grayscale(1); }

.badge-item .badge-emoji {
  font-size: 30px;
  display: block;
  margin-bottom: 4px;
}

.badge-item .badge-name {
  font-size: 10px;
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.3;
}

/* ===== Parent Dashboard ===== */
.dashboard-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border-left: 4px solid var(--primary);
}

.dashboard-card h3 {
  font-size: 15px;
  color: var(--primary-dark);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--bg-soft);
}

.stat-row:last-child { border-bottom: none; }

.stat-row .stat-label {
  font-size: 13px;
  color: var(--text-light);
}

.stat-row .stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-soft);
  border-radius: 5px;
  overflow: hidden;
  margin: 4px 0;
}

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

.weekly-chart {
  display: flex;
  gap: 6px;
  height: 110px;
  align-items: flex-end;
  padding: 10px 0;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary), var(--secondary));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
  position: relative;
}

.bar.today {
  background: linear-gradient(180deg, var(--gold), var(--accent));
}

.bar-label {
  font-size: 10px;
  color: var(--text-light);
}

.weak-point {
  background: var(--error-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 6px 0;
  font-size: 13px;
  color: #C62828;
  display: flex;
  align-items: center;
  gap: 8px;
}

.strength-point {
  background: var(--success-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 6px 0;
  font-size: 13px;
  color: var(--success-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Streak Calendar ===== */
.streak-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.streak-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--text-light);
}

.streak-day.checked {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: var(--shadow);
}

.streak-day.today {
  border: 2px solid var(--gold);
}

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translate(-50%, 20px); }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeIn 0.3s;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.modal .modal-icon {
  font-size: 56px;
  margin-bottom: 10px;
  animation: bounce 0.5s ease;
}

.modal h2 {
  font-size: 20px;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.modal p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 18px;
  line-height: 1.5;
}

.modal .modal-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 25px;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: var(--shadow);
}

.modal .modal-btn:active { transform: scale(0.95); }

/* ===== Loading Spinner ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .task-grid { grid-template-columns: repeat(4, 1fr); }
  .category-grid { grid-template-columns: repeat(4, 1fr); }
  .scene-grid { grid-template-columns: repeat(3, 1fr); }
  .badge-grid { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 400px) {
  .topbar-logo .title { font-size: 16px; }
  .stat-pill { font-size: 12px; padding: 4px 10px; }
  .word-display { font-size: 32px; }
  .welcome-banner h1 { font-size: 20px; }
  .nav-label { font-size: 9px; }
  .nav-label-zh { display: none; }
}

/* ===== Scrollbar styling ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-soft);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ===== Snowflake Animations (Frozen Theme) ===== */
@keyframes snowfall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 0.8; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

@keyframes snowDrift {
  0% { transform: translateX(0); }
  50% { transform: translateX(15px); }
  100% { transform: translateX(0); }
}

.snowflake {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  color: var(--ice-dark);
  font-size: 16px;
  animation: snowfall linear infinite, snowDrift 3s ease-in-out infinite;
  opacity: 0.6;
}

.snowflake:nth-child(1) { left: 10%; animation-duration: 12s, 2.5s; animation-delay: 0s; font-size: 14px; }
.snowflake:nth-child(2) { left: 25%; animation-duration: 15s, 3s; animation-delay: 2s; font-size: 18px; }
.snowflake:nth-child(3) { left: 40%; animation-duration: 13s, 2.8s; animation-delay: 4s; font-size: 12px; }
.snowflake:nth-child(4) { left: 55%; animation-duration: 14s, 3.2s; animation-delay: 1s; font-size: 20px; }
.snowflake:nth-child(5) { left: 70%; animation-duration: 16s, 2.6s; animation-delay: 3s; font-size: 15px; }
.snowflake:nth-child(6) { left: 85%; animation-duration: 11s, 3.4s; animation-delay: 5s; font-size: 17px; }

/* ===== Ice Crystal Shimmer ===== */
@keyframes shimmer {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.3); }
}

.ice-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  animation: shimmer 2.5s ease-in-out infinite;
}

.ice-sparkle:nth-child(7) { top: 15%; left: 12%; animation-delay: 0s; }
.ice-sparkle:nth-child(8) { top: 45%; right: 10%; animation-delay: 1s; }
.ice-sparkle:nth-child(9) { top: 75%; left: 8%; animation-delay: 2s; }
