/**
 * 欣然英语学习乐园 - 全局样式
 * 可爱卡通风格，适合8-9岁儿童
 */

/* ========== CSS 变量 ========== */
:root, [data-gender="girl"] {
  --pink: #ff6b9d;
  --pink-light: #ffb3cc;
  --pink-bg: #fff0f5;
  --purple: #a855f7;
  --purple-light: #d8b4fe;
  --purple-bg: #f5f0ff;
  --body-bg-1: #fff0f5;
  --body-bg-2: #f5f0ff;
  --body-bg-3: #fff9f0;
}

[data-gender="boy"] {
  --pink: #4dabf7;
  --pink-light: #b3d9ff;
  --pink-bg: #f0f7ff;
  --purple: #339af0;
  --purple-light: #a5d8ff;
  --purple-bg: #e7f5ff;
  --body-bg-1: #f0f7ff;
  --body-bg-2: #e8f4fd;
  --body-bg-3: #f0fff4;
}

:root {
  --yellow: #ffd93d;
  --yellow-light: #fff3b0;
  --green: #6bcb77;
  --green-light: #b8f5c0;
  --red: #ff6b6b;
  --red-light: #ffcccc;
  --blue: #4dabf7;
  --blue-light: #b3d9ff;
  --orange: #ffa94d;
  --orange-light: #ffd8a8;
  --white: #ffffff;
  --text: #4a3348;
  --text-light: #7a6b78;
  --shadow: 0 4px 15px rgba(255, 107, 157, 0.15);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

/* ========== 基础重置 ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, var(--body-bg-1) 0%, var(--body-bg-2) 50%, var(--body-bg-3) 100%);
  min-height: 100vh;
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ========== 背景装饰 ========== */
body::before {
  content: '';
  position: fixed;
  top: -100px;
  right: -100px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255, 107, 157, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -80px;
  left: -80px;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

/* ========== 主容器 ========== */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ========== 页面切换 ========== */
.page {
  display: none;
  animation: fadeSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.page.active {
  display: block;
}

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

/* ========== 顶部导航栏 ========== */
.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 10px;
}

.btn-back {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  box-shadow: var(--shadow);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-back:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

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

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--purple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== 按钮通用样式 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--white);
  color: var(--purple);
  border: 2px solid var(--purple-light);
}

.btn-secondary:hover {
  background: var(--purple-bg);
}

.btn-success {
  background: linear-gradient(135deg, #6bcb77, #4ecb71);
  color: white;
  box-shadow: 0 4px 15px rgba(107, 203, 119, 0.3);
}

.btn-warning {
  background: linear-gradient(135deg, var(--orange), #ffc078);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 169, 77, 0.3);
}

.btn-lg {
  padding: 18px 36px;
  font-size: 20px;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 8px 18px;
  font-size: 14px;
  border-radius: var(--radius-xs);
}

/* ========== 首页 ========== */
.home-header {
  text-align: center;
  padding: 24px 0 16px;
}

.home-header .logo {
  font-size: 48px;
  margin-bottom: 8px;
  animation: bounce 2s infinite;
}

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

.home-header h1 {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-header .subtitle {
  font-size: 15px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 进度面板 */
.progress-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-around;
  align-items: center;
  text-align: center;
}

.progress-item {
  flex: 1;
}

.progress-item .icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.progress-item .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--pink);
}

.progress-item .label {
  font-size: 12px;
  color: var(--text-light);
}

.progress-divider {
  width: 1px;
  height: 40px;
  background: var(--pink-light);
}

/* 功能卡片网格 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.feature-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.feature-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 107, 157, 0.05));
  opacity: 0;
  transition: opacity 0.3s;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.feature-card:hover::after {
  opacity: 1;
}

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

.feature-card .card-emoji {
  font-size: 48px;
  margin-bottom: 10px;
  display: block;
  transition: transform 0.3s;
}

.feature-card:hover .card-emoji {
  transform: scale(1.15) rotate(-5deg);
}

.feature-card .card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.feature-card .card-desc {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.feature-card:nth-child(1) .card-name { color: #ff6b9d; }
.feature-card:nth-child(2) .card-name { color: #a855f7; }
.feature-card:nth-child(3) .card-name { color: #4dabf7; }
.feature-card:nth-child(4) .card-name { color: #6bcb77; }
.feature-card:nth-child(5) .card-name { color: #ffa94d; }

/* 底部鼓励语 */
.footer-cheer {
  text-align: center;
  padding: 24px 0;
  font-size: 14px;
  color: var(--text-light);
}

.footer-cheer span {
  font-size: 18px;
}

/* ========== 单词选择题通用样式 ========== */
.quiz-container {
  max-width: 600px;
  margin: 0 auto;
}

/* 模式选择 */
.mode-select {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  justify-content: center;
}

.mode-tab {
  padding: 10px 24px;
  border-radius: 25px;
  border: 2px solid var(--purple-light);
  background: var(--white);
  color: var(--purple);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.mode-tab.active {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
}

/* 进度条 */
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--pink-light);
  border-radius: 5px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--pink);
  white-space: nowrap;
}

/* 题目卡片 */
.question-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

.question-word {
  font-size: 42px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 8px;
}

.question-word.zh {
  font-size: 36px;
}

.btn-speak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--purple-bg);
  border: none;
  border-radius: 20px;
  color: var(--purple);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-speak:hover {
  background: var(--purple-light);
}

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

/* 选项按钮 */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-btn {
  padding: 18px 16px;
  border-radius: var(--radius-sm);
  border: 3px solid var(--purple-light);
  background: var(--white);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
  border-color: var(--purple);
  background: var(--purple-bg);
}

.option-btn:active {
  transform: scale(0.96);
}

.option-btn.correct {
  border-color: var(--green);
  background: var(--green-light);
  color: #2d6a4f;
  animation: correctPulse 0.6s ease;
}

.option-btn.wrong {
  border-color: var(--red);
  background: var(--red-light);
  color: #c92a2a;
  animation: shake 0.5s ease;
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

/* 结果页面 */
.result-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.result-emoji {
  font-size: 72px;
  margin-bottom: 12px;
  animation: bounce 1s ease infinite;
}

.result-score {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-stars {
  font-size: 40px;
  margin: 12px 0;
}

.result-msg {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 24px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 主题筛选 */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  justify-content: center;
}

.category-chip {
  padding: 6px 16px;
  border-radius: 20px;
  border: 2px solid var(--pink-light);
  background: var(--white);
  color: var(--pink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.category-chip.active {
  background: var(--pink);
  color: white;
  border-color: var(--pink);
}

/* ========== 故事模块 ========== */
.story-container {
  max-width: 650px;
  margin: 0 auto;
}

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

.story-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 16px;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.story-card .story-emoji {
  font-size: 44px;
  flex-shrink: 0;
}

.story-card .story-info h3 {
  font-size: 18px;
  color: var(--text);
}

.story-card .story-info .story-title-en {
  font-size: 13px;
  color: var(--text-light);
}

/* 故事播放页 */
.story-player {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.story-player .story-header {
  text-align: center;
  margin-bottom: 24px;
}

.story-player .story-header .story-emoji {
  font-size: 56px;
}

.story-player .story-header h2 {
  font-size: 22px;
  color: var(--text);
  margin-top: 8px;
}

.story-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.sentence-card {
  background: var(--pink-bg);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--pink);
  transition: all 0.3s;
}

.sentence-card.active {
  background: #fff0f7;
  border-left-color: var(--purple);
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.15);
  transform: scale(1.02);
}

.sentence-card .en {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.sentence-card .zh {
  font-size: 15px;
  color: var(--text-light);
}

/* ========== 阅读模块 ========== */
.reading-container {
  max-width: 650px;
  margin: 0 auto;
}

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

.reading-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 16px;
}

.reading-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.reading-card .reading-emoji {
  font-size: 44px;
  flex-shrink: 0;
}

.reading-card .reading-level {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--yellow-light);
  color: #b8860b;
  font-weight: 600;
  margin-top: 4px;
  display: inline-block;
}

/* 阅读内容页 */
.reading-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

.reading-content .reading-header {
  text-align: center;
  margin-bottom: 20px;
}

.reading-content .reading-text {
  font-size: 17px;
  line-height: 2;
  color: var(--text);
}

.reading-content .reading-text .word-clickable {
  cursor: pointer;
  border-bottom: 2px dotted var(--purple-light);
  transition: all 0.2s;
  position: relative;
}

.reading-content .reading-text .word-clickable:hover {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

/* 单词提示气泡 */
.word-tooltip {
  position: fixed;
  background: var(--purple);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  z-index: 100;
  animation: tooltipPop 0.2s ease;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

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

/* ========== 连连看游戏（连线版） ========== */
.match-container { max-width: 650px; margin: 0 auto; }
.match-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.match-stat { background: var(--white); border-radius: var(--radius-sm); padding: 12px 18px; box-shadow: var(--shadow); text-align: center; flex: 1; }
.match-stat .stat-value { font-size: 24px; font-weight: 800; color: var(--pink); }
.match-stat .stat-label { font-size: 11px; color: var(--text-light); }

/* 连线棋盘 */
.match-board {
  display: flex;
  align-items: stretch;
  gap: 0;
  position: relative;
}

.mc-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mc-divider {
  width: 50px;
  flex-shrink: 0;
}

.mc-title {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--purple);
  padding: 8px 0;
  border-bottom: 2px solid var(--purple-light);
  margin-bottom: 4px;
}

.mc-word {
  background: var(--white);
  border: 3px solid var(--purple-light);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.mc-word:hover { border-color: var(--purple); background: var(--purple-bg); transform: scale(1.02); }
.mc-word:active { transform: scale(0.97); }

.mc-word.selected {
  border-color: var(--pink);
  background: var(--pink-bg);
  box-shadow: 0 0 0 4px rgba(255,107,157,0.2);
}

.mc-word.ok {
  border-color: var(--green);
  background: var(--green-light);
  pointer-events: none;
}

.mc-word.bad {
  border-color: var(--red);
  background: var(--red-light);
  animation: shake 0.4s ease;
}

/* SVG连线动画 */
#matchSvg path {
  stroke-dasharray: 300;
  animation: drawLine 0.5s ease forwards;
}
@keyframes drawLine {
  from { stroke-dashoffset: 300; }
  to { stroke-dashoffset: 0; }
}

@media (max-width: 480px) {
  .mc-divider { width: 30px; }
  .mc-word { padding: 12px 6px; font-size: 14px; }
  .mc-title { font-size: 12px; }
}

/* 游戏结束 */
.match-complete {
  text-align: center;
  padding: 30px;
}

/* ========== 听力理解测验 ========== */
.quiz-questions {
  margin-top: 28px;
  border-top: 2px dashed var(--purple-light);
  padding-top: 24px;
}

.quiz-questions h3 {
  font-size: 18px;
  color: var(--purple);
  margin-bottom: 16px;
  text-align: center;
}

.quiz-question-item {
  margin-bottom: 20px;
}

.quiz-question-item .qq-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.quiz-question-item .qq-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qq-option {
  padding: 8px 18px;
  border-radius: 20px;
  border: 2px solid var(--purple-light);
  background: var(--white);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.qq-option:hover {
  border-color: var(--purple);
  background: var(--purple-bg);
}

.qq-option.selected {
  border-color: var(--purple);
  background: var(--purple);
  color: white;
}

.qq-option.correct {
  border-color: var(--green);
  background: var(--green-light);
  color: #2d6a4f;
}

.qq-option.wrong {
  border-color: var(--red);
  background: var(--red-light);
  color: #c92a2a;
}

/* ========== 庆祝动画 ========== */
.celebrate {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  animation: confettiFall 1.5s ease-out forwards;
}

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

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  .app-container {
    padding: 12px;
  }

  .home-header h1 {
    font-size: 26px;
  }

  .question-word {
    font-size: 32px;
  }

  .options-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .match-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .feature-card {
    padding: 18px 12px;
  }

  .feature-card .card-emoji {
    font-size: 36px;
  }

  .story-controls {
    flex-direction: column;
  }
}

/* ========== 用户栏 ========== */
.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--pink);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-grade {
  font-size: 12px;
  color: var(--purple);
  font-weight: 600;
}

/* ========== 模态弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

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

.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  width: 90%;
  text-align: center;
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-box h3 {
  font-size: 20px;
  color: var(--purple);
  margin-bottom: 8px;
}

.grade-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
