/* 小小奧數挑戰 — kid-friendly bilingual UI */
:root {
  --bg: #fff8ef;
  --card: #ffffff;
  --ink: #2b2a4a;
  --muted: #6b6888;
  --accent: #ff7a59;
  --accent2: #5b8def;
  --good: #2f9e6a;
  --bad: #e45757;
  --soft: #ffe6d6;
  --shadow: 0 10px 30px rgba(43,42,74,.08);
  --radius: 18px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font); color: var(--ink);
  background:
    radial-gradient(ellipse at 10% 0%, #ffe8c8 0%, transparent 45%),
    radial-gradient(ellipse at 90% 10%, #dce8ff 0%, transparent 40%),
    var(--bg);
}
.app { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 3rem; }
header.hero {
  text-align: center; padding: 1.5rem 0.5rem 1rem;
}
.badge {
  display: inline-block; background: var(--soft); color: var(--accent);
  font-weight: 700; font-size: .8rem; padding: .35rem .75rem; border-radius: 999px;
  letter-spacing: .02em;
}
h1 { margin: .6rem 0 .25rem; font-size: clamp(1.6rem, 5vw, 2.2rem); }
.sub { color: var(--muted); margin: 0; line-height: 1.45; font-size: .95rem; }
.bilingual { display: flex; flex-direction: column; gap: .15rem; }
.bilingual .zh { font-weight: 700; }
.bilingual .en { color: var(--muted); font-size: .88em; font-weight: 500; }
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin: .75rem 0;
}
.grid { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
@media (min-width: 560px) { .grid.grades { grid-template-columns: repeat(3, 1fr); } }
.btn {
  appearance: none; border: 2px solid transparent; cursor: pointer;
  border-radius: 14px; padding: .9rem 1rem; font: inherit; text-align: left;
  background: #fff; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .12s;
  width: 100%;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.grade { background: linear-gradient(180deg, #fff, #fff6ee); border-color: #ffd7c2; }
.btn.grade .emoji { font-size: 1.6rem; display: block; margin-bottom: .25rem; }
.btn.topic { background: linear-gradient(180deg, #fff, #eef3ff); border-color: #c9d8ff; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #ff9a6b); color: #fff;
  text-align: center; font-weight: 700; border: none;
}
.btn.secondary {
  background: #eef2ff; color: var(--accent2); text-align: center; font-weight: 700; border: none;
}
.btn.option { margin: .5rem 0; border: 2px solid #ebe8f5; }
.btn.option.selected {
  border-color: var(--accent2);
  background: #eef2ff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .18);
}
.btn.option:not(:disabled):hover { border-color: #c7c2e0; }
.btn.option.correct { border-color: var(--good); background: #e8f8ef; }
.btn.option.wrong { border-color: var(--bad); background: #fdecec; }
.btn.option:disabled { cursor: default; opacity: .95; }
.progress-wrap { margin: .5rem 0 1rem; }
.progress-bar {
  height: 10px; background: #efeaf8; border-radius: 999px; overflow: hidden;
}
.progress-bar > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .3s ease;
}
.meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.q-text { font-size: 1.1rem; line-height: 1.55; margin: .5rem 0 1rem; }
.feedback {
  margin-top: .75rem; padding: .9rem 1rem; border-radius: 12px; display: none;
}
.feedback.show { display: block; }
.feedback.ok { background: #e8f8ef; color: #1f6b48; }
.feedback.no { background: #fdecec; color: #9b2c2c; }
.score-big { font-size: 3rem; font-weight: 800; text-align: center; margin: .5rem 0; color: var(--accent); }
.actions { display: grid; gap: .6rem; margin-top: 1rem; }
.back {
  background: none; border: none; color: var(--accent2); font: inherit; cursor: pointer;
  padding: .4rem 0; margin-bottom: .25rem;
}
.pill {
  display: inline-block; background: #f0ecff; color: #5a4db0; font-size: .75rem;
  padding: .2rem .55rem; border-radius: 999px; font-weight: 600;
}
.footer-note { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 2rem; }

.q-text .en { display:block; margin-top:.35rem; color:var(--muted); font-size:.95rem; font-weight:500; }
.feedback .en { display:block; margin-top:.25rem; opacity:.9; }

.kid-explain {
  margin-top: .65rem; padding: .75rem .9rem;
  background: #fffaf0; border: 1px dashed #ffd09a; border-radius: 12px;
}
.kid-explain .kid-label {
  display: flex; flex-direction: column; gap: .05rem;
  margin-bottom: .4rem; font-size: .78rem; color: #c46a2b; font-weight: 700;
}
.kid-explain .kid-label .en { font-weight: 600; color: #a8784a; font-size: .72rem; }
.kid-explain p { margin: .25rem 0; line-height: 1.5; }
.kid-explain p.zh { font-weight: 600; color: var(--ink); }
.kid-explain p.en { color: var(--muted); font-size: .9em; font-weight: 500; }
#result-extra { font-size: .82rem; color: var(--muted); line-height: 1.45; text-align: left; }
#result-extra .bilingual { gap: .35rem; }

/* Quiz toolbar + TTS 讀題 */
.quiz-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .65rem;
}
.tts-bar {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
}
.tts-label { font-size: .78rem; color: var(--muted); }
.tts-label .en { font-size: .72rem; }
#tts-lang {
  font: inherit; font-size: .8rem; padding: .35rem .5rem; border-radius: 10px;
  border: 2px solid #ebe8f5; background: #fff; color: var(--ink);
}
.btn.tts-btn {
  width: auto; padding: .4rem .65rem; font-size: 1.1rem;
  background: #eef3ff; border: 2px solid #c9d8ff; box-shadow: none;
  text-align: center; line-height: 1;
}
.btn.tts-btn:hover { transform: translateY(-1px); }

/* End-of-mock / wrong-answer review */
.result-review { text-align: left; margin: 1rem 0; }
.review-title { margin-bottom: .75rem; padding-bottom: .4rem; border-bottom: 2px dashed #ffe0c2; }
.review-empty { color: var(--good); font-weight: 600; padding: .5rem 0; }
.review-item {
  background: #fffaf7; border: 1px solid #ffe6d6; border-radius: 14px;
  padding: .9rem 1rem; margin: .65rem 0;
}
.review-q { margin-bottom: .35rem; }
.review-item > p.zh { margin: .2rem 0; font-weight: 600; }
.review-item > p.en { margin: .15rem 0 .4rem; color: var(--muted); font-size: .9em; }
.review-ans { font-size: .88rem !important; color: #7a3b3b !important; font-weight: 600 !important; }
.review-ans.en { color: #9b6b6b !important; font-weight: 500 !important; }

button:disabled { opacity: .55; cursor: not-allowed; }
