:root {
  /* 跟報修網站同一套顏色：深藍墨色＋報修單黃色吊牌 */
  --ink: #1B2B44;
  --ink-2: #4A5A72;
  --paper: #F3F5F8;
  --card: #FFFFFF;
  --tag: #F4C430;
  --tag-soft: #FFF6D6;
  --line: #DCE2EA;
  --ok: #1E7B4F;
  --ok-soft: #E6F4EC;
  --bad: #C8342B;
  --bad-soft: #FBEAE8;
  --blue: #2563A8;
  --font-display: "Huninn", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light;
  /* 版面：一題一張大卡片，置中窄欄，平板直拿也好按 */
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 18px; line-height: 1.6; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 760px; margin: 0 auto; padding: 18px 16px 48px; display: grid; gap: 18px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 20px; color: var(--ink); text-decoration: none; line-height: 1.3; }
.brand span:last-child { display: grid; }
.brand small { font-family: var(--font-body); font-size: 13px; color: var(--ink-2); }
.quiz-brand-tiger { width: 52px; height: 52px; object-fit: contain; }
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.tabs a { text-decoration: none; color: var(--ink-2); padding: 6px 14px; border-radius: 999px; font-size: 15px; font-weight: 500; }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.tabs a.feedback { background: var(--tag-soft); color: var(--ink); font-weight: 700; }
.tabs a.home { border-left: 1px solid var(--line); border-radius: 0 999px 999px 0; }
.tabs a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
h1, h2 { font-family: var(--font-display); font-weight: 400; text-wrap: balance; margin: 0; }
h1 { font-size: 34px; line-height: 1.3; }
h2 { font-size: 26px; line-height: 1.4; }
.lead { color: var(--ink-2); margin: 8px 0 0; }
.muted { color: var(--ink-2); }

.tag { position: relative; display: inline-flex; align-items: center; gap: 4px; background: var(--tag); color: var(--ink); font-family: var(--font-display); font-size: 18px; padding: 3px 14px 3px 26px; clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%); white-space: nowrap; }
.tag::before { content: ""; position: absolute; left: 10px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--card); }
.tag small { font-size: 13px; font-family: var(--font-body); }

.start { display: grid; gap: 18px; }
.tiger-hero { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 10px; margin: -24px -24px 0; padding: 28px 30px 18px; overflow: hidden; border-radius: 18px 18px 0 0; background: #fff2c8; }
.tiger-intro { position: relative; z-index: 1; }
.tiger-kicker { display: inline-block; padding: 4px 11px; border-radius: 999px; background: #fff; color: #85501b; font-size: 14px; font-weight: 700; }
.tiger-hero h1 { margin: 12px 0 7px; font-weight: 700; color: #24334b; }
.tiger-hero p { margin: 0; color: #5d513a; }
.tiger-stats { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.tiger-stats span { padding: 3px 10px; border-radius: 999px; background: #fff9e8; color: #674518; font-size: 14px; font-weight: 700; }
.tiger-mascot { width: 100%; max-width: 220px; height: 210px; object-fit: contain; }
.challenge-guide { margin: 0; color: var(--ink-2); font-size: 16px; }
.start .mode { border-color: #ecb632; background: #fff7dd; }
.start .mode:hover { border-color: #a96613; background: #ffefbc; }
@media (max-width: 520px) { .tiger-hero { grid-template-columns: minmax(0, 1fr) 110px; padding: 22px 18px 16px; } .tiger-hero h1 { font-size: 26px; } .tiger-mascot { height: 150px; } .tiger-kicker { font-size: 12px; } .tiger-stats { grid-column: 1 / -1; } .tiger-stats span { font-size: 12px; } }
.who-row { display: grid; grid-template-columns: 8em 1fr; gap: 12px; }
.school-field { margin-bottom: 12px; }
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 700; }
.input { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; min-height: 52px; }
.input:focus { border-color: var(--ink); outline: none; }
.hint { font-size: 14px; color: var(--ink-2); font-weight: 400; }
.err { color: var(--bad); font-size: 15px; }
.modes { display: grid; gap: 10px; }
.mode { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; padding: 14px 18px; border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; min-height: 64px; }
.mode:hover { border-color: var(--ink-2); }
.mode b { font-family: var(--font-display); font-weight: 400; font-size: 21px; }
.mode span { display: grid; }
.mode small { color: var(--ink-2); font-size: 15px; }
.mode .go { margin-left: auto; font-weight: 700; color: var(--blue); white-space: nowrap; }
.btn { appearance: none; border: 0; border-radius: 14px; padding: 12px 22px; font-weight: 700; cursor: pointer; background: var(--ink); color: #fff; min-height: 52px; }
.btn:hover { background: #26395A; }
.btn-ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.btn-ghost:hover { background: var(--paper); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.progress { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--tag); border-radius: 999px; transition: width .3s; }
.qhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cat { font-size: 14px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; background: #fff; }
.q { font-size: 22px; line-height: 1.55; margin: 0 0 18px; font-weight: 500; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; min-height: 56px; }
.opt:hover:not([disabled]) { border-color: var(--ink-2); }
.opt b { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--paper); font-size: 16px; }
.opt[disabled] { cursor: default; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right b { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong b { background: var(--bad); color: #fff; }
.explain { margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--tag-soft); border: 1px solid #EED9A0; }
.explain strong { display: block; margin-bottom: 4px; }

.score { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-display); }
.score b { font-size: 64px; font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 4px 14px; border-radius: 999px; font-weight: 700; background: var(--tag-soft); color: #7A5A00; }
.badge.top { background: var(--ok-soft); color: var(--ok); }
.cats { display: grid; gap: 8px; margin: 18px 0 0; }
.catrow { display: grid; grid-template-columns: 7em 1fr 3.2em; gap: 10px; align-items: center; font-size: 16px; }
.catrow .bar span { background: var(--ink); }
.catrow em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.review { display: grid; gap: 12px; margin: 12px 0 0; padding: 0; list-style: none; }
.review li { border-left: 4px solid var(--bad); padding: 4px 0 4px 14px; }
.review .ans { color: var(--ok); font-weight: 700; }
.review .meta { font-size: 15px; color: var(--ink-2); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.board { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.board th, .board td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.board th { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.board td.n { width: 3em; font-family: var(--font-display); font-size: 20px; }
.board td.s { text-align: right; font-weight: 700; }
.board th.s { text-align: right; }
.board tr.me td { background: var(--tag-soft); }
.medal { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--tag); }
.medal.m2 { background: #D7DDE6; }
.medal.m3 { background: #E9C9A6; }
.myrank { margin-top: 12px; font-weight: 700; }

.bank-tools { display: grid; gap: 10px; }
.bank { display: grid; gap: 10px; }
.bank article { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
.bank h3 { font-size: 17px; margin: 6px 0 6px; font-weight: 700; line-height: 1.5; }
.bank ol { margin: 0; padding-left: 1.4em; display: grid; gap: 2px; font-size: 16px; }
.bank li.ans { color: var(--ok); font-weight: 700; }
.bank p { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; }
.foot { color: var(--ink-2); font-size: 14px; }
@media (max-width: 520px) { h1 { font-size: 28px; } .q { font-size: 20px; } .card { padding: 18px; } .who-row { grid-template-columns: 1fr; } .catrow { grid-template-columns: 6em 1fr 3em; } .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; } .tabs a { padding: 6px 10px; white-space: nowrap; } }
@media (prefers-reduced-motion: reduce) { .bar span { transition: none; } }
.btn-s { padding: 6px 14px; font-size: 15px; min-height: 0; }
.login-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--tag-soft); font-size: 15px; }
.login-box.ok { background: var(--ok-soft); }
.login-box b { word-break: break-all; }
.myrank .btn-s { margin-left: 8px; vertical-align: middle; }
.who-mail { font-size: 13px; color: var(--ink-2); word-break: break-all; }
.btn-s { white-space: nowrap; }
.board td.s { white-space: nowrap; }
@media (max-width: 520px) { .board.adm th:nth-child(5), .board.adm td:nth-child(5) { display: none; } .board.adm td { padding-left: 4px; padding-right: 4px; } }

/* ---------- 3D 打怪 ---------- */
.lite { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--ink-2); margin-top: 14px; cursor: pointer; }
.lite input { width: 18px; height: 18px; }
.battle { display: grid; gap: 14px; }
.arena-box { position: relative; height: clamp(230px, 44vh, 430px); border-radius: 18px; overflow: hidden; background: #1B2B44; }
.arena-3d { position: absolute; inset: 0; }
.arena-3d canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.arena-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(200, 52, 43, 0) 35%, rgba(200, 52, 43, .8)); }
.arena-flash.on { animation: arena-hurt .7s ease-out; }
@keyframes arena-hurt { from { opacity: 1; } to { opacity: 0; } }
.hud { position: absolute; inset: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; padding: 10px 12px; color: #fff; pointer-events: none; font-variant-numeric: tabular-nums; }
.hud-chip { justify-self: start; background: rgba(14, 24, 40, .75); border-radius: 999px; padding: 3px 12px; font-size: 15px; white-space: nowrap; }
.hud-ko { justify-self: end; }
.hud-name { display: grid; justify-items: center; gap: 4px; text-align: center; }
.hud-name b { font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.2; color: var(--tag); text-shadow: 0 2px 0 #0E1828; }
.hud-name small { position: relative; background: #fff; color: var(--ink); border-radius: 12px; padding: 3px 12px; font-size: 14px; line-height: 1.5; max-width: 15em; }
.hud-name small:empty { display: none; }
.hud-name small::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-top-color: #fff; border-bottom: 0; }
.hud-sound { position: absolute; right: 10px; bottom: 10px; border: 0; border-radius: 999px; padding: 4px 12px; font-size: 14px; background: rgba(14, 24, 40, .75); color: #fff; cursor: pointer; }
.combo { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); font-family: var(--font-display); font-size: clamp(26px, 6vw, 44px); color: var(--tag); text-shadow: 0 3px 0 #0E1828, 0 0 18px rgba(124, 247, 255, .7); white-space: nowrap; opacity: 0; pointer-events: none; }
.combo.on { animation: combo 1.4s ease-out; }
@keyframes combo { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 75% { opacity: 1; transform: translate(-50%, -55%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70%); } }
.streak { margin-left: auto; background: var(--tag-soft); border: 1px solid #EED9A0; border-radius: 999px; padding: 0 10px; font-size: 14px; font-weight: 700; }
.keyhint { color: var(--ink-2); font-size: 14px; margin: 10px 0 0; }
.row .keyhint { margin: 0; }
@media (hover: none) { .keyhint { display: none; } }
@media (min-width: 640px) { .battle .opts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .hud-name b { font-size: 20px; } .hud-chip { font-size: 13px; padding: 2px 9px; } .hud-name small { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .combo.on { animation-duration: 2s; } .arena-flash.on { animation-duration: .3s; } }
@media (max-width: 480px) { .arena-box { height: clamp(200px, 34vh, 320px); } }

/* 管理員：暫停排行榜 */
.pause-box { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--tag-soft); border: 1px solid #EED9A0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.pause-box p { margin: 0; flex: 1 1 260px; font-size: 15px; }

/* 血量：5 顆心 */
.hp { display: inline-flex; gap: 2px; line-height: 1; vertical-align: middle; }
.hp i { font-style: normal; font-size: 18px; color: rgba(255, 255, 255, .28); }
.hp i.on { color: #FF5C7A; text-shadow: 0 1px 0 #0E1828; }
.hp i.lost { animation: heart-lost .7s ease-out; }
@keyframes heart-lost { 0% { color: #FF5C7A; transform: scale(1.6); } 100% { transform: scale(1); } }
.hud-left { display: grid; gap: 6px; justify-items: start; }
.hud-hp { padding: 4px 10px; }
.prog-r { display: inline-flex; align-items: center; gap: 10px; }
.progress .hp i { color: #D6DCE5; }
.progress .hp i.on { color: #E8455F; text-shadow: none; }
.over { text-align: center; }
.over .lead { margin-left: auto; margin-right: auto; }
.over .row { justify-content: center; }
.over-hp { margin: 0 0 8px; }
.over-hp .hp i { font-size: 30px; color: #D6DCE5; }
@media (prefers-reduced-motion: reduce) { .hp i.lost { animation: none; } }

/* 看圖題：4 張圖選 1 */
.opts.opts-pic { grid-template-columns: 1fr 1fr; }
.opts-pic .opt { flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; position: relative; }
.opts-pic .opt b { position: absolute; left: 8px; top: 8px; }
.opts-pic .opt svg { width: 100%; max-width: 200px; height: auto; aspect-ratio: 4 / 3; }
.pic-name { font-size: 14px; color: var(--ink-2); text-align: center; }
/* 找位置題：在大圖上點 */
.spot { margin-top: 6px; border-radius: 14px; overflow: hidden; background: #EEF1F5; }
.board-svg { display: block; width: 100%; height: auto; max-height: 62vh; }
.rg rect { fill: transparent; stroke: transparent; stroke-width: 4; }
.rg[tabindex] { cursor: pointer; outline: none; }
@media (hover: hover) { .rg[tabindex]:hover rect { fill: rgba(255, 255, 255, .18); stroke: rgba(255, 255, 255, .7); stroke-dasharray: 6 4; } }
.rg[tabindex]:focus-visible rect { stroke: #F4C430; stroke-dasharray: 6 4; fill: rgba(244, 196, 48, .15); }
.rg.right rect { stroke: #F4C430; stroke-width: 6; fill: rgba(244, 196, 48, .25); }
.rg.wrong rect { stroke: #E8455F; stroke-width: 6; fill: rgba(232, 69, 95, .2); }
.spot-hint { text-align: center; }
@media (hover: none) { .spot-hint { display: block; } }
/* 題庫頁 */
.bank-pic { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding-left: 0; list-style: none; }
.bank-pic li { display: grid; justify-items: center; gap: 2px; font-size: 13px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.bank-pic li.ans { border-color: #2E9E5B; background: #EAF7EF; }
.bank-pic svg { width: 100%; height: auto; }
.spot-s { max-width: 420px; }
.ans-line { font-weight: 700; color: #1F7A4D; }

/* 登上排行榜的慶祝畫面 */
.celebrate { display: flex; align-items: center; gap: 18px; margin-top: 16px; padding: 18px 20px; border-radius: 18px; background: linear-gradient(135deg, #FFF7DA, #FFE9B0); border: 2px solid #F4C430; opacity: 0; transform: scale(.85); }
.celebrate.tier-silver { background: linear-gradient(135deg, #F4F7FB, #DDE4EE); border-color: #9AA3B2; }
.celebrate.tier-bronze { background: linear-gradient(135deg, #FFF1E4, #F6D2B0); border-color: #D08A4E; }
.celebrate.tier-top10 { background: linear-gradient(135deg, #EEF6FF, #D3E7FC); border-color: #5AA9F0; }
.celebrate.tier-go { background: linear-gradient(135deg, #FFFBEA, #FFF0C2); border-color: #F4C430; }
.celebrate.go { animation: cele-in .7s cubic-bezier(.2, 1.5, .4, 1) forwards; }
.celebrate.still { animation: none; opacity: 1; transform: none; }
@keyframes cele-in { to { opacity: 1; transform: scale(1); } }
.trophy { position: relative; flex: none; width: 96px; height: 96px; }
.trophy svg { width: 100%; height: 100%; }
.celebrate.go:not(.still) .trophy svg { animation: trophy-pop 1s .25s both cubic-bezier(.2, 1.6, .4, 1), trophy-glow 2.4s 1.2s ease-in-out 2; }
@keyframes trophy-pop { from { transform: scale(.2) rotate(-25deg); } to { transform: none; } }
@keyframes trophy-glow { 50% { filter: drop-shadow(0 0 14px rgba(244, 196, 48, .9)); transform: scale(1.06); } }
.rank-num { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-family: var(--font-display); font-size: 30px; color: #1B2B44; text-shadow: 0 2px 0 rgba(255, 255, 255, .8); }
.tier-top10 .rank-num { top: 50%; color: #fff; text-shadow: 0 2px 0 #1B4F9A; }
.tier-go .rank-num { top: 38%; font-size: 26px; }
.rank-title { margin: 0; font-family: var(--font-display); font-size: clamp(22px, 5vw, 30px); line-height: 1.3; }
.rank-title b { font-weight: 400; color: #C2410C; font-size: 1.3em; }
.rank-msg { margin: 6px 0 0; font-size: 17px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -20px; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }
@media (max-width: 480px) { .celebrate { gap: 12px; padding: 14px; } .trophy { width: 72px; height: 72px; } .rank-num { font-size: 24px; } }
@media (prefers-reduced-motion: reduce) { .celebrate.go { animation: none; opacity: 1; transform: none; } .celebrate .trophy svg { animation: none !important; } }
.nw { white-space: nowrap; }
