:root {
  --bg: #fdf6ec;
  --card: #ffffff;
  --ink: #2f2a26;
  --muted: #8a7f74;
  --accent: #e07a3f;
  --accent-soft: #f6d9c5;
  --kid: #3b7dd8;
  --ai: #f0eada;
  --good: #4a9d5b;
  --line: #ece2d4;
  --shadow: 0 4px 14px rgba(80, 60, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 20px; margin: 0; }
header .sub { color: var(--muted); font-size: 13px; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* 每日連續紀錄：今天還沒練是半透明，練過就亮起來 */
.streak {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 12px;
  opacity: .5;
}
.streak.today-done { opacity: 1; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  transition: transform .06s ease, box-shadow .15s ease, background .15s;
}
button:active { transform: scale(0.97); }

.btn-ghost {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}

main { max-width: 1000px; margin: 0 auto; padding: 20px; }

/* ---- 設定面板 ---- */
#settings {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
#settings.hidden { display: none; }
#settings label { display: block; font-weight: 600; margin: 10px 0 4px; font-size: 14px; }
#settings input, #settings select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
}
#settings .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---- 場景選單 ---- */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.scene-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.scene-card .emoji { font-size: 42px; }
.scene-card .name { font-weight: 700; margin-top: 6px; }
.scene-card .goal { color: var(--muted); font-size: 12px; margin-top: 4px; }
.scene-card:hover { box-shadow: 0 6px 18px rgba(80,60,40,.14); }

/* ---- 對話畫面 ---- */
.play { display: grid; grid-template-columns: 1fr 280px; gap: 18px; }
@media (max-width: 760px){ .play { grid-template-columns: 1fr; } }

.play-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.play-top .task { font-size: 14px; color: var(--muted); }
.play-top .task b { color: var(--accent); }

.stage-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ---- 舞台：場景背景 + 卡通角色 ---- */
.stage {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 380px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--stage-from, #fdf6ec) 0%, var(--stage-to, #f6e7d3) 68%, var(--stage-ground, #e8d2b4) 68%);
}
.stage .prop {
  position: absolute;
  font-size: 44px;
  opacity: .9;
  filter: drop-shadow(0 3px 4px rgba(80,60,40,.15));
  user-select: none;
}

.char-wrap {
  position: absolute;
  bottom: 0;
  left: 66%;
  width: 180px;
  margin-left: -90px;
  transition: transform .3s ease;
}
.char-wrap.listening { transform: rotate(-4deg) translateY(2px); }
.char { width: 100%; display: block; animation: float 3.4s ease-in-out infinite; }

/* 待機：輕輕呼吸浮動 */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* 眨眼（SVG transform 需要 fill-box 基準） */
.char .eye, .char .mouth, .char .arm { transform-box: fill-box; transform-origin: center; }
.char .eye { animation: blink 4.2s infinite; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.08); } }

/* 講話：嘴巴開合 + 右手揮 */
.char-wrap.talking .mouth { animation: talk .22s ease-in-out infinite alternate; }
@keyframes talk { from { transform: scaleY(.45); } to { transform: scaleY(1.55); } }
.char-wrap.talking .arm-r { transform-origin: top center; animation: wave .6s ease-in-out infinite alternate; }
@keyframes wave { from { transform: rotate(0deg); } to { transform: rotate(-14deg); } }

/* 角色名牌 */
.char-name {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(255,255,255,.82);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

/* 舞台漫畫氣泡：AI 最新一句（雙語、可點重播、左偏不蓋角色臉） */
.stage-bubble {
  position: absolute;
  top: 14px;
  left: 36%;
  transform: translateX(-50%);
  max-width: min(420px, 62%);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 10px 14px;
  line-height: 1.45;
  box-shadow: 0 4px 0 rgba(47,42,38,.18);
  z-index: 2;
  cursor: pointer;
}
.stage-bubble:hover { box-shadow: 0 5px 0 rgba(47,42,38,.26); }
.sb-main { font-size: 15px; font-weight: 700; }
.sb-zh { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; border-top: 1px dashed var(--line); padding-top: 3px; }
.stage-bubble::after {
  content: "";
  position: absolute;
  bottom: -12px;
  left: 62%;
  margin-left: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid var(--ink);
}
.stage-bubble.thinking { color: var(--muted); font-weight: 400; }

/* 雲端語音生成中：氣泡尾端的脈動喇叭，表示「正在開口」 */
.stage-bubble.voice-loading::after {
  content: " 🔊";
  display: inline-block;
  animation: pulse 0.8s infinite;
}

/* 對話紀錄（摺疊） */
.history {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
}
.history summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.history .messages { max-height: 200px; margin-top: 8px; padding: 4px 2px; }

.messages { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

/* 對話列：頭像 + 泡泡 */
.msg-row { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.msg-row.ai { align-self: flex-start; }
.msg-row.kid { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar { font-size: 22px; line-height: 1.2; flex: none; }

.bubble { max-width: 80%; padding: 8px 12px; border-radius: 16px; font-size: 14px; }
.msg-row .bubble { max-width: 100%; }
.bubble.ai { background: var(--ai); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.kid { background: var(--kid); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .zh { display:block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.bubble.kid .zh { color: #dfe9fb; }
.bubble.sys { align-self: center; background: transparent; color: var(--muted); font-size: 13px; }

.composer {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center;
}
/* 手機窄屏：麥克風按鈕獨佔一列（文字長），打字框換行 */
@media (max-width: 560px) {
  .composer { flex-wrap: wrap; }
  .mic-btn { width: 100%; }
  .composer input { min-width: 0; }
  /* 舞台手機適配：氣泡縮、角色縮，垂直錯開不蓋臉 */
  .stage { min-height: 330px; }
  .stage-bubble { left: 44%; max-width: 80%; }
  .sb-main { font-size: 14px; }
  .char-wrap { left: 62%; width: 140px; margin-left: -70px; }
  /* header 瘦身成單行——擠到換行會變超高、蓋住下面的按鈕吃掉點擊 */
  header { padding: 8px 10px; gap: 6px; }
  header h1 { font-size: 15px; white-space: nowrap; }
  header .sub { display: none; }
  .header-right { gap: 5px; flex: none; }
  .btn-ghost { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
  .streak { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
}

/* 「你可以說」建議列（零基礎鷹架） */
.suggest-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #eef6ee;
  border: 1.5px dashed var(--good);
  border-radius: 14px;
  padding: 10px 14px;
}
.suggest-bar.hidden { display: none; }
.suggest-label { font-size: 13px; font-weight: 700; color: var(--good); white-space: nowrap; }
.suggest-btn {
  background: var(--card);
  border: 1.5px solid var(--good);
  color: var(--ink);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 15px;
  font-weight: 700;
}
.suggest-btn:hover { background: #e3f2e6; }
.suggest-hint { font-size: 11px; color: var(--muted); }
.mic-btn {
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  padding: 14px 20px; border-radius: 14px; white-space: nowrap;
}
.mic-btn.listening { background: #c0392b; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }
.composer input {
  flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 15px;
}
.composer .send { background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 12px 16px; }

/* ---- 進度側欄 ---- */
.side { display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.chunk { padding: 8px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.chunk:hover .en { color: var(--accent); }
.dex-card { cursor: pointer; }
.chunk:last-child { border-bottom: none; }
.chunk .en { font-weight: 600; font-size: 14px; }
.chunk .zh { color: var(--muted); font-size: 12px; }
.chunk .meter { display: flex; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.chunk.spoken .en, .chunk.mastered .en { color: var(--good); }
.chunk .stars { letter-spacing: 1px; }

/* 熟練度小標籤：聽過 → 說過 → 熟練 */
.lv-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  white-space: nowrap;
  vertical-align: middle;
  background: var(--bg);
  color: var(--muted);
}
.lv-badge.spoken { background: #e3f2e6; color: var(--good); }
.lv-badge.mastered { background: #fdf0c2; color: #a8772a; }

/* 場景卡片上的進度 */
.card-progress {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 3px 8px;
  display: inline-block;
}
.card-progress.done { background: #fdf0c2; color: #a8772a; }
.card-progress.due { background: #fde8e3; color: #c0512f; }

/* 圖鑑「今日複習」區 */
.dex-card.due { border-color: #e07a3f; background: #fff6f0; }
.dex-due h3 { color: var(--accent); }

/* 頭像選擇 */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.avatar-opt {
  font-size: 24px;
  padding: 6px 10px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 12px;
}
.avatar-opt.sel { border-color: var(--accent); background: var(--accent-soft); }

.parent-tip { font-size: 12px; color: var(--muted); background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; }

/* ---- 語言切換 tab ---- */
.lang-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.lang-tab {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}
.lang-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* 複習債橫幅：到期句太多時先還債 */
.review-banner {
  grid-column: 1 / -1;
  background: #fde8e3;
  border: 1.5px dashed #c0512f;
  color: #8a3a20;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
}

/* ---- 場景卡：第幾幕 ---- */
.card-acts { margin-top: 6px; font-size: 11px; color: var(--muted); }

/* ---- 句子圖鑑 ---- */
.dex-stats { text-align: center; margin: 8px 0 18px; }
.dex-big { font-size: 44px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.dex-big .dex-total { font-size: 22px; color: var(--muted); font-weight: 600; }
.dex-sub { color: var(--muted); font-size: 13px; }
.dex-scene { margin-bottom: 20px; }
.dex-scene h3 { font-size: 15px; margin: 0 0 8px; }
.dex-count { color: var(--muted); font-size: 12px; font-weight: 500; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.dex-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.dex-card .dex-en { font-weight: 700; font-size: 14px; }
.dex-card .dex-zh { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dex-card .dex-lv { font-size: 11px; margin-top: 6px; font-weight: 600; }
.dex-card.bronze { border-color: #c89b6a; }
.dex-card.bronze .dex-lv { color: #a8773f; }
.dex-card.silver { border-color: #9fa8b3; background: #fbfcfe; }
.dex-card.silver .dex-lv { color: #6b7683; }
.dex-card.gold { border-color: #d4af37; background: #fffaf0; box-shadow: 0 4px 14px rgba(212, 175, 55, .25); }
.dex-card.gold .dex-lv { color: #a8772a; }
.dex-card.none { border-style: dashed; opacity: .75; background: var(--bg); }
.dex-card.none .dex-q { font-size: 26px; font-weight: 800; color: var(--muted); }
.dex-card.none .dex-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dex-card.none .dex-lv { color: var(--accent); }

/* ---- Toast 通知 ---- */
#toasts { position: fixed; top: 70px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .3s, transform .3s;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateX(0); }

/* ---- 任務完成撒花 ---- */
.confetti {
  position: absolute;
  top: -36px;
  z-index: 3;
  animation: confetti-fall 2.6s ease-in forwards;
  pointer-events: none;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(440px) rotate(320deg); opacity: 0; }
}

.back { color: var(--accent); background: none; padding: 0; font-weight: 600; font-size: 14px; }
.hidden { display: none; }

/* ---- 熱身關：全螢幕彈窗（蓋住 header 與下方麥克風，杜絕點錯/被蓋）---- */
.warmup {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(253, 246, 236, .96);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
/* display:flex 會以同權重蓋掉全域 .hidden 的 display:none——必須顯式覆寫，否則卡片永遠關不掉 */
.warmup.hidden { display: none; }
.warmup-box {
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  max-width: 420px; width: 100%;
  max-height: calc(100% - 12px); /* 不超過舞台高度——超過會被 overflow:hidden 裁掉、按鈕就點不到 */
  overflow-y: auto;
}
.warmup-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.warmup-box h3 { margin: 0; font-size: 15px; }
.warmup-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.warmup-row.ok { opacity: .75; }
.warmup-row .wlabel { flex: 1; min-width: 0; }
.warmup-row .wen { font-weight: 700; font-size: 14px; }
.warmup-row .wzh { font-size: 12px; color: var(--muted); }
.wbtn { background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 8px 10px; border-radius: 10px; font-size: 13px; white-space: nowrap; }
.wbtn.wtry { background: var(--accent); color: #fff; }
#warmupSkip { white-space: nowrap; flex: none; }

/* ---- 首次開啟引導 ---- */
#onboarding { min-height: 78vh; display: flex; align-items: center; justify-content: center; }
#onboarding.hidden { display: none; }
.ob-step { text-align: center; max-width: 560px; animation: ob-in .45s ease; }
@keyframes ob-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.ob-chars { display: flex; justify-content: center; gap: 4px; margin-bottom: 6px; }
.ob-char { width: 108px; }
.ob-char svg { width: 100%; display: block; }
.ob-char:nth-child(2) { transform: translateY(8px); }
.ob-title { font-size: 26px; margin: 8px 0 6px; letter-spacing: .5px; }
.ob-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.ob-cta {
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 800;
  padding: 14px 38px; border-radius: 16px;
  box-shadow: 0 6px 16px rgba(224,122,63,.35);
}
.ob-cta:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(224,122,63,.42); }
.ob-langs { display: flex; gap: 14px; justify-content: center; margin: 18px 0 10px; flex-wrap: wrap; }
.ob-lang {
  background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  padding: 22px 26px; width: 220px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  box-shadow: var(--shadow);
}
.ob-lang:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(80,60,40,.14); }
.ob-lang .ob-flag { font-size: 40px; }
.ob-lang b { font-size: 17px; }
.ob-lang small { color: var(--muted); font-size: 12px; }
.ob-hint { color: var(--muted); font-size: 12px; }
.ob-avatars { justify-content: center; margin: 14px 0 22px; }

/* ===== 視覺打磨（去土砲感）===== */

/* 舞台層次：陽光斑 + 柔光，背景不再是死板漸層 */
.stage::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 320px 200px at 78% 8%, rgba(255,255,255,.5), transparent 65%),
    radial-gradient(ellipse 220px 140px at 12% 22%, rgba(255,255,255,.32), transparent 70%);
  pointer-events: none;
}
/* 角色腳下陰影：立刻有「站在地上」的立體感 */
.char-wrap::after {
  content: "";
  position: absolute;
  bottom: 2px; left: 50%;
  width: 130px; height: 16px;
  margin-left: -65px;
  background: radial-gradient(ellipse, rgba(60,40,20,.22), transparent 70%);
  border-radius: 50%;
  z-index: -1;
}
/* 道具更柔和、有遠近 */
.stage .prop { opacity: .85; }
.stage .prop:nth-child(1) { font-size: 50px; }
.stage .prop:nth-child(3) { font-size: 38px; opacity: .7; }

/* 標題字距與層級 */
header h1 { letter-spacing: .5px; }
h2 { letter-spacing: .4px; }
.scene-card .name { font-size: 15px; letter-spacing: .3px; }

/* 場景卡：hover 浮起 + 邊框漸亮 + 進場動畫 */
.scene-card {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  animation: card-in .4s ease backwards;
}
.scene-card:hover { transform: translateY(-3px); border-color: var(--accent-soft); }
.scene-card:nth-child(2) { animation-delay: .03s; } .scene-card:nth-child(3) { animation-delay: .06s; }
.scene-card:nth-child(4) { animation-delay: .09s; } .scene-card:nth-child(5) { animation-delay: .12s; }
.scene-card:nth-child(6) { animation-delay: .15s; } .scene-card:nth-child(7) { animation-delay: .18s; }
.scene-card:nth-child(8) { animation-delay: .21s; } .scene-card:nth-child(n+9) { animation-delay: .24s; }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 場景 emoji 微互動 */
.scene-card .emoji { transition: transform .18s ease; display: inline-block; }
.scene-card:hover .emoji { transform: scale(1.12) rotate(-4deg); }

/* 圖鑑金卡：流光質感 */
.dex-card { transition: transform .15s ease, box-shadow .15s ease; }
.dex-card:hover { transform: translateY(-2px); }
.dex-card.gold {
  background: linear-gradient(135deg, #fffaf0 0%, #fdf3d5 45%, #fffaf0 60%);
  position: relative; overflow: hidden;
}
.dex-card.gold::after {
  content: "";
  position: absolute; top: -60%; left: -30%;
  width: 40%; height: 220%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.75), transparent);
  transform: rotate(18deg);
  animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine { 0%, 60%, 100% { left: -40%; } 30% { left: 130%; } }

/* 舞台氣泡進場 */
.stage-bubble { animation: bubble-pop .25s ease backwards; }
@keyframes bubble-pop { from { opacity: 0; transform: translateX(-50%) scale(.92); } to { opacity: 1; transform: translateX(-50%) scale(1); } }

/* 對話畫面整體淡入 */
#playView { animation: ob-in .35s ease; }

/* 按鈕統一手感 */
.mic-btn { box-shadow: 0 4px 12px rgba(224,122,63,.3); }
.mic-btn:hover { box-shadow: 0 6px 16px rgba(224,122,63,.4); transform: translateY(-1px); }
.suggest-btn:active, .wbtn:active { transform: scale(.96); }

/* toast 更精緻 */
.toast { backdrop-filter: blur(4px); background: rgba(47,42,38,.92); }

/* ---- 🌙 睡前小故事 ---- */
.story-card {
  background: linear-gradient(170deg, #2b3158 0%, #3a3f6e 55%, #4a4480 100%);
  border-radius: 20px;
  padding: 24px 22px;
  color: #f2efff;
  box-shadow: 0 10px 30px rgba(43, 49, 88, .4);
  max-width: 640px;
  margin: 8px auto;
  position: relative;
  overflow: hidden;
}
.story-card::before {
  content: "✦   ✧     ✦    ✧  ✦";
  position: absolute; top: 10px; left: 0; right: 0;
  text-align: center; color: rgba(255,255,255,.3); font-size: 12px; letter-spacing: 8px;
}
.story-card h2 { margin: 6px 0 2px; font-size: 22px; letter-spacing: 1px; }
.story-sub { color: #bdb8e8; font-size: 13px; margin: 0 0 16px; }
.story-line {
  padding: 9px 12px; border-radius: 12px; margin-bottom: 6px;
  cursor: pointer; transition: background .25s, opacity .25s;
  opacity: .55;
}
.story-line .st { font-size: 17px; font-weight: 600; }
.story-line .sz { font-size: 12px; color: #bdb8e8; }
.story-line.active { background: rgba(255,255,255,.14); opacity: 1; }
.story-line.done { opacity: .8; }
.story-line:hover { background: rgba(255,255,255,.08); opacity: 1; }
.story-loading { color: #bdb8e8; padding: 22px 0; text-align: center; animation: pulse 1.6s infinite; }
.story-controls { display: flex; gap: 10px; margin-top: 16px; }
.story-btn {
  background: rgba(255,255,255,.14); color: #f2efff;
  padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
}
.story-btn:hover { background: rgba(255,255,255,.22); }
.story-entry {
  background: linear-gradient(160deg, #2b3158, #4a4480);
  color: #f2efff; border: none;
}
.story-entry .name { color: #fff; }
.story-entry .goal { color: #bdb8e8 !important; }

/* ---- 👨‍👩‍👧 家長共玩提示 ---- */
.coach-tip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}
.coach-tip summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.coach-tip p { margin: 8px 0 0; }
.coach-quote {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #8a5a2e;
}

/* ---- 🌱 單詞樂園 ---- */
/* 雙軌入口分頁（首頁玩法切換：夠大、一眼懂，小孩手指也好按） */
.mode-tabs { display: flex; gap: 10px; margin: 2px 0 16px; }
.mode-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.mode-tab b { font-size: 16px; color: var(--ink); }
.mode-tab small { font-size: 12px; color: var(--muted); }
.mode-tab.active { border-color: var(--accent); background: var(--accent-soft); }
.mode-tab.active b { color: var(--accent); }
.mode-tab:hover { border-color: var(--accent); }

/* 階段膠囊：👂 聽聲選圖 → 🗣️ 看圖開口 → 💬 串成小句 */
.vp-phases { display: flex; align-items: center; gap: 6px; margin: 12px 0 6px; flex-wrap: wrap; }
.vp-phase {
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.vp-phase.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.vp-phase.done { border-color: #bcd9a8; background: #eef7e4; color: #5f8d43; }
.vp-arrow { color: var(--muted); font-size: 12px; }

/* 題目進度點 */
.vp-progress { display: flex; gap: 5px; margin: 4px 0 10px; }
.vp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.vp-dot.now { background: var(--accent); transform: scale(1.25); }
.vp-dot.done { background: #9ec77f; }

/* 遊戲區（confetti 是 absolute，這裡要當它的定位容器） */
.vp-area {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 16px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 320px;
  justify-content: center;
}

/* 大大的「再聽一次」 */
.vp-play {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
}
.vp-play:hover { filter: brightness(.97); }

/* 聽聲選圖：2×2 大圖卡 */
.vp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 170px));
  gap: 14px;
  justify-content: center;
}
.vp-card {
  background: #fffdf8;
  border: 2px solid var(--line);
  border-radius: 18px;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.vp-card:hover { transform: translateY(-2px); border-color: var(--accent-soft); }
.vp-card .vp-emoji { font-size: 52px; line-height: 1; }
.vp-card.right { border-color: #7fb95d; background: #f1f9e8; animation: vp-pop .35s ease; }
.vp-card.wrong { border-color: #e0b4a4; background: #fdf1ec; opacity: .55; animation: vp-shake .4s ease; }
.vp-card:disabled { cursor: default; }
.vp-reveal { font-size: 15px; font-weight: 700; color: #4a7d2e; display: flex; flex-direction: column; align-items: center; }
.vp-reveal small { font-weight: 500; color: var(--muted); font-size: 12px; }
@keyframes vp-pop { 0% { transform: scale(1); } 45% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes vp-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* 看圖開口 / 串成小句 */
.vp-hero { font-size: 92px; line-height: 1.1; }
.vp-hero-sm { font-size: 56px; }
.vp-word { font-size: 30px; font-weight: 800; color: var(--ink); text-align: center; }
.vp-word.vp-sent { font-size: 23px; line-height: 1.45; max-width: 560px; }
.vp-hl { color: var(--accent); }
.vp-zh { font-size: 15px; color: var(--muted); text-align: center; }
.vp-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }

/* 完成頁 */
.vp-done { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.vp-done-big { font-size: 64px; }
.vp-done h3 { margin: 0; font-size: 22px; }
.vp-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; }
.vp-chip {
  background: var(--accent-soft);
  color: #8a5a2e;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 600;
}
.vp-back-menu { margin-top: 2px; }

/* 手機：圖卡縮一點、字級收斂（390px 實測基準） */
@media (max-width: 560px) {
  .mode-tab b { font-size: 14.5px; }
  .mode-tab small { font-size: 11px; }
  .vp-grid { grid-template-columns: repeat(2, 1fr); width: 100%; gap: 10px; }
  .vp-card .vp-emoji { font-size: 44px; }
  .vp-hero { font-size: 72px; }
  .vp-word { font-size: 25px; }
  .vp-word.vp-sent { font-size: 19px; }
  .vp-actions { width: 100%; }
  .vp-actions .mic-btn { flex: 1; }
}

/* ---- 圖鑑：家長視角（卡點偵測）---- */
.dex-coach-tip { font-size: 13px; color: var(--muted); margin: 4px 0 10px; line-height: 1.6; }
.dex-card.stuck { border-color: #e8c89a; background: #fdf7ec; }

/* ---- ☁️ 進度同步設定 ---- */
.sync-row { display: flex; gap: 8px; align-items: center; }
.sync-row input { flex: 1; }
.sync-status { font-size: 12px; color: #5f8d43; margin-top: 4px; }
