/* game.css — 遊戲化 UI 改版 Phase A (research/20261121_遊戲化UI改版方案 v2.md §4, §6 A1–A7). Added 2026-11-21.
   Loaded after every other stylesheet so the overrides win.
   Scope: the student area only — the student shell (.screen.student) and practice / writing (.screen.session) —
   written as `:is(.screen.student, .screen.session:not(.exam))`. 考試 (.screen.session.exam, .screen.exam-report),
   家長專區 (.screen.parent), 登入 (.screen.auth) and 誰在學習？ (.screen.profiles) are left exactly as they were.
   Motion (§4.10): every animation sits under html:not([data-motion="reduce"]); app.js sets data-motion="reduce" when
   the system asks for reduced motion. The 80 ms button press stays in both modes (it is a direct response).
   Child safety (§1.3): no flashing, nothing faster than 3 per second, no red full-screen, no countdown. */

/* ---------- A1: tokens (§4.1) ---------- */
:root {
  /* text */
  --g-ink: #22314a;          /* main text, ≥ 4.5:1 on every pastel below */
  --g-ink-soft: #4a5872;     /* secondary text, white or very light backgrounds only */
  /* backgrounds */
  --g-bg: #fdf6ea;
  --g-panel: #fffdf8;
  /* roles: pastel fill + same-hue darker edge */
  --g-primary: #ffd86b;   --g-primary-edge: #d19a1f;
  --g-secondary: #bfe8cf; --g-secondary-edge: #5fa57f;
  --g-info: #cfe3f7;      --g-info-edge: #6e9cc9;
  --g-neutral: #ffffff;   --g-neutral-edge: #cdbfa6;
  --g-badge: #2a6f6b;
  --g-correct: #3f9f6e;  --g-wrong: #d27a6f;           /* always paired with ✓ / ✗ */
  --g-correct-ink: #1f7a4d; --g-wrong-ink: #a8443a;    /* when the colour itself carries text (≥ 4.5:1) */
  /* rarity */
  --r-common: #cdbfa6; --r-rare: #a9b8c9; --r-epic: #e2b64c;
  /* shape */
  --g-radius: 18px; --g-radius-lg: 22px; --g-edge: 4px;
  --g-panel-line: #eadfca;
  --g-ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- A1: buttons (§4.2) ---------- */
.g-btn {
  --fill: var(--g-neutral); --edge: var(--g-neutral-edge);
  min-height: 48px; padding: 10px 20px; border-radius: var(--g-radius);
  border: 2px solid var(--edge); background: var(--fill); color: var(--g-ink);
  font-weight: 800; font-size: 17px; line-height: 1.3;
  box-shadow: 0 var(--g-edge) 0 var(--edge), inset 0 2px 0 rgba(255, 255, 255, .65);
  transform: translateY(0); transition: transform 80ms ease-out, box-shadow 80ms ease-out;
}
.g-btn:active:not(:disabled) { transform: translateY(var(--g-edge)); box-shadow: 0 0 0 var(--edge), inset 0 2px 0 rgba(255, 255, 255, .4); }
.g-btn.primary   { --fill: var(--g-primary);   --edge: var(--g-primary-edge);   min-height: 56px; font-size: 19px; }
.g-btn.secondary { --fill: var(--g-secondary); --edge: var(--g-secondary-edge); }
.g-btn.neutral   { --fill: var(--g-neutral);   --edge: var(--g-neutral-edge); }
.g-btn:disabled  { filter: grayscale(.8); opacity: .7; box-shadow: 0 var(--g-edge) 0 #bbb; }
.g-round {
  width: 48px; height: 48px; min-width: 48px; border-radius: 50%; padding: 0; display: inline-grid; place-items: center;
  border: 2px solid var(--g-neutral-edge); background: var(--g-neutral); color: var(--g-ink); font-size: 20px; font-weight: 800;
  box-shadow: 0 3px 0 var(--g-neutral-edge); transition: transform 80ms ease-out, box-shadow 80ms ease-out;
}
.g-round:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--g-neutral-edge); }
/* focus ring: new classes everywhere, old elements only inside the student area (other screens keep their look) */
.g-btn:focus-visible, .g-round:focus-visible,
:is(.screen.student, .screen.session:not(.exam)) :focus-visible { outline: 3px solid #1f5fbf; outline-offset: 3px; }

/* ---------- A2: student-area background, text colour and panels (§4.4) ---------- */
html:has(.screen.student, .screen.session:not(.exam)), body:has(.screen.student, .screen.session:not(.exam)) { background: var(--g-bg); }
:is(.screen.student, .screen.session:not(.exam)) { background: var(--g-bg); color: var(--g-ink); font-size: 17px; overflow-x: clip;
  --muted: var(--g-ink-soft); --ink: var(--g-ink); }  /* old grey #6b7680 was 4.1–4.3:1 on the cream backgrounds */
.screen.student .top { background: var(--g-bg); }
:is(.screen.student, .screen.session:not(.exam)) .muted { color: var(--g-ink-soft); }
:is(.screen.student, .screen.session:not(.exam)) :is(.card, .q-card) {
  background: var(--g-panel); border: 3px solid var(--g-panel-line); border-radius: var(--g-radius-lg);
  box-shadow: 0 4px 0 var(--g-panel-line);
}
/* cards that carried their own accent keep it */
.screen.student .card.subject-head { border-left: 7px solid var(--sub); }
.screen.student .card.exam-entry { background: #fffaf0; border-color: #e8cf97; box-shadow: 0 4px 0 #e8cf97; }
.screen.student .card.exam-entry:active { transform: translateY(4px); box-shadow: 0 0 0 #e8cf97; }

/* ---------- A3: existing buttons take the .g-btn look (§4.2), no JS change ---------- */
:is(.screen.student, .screen.session:not(.exam)) .btn {
  --fill: var(--g-neutral); --edge: var(--g-neutral-edge);
  min-height: 48px; padding: 10px 18px; border-radius: var(--g-radius);
  border: 2px solid var(--edge); background: var(--fill); color: var(--g-ink);
  font-weight: 800; font-size: 17px; line-height: 1.3;
  box-shadow: 0 var(--g-edge) 0 var(--edge), inset 0 2px 0 rgba(255, 255, 255, .65);
  transform: translateY(0); transition: transform 80ms ease-out, box-shadow 80ms ease-out;
}
:is(.screen.student, .screen.session:not(.exam)) .btn:is(.primary, .gold) {
  --fill: var(--g-primary); --edge: var(--g-primary-edge); min-height: 56px; font-size: 19px;
}
/* §3.2.4 / §1.3 #11: buttons that spend parent-paid gems stay white (.neutral), never the yellow learning CTA */
:is(.screen.student, .screen.session:not(.exam)) .btn.primary.neutral {
  --fill: var(--g-neutral); --edge: var(--g-neutral-edge); min-height: 48px; font-size: 17px;
}
:is(.screen.student, .screen.session:not(.exam)) .btn.small { min-height: 48px; padding: 8px 14px; font-size: 15px; border-radius: 14px; }
:is(.screen.student, .screen.session:not(.exam)) .btn:active:not(:disabled) {
  transform: translateY(var(--g-edge)); box-shadow: 0 0 0 var(--edge), inset 0 2px 0 rgba(255, 255, 255, .4);
}
:is(.screen.student, .screen.session:not(.exam)) .btn:disabled { filter: grayscale(.8); opacity: .7; box-shadow: 0 var(--g-edge) 0 #bbb; }
:is(.screen.student, .screen.session:not(.exam)) .btn.block { margin-top: 12px; }
/* other tap targets in the student area reach 48 px (§4.11) */
:is(.screen.student, .screen.session:not(.exam)) .icon-btn { min-width: 48px; min-height: 48px; display: inline-grid; place-items: center; font-size: 20px; }
:is(.screen.student, .screen.session:not(.exam)) .link { min-height: 48px; display: inline-flex; align-items: center; font-weight: 700; }
:is(.screen.student, .screen.session:not(.exam)) :is(.seg button, .chip-btn, .pet-tabs button) { min-height: 48px; }
.screen.student .who { min-height: 48px; }
:is(.screen.student, .screen.session:not(.exam)) .order-picked .link { min-height: 48px; min-width: 48px; margin: -8px 0; justify-content: center; }

/* ---------- A4: type sizes (§4.9) — body 17, question 20, nothing under 14 px ---------- */
:is(.screen.student, .screen.session:not(.exam)) h3 { font-size: 20px; }
:is(.screen.student, .screen.session:not(.exam)) h4 { font-size: 18px; }
:is(.screen.student, .screen.session:not(.exam)) .stem { font-size: 20px; font-weight: 600; }
:is(.screen.student, .screen.session:not(.exam)) :is(.opt, .passage-text, .hint, .task, .topic, .kv, .wr-task, .wr-text) { font-size: 17px; }
:is(.screen.student, .screen.session:not(.exam)) :is(.small, small, .term, .chip, .chip-btn, .tag, .opt-key, .hint-n, .review-note,
  .match-to, .stages span, .seg button, .odds, .odds-items, .wr-steps span, .wr-label, .wr-band-name, .wr-group .glyph, .wr-count) { font-size: 14px; }
.screen.student .tabs button { font-size: 14px; font-weight: 700; color: var(--g-ink-soft); }
.screen.student .tabs button.on { color: var(--g-ink); }
.screen.student .who small { font-size: 14px; color: var(--g-ink-soft); }
.screen.student .subject small { font-size: 14px; }
.screen.student .item { font-size: 14px; }
.screen.student .item em, .screen.student .item .tag { font-size: 14px; }
/* 首頁 pet card, medals, ability radar */
.screen.student :is(.hm-lv, .hm-name small, .hm-title, .hm-xp small, .hm-stats, .hm-stats em, .hm-index small, .hm-gain-item) { font-size: 14px; }
.screen.student .hm-medal { font-size: 16px; } .screen.student .hm-medal.sm { font-size: 14px; }
.screen.student .radar text { font-size: 14px; }
/* 寵物 tab */
.screen.student .pet-screen :is(.title-plate, .xp-row small, .stat small, .ladder-name small, .slot-name, .equip-tag,
  .series-card small, .coll-group summary .sc-done, .medal-cell .pin) { font-size: 14px; }
.screen.student .pet-screen .pet-tabs button { font-size: 15px; }
.screen.student .pet-screen .roster-cell small { font-size: 14px; }   /* 寵物名冊 (f-pet.css:58) */
.screen.student .pet-screen .medal-cell small { font-size: 14px; }    /* 勳章名 (f-pet.css:75) */
.screen.student .pet-screen .series-card b { font-size: 14px; }
.screen.student .pet-screen .ladder-row { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
/* scene HUD: level emblem and medal count grow so their labels reach 14 px */
.screen.student .pet-screen .hud-lv { width: 13cqw; height: 13cqw; min-width: 48px; min-height: 48px; }
.screen.student .pet-screen .hud-lv small { font-size: 14px; } .screen.student .pet-screen .hud-lv b { font-size: 18px; }
.screen.student .pet-screen .hud-plate { font-size: 14px; }
.screen.student .pet-screen .hud-count { display: flex; width: auto; border-radius: 999px; padding: 0 8px; flex-direction: row; gap: 3px; align-items: center; }
.screen.student .pet-screen .hud-count b, .screen.student .pet-screen .hud-count small { font-size: 14px; }
.screen.student .pet-screen .hud-z3 { font-size: 14px; } .screen.student .pet-screen .hud-z3 b { font-size: 16px; }
/* leaderboard, pack overlay text */
.screen.student :is(.board-title, .exam-secs) { font-size: 14px; }
.screen.student :is(.pack-mode, .pack-hint, .pack-ph small, .pc-label small, .pack-reward-frame small) { font-size: 14px; }
.screen.student .pack-mode { min-height: 48px; padding: 8px 14px; } /* §4.11 tap target */
/* drawn card ribbon: name and 類別・稀有度 at ≥ 14 px; the two lines may sit 1–2 px past the ribbon art on the
   smallest card (珍貴, or the shrunk card beside a 集齊 reward), so the ribbon no longer clips them */
.screen.student .pack-card .pc-ribbon { line-height: 1.05; overflow: visible; }
.screen.student .pack-card .pc-ribbon b { font-size: max(14px, calc(var(--pw) * .054)); }

/* ---------- A8: contrast fixes found by the check (text ≥ 4.5:1) ---------- */
/* white text on the bright subject colours was 2.4–3.4:1 → ink on a soft tint of the same colour, edge in the colour */
:is(.screen.student, .screen.session:not(.exam)) .glyph { background: color-mix(in srgb, var(--sub) 24%, white); color: var(--g-ink); box-shadow: inset 0 0 0 2px var(--sub); }
:is(.screen.student, .screen.session:not(.exam)) .q-meta .chip[style] { background: color-mix(in srgb, var(--sub) 22%, white) !important; color: var(--g-ink); box-shadow: inset 0 0 0 1.5px var(--sub); }
:is(.screen.student, .screen.session:not(.exam)) .wr-steps span.on { background: color-mix(in srgb, var(--sub) 24%, white); color: var(--g-ink); box-shadow: inset 0 0 0 1.5px var(--sub); }
.screen.student .exam-subjects .chip-btn.on { background: color-mix(in srgb, var(--sub) 24%, white); color: var(--g-ink); border-color: var(--sub); border-width: 2px; }
.screen.student :is(.pet-screen .stat .up, .hm-stats em.up, .pet-screen .hud-z3 .up) { color: var(--g-correct-ink); }
.screen.student :is(.pet-screen .stat .down, .hm-stats em.down) { color: var(--g-wrong-ink); }
.screen.student .pet-screen .hud-z3 .flat { color: var(--g-ink-soft); }
.screen.student :is(.stages span:not(.on), .pet-screen .roster-cell.locked, .pet-screen .title-row.locked .title-plate, .item.locked, .tag) { color: var(--g-ink-soft); }
.screen.session:not(.exam) .wr-done { color: var(--g-correct-ink); }
/* rarity names are coloured inline (game.js RARITY, 3.4–3.6:1 for 普通); darken the same hue to ≥ 4.5:1 */
.screen.student :is(.pc-ribbon small span, .pc-label small span, .odds td)[style] { filter: brightness(.68); }
/* .feedback.ok also matched the global .ok (green text, 3.1:1): the explanation is ink */
.screen.session:not(.exam) .feedback { color: var(--g-ink); }

/* ---------- A5: practice feedback (§4.10) ---------- */
/* answer states: colour + ✓ / ✗ (state is never colour only) */
.screen.session:not(.exam) .opt.right { border-color: var(--g-correct); background: #eaf7f0; }
.screen.session:not(.exam) .opt.wrong { border-color: var(--g-wrong); background: #fdf0ee; }
.screen.session:not(.exam) .opt.right .opt-key { background: var(--g-correct-ink); color: #fff; }
.screen.session:not(.exam) .opt.wrong .opt-key { background: var(--g-wrong-ink); color: #fff; }
.screen.session:not(.exam) .opt:is(.right, .wrong)::after { margin-left: auto; padding-left: 8px; font-weight: 800; font-size: 20px; line-height: 1.2; }
.screen.session:not(.exam) .opt.right::after { content: '✓'; color: var(--g-correct-ink); }
.screen.session:not(.exam) .opt.wrong::after { content: '✗'; color: var(--g-wrong-ink); }
.screen.session:not(.exam) .q-card.is-ok { border-color: var(--g-correct); box-shadow: 0 4px 0 color-mix(in srgb, var(--g-correct) 45%, white); }
.screen.session:not(.exam) .q-card.is-no { border-color: var(--g-wrong); box-shadow: 0 4px 0 color-mix(in srgb, var(--g-wrong) 45%, white); }
.screen.session:not(.exam) .feedback .fb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.screen.session:not(.exam) .feedback .fb-head > b { font-size: 19px; }
/* +n 經驗值: a small pill; a soft copy floats up toward the progress bar once */
.xp-float { position: relative; display: inline-block; flex-shrink: 0; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 800;
  color: var(--g-ink); background: var(--g-primary); box-shadow: inset 0 0 0 1.5px var(--g-primary-edge); }
html:not([data-motion="reduce"]) .xp-float::after { content: attr(data-xp); position: absolute; inset: 0; padding: inherit; border-radius: inherit;
  background: var(--g-primary); box-shadow: inherit; pointer-events: none; animation: g-xp-up 600ms var(--g-ease) both; }
@keyframes g-xp-up { from { transform: translateY(0); opacity: .9; } to { transform: translateY(-36px); opacity: 0; } }
html:not([data-motion="reduce"]) .screen.session:not(.exam) .q-card.is-ok { animation: g-pop 150ms var(--g-ease); }
html:not([data-motion="reduce"]) .screen.session:not(.exam) .q-card.is-no { animation: g-shake 300ms ease-in-out; }
@keyframes g-pop { 50% { transform: scale(1.06); } }
@keyframes g-shake { 0%, 50%, 100% { transform: translateX(0); } 12.5%, 62.5% { transform: translateX(-4px); } 37.5%, 87.5% { transform: translateX(4px); } }

/* ---------- A6: firefly hint (§3.2.2): tap the firefly for the next teacher-reviewed hint ---------- */
.screen.session:not(.exam) .tutor { align-items: stretch; }
.ff-hint { align-self: flex-end; display: inline-flex; align-items: center; gap: 6px; min-height: 56px; padding: 0; border: 0; background: none;
  color: var(--g-ink); font: inherit; cursor: pointer; }
.ff-say { position: relative; padding: 6px 12px; border-radius: 14px; background: #fff8e6; border: 2px solid #f0d58f; font-size: 15px; font-weight: 700; white-space: nowrap; }
.ff-say::after { content: ''; position: absolute; right: -8px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left: 8px solid #f0d58f; border-right: 0; }
.ff-say b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.ff-img { height: 56px; width: auto; aspect-ratio: 256 / 156; display: block; filter: drop-shadow(0 0 6px rgba(255, 224, 120, .75)); }
.ff-hint:active .ff-img { transform: translateY(2px); }
html:not([data-motion="reduce"]) .ff-img { animation: g-firefly 2.4s ease-in-out infinite; }
@keyframes g-firefly { 0%, 100% { opacity: .7; transform: scale(1); } 50% { opacity: 1; transform: scale(1.04); } }

/* =====================================================================================================================
   Phase B (§2.2–§3.1, §4.3–§4.8, §6 B1–B3), 2026-11-21: top bar, 5-tab bar with the centre button, 主頁 scene hub.
   Only the student shell (.screen.student.g-shell) uses these classes. No element here bounces, pulses or flashes;
   the only loops are the firefly glow (2.4 s) and the pet's 3 s breathing, both off under data-motion="reduce".
   ===================================================================================================================== */
.screen.student.g-shell { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.screen.student.g-shell.tab-home { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.screen.student.g-shell:has(.g-packstrip) { padding-bottom: calc(180px + env(safe-area-inset-bottom)); }
body:has(.g-tabbar) .toast { bottom: calc(112px + env(safe-area-inset-bottom)); }
body:has(.g-packstrip) .toast { bottom: calc(176px + env(safe-area-inset-bottom)); }
.screen.student .g-page-title { font-size: 24px; font-weight: 800; margin: 4px 0 8px; }

/* IconPlate (§4.8): emoji on a round pastel plate until the drawn icons arrive */
.g-plate { display: inline-grid; place-items: center; border-radius: 50%; background: var(--plate, #fff); flex-shrink: 0; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(34, 49, 74, .12); overflow: hidden; }
.g-plate img { width: 88%; height: 88%; object-fit: contain; }
.g-plate-emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }

/* Badge (§4.7): static, brand teal, white number; never animated */
.g-badge { position: absolute; top: -6px; right: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 999px; z-index: 2;
  background: var(--g-badge); color: #fff; font-size: 14px; font-weight: 800; line-height: 22px; text-align: center;
  box-shadow: 0 0 0 2px #fff; font-variant-numeric: tabular-nums; pointer-events: none; }

/* TopBar (§4.5) */
.g-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; min-height: 60px; margin: -16px -16px 8px;
  padding: 4px 12px; background: rgba(255, 253, 248, .88); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--g-panel-line); }
.g-avatar { position: relative; z-index: 1; width: 52px; height: 52px; padding: 0; border: 0; background: none; flex-shrink: 0; border-radius: 50%; }
.g-avatar-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.g-avatar-art { position: absolute; inset: 7px; border-radius: 50%; overflow: hidden; background: #fff; display: grid; place-items: center; }
.g-avatar-art .pet-art { width: 38px !important; height: 38px !important; }
.g-avatar-lv { position: absolute; right: -4px; bottom: -2px; min-width: 24px; height: 22px; padding: 0 4px; border-radius: 999px;
  background: var(--g-primary); border: 2px solid var(--g-primary-edge); color: var(--g-ink); font-size: 14px; font-weight: 800; line-height: 18px; text-align: center; }
/* 8 px between capsule tap areas (§4.11). If the capsules still do not fit (very narrow screen, big numbers), they wrap
   to a second row instead of sliding over the avatar. */
.g-caps { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; justify-content: flex-end; min-width: 0; }
.g-cap { position: relative; display: inline-flex; align-items: center; gap: 4px; height: 36px; margin: 6px 0; padding: 0 10px 0 4px;
  border-radius: 999px; background: #fff; border: 2px solid var(--g-panel-line); color: var(--g-ink); font-weight: 800; font-size: 15px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.g-cap::before { content: ''; position: absolute; inset: -6px 0; } /* 48 px tap height (§4.11) */
.g-cap small { font-size: 14px; color: var(--g-ink-soft); }
.g-cap:active { transform: translateY(2px); }
.g-gear { flex-shrink: 0; margin-left: 6px; } /* with the bar gap: ≥ 8 px from the last capsule's tap area */
/* Narrow phones: smaller capsules; at 360 px and below the 「/12」 is dropped (the full count stays in the aria-label). */
@media (max-width: 400px) {
  .g-topbar { gap: 4px; padding: 4px 8px; }
  .g-cap { gap: 2px; height: 34px; margin: 7px 0; padding: 0 7px 0 3px; font-size: 14px; }
  .g-cap .g-plate { width: 22px !important; height: 22px !important; font-size: 12px !important; }
  .g-cap::before { inset: -7px 0; }
}
@media (max-width: 360px) {
  .g-topbar { gap: 2px; padding: 4px 6px; }
  .g-cap { padding: 0 5px 0 2px; }
  .g-cap small { display: none; }
}

/* TabBar (§4.3): 72 px, five columns; the centre is a 72 px circle raised 20 px */
.g-tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); height: calc(72px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 2px solid var(--g-neutral-edge); box-shadow: 0 -4px 12px rgba(34, 49, 74, .08); }
.g-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 72px;
  padding: 0; border: 0; background: none; color: var(--g-ink-soft); font-size: 14px; font-weight: 700; }
.g-tab-ic { position: relative; display: inline-grid; place-items: center; height: 36px; }
.g-tab.on { color: var(--g-ink); }
.g-tab.on::after { content: ''; position: absolute; bottom: 4px; left: 50%; width: 28px; height: 4px; margin-left: -14px; border-radius: 4px; background: var(--g-primary-edge); }
.g-tab.locked .g-plate { filter: grayscale(1); }
.g-center-slot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 1px; }
.g-center { position: absolute; top: -24px; left: 50%; margin-left: -36px; width: 72px; height: 72px; padding: 0; border-radius: 50%;
  border: 6px solid #fff; background: var(--g-primary); display: grid; place-items: center;
  box-shadow: 0 4px 0 var(--g-primary-edge), 0 6px 14px rgba(34, 49, 74, .18); transition: transform 80ms ease-out, box-shadow 80ms ease-out; }
.g-center:active { transform: translateY(4px); box-shadow: 0 0 0 var(--g-primary-edge), 0 2px 6px rgba(34, 49, 74, .18); }
.g-center.k-done { background: var(--g-secondary); box-shadow: 0 4px 0 var(--g-secondary-edge), 0 6px 14px rgba(34, 49, 74, .18); }
.g-center.k-resume { background: color-mix(in srgb, var(--sub, var(--g-primary)) 22%, white); }
.g-center.k-pack, .g-center.k-album { background: #ffe3b3; }
.g-center .g-plate { box-shadow: none; }
.g-center-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); pointer-events: none; }
.g-center-sub { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: 999px; background: #fff;
  font-size: 14px; font-weight: 800; color: var(--g-ink); white-space: nowrap; box-shadow: inset 0 0 0 1.5px var(--g-neutral-edge); }
.g-center .g-badge { top: -6px; right: -6px; }
.g-center-name { font-size: 14px; line-height: 18px; font-weight: 800; color: var(--g-ink); white-space: nowrap; }

/* 3b pack strip with 「稍後」: static, above the tab bar, only after a learning-earned pack */
.g-packstrip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 29;
  width: calc(100% - 24px); max-width: 456px; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px;
  background: var(--g-panel); border: 3px solid var(--g-panel-line); border-radius: 18px; box-shadow: 0 4px 0 var(--g-panel-line);
  color: var(--g-ink); font-size: 15px; font-weight: 600; }
.g-packstrip .g-later { min-height: 48px; padding: 8px 16px; font-size: 16px; }

/* segmented sub-tabs (成就): two or three 48 px buttons (§3.5) */
.g-seg { display: flex; gap: 8px; margin: 4px 0 12px; }
.g-seg button { flex: 1; min-height: 48px; border-radius: 16px; border: 2px solid var(--g-neutral-edge); background: #fff; color: var(--g-ink-soft);
  font-size: 16px; font-weight: 800; box-shadow: 0 3px 0 var(--g-neutral-edge); }
.g-seg button.on { background: var(--g-primary); border-color: var(--g-primary-edge); color: var(--g-ink); box-shadow: 0 3px 0 var(--g-primary-edge); }
.g-seg button:active { transform: translateY(3px); box-shadow: none; }
.screen.student .pet-screen[class*="view-"] > .card:first-child { margin-top: 0; }

/* panels opened from the shell */
.screen.student .modal { background: var(--g-panel); border: 3px solid var(--g-panel-line); border-bottom: 0; }
.g-info { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.g-info p { margin: 2px 0; }
.g-wide { width: 100%; margin-top: 8px; }
.g-task .g-btn { min-height: 48px; padding: 8px 14px; font-size: 15px; white-space: nowrap; }
.g-sum-pack { display: flex; gap: 10px; align-items: center; text-align: left; background: #fffaf0; border: 2px solid #f0d58f; border-radius: 16px; padding: 10px; margin: 12px 0 0; }
.g-sum-pack p { margin: 0; }
.screen.student .g-two { display: flex; gap: 10px; margin-top: 12px; }
.screen.student .g-two .btn { flex: 1; min-height: 56px; font-size: 18px; }

/* ---------- B3: 主頁 scene hub (§3.1) ---------- */
.g-home { margin: -8px -16px 0; }
.g-scene { position: relative; height: max(500px, calc(100dvh - 160px - env(safe-area-inset-bottom))); overflow: hidden; container-type: inline-size;
  background-color: #f6e7d2; background-size: cover; background-position: center bottom; }
.g-bubbles { position: absolute; left: 12px; top: 12px; z-index: 5; display: flex; flex-direction: column; gap: 10px; }
.g-bubble { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; min-height: 72px; padding: 6px 4px 4px;
  border-radius: 18px; border: 2px solid var(--g-panel-line); background: rgba(255, 253, 248, .94); color: var(--g-ink);
  font-size: 14px; font-weight: 800; box-shadow: 0 3px 0 var(--g-panel-line); }
.g-bubble:active, .g-cont:active { transform: translateY(3px); box-shadow: none; }
.g-bubble-ic { position: relative; display: inline-grid; }
.g-cont { position: absolute; right: 12px; top: 12px; z-index: 5; width: 96px; min-height: 104px; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 24px;
  border: 3px solid var(--sub, var(--g-primary-edge)); background: rgba(255, 253, 248, .96); color: var(--g-ink);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--sub, var(--g-primary-edge)) 55%, white); }
.g-cont b { font-size: 17px; line-height: 1.1; }
.g-cont small { font-size: 14px; font-weight: 800; color: var(--g-ink-soft); }
.g-cont .g-cont-name { font-size: 14px; font-weight: 800; }
.g-cont.k-done { --sub: var(--g-secondary-edge); }
.g-decor { position: absolute; z-index: 2; width: 22%; max-width: 104px; aspect-ratio: 1; display: grid; place-items: center; pointer-events: none; }
.g-decor img { width: 100%; height: 100%; object-fit: contain; }
.g-decor span { font-size: 40px; }
.g-decor.high { right: 4%; top: 132px; }
.g-decor.ground { left: 4%; bottom: 160px; }
.g-pet { position: absolute; left: 50%; bottom: 156px; z-index: 3; width: min(200px, 54cqw); aspect-ratio: 1; margin-left: calc(min(200px, 54cqw) / -2);
  padding: 0; border: 0; background: none; border-radius: 50%; }
.g-pet .pet-art { width: 100% !important; height: 100% !important; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(31, 41, 51, .22)); }
.g-pet .pet-art.sleeping { filter: grayscale(.25) brightness(.95) drop-shadow(0 8px 10px rgba(31, 41, 51, .22)); }
html:not([data-motion="reduce"]) .g-pet:not(.resting) .pet-art { animation: g-breathe 3s ease-in-out infinite; }
@keyframes g-breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.g-zz { position: absolute; z-index: 4; left: calc(50% + 48px); bottom: calc(156px + min(170px, 46cqw)); font-size: 24px; }
.g-ff { position: absolute; z-index: 4; left: calc(50% + min(76px, 20cqw)); bottom: calc(156px + min(150px, 40cqw)); min-width: 56px; min-height: 56px;
  padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(255, 246, 200, .85) 0%, rgba(255, 246, 200, .45) 50%, rgba(255, 246, 200, 0) 72%); }
.g-ff img { height: 48px; width: auto; filter: drop-shadow(0 0 6px rgba(255, 224, 120, .8)); }
html:not([data-motion="reduce"]) .g-ff img { animation: g-firefly 2.4s ease-in-out infinite; }
.g-ff-say { position: absolute; z-index: 6; left: 96px; right: 12px; top: 128px; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: #fff8e6; border: 2px solid #f0d58f; border-radius: 16px; box-shadow: 0 3px 0 #f0d58f; }
.g-ff-say p { margin: 0; flex: 1; font-size: 16px; font-weight: 700; }
.g-ff-say small { font-size: 14px; font-weight: 600; color: var(--g-ink-soft); }
.g-ff-say .g-btn { min-height: 48px; padding: 8px 14px; font-size: 16px; }
.g-footprint { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 28px; padding: 8px 10px; border-radius: 18px;
  background: rgba(255, 253, 248, .95); border: 3px solid var(--g-panel-line); box-shadow: 0 4px 0 var(--g-panel-line); }
.g-fp-head { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.g-fp-head b { flex: 1; }
.g-fp-head b small { margin-left: 6px; font-size: 14px; font-weight: 600; color: var(--g-ink-soft); }
.g-fp-n { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.g-fp-week { display: flex; justify-content: space-between; margin: 6px 2px 2px; }
.g-fp-dot { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 34px; }
.g-fp-dot i { width: 26px; height: 26px; border-radius: 50%; border: 2px dashed var(--g-neutral-edge); display: grid; place-items: center;
  font-style: normal; font-size: 14px; background: #fff; }
.g-fp-dot.on i { border: 2px solid var(--g-secondary-edge); background: var(--g-secondary); }
.g-fp-dot.today i { box-shadow: 0 0 0 2px var(--g-primary-edge); }
.g-fp-dot small { font-size: 14px; color: var(--g-ink-soft); }
.g-fp-dot.today small { color: var(--g-ink); font-weight: 800; }
.g-fp-note { margin: 4px 0 0; text-align: center; font-size: 15px; }
.g-fp-note small { margin-left: 4px; color: var(--g-ink-soft); }
.g-fp-claim { width: 100%; margin-top: 6px; min-height: 48px; font-size: 16px; }

/* fill-in answer row: keep 提交 on one line next to the input (2026-11-21 live check) */
:is(.screen.student, .screen.session:not(.exam)) .fill .btn { white-space: nowrap; min-width: 96px; flex-shrink: 0; }

/* practice-map region tiles (UI art v1 priority B) on the subject rows and the 考試／寫作 entries */
:is(.screen.student) .g-maptile { width: 84px; height: 59px; object-fit: cover; border-radius: 12px; flex-shrink: 0; box-shadow: 0 2px 0 rgba(122, 82, 54, .18); }

/* ---------- 術語解釋 (Kevin 2026-11-21): dotted-underline key terms in the stem / passage, tap for a short explanation ----------
   Base look = the game UI (cream panel, soft shadow, ink text), used in 練習. 考試 overrides it with a neutral, subtler look in
   css/exam.css (more specific selectors, so the order of the files does not matter). Fade only, and none under reduced motion. */
.gl-host { position: relative; }
.gl-term {
  position: relative; display: inline; margin: 0; padding: 0; border: 0; border-radius: 4px; background: none;
  font: inherit; color: inherit; line-height: inherit; letter-spacing: inherit; text-align: inherit; white-space: inherit;
  text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--sub, #6e9cc9) 70%, #22314a);
  cursor: help; -webkit-tap-highlight-color: transparent;
}
/* 48 x 48 px (at least) tap target, centred on the term, without changing the line height; short terms (因數) included */
.gl-term::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: max(calc(100% + 8px), 48px); height: 48px; transform: translate(-50%, -50%);
}
.gl-term:hover, .gl-term.on { background: color-mix(in srgb, var(--sub, #6e9cc9) 14%, transparent); }
.gl-term:focus-visible { outline: 3px solid #1f5fbf; outline-offset: 2px; }
.gl-pop {
  position: absolute; z-index: 40; box-sizing: border-box; max-width: calc(100vw - 32px); padding: 12px 14px;
  background: var(--g-panel); color: var(--g-ink); border: 3px solid var(--g-panel-line); border-radius: var(--g-radius);
  box-shadow: 0 4px 0 var(--g-panel-line), 0 10px 24px rgba(34, 49, 74, .14);
  font-size: 16px; font-weight: 400; line-height: 1.6; text-align: left; white-space: normal;
}
.gl-pop:focus { outline: none; }
.gl-pop:focus-visible { outline: 3px solid #1f5fbf; outline-offset: 2px; }
.gl-head { font-weight: 800; font-size: 17px; margin-bottom: 4px; }
.gl-explain, .gl-ask { margin: 0; }
.gl-ask { font-weight: 700; }
.gl-note, .gl-sub { margin: 8px 0 0; font-size: 14px; color: var(--g-ink-soft); }
.gl-actions { display: flex; gap: 8px; margin-top: 10px; }
.gl-actions .btn { flex: 1; min-height: 48px; margin: 0; }
html:not([data-motion="reduce"]) .gl-pop { animation: gl-in 140ms ease-out; }
@media (prefers-reduced-motion: reduce) { .gl-pop { animation: none !important; } }
@keyframes gl-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
