/* === 快乐学习 Happy Learn — Global Styles === */

:root {
  --primary: #FF6B6B;
  --primary-dark: #E55A5A;
  --secondary: #4ECDC4;
  --secondary-dark: #3DBDB5;
  --chinese: #FF6B6B;
  --math: #4ECDC4;
  --english: #FFD93D;
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-light: #636E72;
  --text-muted: #B2BEC3;
  --star: #FDCB6E;
  --star-empty: #DFE6E9;
  --gem: #A29BFE;
  --success: #00B894;
  --error: #FF7675;
  --error-soft: #FFEAA7;
  --streak: #FD79A8;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --radius: 20px;
  --radius-sm: 12px;
  --font: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* === Layout === */
#app {
  max-width: 800px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* === Header === */
.app-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-bottom: 2px solid #f0f0f0;
  z-index: 10;
  min-height: 56px;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 14px; }

.mascot-mini {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff, #f0f0f0);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  background: #f8f8f8;
}
.stat-badge.streak { color: var(--streak); }
.stat-badge.gems { color: var(--gem); }
.stat-icon { font-size: 18px; }

/* === Main Content Area === */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar */
.main-content::-webkit-scrollbar { width: 0; }

/* === Screens === */
.screen {
  display: none;
  animation: fadeSlideIn 0.35s ease;
}
.screen.active { display: block; }

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

/* === Home Screen === */
.welcome-section {
  text-align: center;
  padding: 30px 0 20px;
}

.mascot-large {
  width: 120px; height: 120px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF, #F0F0F0);
  display: flex; align-items: center; justify-content: center;
  font-size: 64px;
  box-shadow: var(--shadow-lg);
  animation: float 3s ease-in-out infinite;
}

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

.welcome-title {
  font-size: 28px; font-weight: 800;
  margin-bottom: 4px;
}

.welcome-subtitle {
  font-size: 16px; color: var(--text-light);
  margin-bottom: 16px;
}

.streak-banner {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #FFE0EC, #FFE8F5);
  border-radius: var(--radius);
  font-weight: 700; font-size: 15px;
  color: var(--streak);
}

/* === Subject Cards === */
.subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 8px;
}

.subject-card {
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
  background: var(--card);
  position: relative;
  overflow: hidden;
}

.subject-card:active { transform: scale(0.97); }

.subject-card .card-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800;
  flex-shrink: 0;
}

.subject-card .card-info { flex: 1; }
.subject-card .card-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.subject-card .card-progress { font-size: 13px; color: var(--text-light); }
.subject-card .card-arrow { font-size: 20px; color: var(--text-muted); }

.progress-mini {
  height: 4px; background: #eee;
  border-radius: 2px; margin-top: 6px;
  overflow: hidden;
}
.progress-mini-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.5s ease;
}

.card-icon.chinese { background: #FFF0F0; color: var(--chinese); }
.progress-mini-fill.chinese { background: var(--chinese); }
.card-icon.math { background: #F0FFFB; color: var(--math); }
.progress-mini-fill.math { background: var(--math); }
.card-icon.english { background: #FFFEF0; color: #E8C800; }
.progress-mini-fill.english { background: var(--english); }

/* === Path Screen (Subject Learning Path) === */
.path-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}

.back-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none; background: var(--card);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.back-btn:active { transform: scale(0.9); }

.path-title {
  font-size: 22px; font-weight: 800;
}

.path-subtitle {
  font-size: 13px; color: var(--text-light);
}

.unit-list { display: flex; flex-direction: column; gap: 12px; }

.unit-node {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
}
.unit-node:active { transform: scale(0.97); }
.unit-node.locked { opacity: 0.5; cursor: not-allowed; }

.unit-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.unit-icon.completed { background: #D4FCEB; }
.unit-icon.current { background: #FFF3E0; animation: pulse 2s infinite; }
.unit-icon.locked-icon { background: #F5F5F5; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,152,0,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255,152,0,0); }
}

.unit-info { flex: 1; }
.unit-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.unit-desc { font-size: 12px; color: var(--text-light); }

.unit-stars { display: flex; gap: 3px; }
.star-icon { font-size: 16px; }
.star-icon.filled { color: var(--star); }
.star-icon.empty { color: var(--star-empty); }

/* === Lesson Screen === */
.lesson-progress {
  height: 6px; background: #eee;
  border-radius: 3px; margin-bottom: 20px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.4s ease;
}

.lesson-question-area {
  text-align: center;
  padding: 10px 0 20px;
}

.question-prompt {
  font-size: 22px; font-weight: 700;
  margin-bottom: 8px;
}

.question-media {
  font-size: 72px;
  margin: 16px 0;
  min-height: 100px;
  display: flex; align-items: center; justify-content: center;
}

.question-media.small { font-size: 42px; min-height: 60px; }

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.answer-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.answer-btn {
  padding: 18px 14px;
  border: 3px solid #E8E8E8;
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 18px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  min-height: 60px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  word-break: break-word;
}
.answer-btn:active { transform: scale(0.95); }
.answer-btn.correct {
  border-color: var(--success); background: #E6FFF5;
  animation: popCorrect 0.5s;
}
.answer-btn.wrong {
  border-color: var(--error); background: #FFF0F0;
  animation: shake 0.5s;
}

@keyframes popCorrect {
  0% { transform: scale(1); }
  30% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* === Lesson Complete === */
.lesson-complete-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s;
  padding: 20px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lesson-complete-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  max-width: 360px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: bounceIn 0.5s;
}

@keyframes bounceIn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.complete-title {
  font-size: 26px; font-weight: 800;
  margin-bottom: 8px;
}

.stars-display {
  font-size: 48px;
  margin: 16px 0;
  letter-spacing: 8px;
}

.rewards-row {
  display: flex; gap: 16px;
  justify-content: center;
  margin: 16px 0;
}

.reward-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 16px; font-weight: 700;
  padding: 8px 14px;
  border-radius: 20px;
  background: #F8F8F8;
}

.continue-btn {
  width: 100%;
  padding: 16px;
  border: none; border-radius: 16px;
  font-size: 18px; font-weight: 700;
  cursor: pointer;
  color: white;
  transition: transform 0.15s;
  font-family: var(--font);
  margin-top: 16px;
}
.continue-btn:active { transform: scale(0.96); }

/* === Parent Dashboard === */
.dashboard-grid {
  display: grid; gap: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card h3 {
  font-size: 14px; color: var(--text-light);
  margin-bottom: 8px; text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-card .big-number {
  font-size: 36px; font-weight: 800;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.mini-stat {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.mini-stat .value { font-size: 24px; font-weight: 700; }
.mini-stat .label { font-size: 11px; color: var(--text-light); margin-top: 4px; }

.subject-progress-bar {
  margin: 12px 0;
}
.subject-progress-bar .label-row {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 4px;
}
.subject-progress-bar .bar {
  height: 8px; background: #eee;
  border-radius: 4px; overflow: hidden;
}
.subject-progress-bar .fill {
  height: 100%; border-radius: 4px;
  transition: width 0.6s;
}

/* === Buttons === */
.btn {
  padding: 14px 24px;
  border: none; border-radius: 16px;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-outline { background: white; border: 2px solid #e0e0e0; color: var(--text); }

/* === Confetti === */
.confetti-container {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 200;
}

.confetti-piece {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 3px;
  animation: confettiFall 2s ease-out forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* === Toast === */
.toast {
  position: fixed; top: 20px;
  left: 50%; transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 20px;
  font-weight: 700; font-size: 15px;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s, toastOut 0.3s 2s forwards;
  white-space: nowrap;
}

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

.toast.success { background: #D4FCEB; color: #006B4A; }
.toast.streak { background: #FFE0EC; color: #D6336C; }

/* === Responsive === */
@media (min-width: 600px) {
  .subject-grid { grid-template-columns: 1fr; max-width: 500px; margin: 0 auto; }
  .answer-grid { max-width: 500px; margin: 0 auto; }
}

@media (min-width: 800px) {
  .subject-grid { grid-template-columns: 1fr; }
  .unit-list { max-width: 600px; margin: 0 auto; }
}

/* === 单词卡带读 Word Cards（设计移植自 Fennec-Kids）=== */
#screen-cards.active {
  display: flex;
  flex-direction: column;
  /* 减去顶部 header 与 main-content 上下内边距，保证一屏放得下、不用滚动 */
  min-height: calc(100vh - 130px);
}

.cards-progress {
  height: 6px;
  background: #EEE7D8;
  border-radius: 3px;
  margin-bottom: 14px;
  overflow: hidden;
}
.cards-progress-fill {
  height: 100%;
  background: var(--english);
  border-radius: 3px;
  transition: width 0.25s ease;
}

.card-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0 8px;
}

.word-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: linear-gradient(160deg, #FFFDF6 0%, #FFF2D4 100%);
  border: 2px solid #FFE7A3;
  border-radius: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
  padding: 30px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease;
  animation: cardIn 0.28s ease;
}
.word-card:active { transform: scale(0.97); }
.word-card.pop { animation: cardPop 0.35s ease; }

.word-card-emoji {
  font-size: 104px;
  line-height: 1.15;
  min-height: 120px;
  display: flex;
  align-items: center;
}
.word-card-en {
  font-size: 40px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.5px;
  text-align: center;
  word-break: break-word;
}
.word-card-cn {
  font-size: 18px;
  color: #8A7A55;
}
.word-card-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.cards-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0;
}
.cards-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: #E3D9C6;
  transition: all 0.2s;
}
.cards-dot.active {
  width: 22px;
  background: var(--english);
}

.cards-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-bottom: 10px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}
.card-nav-btn {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 16px;
  border: none;
  background: #F3ECD9;
  color: #8A7A55;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s;
}
.card-nav-btn:active { transform: scale(0.92); }
.card-nav-btn:disabled { opacity: 0.35; cursor: default; }

.cards-actions .continue-btn { margin-top: 0; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes cardPop {
  0% { transform: scale(0.95); }
  55% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (max-height: 640px) {
  .word-card-emoji { font-size: 76px; min-height: 88px; }
  .word-card-en { font-size: 32px; }
  .word-card { padding: 20px 16px 16px; }
}
