/* 惦記小學堂：墨黑 × 蛋黃金 × 奶油米 */
@font-face {
  font-family: 'BpmfKai';
  src: url('fonts/bpmf-kai.woff') format('woff');
  font-display: swap;
}
:root {
  --ink: #1A1A1A; --ink2: #2A2723; --gold: #F0B010; --gold-d: #C98F00; --cream: #F0E0B0;
  --paper: #FAF5EA; --card: #FFFDF8; --line: #EADFC6; --mute: #7A715F;
  --ok: #2E8B57; --ok-bg: #E4F3EA; --bad: #C8452F; --bad-bg: #FBE8E3;
  --r: 22px; --shadow: 0 1px 0 rgba(26,26,26,.04), 0 8px 24px -12px rgba(60,40,0,.28);
  --font: 'BpmfKai', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.6; font-synthesis: none; }
/* 注音字型只有一種粗細：不硬加粗，注音才清楚 */
body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(240,176,16,.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(240,224,176,.55), transparent 60%),
    var(--paper);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; }
[hidden] { display: none !important; }

/* ── 頂欄 ── */
header.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(26,26,26,.94); backdrop-filter: blur(8px); color: #fff;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.logo .mark { width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 46% 46%, #FFD24D 0 18%, var(--gold) 19% 40%, #fff 41% 100%); box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.logo small { opacity: .6; font-weight: 400; letter-spacing: 0; }
header .sp { flex: 1; }
.back { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-size: 22px; display: grid; place-items: center; }
.back:hover { background: rgba(255,255,255,.1); }
.pts { display: flex; align-items: center; gap: 6px; background: var(--gold); color: var(--ink); border-radius: 999px; padding: 4px 14px 4px 8px; font-weight: 900; white-space: nowrap; }
.pts .s { display: inline-block; }
.pts.pop .s { animation: pop .6s cubic-bezier(.2,1.6,.4,1); }

main { max-width: 1000px; margin: 0 auto; padding: 22px 18px 40px; animation: rise .35s ease both; }
h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.3; margin: 6px 0 6px; letter-spacing: .02em; }
h2 { font-size: clamp(20px, 3.4vw, 26px); margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
h2::before { content: ''; width: 8px; height: 22px; border-radius: 4px; background: var(--gold); }
.sub { color: var(--mute); margin: 0 0 14px; }

/* ── 按鈕 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 10px 26px;
  border-radius: 999px; font-weight: 700; font-size: 19px; background: var(--gold); color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--gold-d), 0 6px 14px -8px rgba(201,143,0,.8); transition: transform .12s, box-shadow .12s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 var(--gold-d); }
.btn.dark { background: var(--ink); color: #fff; box-shadow: inset 0 -3px 0 #000; }
.btn.ghost { background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 2px var(--gold); }
.btn.small { min-height: 44px; padding: 6px 18px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.center { justify-content: center; text-align: center; }

/* ── 卡片 ── */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); }
.panel { padding: 26px; max-width: 580px; margin: 0 auto; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stagger > * { animation: rise .45s cubic-bezier(.2,.8,.2,1) both; }
.stagger > *:nth-child(2) { animation-delay: .04s } .stagger > *:nth-child(3) { animation-delay: .08s }
.stagger > *:nth-child(4) { animation-delay: .12s } .stagger > *:nth-child(5) { animation-delay: .16s }
.stagger > *:nth-child(6) { animation-delay: .2s } .stagger > *:nth-child(7) { animation-delay: .24s }
.stagger > *:nth-child(8) { animation-delay: .28s } .stagger > *:nth-child(n+9) { animation-delay: .32s }

/* 科目磚 */
.subj { --c: var(--gold); position: relative; overflow: hidden; min-height: 150px; padding: 18px 16px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 21px; font-weight: 700;
  transition: transform .18s, box-shadow .18s; }
.subj::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--c); }
.subj .ico { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; font-size: 36px;
  background: color-mix(in srgb, var(--c) 14%, #fff); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 25%, transparent); transition: transform .25s; }
.subj:hover { transform: translateY(-4px); box-shadow: 0 16px 30px -16px color-mix(in srgb, var(--c) 70%, transparent); }
.subj:hover .ico { transform: rotate(-8deg) scale(1.08); }
.subj:active { transform: scale(.97); }

/* 單元卡 */
.unit { padding: 20px; border-left: 8px solid var(--c, var(--gold)); }
.unit .t { font-size: 22px; font-weight: 700; }
.unit .m { color: var(--mute); font-size: 15px; margin: 4px 0 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; background: var(--cream); color: var(--ink); }
.tag.ok { background: var(--ok-bg); color: #1d6b40; }

/* 首頁主視覺 */
.hero { position: relative; overflow: hidden; background: var(--ink); color: #fff; border-radius: 28px; padding: 26px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 22px; align-items: center; box-shadow: 0 20px 40px -24px rgba(0,0,0,.6); }
.hero::before { content: ''; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, var(--gold) 0 34%, transparent 35%), radial-gradient(circle, rgba(255,255,255,.08) 0 70%, transparent 71%); opacity: .35; }
.hero > * { position: relative; }
.ring { width: 118px; height: 118px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .v { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .v b { font-size: 38px; color: var(--gold); font-family: system-ui, sans-serif; font-weight: 900; }
.ring .v small { display: block; font-size: 13px; opacity: .7; }
.hero .hi { font-size: clamp(22px, 4vw, 30px); font-weight: 700; }
.hero .meta { opacity: .75; font-size: 15px; }
.hero .goal { margin-top: 8px; font-size: 15px; color: var(--cream); }
@media (max-width: 640px) {
  .hero { grid-template-columns: auto 1fr; padding: 20px; gap: 16px; }
  .hero .btn { grid-column: 1 / -1; }
  .ring { width: 96px; height: 96px; } .ring .v b { font-size: 30px; }
}

/* 表單 */
.field { display: block; margin: 0 0 18px; }
.field > span { display: block; font-weight: 700; margin-bottom: 8px; }
.field input[type=text] { width: 100%; min-height: 56px; border: 2px solid var(--line); border-radius: 16px; padding: 10px 16px; background: #fff; font-size: 20px; }
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(240,176,16,.18); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 48px; padding: 6px 18px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); font-weight: 700; transition: all .15s; }
.chip.on { background: var(--ink); color: #fff; box-shadow: none; }
.check { display: flex; gap: 12px; align-items: flex-start; background: #FBF1D6; padding: 14px 16px; border-radius: 16px; font-size: 16px; }
.check input { width: 26px; height: 26px; margin-top: 3px; flex: none; accent-color: var(--ink); }

/* 帳號頭像 */
.who { padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; transition: transform .15s; }
.who:hover { transform: translateY(-3px); }
.av { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 900; color: #fff; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); }

/* ── 題目 ── */
.quiz { max-width: 800px; margin: 0 auto; }
.qtop { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--mute); font-weight: 700; margin-bottom: 10px; }
.steps { display: flex; gap: 5px; margin-bottom: 16px; }
.steps i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); transition: background .3s; }
.steps i.done { background: var(--ink); } .steps i.now { background: var(--gold); }
.steps i.r { background: var(--ok); } .steps i.w { background: var(--bad); }
.qbox { padding: 26px; }
.qtext { font-size: clamp(23px, 4.4vw, 32px); font-weight: 700; line-height: 1.5; margin: 0; }
.qpic { font-size: clamp(32px, 7vw, 48px); letter-spacing: 6px; word-break: break-all; margin: 12px 0 0; }
.qsvg { margin: 14px 0 0; display: flex; justify-content: center; }
.qsvg svg { width: min(220px, 60vw); height: auto; filter: drop-shadow(0 6px 12px rgba(60,40,0,.15)); }
.qsvg.small svg { width: 120px; }
.speak { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; background: #FBF1D6; border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 16px; }
.speak:hover { background: var(--cream); }
.opts { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 22px; }
@media (max-width: 600px) { .opts { grid-template-columns: 1fr; } }
.opt { display: flex; align-items: center; gap: 14px; min-height: 70px; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 2px var(--line);
  padding: 12px 16px; font-size: clamp(19px, 3.4vw, 23px); font-weight: 700; text-align: left; transition: transform .12s, box-shadow .12s, background .12s; }
.opt .k { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); font-family: system-ui, sans-serif; font-size: 17px; font-weight: 900; }
.opt:hover { box-shadow: inset 0 0 0 2px var(--gold); transform: translateY(-1px); }
.opt.sel { box-shadow: inset 0 0 0 3px var(--ink); background: #FBF1D6; }
.opt.sel .k { background: var(--ink); color: #fff; }
.opt.ok { box-shadow: inset 0 0 0 3px var(--ok); background: var(--ok-bg); animation: bounce .45s; }
.opt.ok .k { background: var(--ok); color: #fff; }
.opt.bad { box-shadow: inset 0 0 0 3px var(--bad); background: var(--bad-bg); animation: shake .4s; }
.opt.bad .k { background: var(--bad); color: #fff; }
.fb { margin-top: 18px; padding: 16px 18px; border-radius: 16px; font-weight: 700; animation: rise .3s both; }
.fb.ok { background: var(--ok-bg); color: #1d6b40; } .fb.bad { background: var(--bad-bg); color: #9b2f1d; }
.fb p { margin: 4px 0 0; font-weight: 400; color: var(--ink); }
.timer { font-family: system-ui, sans-serif; font-variant-numeric: tabular-nums; background: var(--card); padding: 2px 12px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--line); }
.timer.low { color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }

/* ── PIN ── */
.dots { display: flex; gap: 16px; justify-content: center; margin: 20px 0 8px; }
.dots i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--ink); transition: all .15s; }
.dots i.on { background: var(--gold); box-shadow: inset 0 0 0 3px var(--ink); transform: scale(1.1); }
.dots.shake { animation: shake .4s; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 330px; margin: 10px auto 0; }
.pad button { min-height: 70px; border-radius: 20px; background: #fff; box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--line);
  font-family: system-ui, sans-serif; font-size: 28px; font-weight: 800; transition: transform .08s; }
.pad button:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--line); background: #FBF1D6; }
.pad .fn { font-family: var(--font); font-size: 17px; }
.err { color: var(--bad); font-weight: 700; text-align: center; min-height: 1.6em; }

/* ── 結果、兌換 ── */
.result { text-align: center; padding: 30px 22px; max-width: 760px; margin: 0 auto; }
.big-emoji { font-size: 90px; line-height: 1; animation: pop .7s cubic-bezier(.2,1.6,.4,1); }
.score { font-size: clamp(56px, 12vw, 84px); font-weight: 900; font-family: system-ui, sans-serif; line-height: 1; margin: 10px 0 0; }
.gain { display: inline-flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 900; background: var(--gold); padding: 8px 24px; border-radius: 999px; margin: 14px 0; animation: pop .7s .3s cubic-bezier(.2,1.6,.4,1) both; }
.review { text-align: left; margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.review .card { padding: 14px 18px; }

.reward { position: relative; padding: 24px 16px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 21px; transition: transform .15s; }
.reward::before { content: ''; position: absolute; left: 14px; right: 14px; top: 62%; border-top: 2px dashed var(--line); }
.reward .ico { font-size: 54px; line-height: 1.1; margin-bottom: 18px; }
.reward .cost { margin-top: 6px; }
.reward:hover:not(:disabled) { transform: translateY(-4px) rotate(-1deg); }
.reward:disabled { opacity: .45; filter: grayscale(.6); cursor: not-allowed; }

.ticket { max-width: 460px; margin: 0 auto; text-align: center; padding: 30px 24px; position: relative; }
.ticket .code { font-family: system-ui, sans-serif; font-size: 32px; font-weight: 900; letter-spacing: .08em; background: #FBF1D6; display: inline-block; padding: 6px 20px; border-radius: 12px; margin: 10px 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.li { padding: 14px 18px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.li .when { color: var(--mute); font-size: 15px; }

footer.note { max-width: 1000px; margin: 0 auto; padding: 0 18px 32px; color: var(--mute); font-size: 13px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-weight: 700; z-index: 40; animation: rise .25s both; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }

#loading { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(250,245,234,.7); backdrop-filter: blur(2px); font-weight: 700; }
.egg { width: 64px; height: 64px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); display: grid; place-items: center; animation: wobble 1s ease-in-out infinite; }
.egg i { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); }

/* 彩帶 */
.confetti { position: fixed; pointer-events: none; z-index: 35; font-size: 26px; animation: fly 1.1s cubic-bezier(.2,.7,.3,1) forwards; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes bounce { 0%,100% { transform: none; } 40% { transform: scale(1.04); } }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes wobble { 0%,100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
