/* ============================================================
   儿童益智游戏 - 全局样式
   ============================================================ */

/* --- 字体 --- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* --- CSS 变量 --- */
:root {
  --primary: #FF6B6B;       /* 珊瑚红 */
  --secondary: #4ECDC4;     /* 青绿 */
  --accent: #FFE66D;        /* 明黄 */
  --purple: #A29BFE;        /* 薰衣草紫 */
  --green: #55EFC4;         /* 薄荷绿 */
  --dark: #2D3436;          /* 深灰 */
  --light: #F8F9FA;         /* 浅灰 */
  --white: #FFFFFF;
  --shadow: rgba(0,0,0,0.12);
  --radius: 20px;
  --radius-sm: 12px;
}

/* --- 重置 --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Nunito', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 20px 0;
  overflow-x: hidden;
}

/* --- 主容器 --- */
.game-container {
  width: 100%;
  max-width: 520px;
  background: var(--white);
  border-radius: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  position: relative;
}

/* --- 顶部分数区 --- */
.header {
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  padding: 20px 24px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -30px; left: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}
.header::after {
  content: '';
  position: absolute;
  bottom: -20px; right: -20px;
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

/* 品牌标识 */
.brand-logo {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 22px;
  font-weight: 900;
  color: rgba(255,255,255,0.95);
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 8px;
}

/* Record 链接 */
.record-link {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  text-decoration: none;
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.record-link:hover {
  background: rgba(255,255,255,0.35);
  transform: translateY(-1px);
}

.score-label {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.score-value {
  font-size: 56px;
  font-weight: 900;
  color: var(--white);
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}

.score-value.bump {
  animation: scoreBump 0.4s ease;
}

@keyframes scoreBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.score-value.wrong {
  animation: scoreShake 0.4s ease;
}

@keyframes scoreShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-6px); }
  80%     { transform: translateX(6px); }
}

/* --- 蛋/宠物展示区 --- */
.egg-section {
  padding: 10px 24px 8px;
  text-align: center;
  background: #f8f9ff;
  position: relative;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.egg-hint {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 1px;
  transition: opacity 0.3s ease;
}

/* --- 进度条容器 --- */
.progress-container {
  width: 100%;
  max-width: 280px;
  margin: 8px 0;
}

.progress-bar-wrapper {
  position: relative;
  width: 100%;
  height: 28px;
  background: #e8ecf4;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.1);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #FF6B6B 0%, #FF8E53 50%, #FFE66D 100%);
  border-radius: 14px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

/* 进度条光泽效果 */
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
  border-radius: 14px 14px 0 0;
}

/* 进度条条纹动画 */
.progress-bar-fill::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(255,255,255,0.15) 8px,
    rgba(255,255,255,0.15) 16px
  );
  animation: progressStripes 1s linear infinite;
}

@keyframes progressStripes {
  0% { background-position: 0 0; }
  100% { background-position: 22.6px 0; }
}

/* 进度条数值显示 */
.progress-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 800;
  color: #666;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
  z-index: 2;
}

/* 宠物图标 */
.pet-icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

.pet-icon {
  font-size: 28px;
  opacity: 0.7;
}

/* 进度条满时的闪烁效果 */
.progress-bar-fill.ready {
  animation: progressGlow 0.6s ease-in-out infinite alternate;
}

@keyframes progressGlow {
  0% { box-shadow: 0 0 10px rgba(255,107,107,0.5); }
  100% { box-shadow: 0 0 20px rgba(255,107,107,0.9); }
}


/* --- 导航标签 --- */
.nav-tabs {
  display: flex;
  padding: 12px 16px 0;
  gap: 6px;
  background: var(--white);
}

.nav-tab {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: #f1f3f8;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #888;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-bottom: 3px solid transparent;
}

.nav-tab:hover { background: #e8ecf4; color: #555; }
.nav-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: var(--white);
  border-bottom-color: rgba(255,255,255,0.3);
}

/* --- 游戏内容区 --- */
.game-content {
  padding: 16px 24px 20px;
  min-height: 240px;
  position: relative;
  background: var(--white);
}

.game-panel {
  display: none;
  animation: fadeSlide 0.3s ease;
}

.game-panel.active {
  display: block;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- 题目标题 --- */
.game-question-label {
  font-size: 12px;
  font-weight: 700;
  color: #ccc;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* --- 题目展示 --- */
.question-box {
  background: linear-gradient(135deg, #f8f9ff, #eee8ff);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.question-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--purple), var(--secondary));
}

.question-text {
  font-size: 38px;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: 2px;
  line-height: 1.2;
}

/* 语文题文字更大 */
.game-panel[data-type="chinese"] .question-text {
  font-size: 72px;
  letter-spacing: 8px;
}

/* 点击发音文字样式 */
.question-text.speakable {
  cursor: pointer;
  transition: transform 0.2s ease, text-shadow 0.2s ease;
  user-select: none;
}

.question-text.speakable:hover {
  transform: scale(1.05);
  text-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

.question-text.speakable.speaking {
  animation: speakPulse 0.5s ease;
}

@keyframes speakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* --- 选项区 --- */
.options-grid {
  display: grid;
  gap: 12px;
}

.options-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.options-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* --- 数学题输入区 --- */
.math-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.math-input {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid #e0e8ff;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 28px;
  font-weight: 900;
  color: var(--dark);
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f8f9ff;
}

.math-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(162, 155, 254, 0.2);
  background: var(--white);
}

.math-input.correct {
  border-color: var(--green);
  background: #eafffe;
  animation: correctPop 0.5s ease;
}

.math-input.wrong {
  border-color: var(--primary);
  background: #fff0f0;
  animation: wrongShake 0.4s ease;
}

.confirm-btn {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--purple), #8b7ff5);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(162, 155, 254, 0.3);
}

.confirm-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(162, 155, 254, 0.4);
}

.confirm-btn:active {
  transform: translateY(0);
}

.confirm-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.math-answer-feedback {
  font-size: 16px;
  font-weight: 700;
  padding: 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 12px;
  animation: fadeSlide 0.3s ease;
}

.math-answer-feedback.correct {
  color: var(--green);
  background: #eafffe;
  border: 2px solid var(--green);
}

.math-answer-feedback.wrong {
  color: var(--primary);
  background: #fff0f0;
  border: 2px solid var(--primary);
}

.option-btn {
  padding: 14px 12px;
  border: 3px solid #e8ecf4;
  border-radius: var(--radius);
  background: var(--white);
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  color: var(--dark);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.option-btn:hover {
  border-color: var(--secondary);
  background: #f0fffe;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78,205,196,0.25);
}

.option-btn:active { transform: translateY(0); }

/* 选项反馈 */
.option-btn.correct {
  border-color: var(--green);
  background: #eafffe;
  animation: correctPop 0.5s ease;
}

.option-btn.wrong {
  border-color: var(--primary);
  background: #fff0f0;
  animation: wrongShake 0.4s ease;
}

@keyframes correctPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* 禁用其他按钮 */
.option-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- 反馈提示 --- */
.feedback-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: var(--white);
  border-radius: 20px;
  padding: 16px 32px;
  font-size: 22px;
  font-weight: 900;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.feedback-toast.show {
  transform: translate(-50%, -50%) scale(1);
}

.feedback-toast.correct { color: var(--green); border: 3px solid var(--green); }
.feedback-toast.wrong   { color: var(--primary); border: 3px solid var(--primary); }

/* --- 下一题按钮 --- */
.next-btn {
  display: none;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--secondary), #38b2ac);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 1px;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(78,205,196,0.4);
}

.next-btn.show { display: block; }

/* --- 清零按钮 --- */
.reset-section {
  padding: 0 24px 20px;
  display: flex;
  justify-content: center;
}

.reset-btn {
  padding: 8px 24px;
  background: transparent;
  border: 2px solid #ddd;
  border-radius: 30px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff5f5;
}

/* --- 访问次数统计 --- */
.visit-counter {
  padding: 12px 24px 28px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.visit-icon {
  font-size: 18px;
}

.visit-text {
  font-size: 13px;
  color: #999;
  font-weight: 600;
}

.visit-count {
  font-size: 18px;
  font-weight: 900;
  color: var(--purple);
  min-width: 40px;
}

/* --- 通关遮罩 --- */
.victory-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}

.victory-overlay.show { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.victory-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 8px;
}

.victory-sub {
  font-size: 14px;
  color: #888;
  margin-bottom: 20px;
}

/* --- 通关宠物容器 --- */
.victory-pet-container {
  position: relative;
  margin: 10px 0 20px;
}

.victory-pet {
  font-size: 150px;
  line-height: 1;
  display: inline-block;
  animation: petBounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.victory-pet:hover {
  transform: scale(1.1);
  transition: transform 0.2s ease;
}

.victory-bubble {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  box-shadow: 0 4px 12px var(--shadow);
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.victory-bubble::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid var(--white);
}

/* --- 通关按钮 --- */
.victory-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.victory-close-btn {
  padding: 12px 28px;
  background: transparent;
  border: 2px solid var(--purple);
  border-radius: 30px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--purple);
  cursor: pointer;
  transition: all 0.2s ease;
}

.victory-close-btn:hover {
  background: var(--purple);
  color: white;
}

.victory-reset-btn {
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--primary), #FF8E53);
  border: none;
  border-radius: 30px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.victory-reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

/* --- 150分奖励遮罩 --- */
.reward-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  z-index: 60;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}

.reward-overlay.show { display: flex; }

.reward-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 10px;
}

.reward-sub {
  font-size: 16px;
  font-weight: 700;
  color: #888;
  margin-bottom: 6px;
}

.reward-desc {
  font-size: 14px;
  color: #aaa;
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.reward-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
}

.reward-btn-primary {
  padding: 13px 32px;
  background: linear-gradient(135deg, var(--primary), #FF8E53);
  border: none;
  border-radius: 30px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: white;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
  transition: all 0.2s ease;
}

.reward-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.reward-btn-secondary {
  padding: 11px 26px;
  background: transparent;
  border: 2px solid var(--purple);
  border-radius: 30px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--purple);
  cursor: pointer;
  transition: all 0.2s ease;
}

.reward-btn-secondary:hover {
  background: var(--purple);
  color: white;
}

/* --- 宠物CSS样式 --- */
.pet-wrapper {
  display: none;
  flex-direction: column;
  align-items: center;
  animation: petBounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pet-wrapper.visible {
  display: flex;
}

@keyframes petBounceIn {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.pet-sprite {
  font-size: 100px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.2));
  user-select: none;
}

.pet-sprite:hover {
  transform: scale(1.15) rotate(-5deg);
}

.pet-sprite:active {
  transform: scale(0.9);
}

.pet-bubble {
  background: var(--white);
  border-radius: 16px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-top: 6px;
  box-shadow: 0 4px 12px var(--shadow);
  position: relative;
  animation: bubblePop 0.3s ease;
  white-space: nowrap;
  max-width: 200px;
  text-align: center;
}

.pet-bubble::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--white);
}

/* --- 飘分动画 --- */
.floating-score {
  position: absolute;
  font-size: 28px;
  font-weight: 900;
  pointer-events: none;
  animation: floatUp 0.9s ease forwards;
  z-index: 200;
}

.floating-score.positive { color: var(--green); }
.floating-score.negative { color: var(--primary); }

@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.4); }
}

/* --- AI探索入口 --- */
.ai-explore-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  text-decoration: none;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
  transition: all 0.2s ease;
}

.ai-explore-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.ai-explore-link:active {
  transform: translateY(0);
}

/* --- 响应式 --- */
@media (max-width: 480px) {
  .score-value { font-size: 44px; }
  .question-text { font-size: 30px; }
  .game-panel[data-type="chinese"] .question-text { font-size: 56px; }
  .option-btn { font-size: 15px; padding: 12px 8px; }
}
