/* ===== 宝贝乐园 · 可爱风格 ===== */
:root {
  --pink: #ffd6e8;
  --yellow: #fff3b0;
  --green: #c8f7c5;
  --blue: #c3e8ff;
  --purple: #e5d4ff;
  --ink: #5a4a6a;
  --white: #ffffff;
  --radius: 26px;
  --shadow: 0 8px 0 rgba(90, 74, 106, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Baloo 2", "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #bfe9ff 0%, #e8f7ff 45%, #fff0f7 100%);
  min-height: 100vh;
  overflow-x: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== 漂浮装饰 ===== */
.cloud, .rainbow {
  position: fixed;
  font-size: 3rem;
  opacity: 0.85;
  pointer-events: none;
  z-index: 0;
  animation: float 6s ease-in-out infinite;
}
.cloud-1 { top: 6%; left: 5%; animation-delay: 0s; }
.cloud-2 { top: 14%; right: 8%; animation-delay: 1.5s; font-size: 2.4rem; }
.cloud-3 { bottom: 12%; left: 8%; animation-delay: 3s; font-size: 2.6rem; }
.rainbow { top: 4%; right: 20%; font-size: 2.2rem; animation-delay: 2s; }

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

/* ===== 视图切换 ===== */
.view {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ===== 首页 ===== */
.home-header { text-align: center; margin: 5vh 0 4vh; }
.site-title {
  font-family: "ZCOOL KuaiLe", "Baloo 2", sans-serif;
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  color: #ff6fa5;
  text-shadow: 0 3px 0 #ffffff, 0 6px 12px rgba(255, 111, 165, 0.3);
  letter-spacing: 2px;
}
.site-subtitle { margin-top: 8px; font-size: 1.1rem; color: #8a7aa0; }

.adventure-bar {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
  background: rgba(255, 255, 255, 0.88); border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px; padding: 10px 14px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.player-badge { display: flex; align-items: center; gap: 8px; }
.player-badge > span:last-child { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.player-badge small { color: #8a7aa0; font-weight: 700; }
.player-badge strong { color: #ff8b3d; font-size: 1.15rem; }
.player-avatar { font-size: 2rem; animation: bob 2s ease-in-out infinite; }
.mission-box { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.mission-copy { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; }
.mission-copy span { color: #8a7aa0; }
.mission-track, .round-track { height: 9px; border-radius: 99px; background: #ebe5f1; overflow: hidden; }
.mission-track span, .round-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ff8fbd, #ffd45c); transition: width .35s ease; }
.mission-count { grid-row: 1 / 3; grid-column: 2; font-weight: 800; color: #ff6fa5; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(5deg); } }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  flex: 1;
  align-content: center;
}

.menu-card {
  position: relative;
  border: none;
  border-radius: var(--radius);
  padding: 26px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-family: inherit;
  color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: pop-in 0.4s ease backwards;
}
.card-badge { position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.75); color: #856d95; font-size: .72rem; font-weight: 800; }
.card-badge.done { color: #4b9b58; background: #edffe7; }
.menu-card:nth-child(2) { animation-delay: 0.08s; }
.menu-card:nth-child(3) { animation-delay: 0.16s; }
.menu-card:nth-child(4) { animation-delay: 0.24s; }
.menu-card:active { transform: scale(0.94); box-shadow: 0 3px 0 rgba(90, 74, 106, 0.12); }

@keyframes pop-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.card-pink { background: var(--pink); }
.card-yellow { background: var(--yellow); }
.card-green { background: var(--green); }
.card-blue { background: var(--blue); }

.menu-emoji { font-size: 3.4rem; }
.menu-title { font-size: 1.5rem; font-weight: 800; }
.menu-sub { font-size: 0.9rem; color: #8a7aa0; font-weight: 700; }

.home-footer { text-align: center; margin-top: 24px; color: #a794c0; font-size: 1rem; }

/* ===== 子页面头部 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.page-header h2 { font-size: 1.6rem; }

.btn-back, .btn-sound {
  border: none;
  background: var(--white);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-back:active, .btn-sound:active { transform: scale(0.88); }

/* ===== 字母/数字大舞台 ===== */
.letter-stage {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
  margin-bottom: 18px;
}
.big-letter {
  font-size: clamp(4.5rem, 22vw, 8rem);
  font-weight: 800;
  color: #ff6fa5;
  line-height: 1.1;
}
.big-emoji { font-size: clamp(3rem, 14vw, 5rem); margin: 6px 0; line-height: 1.4; word-break: break-all; }
.big-word { font-size: clamp(1.4rem, 6vw, 2rem); font-weight: 700; color: #7a68a0; }

.letter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.number-grid { grid-template-columns: repeat(5, 1fr); }

.letter-btn {
  border: none;
  border-radius: 18px;
  background: var(--white);
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  padding: 12px 0;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(90, 74, 106, 0.1);
  transition: transform 0.1s ease;
}
.letter-btn:active { transform: scale(0.88); }
.letter-btn.active { background: #ffb3d1; color: #fff; }

/* ===== Tab 切换 ===== */
.tab-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 12px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 4px 0 rgba(90, 74, 106, 0.1);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.tab-btn:active { transform: scale(0.95); }
.tab-btn.active { background: #8fd3ff; color: #fff; }
.challenge-tab { color: #d97924; }
.challenge-tab.active { background: linear-gradient(135deg, #ff9ec7, #ffbd59); }

/* ===== 挑战关卡 ===== */
.challenge-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 16px 24px; text-align: center; }
.round-status { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; color: #7a68a0; font-size: .95rem; font-weight: 800; }
.round-track { margin-bottom: 18px; }
.challenge-hero { font-size: 5rem; line-height: 1.15; animation: wiggle 2.4s ease-in-out infinite; }
.challenge-word { font-size: 1.65rem; font-weight: 800; margin: 6px 0 18px; color: #7a68a0; }
.letter-options { flex-wrap: wrap; }
.letter-options .quiz-option { width: 70px; height: 70px; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choice-btn { min-height: 112px; border: none; border-radius: 22px; background: #f7f3fb; box-shadow: 0 5px 0 rgba(90,74,106,.1); font-family: inherit; color: var(--ink); font-size: 1.05rem; font-weight: 800; cursor: pointer; transition: transform .1s ease; }
.choice-btn:active { transform: scale(.94); }
.choice-btn.correct { outline: 5px solid #8be89b; background: #e9ffe7; }
.choice-btn.wrong { animation: shake .4s; outline: 4px solid #ff9c9c; }
.choice-icon { display: block; font-size: 3rem; margin-bottom: 5px; }
.color-choice { width: 54px; height: 54px; display: block; border-radius: 50%; margin: 0 auto 7px; box-shadow: inset 0 -6px 0 rgba(0,0,0,.12); }
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 92% { transform: rotate(-7deg) scale(1.08); } 96% { transform: rotate(7deg) scale(1.08); } }

/* ===== 数一数问答 ===== */
.quiz-stage {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 16px;
  text-align: center;
}
.quiz-question { font-size: 1.5rem; font-weight: 800; margin-bottom: 12px; }
.quiz-emojis { font-size: 2.6rem; min-height: 90px; line-height: 1.5; margin-bottom: 16px; }
.quiz-options { display: flex; gap: 14px; justify-content: center; }
.quiz-option {
  width: 84px;
  height: 84px;
  border: none;
  border-radius: 24px;
  background: var(--yellow);
  font-family: inherit;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(90, 74, 106, 0.12);
  transition: transform 0.1s ease;
}
.quiz-option:active { transform: scale(0.9); }
.quiz-option.correct { background: #8be89b; }
.quiz-option.wrong { background: #ffb3b3; animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.quiz-feedback { margin-top: 14px; font-size: 1.3rem; font-weight: 800; min-height: 1.6em; color: #ff6fa5; }

/* ===== 颜色 / 形状 ===== */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.swatch-btn {
  border: none;
  border-radius: var(--radius);
  padding: 22px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-family: inherit;
  background: var(--white);
  transition: transform 0.1s ease;
}
.swatch-btn:active { transform: scale(0.92); }
.swatch-icon { font-size: 3rem; line-height: 1; }
.swatch-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
}
.swatch-name { font-size: 1.25rem; font-weight: 800; color: var(--ink); }
.swatch-en { font-size: 0.95rem; font-weight: 700; color: #8a7aa0; }

/* ===== 记忆翻牌 ===== */
.game-tip { text-align: center; font-size: 1.15rem; font-weight: 700; margin-bottom: 14px; color: #7a68a0; }
.difficulty-row { display: flex; gap: 7px; margin-bottom: 10px; }
.difficulty-btn { flex: 1; border: 0; border-radius: 99px; padding: 9px 5px; background: rgba(255,255,255,.8); color: var(--ink); font-family: inherit; font-weight: 800; cursor: pointer; }
.difficulty-btn.active { background: #ffb3d1; color: #fff; }
.game-hud { display: flex; justify-content: center; gap: 28px; margin-bottom: 7px; font-size: 1.05rem; }
.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.mem-card {
  aspect-ratio: 3 / 4;
  perspective: 600px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.mem-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s;
  transform-style: preserve-3d;
}
.mem-card.flipped .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: 2.6rem;
  box-shadow: 0 5px 0 rgba(90, 74, 106, 0.12);
}
.mem-front { background: linear-gradient(135deg, #ffb3d1, #c3e8ff); }
.mem-front::after { content: "❓"; font-size: 2rem; }
.mem-back { background: var(--white); transform: rotateY(180deg); }
.mem-card.matched .mem-back { background: #d9f7c0; }

.game-win { text-align: center; margin-top: 22px; }
.win-text { font-size: 1.5rem; font-weight: 800; color: #ff6fa5; margin-bottom: 14px; animation: pop-in 0.4s ease; }
.result-stars { font-size: 2rem; letter-spacing: 5px; }
.result-copy { color: #7a68a0; font-weight: 700; margin: 4px 0 14px; }
.big-action-btn {
  border: none;
  border-radius: 999px;
  background: #ff9ec7;
  color: #fff;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 14px 40px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(214, 90, 140, 0.5);
  transition: transform 0.1s ease;
}
.big-action-btn:active { transform: scale(0.93); }

/* ===== 星星奖励动画 ===== */
#stars-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  overflow: hidden;
}
.star-burst {
  position: absolute;
  font-size: 1.8rem;
  animation: burst 1s ease-out forwards;
}
.reward-toast { position: fixed; z-index: 100; top: 18px; left: 50%; transform: translate(-50%, -120px); background: #fff; color: #7a4a20; border: 3px solid #ffd45c; border-radius: 99px; padding: 10px 20px; box-shadow: 0 8px 24px rgba(90,74,106,.2); font-size: 1.05rem; font-weight: 800; opacity: 0; transition: transform .35s ease, opacity .35s ease; white-space: nowrap; }
.reward-toast.show { transform: translate(-50%, 0); opacity: 1; }
@keyframes burst {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 0; }
}

/* ===== 小屏微调 ===== */
@media (max-width: 380px) {
  .letter-grid { grid-template-columns: repeat(5, 1fr); }
  .menu-emoji { font-size: 2.8rem; }
  .menu-title { font-size: 1.3rem; }
}

@media (max-width: 520px) {
  .home-header { margin: 2.5vh 0 2vh; }
  .adventure-bar { grid-template-columns: 1fr; }
  .player-badge { justify-content: center; }
  .menu-grid { gap: 12px; }
  .menu-card { padding: 20px 8px; }
  .mission-copy { font-size: .76rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
