/* 朵拉九九乘法冒險島 — DORA 兒童品牌系統 */
:root {
  --bg: #FAF8F3;
  --card: #FFFFFF;
  --border: #EAE6DC;
  --text: #4A4A4A;
  --text-light: #8A8A8A;
  --yellow: #FCE89A; --yellow-l: #FEF4D0; --yellow-d: #8A6B00;
  --blue: #8DD3E8;   --blue-l: #C9EBF5;   --blue-d: #1F5C73;
  --mint: #8FCFC8;   --mint-l: #CCE9E5;   --mint-d: #2D6660;
  --pink: #E89BAE;   --pink-l: #F4CFD9;   --pink-d: #8A2F47;
  --radius: 20px;
  --shadow: 0 4px 14px rgba(74, 74, 74, .10);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: 'Noto Sans TC', -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.view { display: none; max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; min-height: 100vh; }
.view.active { display: block; animation: viewIn .25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── 按鈕 ── */
.btn {
  border-radius: 999px; font-weight: 700; font-size: 1.05rem;
  padding: 12px 22px; box-shadow: var(--shadow);
  transition: transform .12s ease; user-select: none;
}
.btn:active { transform: scale(.95); }
.btn-lg { font-size: 1.15rem; padding: 15px 26px; }
.btn-full { width: 100%; }
.btn-yellow { background: var(--yellow); color: var(--yellow-d); }
.btn-blue   { background: var(--blue);   color: var(--blue-d); }
.btn-mint   { background: var(--mint);   color: var(--mint-d); }
.btn-pink   { background: var(--pink);   color: #fff; }
.btn-ghost  { background: var(--card); color: var(--text); border: 2px solid var(--border); box-shadow: none; }

/* ── 首頁 ── */
.home-header { text-align: center; padding: 24px 0 10px; }
.home-logo { font-size: 3rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.home-header h1 {
  font-size: 2rem; font-weight: 900; letter-spacing: .05em; margin-top: 4px;
}
.home-header .accent { color: var(--pink-d); }
.home-sub { color: var(--text-light); font-size: .95rem; margin-top: 6px; }

.diff-row { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.diff-row .chip { font-size: .9rem; }

.island-map {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 22px 0;
}
.island {
  border-radius: var(--radius); padding: 18px 14px 14px; text-align: center;
  box-shadow: var(--shadow); position: relative; transition: transform .12s ease;
  border: 3px solid transparent;
}
.island:active { transform: scale(.96); }
.island.c-yellow { background: var(--yellow-l); border-color: var(--yellow); }
.island.c-blue   { background: var(--blue-l);   border-color: var(--blue); }
.island.c-mint   { background: var(--mint-l);   border-color: var(--mint); }
.island.c-pink   { background: var(--pink-l);   border-color: var(--pink); }
.island .isl-emoji { font-size: 2.2rem; }
.island .isl-num {
  font-family: 'Baloo 2', 'Noto Sans TC', sans-serif; font-size: 1.5rem; font-weight: 800; line-height: 1.1;
}
.island .isl-name { font-size: .85rem; color: var(--text-light); font-weight: 500; }
.island .isl-stars { font-size: .95rem; letter-spacing: .1em; margin-top: 4px; min-height: 1.2em; }
.island.locked { filter: grayscale(.9); opacity: .55; }
.island.locked::after {
  content: '🔒'; position: absolute; top: 8px; right: 10px; font-size: 1.1rem;
}
.island.boss { grid-column: 1 / -1; background: linear-gradient(120deg, var(--pink-l), var(--yellow-l)); border-color: var(--pink); }
.island.boss .isl-emoji { font-size: 2.6rem; }
.island.sprint { grid-column: 1 / -1; background: linear-gradient(120deg, var(--blue-l), var(--mint-l)); border-color: var(--blue); }
.island.sprint .isl-emoji { font-size: 2.6rem; }

.home-actions { display: flex; gap: 12px; }
.home-actions .btn { flex: 1; }

.brand-footer { text-align: center; margin-top: 34px; color: var(--text-light); font-size: .85rem; line-height: 1.7; }
.brand-footer .brand-name { font-weight: 700; color: var(--text); }
.brand-footer b { color: var(--mint-d); }
.app-version { font-size: .7rem; color: var(--text-light); opacity: .6; margin-top: 4px; }

/* ── 招生卡（與注音特訓一致的版式） ── */
.recruit { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 16px; margin-top: 36px; text-align: center; }
.recruit h3 { font-size: 1.15rem; font-weight: 900; }
.recruit .slogan { font-size: .85rem; color: var(--text-light); margin: 6px 0 12px; }
.branches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.branch { background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.bn { font-weight: 900; font-size: .82rem; }
.bi { font-size: .72rem; color: var(--text-light); line-height: 1.5; }
.bi a { color: var(--text-light); }
.line-row { margin-top: 12px; font-size: .85rem; font-weight: 700; }
.line-row a { color: var(--mint-d); }
.sitefoot { text-align: center; margin-top: 22px; color: var(--text-light); font-size: .78rem; line-height: 1.8; }
.flogo { height: 34px; margin-bottom: 4px; }

/* ── 通用頁首 ── */
.stage-header { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.btn-back {
  width: 42px; height: 42px; border-radius: 50%; background: var(--card);
  border: 2px solid var(--border); font-size: 1.2rem; font-weight: 700; flex-shrink: 0;
}
.stage-title { font-size: 1.2rem; font-weight: 900; flex: 1; }
.btn-print { background: var(--card); border: 2px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: .9rem; font-weight: 700; }

/* ── 口訣總覽 ── */
.recite-hint { text-align: center; color: var(--text-light); font-size: .92rem; margin-bottom: 12px; }
.recite-list { display: grid; grid-template-columns: 1fr; gap: 10px; padding-bottom: 90px; }
.recite-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 2px solid var(--border); border-radius: 16px;
  padding: 12px 18px; font-size: 1.15rem; font-weight: 700; text-align: left;
  transition: transform .1s ease;
}
.recite-item:active { transform: scale(.97); }
.recite-item .eq { font-family: 'Baloo 2', 'Noto Sans TC', sans-serif; font-size: 1.25rem; }
.recite-item .zh { color: var(--blue-d); font-size: 1.05rem; }
.recite-item.playing { border-color: var(--yellow); background: var(--yellow-l); }
.sticky-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px 22px;
  background: linear-gradient(transparent, var(--bg) 35%);
  max-width: 560px; margin: 0 auto;
}

/* ── 答題 ── */
.quiz-progress { flex: 1; height: 12px; background: var(--border); border-radius: 999px; overflow: hidden; }
#quiz-progress-bar { height: 100%; width: 0; background: var(--mint); border-radius: 999px; transition: width .3s ease; }
.quiz-count { font-family: 'Baloo 2', sans-serif; font-weight: 700; color: var(--text-light); }
.quiz-timer { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
#quiz-timer-bar { height: 100%; width: 100%; background: var(--pink); border-radius: 999px; transition: width 1s linear; }
.quiz-timer.urgent #quiz-timer-bar { background: #C84B31; }
.quiz-timer.urgent { animation: urgentPulse .5s ease-in-out infinite alternate; }
@keyframes urgentPulse { from { transform: scaleY(1); } to { transform: scaleY(1.6); } }
.quiz-stage-label { text-align: center; font-size: .9rem; font-weight: 700; color: var(--text-light); margin: 4px 0 10px; }
.question-card {
  background: var(--card); border: 3px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px 16px; text-align: center; margin-bottom: 18px;
}
.question-text {
  font-family: 'Baloo 2', 'Noto Sans TC', sans-serif;
  font-size: 3rem; font-weight: 800; letter-spacing: .04em;
}
.question-text .blank {
  display: inline-block; min-width: 1.4em; border-bottom: 5px solid var(--blue);
  color: var(--blue-d); line-height: 1.1;
}
.question-card.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.answer-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choice-btn {
  font-family: 'Baloo 2', sans-serif; font-size: 1.8rem; font-weight: 800;
  background: var(--card); border: 3px solid var(--border); border-radius: var(--radius);
  padding: 20px 0; box-shadow: var(--shadow); transition: transform .1s ease;
}
.choice-btn:active { transform: scale(.95); }
.choice-btn.correct { background: var(--mint-l); border-color: var(--mint); color: var(--mint-d); }
.choice-btn.wrong { background: var(--pink-l); border-color: var(--pink); color: var(--pink-d); }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 340px; margin: 0 auto; }
.num-key {
  font-family: 'Baloo 2', sans-serif; font-size: 1.7rem; font-weight: 800;
  background: var(--card); border: 2px solid var(--border); border-radius: 16px;
  padding: 14px 0; box-shadow: var(--shadow); transition: transform .08s ease;
}
.num-key:active { transform: scale(.92); }
.key-del { background: var(--yellow-l); color: var(--yellow-d); }
.key-ok { background: var(--mint); color: var(--mint-d); }

.feedback-overlay {
  position: fixed; inset: 0; background: rgba(74,74,74,.35);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.feedback-box {
  background: var(--card); border-radius: var(--radius); padding: 28px 24px;
  text-align: center; max-width: 380px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  animation: popIn .25s cubic-bezier(.3, 1.4, .6, 1);
}
@keyframes popIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.feedback-box .fb-emoji { font-size: 3rem; }
.feedback-box .fb-title { font-size: 1.3rem; font-weight: 900; margin: 8px 0; }
.feedback-box .fb-koujue {
  font-size: 1.4rem; font-weight: 700; color: var(--blue-d);
  background: var(--blue-l); border-radius: 12px; padding: 10px; margin: 10px 0 16px;
}
.feedback-box .btn { margin-top: 4px; }

/* ── 結果頁 ── */
.result-wrap { text-align: center; padding-top: 40px; position: relative; }
.result-emoji { font-size: 4rem; }
.result-stars { font-size: 3rem; letter-spacing: .1em; margin: 10px 0; min-height: 1.2em; }
.result-stars .star { display: inline-block; opacity: 0; transform: scale(0); }
.result-stars .star.on { animation: starPop .5s cubic-bezier(.3, 1.6, .6, 1) forwards; }
@keyframes starPop { to { opacity: 1; transform: scale(1); } }
.result-wrap h2 { font-size: 1.5rem; font-weight: 900; margin-bottom: 14px; }
.result-stats {
  display: flex; justify-content: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.result-stats .stat {
  background: var(--card); border: 2px solid var(--border); border-radius: 16px;
  padding: 10px 18px; font-size: .9rem; color: var(--text-light);
}
.result-stats .stat b { display: block; font-family: 'Baloo 2', sans-serif; font-size: 1.4rem; color: var(--text); }
.result-wrong {
  background: var(--yellow-l); border: 2px solid var(--yellow); border-radius: var(--radius);
  padding: 14px 18px; text-align: left; margin-bottom: 20px; font-size: 1rem; line-height: 2;
}
.result-wrong .rw-title { font-weight: 900; margin-bottom: 4px; }
.result-wrong .rw-item b { color: var(--pink-d); font-family: 'Baloo 2', 'Noto Sans TC', sans-serif; }
.result-actions { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 0 auto; }

/* 彩帶 */
#result-confetti { position: absolute; inset: -40px 0 0; pointer-events: none; overflow: visible; }
.confetti {
  position: absolute; top: -10px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(75vh) rotate(720deg); opacity: 0; }
}

/* ── 自由練習設定 ── */
.free-setup h3 { font-size: 1.05rem; font-weight: 900; margin: 18px 0 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 2px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 10px 18px; font-size: 1rem; font-weight: 700; transition: transform .1s ease;
  font-family: 'Baloo 2', 'Noto Sans TC', sans-serif;
}
.chip:active { transform: scale(.94); }
.chip.selected { background: var(--blue); border-color: var(--blue); color: var(--blue-d); }
.free-setup { padding-bottom: 100px; }

/* ── 家長成績單 ── */
.report-body h3 { font-size: 1.05rem; font-weight: 900; margin: 22px 0 10px; }
.h3-note { font-size: .8rem; color: var(--text-light); font-weight: 400; }
.report-brand-top { display: none; }
.report-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rl-item {
  background: var(--card); border: 2px solid var(--border); border-radius: 14px;
  text-align: center; padding: 10px 4px; font-size: .9rem;
}
.rl-item .rl-num { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 1.2rem; }
.rl-item .rl-stars { font-size: .8rem; letter-spacing: .05em; }
.mastery-scroll { overflow-x: auto; }
.mastery-grid { display: grid; grid-template-columns: auto repeat(9, 1fr); gap: 4px; min-width: 330px; }
.mg-cell {
  aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-family: 'Baloo 2', sans-serif; font-size: .72rem; font-weight: 700; color: rgba(0,0,0,.45);
}
.mg-head { background: none; color: var(--text-light); font-size: .8rem; }
.mg-none { background: var(--border); }
.mg-good { background: var(--mint); }
.mg-ok   { background: var(--yellow); }
.mg-weak { background: var(--pink); color: #fff; }
.mastery-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: .82rem; color: var(--text-light); }
.mastery-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 4px; margin-right: 5px; vertical-align: -2px; }
.lg-good { background: var(--mint); } .lg-ok { background: var(--yellow); }
.lg-weak { background: var(--pink); } .lg-none { background: var(--border); }
.report-weak { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 18px; line-height: 2.1; }
.report-weak .wk-item b { font-family: 'Baloo 2', 'Noto Sans TC', sans-serif; color: var(--pink-d); }
.report-weak .wk-koujue { color: var(--blue-d); font-weight: 700; }
.report-weak .wk-empty { color: var(--text-light); }
.report-summary { margin-top: 14px; color: var(--text-light); font-size: .9rem; text-align: center; }
.report-cta { background: var(--mint-l); border-radius: var(--radius); padding: 18px; margin-top: 26px; }
.report-cta .brand-addr { font-size: .78rem; margin-top: 4px; }

.hidden { display: none !important; }

@media (min-width: 480px) {
  .island-map { gap: 16px; }
  .question-text { font-size: 3.6rem; }
}

@media print {
  .no-print, .btn-back, .btn-print { display: none !important; }
  body { background: #fff; }
  .view { display: none; }
  #view-report { display: block !important; }
  .report-brand-top { display: block; text-align: center; font-weight: 900; font-size: 1.2rem; margin-bottom: 8px; }
  .report-cta { border: 1px solid #ccc; }
}
