/* 小鹿英语 v1.0 — 儿童友好样式 */
:root {
  --bg: #FFF8EC;
  --ink: #3A3226;
  --sub: #8A7E6A;
  --orange: #FF8A3D;
  --orange-deep: #E86A1C;
  --teal: #2AB3A6;
  --teal-deep: #1C8C81;
  --purple: #9B7EDE;
  --pink: #FF6B9D;
  --yellow: #FFC53D;
  --card: #FFFFFF;
  --shadow: 0 6px 0 rgba(58, 50, 38, .12);
  --radius: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; touch-action: manipulation; }

#app { position: relative; width: 100%; height: 100dvh; }

/* ───────── 屏幕切换 ───────── */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 16px calc(12px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: pop-in .25s ease; }
@keyframes pop-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }

/* ───────── 顶栏 ───────── */
.screen-bar {
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; margin-bottom: 6px;
}
.screen-bar h2 { font-size: 24px; font-weight: 800; flex: 1; text-align: center; }
.back-btn {
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 24px; flex-shrink: 0;
}
.back-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(58,50,38,.12); }
.bar-spacer { width: 56px; flex-shrink: 0; }
.round-chip {
  background: var(--card); border-radius: 999px; padding: 8px 16px;
  font-size: 18px; font-weight: 700; box-shadow: var(--shadow); flex-shrink: 0;
}
.screen-hint { text-align: center; color: var(--sub); font-size: 17px; margin-bottom: 12px; }

.star-chip {
  background: var(--card); border-radius: 999px; padding: 8px 18px;
  font-size: 20px; font-weight: 800; box-shadow: var(--shadow);
}
.star-chip.small { font-size: 16px; padding: 6px 14px; }

/* ───────── 首页 ───────── */
#screen-home { justify-content: center; }
.home-header { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.mascot { font-size: 72px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.home-title h1 { font-size: 34px; font-weight: 900; letter-spacing: 2px; }
.home-title .subtitle { color: var(--sub); font-size: 16px; margin-top: 2px; }
.home-header .star-chip { margin-left: auto; }

.tile-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  margin: 18px 0 10px;
}
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 140px; border-radius: var(--radius);
  box-shadow: var(--shadow); color: #fff;
  transition: transform .08s;
}
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(58,50,38,.12); }
.tile-icon { font-size: 56px; line-height: 1; }
.tile-label { font-size: 24px; font-weight: 800; letter-spacing: 2px; }
.tile-ear { background: linear-gradient(160deg, #35C2B5, var(--teal-deep)); }
.tile-speak { background: linear-gradient(160deg, #FFA35D, var(--orange-deep)); }
.tile-games { background: linear-gradient(160deg, #B493F0, #7451C9); }
.tile-rewards { background: linear-gradient(160deg, #FF8FB1, #E84E7F); }

.home-footer { text-align: center; margin-top: 10px; }
.home-tip { color: var(--sub); font-size: 16px; }

.parent-corner {
  position: absolute; right: 14px; bottom: calc(14px + var(--safe-bottom));
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(58, 50, 38, .07); font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}

/* ───────── 通用卡片网格 ───────── */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; padding-bottom: 14px;
}
.pack-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 10px 16px; min-height: 130px; justify-content: center;
  transition: transform .08s;
}
.pack-card:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(58,50,38,.12); }
.pack-icon { font-size: 52px; line-height: 1; }
.pack-name { font-size: 20px; font-weight: 800; }
.pack-sub { font-size: 14px; color: var(--sub); }
.pack-card.lv-aa { border-top: 6px solid #3CB471; }
.pack-card.lv-a { border-top: 6px solid #E8A200; }
.pack-card.lv-b { border-top: 6px solid #E87A2C; }
.pack-card.lv-c { border-top: 6px solid #8C5FD9; }
.pack-card.lv-phonics { border-top: 6px solid #2AB3A6; }
.pack-card.lv-books { border-top: 6px solid #FF6B9D; }
.pack-card.theme { border-top: 6px solid #3CB471; }

/* ── 梯级分组标题 ── */
.pack-group { margin-bottom: 6px; }
.group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 800; color: var(--ink);
  margin: 14px 0 10px; padding: 0 4px;
}
.group-title .lv-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.group-title.lv-aa .lv-dot { background: #3CB471; }
.group-title.lv-a .lv-dot { background: #E8A200; }
.group-title.lv-b .lv-dot { background: #E87A2C; }
.group-title.lv-c .lv-dot { background: #8C5FD9; }
.group-title.lv-phonics .lv-dot { background: #2AB3A6; }
.group-title.lv-books .lv-dot { background: #FF6B9D; }
.group-count { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--sub); }

/* ───────── 睡眠定时 ───────── */
.sleep-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 6px 0 14px; padding: 12px 14px;
  background: rgba(58,50,38,.05); border-radius: 18px;
}
.sleep-label { font-size: 17px; font-weight: 700; }
.sleep-options { display: flex; gap: 8px; flex-wrap: wrap; }
.sleep-options button {
  padding: 10px 16px; border-radius: 999px; background: var(--card);
  font-size: 16px; font-weight: 700; box-shadow: 0 3px 0 rgba(58,50,38,.10);
}
.sleep-options button.active { background: var(--teal); color: #fff; }

/* ───────── 磨耳朵播放器 ───────── */
#screen-earplayer { align-items: center; }
#screen-earplayer .screen-bar { align-self: stretch; }
.ear-stage {
  flex: 1; width: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; min-height: 0;
}
.ear-emoji { font-size: clamp(120px, 30vmin, 220px); line-height: 1.1; transition: transform .2s; }
.ear-emoji.bounce { animation: bounce .5s ease; }
@keyframes bounce { 0%{transform:scale(1)} 40%{transform:scale(1.15)} 100%{transform:scale(1)} }
.ear-caption { font-size: clamp(34px, 7vmin, 52px); font-weight: 900; letter-spacing: 2px; }
.ear-caption .w { display: inline-block; transition: color .1s; }
.ear-caption .w.on { color: var(--orange-deep); transform: scale(1.12); }
.ear-sub { font-size: clamp(18px, 3.4vmin, 24px); color: var(--sub); font-weight: 600; }
.ear-progress { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; justify-content: center; }
.ear-progress span { width: 12px; height: 12px; border-radius: 50%; background: rgba(58,50,38,.15); }
.ear-progress span.done { background: var(--teal); }
.ear-progress span.cur { background: var(--orange); transform: scale(1.25); }
.ear-controls { display: flex; gap: 22px; align-items: center; margin-bottom: 8px; }
.ctrl-btn {
  width: 68px; height: 68px; border-radius: 50%; background: var(--card);
  box-shadow: var(--shadow); font-size: 26px;
}
.ctrl-btn.big { width: 92px; height: 92px; font-size: 38px; background: var(--orange); color: #fff; }
.ctrl-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(58,50,38,.12); }
.ear-tip { color: var(--sub); font-size: 15px; margin-bottom: 8px; }

/* ───────── 跟读卡片 ───────── */
.speak-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; min-height: 0;
}
.speak-emoji { font-size: clamp(90px, 22vmin, 160px); line-height: 1.15; }
.speak-word { font-size: clamp(40px, 9vmin, 60px); font-weight: 900; letter-spacing: 3px; }
.speak-sentence { font-size: clamp(20px, 4.4vmin, 28px); color: var(--teal-deep); font-weight: 700; }
.word-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; min-height: 40px; }
.word-chips span {
  padding: 7px 14px; border-radius: 999px; font-size: 18px; font-weight: 700;
  background: rgba(58,50,38,.07); transition: all .2s;
}
.word-chips span.good { background: #C9F0DD; color: #14795A; }
.word-chips span.close { background: #FFE7B3; color: #9A6A00; }
.word-chips span.miss { background: #FFD9D9; color: #B3382E; }
.speak-result { text-align: center; margin: 4px 0; }
.result-stars { font-size: 40px; }
.result-msg { font-size: 20px; font-weight: 800; color: var(--orange-deep); }

.speak-controls { display: flex; gap: 14px; justify-content: center; margin: 8px 0; }
.speak-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 130px; min-height: 84px; padding: 8px 18px;
  border-radius: 22px; font-size: 20px; font-weight: 800; color: #fff;
  box-shadow: var(--shadow); transition: transform .08s;
}
.speak-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(58,50,38,.12); }
.speak-btn:disabled { opacity: .45; }
.speak-btn.listen { background: var(--teal); }
.speak-btn.slow { background: #5AA9E6; }
.speak-btn.record { background: var(--orange); min-width: 160px; }
.speak-btn.record.recording { background: #E23B3B; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }
.speak-btn.playmine { background: var(--purple); }
.speak-nav { display: flex; justify-content: center; margin-top: 2px; }
.skip-btn {
  padding: 12px 24px; border-radius: 999px; background: rgba(58,50,38,.08);
  font-size: 17px; font-weight: 700;
}
.speak-micnote { text-align: center; color: var(--sub); font-size: 14px; min-height: 20px; margin-top: 4px; }

/* ───────── 游戏菜单 ───────── */
.game-menu { display: flex; flex-direction: column; gap: 16px; padding-bottom: 14px; }
.game-card {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; text-align: left;
  transition: transform .08s;
}
.game-card:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(58,50,38,.12); }
.game-icon { font-size: 52px; line-height: 1; }
.game-name { font-size: 22px; font-weight: 800; display: block; }
.game-desc { font-size: 15px; color: var(--sub); }
.game-card > div { flex: 1; } /* no-op guard */

/* ───────── 游戏1 听音选图 ───────── */
.listen-question { text-align: center; margin: 8px 0 14px; }
.replay-btn {
  padding: 14px 28px; border-radius: 999px; background: var(--teal);
  color: #fff; font-size: 20px; font-weight: 800; box-shadow: var(--shadow);
}
.replay-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(58,50,38,.12); }
.listen-hint { color: var(--sub); font-size: 16px; margin-top: 10px; }
.option-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  max-width: 560px; width: 100%; margin: 0 auto; padding-bottom: 10px;
}
.option-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  min-height: 120px; font-size: 64px; display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.option-card:active { transform: scale(.96); }
.option-card.right { animation: pop .4s ease; background: #E4F8EF; }
.option-card.wrong { animation: shake .4s ease; }
@keyframes pop { 0%{transform:scale(1)} 50%{transform:scale(1.12)} 100%{transform:scale(1)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
.game-praise { text-align: center; font-size: 26px; font-weight: 900; min-height: 40px; color: var(--orange-deep); }

/* ───────── 游戏2 拼读积木 ───────── */
.cvc-question { text-align: center; margin: 6px 0 12px; }
.cvc-emoji { font-size: clamp(80px, 18vmin, 130px); line-height: 1.15; }
.cvc-hint { color: var(--sub); font-size: 16px; margin-top: 4px; }
.cvc-slots {
  display: flex; gap: 12px; justify-content: center; margin: 10px 0 18px;
}
.cvc-slots .slot {
  width: clamp(58px, 14vmin, 78px); height: clamp(58px, 14vmin, 78px);
  border-radius: 18px; border: 3px dashed rgba(58,50,38,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(28px, 7vmin, 40px); font-weight: 900; color: var(--teal-deep);
  background: rgba(255,255,255,.6);
}
.cvc-slots .slot.filled { border-style: solid; border-color: var(--teal); background: var(--card); box-shadow: var(--shadow); }
.cvc-tiles { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.cvc-tiles .letter-tile {
  width: clamp(58px, 14vmin, 78px); height: clamp(58px, 14vmin, 78px);
  border-radius: 18px; background: var(--orange); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(28px, 7vmin, 40px); font-weight: 900;
  box-shadow: var(--shadow); transition: transform .1s, opacity .2s;
}
.cvc-tiles .letter-tile:active { transform: scale(.92); }
.cvc-tiles .letter-tile.used { opacity: .25; pointer-events: none; }
.cvc-actions { display: flex; justify-content: center; margin-top: 14px; }

/* ───────── 游戏3 单词泡泡 ───────── */
.bubble-target {
  text-align: center; margin: 6px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.bubble-target-text {
  font-size: clamp(40px, 9vmin, 60px); font-weight: 900; color: var(--purple);
}
.bubble-field {
  position: relative; flex: 1; margin: 4px -4px 10px; min-height: 260px;
  border-radius: 22px; background: rgba(146, 205, 235, .18); overflow: hidden;
}
.bubble {
  position: absolute;
  width: clamp(64px, 15vmin, 92px); height: clamp(64px, 15vmin, 92px);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #FFFFFF, #CFE9F7 60%, #9CCBE8);
  box-shadow: inset -4px -6px 10px rgba(90,140,180,.25), 0 4px 8px rgba(58,50,38,.10);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(20px, 5vmin, 30px); font-weight: 900; color: #2C5D7C;
  animation: floaty 3.2s ease-in-out infinite;
}
.bubble:active { transform: scale(.9); }
.bubble.popped { animation: pop .3s ease forwards; }
.bubble.wrong { animation: shake .35s ease; }
@keyframes floaty { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-14px);} }

/* ───────── 我的奖励 ───────── */
.rewards-hero {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}
.rewards-deer { font-size: 76px; line-height: 1.2; animation: bob 2.4s ease-in-out infinite; }
.rewards-total { font-size: 26px; font-weight: 900; }
.rewards-level { color: var(--sub); font-size: 16px; }
.rewards-sub { font-size: 19px; font-weight: 800; margin: 4px 0 10px; }
.sticker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 12px; padding-bottom: 16px;
}
.sticker-cell {
  aspect-ratio: 1; border-radius: 18px; background: var(--card);
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
  font-size: 44px;
}
.sticker-cell.locked { background: rgba(58,50,38,.05); box-shadow: none; font-size: 30px; opacity: .6; }
.sticker-cell.new { animation: pop .5s ease; }

/* ───────── 家长中心 ───────── */
.parent-gate, .parent-center { max-width: 420px; width: 100%; margin: 0 auto; }
.gate-title { text-align: center; font-size: 20px; font-weight: 800; margin: 10px 0; }
.gate-question { text-align: center; font-size: 26px; font-weight: 800; color: var(--teal-deep); }
.gate-display {
  text-align: center; font-size: 34px; font-weight: 900;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  margin: 12px auto; padding: 10px; min-height: 64px; max-width: 200px; letter-spacing: 4px;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  height: 60px; border-radius: 16px; background: var(--card);
  box-shadow: var(--shadow); font-size: 24px; font-weight: 800;
}
.keypad button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(58,50,38,.12); }
.gate-error { text-align: center; color: #D0453A; font-size: 16px; margin-top: 10px; font-weight: 700; }

.pc-title { font-size: 18px; font-weight: 800; margin: 16px 0 8px; }
.pc-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.pc-stat {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 12px 8px; text-align: center;
}
.pc-stat b { display: block; font-size: 24px; }
.pc-stat span { font-size: 13px; color: var(--sub); }
.pc-week { display: flex; gap: 8px; align-items: flex-end; height: 90px; }
.pc-week .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--sub); }
.pc-week .bar { width: 100%; background: var(--teal); border-radius: 6px 6px 0 0; min-height: 4px; }
.pc-setting {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  font-size: 16px; font-weight: 600;
}
.pc-setting select { font-size: 16px; padding: 6px 10px; border-radius: 10px; border: 1px solid rgba(58,50,38,.2); }
.pc-value { color: var(--sub); }
.pc-actions { display: flex; gap: 10px; margin-top: 14px; }
.pc-actions button {
  flex: 1; padding: 12px; border-radius: 14px; background: var(--teal);
  color: #fff; font-size: 15px; font-weight: 800;
}
.pc-actions button.danger { background: #E2695C; }
.pc-version { text-align: center; color: var(--sub); font-size: 13px; margin: 16px 0 8px; }

/* ───────── 全屏遮罩 ───────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(43, 36, 26, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.overlay.light { background: rgba(255, 248, 236, .96); }
.overlay-card {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 36px 30px; text-align: center; max-width: 380px; width: 100%;
}
.overlay-card h2 { font-size: 26px; font-weight: 900; margin-bottom: 8px; }
.overlay-card p { color: var(--sub); font-size: 17px; }
.break-icon { font-size: 76px; margin-bottom: 10px; animation: bob 2s ease-in-out infinite; }
.break-count { font-size: 56px; font-weight: 900; color: var(--orange-deep); margin-top: 12px; }
.moon-stars { font-size: 34px; margin: 14px 0; }
.limit-parent { margin-top: 14px; padding: 10px 18px; border-radius: 999px; background: rgba(58,50,38,.08); font-size: 14px; color: var(--sub); }
.cheer-box { text-align: center; font-size: 30px; font-weight: 900; animation: pop .45s ease; }
.cheer-box .big { font-size: 80px; display: block; margin-bottom: 10px; }

/* ───────── Toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: calc(40px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(43,36,26,.88); color: #fff; padding: 12px 22px;
  border-radius: 999px; font-size: 16px; font-weight: 600; z-index: 200;
  max-width: 86vw; text-align: center;
}

/* ───────── 平板 / iPad 横屏适配 ───────── */
@media (min-width: 700px) {
  .screen { padding-left: 32px; padding-right: 32px; }
  #screen-home .tile-grid { max-width: 640px; margin-left: auto; margin-right: auto; width: 100%; }
  #screen-home { align-items: center; }
  #screen-home .home-header { width: 640px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); max-width: 980px; margin: 0 auto; width: 100%; }
  .game-menu { max-width: 560px; width: 100%; margin: 0 auto; }
  .option-grid { grid-template-columns: repeat(2, 1fr); max-width: 640px; }
  #screen-earplayer, #screen-speakcard { align-items: center; }
  #screen-earplayer .screen-bar, #screen-speakcard .screen-bar { align-self: stretch; }
  .speak-stage, .ear-stage { max-width: 720px; }
  .sticker-grid { max-width: 720px; margin: 0 auto; width: 100%; }
}
