/* 學測上岸計畫
   版面概念：航海圖。首頁是港口與海圖，四個科目是島，關卡是一顆顆浮標排成的航線，終點是資管港。 */
:root {
  --sea: #E4F0EF;
  --sea-2: #CBE3E2;
  --paper: #FFFFFF;
  --paper-2: #F2F8F7;
  --ink: #0F2D40;
  --ink-2: #4A6372;
  --line: #CFE0E0;
  --buoy: #D4501C;
  --buoy-ink: #FFFFFF;
  --buoy-soft: #FBE2D5;
  --kelp: #17805F;
  --kelp-soft: #D5EFE4;
  --rose: #C2364F;
  --rose-soft: #F8DCE1;
  --lamp: #E2A00E;
  --lamp-soft: #FBEFCB;
  --sand: #EFDDB0;
  --leaf: #79B98A;
  --zh: #B4443A;
  --en: #2B68AC;
  --ma: #6A51B2;
  --cy: #17805F;
  --wave: rgba(255, 255, 255, .55);
  --hero: #0F2D40;
  --hero-ink: #F4FAFA;
  --shadow: 0 1px 2px rgba(15, 45, 64, .06), 0 8px 22px rgba(15, 45, 64, .08);
  --font-display: 'Huninn', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-body: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --r: 16px;
  --r-sm: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sea: #0A1A24; --sea-2: #0E2634; --paper: #12293A; --paper-2: #173246; --ink: #E2EFF0; --ink-2: #98B2BF; --line: #234459;
    --buoy: #FF7B45; --buoy-ink: #1C0D05; --buoy-soft: #47261A; --kelp: #3CC796; --kelp-soft: #123A2E; --rose: #FF6F86; --rose-soft: #46202A;
    --lamp: #FFC94D; --lamp-soft: #43381A; --sand: #4A4330; --leaf: #2F6B51; --zh: #F2806F; --en: #72AAF0; --ma: #A88CFA; --cy: #3CC796;
    --wave: rgba(255, 255, 255, .06); --hero: #173A50; --hero-ink: #E8F3F4; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sea: #0A1A24; --sea-2: #0E2634; --paper: #12293A; --paper-2: #173246; --ink: #E2EFF0; --ink-2: #98B2BF; --line: #234459;
  --buoy: #FF7B45; --buoy-ink: #1C0D05; --buoy-soft: #47261A; --kelp: #3CC796; --kelp-soft: #123A2E; --rose: #FF6F86; --rose-soft: #46202A;
  --lamp: #FFC94D; --lamp-soft: #43381A; --sand: #4A4330; --leaf: #2F6B51; --zh: #F2806F; --en: #72AAF0; --ma: #A88CFA; --cy: #3CC796;
  --wave: rgba(255, 255, 255, .06); --hero: #173A50; --hero-ink: #E8F3F4; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sea);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--buoy); outline-offset: 2px; border-radius: 6px; }
svg { display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.3; margin: 0; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }
.wrap { max-width: 980px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 20px 48px; }
.wrap--narrow { max-width: 720px; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.stack { display: grid; gap: 16px; }

/* ── 頂部列 ── */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar__in { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 19px; border: 0; background: none; padding: 0; color: var(--ink); }
.brand svg { width: 28px; height: 28px; color: var(--buoy); }
.topbar__stats { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lv { display: flex; align-items: center; gap: 8px; }
.lv__badge { font-family: var(--font-display); font-size: 14px; background: var(--ink); color: var(--paper); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.lv__bar { width: 84px; height: 8px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.lv__bar i { display: block; height: 100%; background: var(--lamp); border-radius: 99px; transition: width .5s; }
.chip-stat { display: flex; align-items: center; gap: 4px; font-family: var(--font-display); font-size: 15px; white-space: nowrap; }
.chip-stat svg { width: 18px; height: 18px; }
.chip-stat--fire svg { color: var(--buoy); }
.chip-stat--dim { color: var(--ink-2); }
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--paper-2); }
@media (max-width: 520px) {
  .brand span { display: none; }
  .lv__bar { width: 54px; }
}

/* ── 按鈕 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 700; font-size: 16px; text-decoration: none; transition: transform .12s, background .12s; }
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--paper-2); }
.btn--primary { background: var(--buoy); border-color: var(--buoy); color: var(--buoy-ink); box-shadow: 0 3px 0 color-mix(in srgb, var(--buoy) 60%, #000); }
.btn--primary:hover { background: color-mix(in srgb, var(--buoy) 90%, #fff); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── 卡片與標籤 ── */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel h3 { font-size: 20px; margin-bottom: 10px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag--zh { color: var(--zh); border-color: color-mix(in srgb, var(--zh) 35%, transparent); background: color-mix(in srgb, var(--zh) 10%, var(--paper)); }
.tag--en { color: var(--en); border-color: color-mix(in srgb, var(--en) 35%, transparent); background: color-mix(in srgb, var(--en) 10%, var(--paper)); }
.tag--ma { color: var(--ma); border-color: color-mix(in srgb, var(--ma) 35%, transparent); background: color-mix(in srgb, var(--ma) 10%, var(--paper)); }
.tag--cy { color: var(--cy); border-color: color-mix(in srgb, var(--cy) 35%, transparent); background: color-mix(in srgb, var(--cy) 10%, var(--paper)); }
.tag--hot { color: var(--buoy-ink); background: var(--buoy); border-color: var(--buoy); }
.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 16px; height: 16px; color: var(--line); }
.stars svg.on { color: var(--lamp); }

/* ── 首頁：港口 ── */
.harbor { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: stretch; }
@media (max-width: 760px) { .harbor { grid-template-columns: 1fr; } }
.hello { position: relative; overflow: hidden; background: var(--hero); color: var(--hero-ink); border-radius: var(--r); padding: 22px; border: 1px solid var(--line); display: grid; gap: 14px; }
.hello__greet { font-size: 15px; opacity: .85; }
.hello h1 { font-size: clamp(26px, 5vw, 34px); color: var(--hero-ink); }
.countdown { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.countdown b { font-family: var(--font-display); font-weight: 400; font-size: clamp(44px, 9vw, 60px); line-height: 1; color: var(--lamp); }
.countdown span { font-size: 15px; opacity: .9; }
.hello__note { font-size: 12.5px; opacity: .7; }
.hello .btn--ghost { color: var(--hero-ink); border-color: color-mix(in srgb, var(--hero-ink) 35%, transparent); }
.hello .btn--ghost:hover { background: color-mix(in srgb, var(--hero-ink) 10%, transparent); }
.hello__boat { position: absolute; right: -6px; bottom: -4px; width: 150px; opacity: .9; pointer-events: none; }
@media (max-width: 520px) { .hello__boat { width: 110px; opacity: .35; } }
.hello > *:not(.hello__boat) { position: relative; }

.rule-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.rule { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.rule__bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--paper-2); border: 1px solid var(--line); overflow: hidden; }
.rule__bar i { display: block; height: 100%; border-radius: 99px; }
.rule__text { font-size: 14.5px; }
.rule__text b { font-weight: 700; }
.src-note { font-size: 12.5px; color: var(--ink-2); margin-top: 10px; }

/* 海圖 */
.chart { position: relative; margin-top: 16px; border-radius: 22px; padding: 26px 18px 30px; background-color: var(--sea-2); background-image:
  radial-gradient(circle at 20% 30%, var(--wave) 0 1.5px, transparent 2px),
  radial-gradient(circle at 70% 70%, var(--wave) 0 1.5px, transparent 2px);
  background-size: 46px 46px, 62px 62px; border: 1px solid var(--line); overflow: hidden; }
.chart__title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chart__title h2 { font-size: 24px; }
.chart__route { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; color: var(--ink-2); opacity: .45; }
.islands { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
@media (max-width: 600px) { .islands { grid-template-columns: 1fr; gap: 14px; } }
.island { position: relative; display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; text-align: left; border: 0; background: color-mix(in srgb, var(--paper) 88%, transparent); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); transition: transform .15s; }
.island:hover { transform: translateY(-2px); }
.island:nth-child(2) { margin-top: 26px; }
.island:nth-child(3) { margin-top: -10px; }
@media (max-width: 600px) { .island:nth-child(n) { margin-top: 0; } }
.island__art { position: relative; width: 92px; height: 72px; }
.island__land { position: absolute; inset: 14px 4px 6px; background: var(--sand); border-radius: 58% 42% 52% 48% / 60% 55% 45% 40%; box-shadow: 0 0 0 5px color-mix(in srgb, var(--paper) 55%, transparent); }
.island__hill { position: absolute; left: 22px; right: 26px; top: 6px; height: 34px; background: var(--leaf); border-radius: 50% 50% 40% 40% / 70% 70% 30% 30%; }
.island__flag { position: absolute; left: 52px; top: -4px; width: 3px; height: 26px; background: var(--ink); border-radius: 2px; }
.island__flag::after { content: ""; position: absolute; left: 3px; top: 1px; width: 18px; height: 12px; background: var(--flag, var(--buoy)); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.island--zh { --flag: var(--zh); }
.island--en { --flag: var(--en); }
.island--ma { --flag: var(--ma); }
.island--cy { --flag: var(--cy); }
.island__name { font-family: var(--font-display); font-size: 22px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.island__role { font-size: 13.5px; color: var(--ink-2); }
.island__meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 14px; }
.meter { flex: 1; height: 7px; border-radius: 99px; background: var(--paper-2); border: 1px solid var(--line); overflow: hidden; min-width: 40px; }
.meter i { display: block; height: 100%; background: var(--flag, var(--kelp)); border-radius: 99px; }
.island--cy .island__land { border-radius: 30% 70% 40% 60% / 50% 40% 60% 50%; }
.lighthouse { position: absolute; left: 44px; top: -8px; width: 12px; height: 34px; background: repeating-linear-gradient(var(--paper) 0 7px, var(--rose) 7px 14px); border-radius: 4px 4px 2px 2px; border: 1px solid var(--line); }
.lighthouse::before { content: ""; position: absolute; left: -3px; top: -7px; width: 16px; height: 8px; background: var(--lamp); border-radius: 50% 50% 0 0; }

/* 首頁下半 */
.dash { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 860px) { .dash { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .dash { grid-template-columns: 1fr; } }
.dash .panel--wide { grid-column: span 2; }
@media (max-width: 600px) { .dash .panel--wide { grid-column: auto; } }
.quest { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--line); }
.quest:first-of-type { border-top: 0; padding-top: 0; }
.quest__bar { grid-column: 1; height: 6px; border-radius: 9px; background: var(--paper-2); overflow: hidden; }
.quest__bar i { display: block; height: 100%; background: var(--kelp); }
.quest .btn { min-height: 34px; padding: 4px 12px; font-size: 14px; grid-row: span 2; }
.quest__done { grid-row: span 2; color: var(--kelp); font-weight: 700; font-size: 14px; }
.games { display: grid; gap: 10px; }
.game-card { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; text-align: left; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper-2); }
.game-card:hover { border-color: var(--buoy); }
.game-card__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); font-family: var(--font-display); font-size: 20px; }
.game-card b { display: block; font-size: 16px; }
.game-card small { color: var(--ink-2); font-size: 13px; }
.best { font-family: var(--font-display); font-size: 13px; color: var(--ink-2); text-align: right; white-space: nowrap; }
.big-num { font-family: var(--font-display); font-size: 44px; line-height: 1; }
.acc-row { display: grid; grid-template-columns: 56px 1fr 72px; gap: 10px; align-items: center; font-size: 14px; padding: 4px 0; }
.acc-row .meter i { background: var(--c); }

/* ── 島（科目頁） ── */
.isle-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.isle-head h1 { font-size: 30px; }
.isle-intro { margin-top: 12px; }
.route { position: relative; margin-top: 18px; display: grid; gap: 6px; padding: 10px 0 30px; }
.route::before { content: ""; position: absolute; left: 50%; top: 20px; bottom: 30px; border-left: 3px dashed color-mix(in srgb, var(--ink-2) 40%, transparent); transform: translateX(-1.5px); }
.stop { position: relative; display: grid; grid-template-columns: 1fr 76px 1fr; align-items: center; gap: 14px; }
.stop__card { grid-column: 3; min-width: 0; text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); }
.stop:nth-child(even) .stop__card { grid-column: 1; grid-row: 1; text-align: right; }
.stop:nth-child(even) .stop__card .stop__meta { justify-content: flex-end; }
.stop__buoy { grid-column: 2; grid-row: 1; justify-self: center; position: relative; width: 66px; height: 66px; border-radius: 50%; border: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 24px; color: var(--buoy-ink); background: var(--flag, var(--buoy)); box-shadow: 0 5px 0 color-mix(in srgb, var(--flag, var(--buoy)) 60%, #000), 0 0 0 6px var(--sea); transition: transform .12s; }
.stop__buoy:hover { transform: translateY(-2px); }
.stop__buoy svg { width: 28px; height: 28px; }
.stop.is-locked .stop__buoy { background: var(--paper-2); color: var(--ink-2); box-shadow: 0 5px 0 var(--line), 0 0 0 6px var(--sea); border: 1px solid var(--line); }
.stop.is-locked .stop__card { opacity: .62; }
.stop.is-next .stop__buoy::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 3px solid var(--flag, var(--buoy)); animation: ping 1.6s ease-out infinite; }
@keyframes ping { from { transform: scale(.85); opacity: .9; } to { transform: scale(1.25); opacity: 0; } }
.stop__title { font-family: var(--font-display); font-size: 19px; }
.stop__goal { font-size: 13.5px; color: var(--ink-2); }
.stop__meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.stop--boss .stop__buoy { width: 76px; height: 76px; background: var(--ink); color: var(--lamp); }
.isle--zh { --flag: var(--zh); }
.isle--en { --flag: var(--en); }
.isle--ma { --flag: var(--ma); }
.isle--cy { --flag: var(--cy); }
@media (max-width: 600px) {
  .route::before { left: 33px; }
  .stop, .stop:nth-child(even) { grid-template-columns: 66px 1fr; }
  .stop__buoy, .stop:nth-child(even) .stop__buoy { grid-column: 1; }
  .stop__card, .stop:nth-child(even) .stop__card { grid-column: 2; grid-row: 1; text-align: left; }
  .stop:nth-child(even) .stop__card .stop__meta { justify-content: flex-start; }
  .stop__buoy { width: 58px; height: 58px; font-size: 21px; }
  .stop--boss .stop__buoy { width: 62px; height: 62px; }
}
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--lamp-soft); border: 1px solid color-mix(in srgb, var(--lamp) 40%, transparent); font-size: 14.5px; }
.callout svg { width: 22px; height: 22px; flex: none; color: var(--lamp); margin-top: 2px; }

/* ── 單元頁：重點卡 ── */
.unit-head { display: grid; gap: 8px; }
.unit-head h1 { font-size: 30px; }
.cards { display: grid; grid-auto-flow: column; grid-auto-columns: min(86%, 420px); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 14px; margin-top: 14px; overscroll-behavior-x: contain; }
.note-card { scroll-snap-align: start; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; position: relative; }
.note-card__n { font-family: var(--font-display); font-size: 13px; color: var(--ink-2); }
.note-card h3 { font-size: 20px; margin: 2px 0 8px; }
.note-card ul { margin: 6px 0; padding-left: 1.2em; }
.note-card li { margin: 2px 0; }
.note-card b { color: var(--flag, var(--buoy)); }
.swipe-hint { font-size: 13px; color: var(--ink-2); }

/* ── 答題 ── */
.quiz { max-width: 720px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 14px 220px; }
.quiz__top { display: flex; align-items: center; gap: 12px; }
.pbar { flex: 1; display: flex; gap: 4px; }
.pbar span { flex: 1; height: 10px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); }
.pbar span.cur { background: var(--lamp-soft); border-color: var(--lamp); }
.pbar span.ok { background: var(--kelp); border-color: var(--kelp); }
.pbar span.ng { background: var(--rose); border-color: var(--rose); }
.combo { display: flex; align-items: center; gap: 2px; font-family: var(--font-display); color: var(--ink-2); min-width: 44px; }
.combo svg { width: 20px; height: 20px; }
.combo.on { color: var(--buoy); }
.combo.on b { animation: pop .3s; }
@keyframes pop { 50% { transform: scale(1.4); } }
.quiz__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; font-size: 14px; color: var(--ink-2); }
.passage { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; margin: 8px 0 12px; }
.passage summary { cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.passage__body { padding: 0 16px 14px; max-height: 46vh; overflow-y: auto; font-size: 15.5px; line-height: 1.85; white-space: normal; }
.qtext { font-family: var(--font-body); font-weight: 700; font-size: 20px; line-height: 1.6; margin: 6px 0 14px; overflow-wrap: anywhere; }
.opts { display: grid; gap: 10px; }
.opt { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; text-align: left; min-height: 56px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); font-size: 17px; line-height: 1.5; box-shadow: 0 3px 0 var(--line); transition: transform .1s, border-color .1s; overflow-wrap: anywhere; }
.opt:hover:not([disabled]) { border-color: var(--ink-2); }
.opt:active:not([disabled]) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.opt__key { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--font-display); background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2); }
.opt[disabled] { cursor: default; }
.opt.is-right { border-color: var(--kelp); background: var(--kelp-soft); box-shadow: 0 3px 0 var(--kelp); }
.opt.is-right .opt__key { background: var(--kelp); color: var(--paper); border-color: var(--kelp); }
.opt.is-wrong { border-color: var(--rose); background: var(--rose-soft); box-shadow: 0 3px 0 var(--rose); animation: shake .35s; }
.opt.is-wrong .opt__key { background: var(--rose); color: var(--paper); border-color: var(--rose); }
.opt.is-dim { opacity: .55; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.hint-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--lamp); background: transparent; color: var(--ink-2); border-radius: 99px; padding: 4px 12px; font-size: 14px; margin-bottom: 12px; }
.hint-btn svg { width: 16px; height: 16px; color: var(--lamp); }
.hint { background: var(--lamp-soft); border-radius: 12px; padding: 10px 14px; font-size: 15px; margin-bottom: 12px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(100%); } }
.sheet__in { max-width: 720px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); border: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .12); max-height: 62vh; overflow-y: auto; }
.sheet__in.ok { background: var(--kelp-soft); }
.sheet__in.ng { background: var(--rose-soft); }
.sheet__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--font-display); font-size: 22px; }
.sheet__in.ok .sheet__head { color: var(--kelp); }
.sheet__in.ng .sheet__head { color: var(--rose); }
.sheet__xp { font-size: 15px; background: var(--lamp); color: #3A2A00; padding: 1px 10px; border-radius: 99px; }
.sheet__note { font-family: var(--font-body); font-size: 13px; color: var(--ink-2); }
.sheet__ans { margin-top: 6px; font-weight: 700; }
.sheet__ex { margin: 8px 0 14px; font-size: 15.5px; line-height: 1.75; overflow-wrap: anywhere; }

/* ── 結算 ── */
.result { text-align: center; display: grid; gap: 14px; justify-items: center; }
.result__stars { display: flex; gap: 10px; }
.result__stars svg { width: 64px; height: 64px; color: var(--line); }
.result__stars svg.on { color: var(--lamp); animation: starIn .5s both; }
.result__stars svg.on:nth-child(2) { animation-delay: .15s; }
.result__stars svg.on:nth-child(3) { animation-delay: .3s; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.2); } }
.result h1 { font-size: 32px; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; }
.kpi b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.2; }
.kpi span { font-size: 13px; color: var(--ink-2); }
.miss-list { width: 100%; text-align: left; display: grid; gap: 8px; }
.miss { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14.5px; }
.miss b { color: var(--kelp); }

/* ── 錯題本 ── */
.filter { display: flex; gap: 8px; flex-wrap: wrap; }
.filter button { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 4px 14px; font-size: 14px; }
.filter button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.wrong-item { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: start; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.wrong-item__q { font-size: 15px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wrong-item__meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); }
.empty svg { width: 56px; height: 56px; margin: 0 auto 10px; color: var(--line); }

/* ── 小遊戲 ── */
.game { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 14px 48px; }
.game__hud { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.timer { height: 12px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); overflow: hidden; }
.timer i { display: block; height: 100%; background: var(--kelp); border-radius: 99px; transition: width .1s linear; }
.timer.low i { background: var(--rose); }
.score { font-family: var(--font-display); font-size: 22px; min-width: 64px; text-align: right; }
.flash-word { text-align: center; margin: 30px 0 22px; }
.flash-word b { display: block; font-family: var(--font-body); font-weight: 700; font-size: clamp(34px, 9vw, 48px); letter-spacing: .01em; overflow-wrap: anywhere; }
.flash-word span { color: var(--ink-2); font-size: 15px; }
.speak { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 3px 12px; font-size: 13px; color: var(--ink-2); }
.speak svg { width: 16px; height: 16px; }
.flip { perspective: 1200px; margin: 18px 0; }
.flip__card { position: relative; min-height: 260px; border: 0; background: none; padding: 0; width: 100%; transform-style: preserve-3d; transition: transform .45s; }
.flip__card.on { transform: rotateY(180deg); }
.flip__face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-content: center; gap: 10px; text-align: center; padding: 20px; border-radius: 20px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.flip__back { transform: rotateY(180deg); }
.flip__face .w { font-size: clamp(32px, 8vw, 44px); font-weight: 700; overflow-wrap: anywhere; }
.flip__face .zh { font-family: var(--font-display); font-size: 28px; color: var(--en); }
.flip__face .ex { font-size: 15px; color: var(--ink-2); }
.typo-sent { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 26px 0 18px; }
.typo-sent button, .typo-sent span { width: 42px; height: 48px; display: grid; place-items: center; font-size: 24px; border-radius: 10px; }
.typo-sent button { border: 1px solid var(--line); background: var(--paper); box-shadow: 0 3px 0 var(--line); }
.typo-sent button:hover:not([disabled]) { border-color: var(--zh); }
.typo-sent span { width: 18px; color: var(--ink-2); }
.typo-sent button.is-right { background: var(--kelp-soft); border-color: var(--kelp); color: var(--kelp); }
.typo-sent button.is-wrong { background: var(--rose-soft); border-color: var(--rose); animation: shake .35s; }
.typo-sent button.is-answer { background: var(--lamp-soft); border-color: var(--lamp); }
@media (max-width: 480px) { .typo-sent button { width: 34px; height: 42px; font-size: 20px; } .typo-sent span { width: 12px; } }
.lives { display: flex; gap: 4px; }
.lives svg { width: 22px; height: 22px; color: var(--rose); }
.lives svg.off { color: var(--line); }
.fix-box { text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 6px; }
.fix-box .big { font-family: var(--font-display); font-size: 26px; }
.quick-q { text-align: center; font-size: clamp(32px, 8vw, 44px); margin: 34px 0 24px; min-height: 64px; }
.game-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-opts .opt { grid-template-columns: 1fr; text-align: center; justify-items: center; font-size: 18px; }
@media (max-width: 420px) { .game-opts { grid-template-columns: 1fr; } }

/* ── 國寫 ── */
.prompt-card { display: grid; gap: 6px; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px; width: 100%; }
.prompt-card:hover { border-color: var(--zh); }
.material { white-space: pre-wrap; background: var(--paper-2); border-left: 4px solid var(--zh); border-radius: 8px; padding: 12px 14px; font-size: 15px; line-height: 1.8; }
.editor { width: 100%; min-height: 300px; resize: vertical; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); padding: 14px; font-size: 17px; line-height: 1.9; }
.editor-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.checklist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.checklist input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--kelp); flex: none; }
.outline { display: grid; gap: 6px; margin: 0; padding-left: 1.2em; font-size: 15px; }

/* ── 設定、彈窗、提示 ── */
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: 14px; }
.input, .code-box { width: 100%; border: 1px solid var(--line); background: var(--paper-2); border-radius: 12px; padding: 10px 12px; font-size: 16px; }
.code-box { min-height: 90px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; resize: vertical; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); }
.switch:first-of-type { border-top: 0; }
.switch input { width: 46px; height: 26px; accent-color: var(--kelp); flex: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(6, 20, 30, .55); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal__box { width: min(440px, 100%); max-height: 88vh; overflow-y: auto; background: var(--paper); border-radius: 20px; padding: 22px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal__box h2 { font-size: 24px; }
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 99px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow); animation: toast 2.6s both; max-width: calc(100% - 32px); text-align: center; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -10px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.foot { margin-top: 28px; font-size: 12.5px; color: var(--ink-2); text-align: center; line-height: 1.8; }
.katex { font-size: 1.08em; }
.opt .katex, .quick-q .katex { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
