/* 聖經知識王 — 溫暖紙質 × 競賽金（沿用 versele 視覺語言） */
:root {
  --bg: #faf6ee;
  --card: #fffdf7;
  --ink: #2d2416;
  --ink-soft: #6f6352;
  --line: #e6dcc8;
  --gold: #a87b2d;
  --gold-soft: #f3e8d2;
  --green: #4a7c46;
  --green-bg: #e4efe0;
  --red: #b0483e;
  --red-bg: #f5e0dc;
  --yellow: #b98f1e;
  --yellow-bg: #f7edd0;
  --gray-bg: #efeade;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(90, 70, 30, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171310;
    --card: #211c16;
    --ink: #ece2d0;
    --ink-soft: #a2947c;
    --line: #3a3226;
    --gold: #d3a856;
    --gold-soft: #33291a;
    --green: #8fbf87;
    --green-bg: #263822;
    --red: #d98a80;
    --red-bg: #3c221e;
    --yellow: #d8b34a;
    --yellow-bg: #3a2f14;
    --gray-bg: #2a251d;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  }
}
/* 關鍵：author 的 display 會蓋掉 hidden 屬性，必須明確補回（前款遊戲踩過的雷） */
[hidden] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  max-width: 520px; margin: 0 auto; padding: 0 14px 40px;
  min-height: 100%;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
h1 { font-size: 1.15rem; letter-spacing: .12em; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.brand-icon { font-size: 1rem; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft); font-size: .95rem; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
}
.icon-btn:active { transform: scale(.93); }

/* ---------- 畫面切換 ---------- */
.screen { display: none; }
.screen.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 主頁：段位卡 ---------- */
.rank-card {
  background: linear-gradient(135deg, var(--gold-soft), var(--card));
  border: 1px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 14px;
}
.rank-line { display: flex; align-items: baseline; gap: 8px; }
.rank-name { font-size: 1.2rem; font-weight: 800; color: var(--gold); letter-spacing: .1em; }
.rank-total { font-size: .8rem; color: var(--ink-soft); margin-left: auto; }
.rank-bar { height: 8px; background: var(--gray-bg); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.rank-bar > div { height: 100%; background: var(--gold); border-radius: 99px; transition: width .5s ease; }
.rank-next { font-size: .72rem; color: var(--ink-soft); margin-top: 6px; }

/* ---------- 主頁：模式卡 ---------- */
.mode-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
  font: inherit; color: inherit; cursor: pointer;
}
.mode-card:not(.static):active { transform: scale(.985); }
.mode-card.static { cursor: default; }
.mode-icon { font-size: 1.6rem; flex-shrink: 0; }
.mode-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mode-title { font-size: 1rem; font-weight: 700; letter-spacing: .08em; }
.mode-desc { font-size: .76rem; color: var(--ink-soft); }
.mode-tag { font-size: .74rem; font-weight: 700; color: var(--gold); white-space: nowrap; }
.cat-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cat-chip {
  font: inherit; font-size: .82rem; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
}
.cat-chip:active { transform: scale(.95); }
.cat-chip .acc { color: var(--ink-soft); font-size: .72rem; margin-left: 4px; }

/* ---------- 答題 ---------- */
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.quiz-mid { flex: 1; min-width: 0; }
#quiz-progress { font-size: .78rem; color: var(--ink-soft); letter-spacing: .08em; margin-bottom: 4px; }
.timer-wrap { display: flex; align-items: center; gap: 8px; }
.timer-bar { flex: 1; height: 8px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
#timer-fill { height: 100%; width: 100%; background: var(--gold); border-radius: 99px; }
#timer-fill.hurry { background: var(--red); }
#timer-num { font-size: .8rem; font-weight: 700; color: var(--ink-soft); min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }
.quiz-score { font-weight: 800; color: var(--gold); font-size: 1.05rem; display: flex; align-items: baseline; gap: 2px; font-variant-numeric: tabular-nums; }
.score-lbl { font-size: .7rem; color: var(--ink-soft); font-weight: 400; }

.combo-badge {
  display: inline-block; font-size: .8rem; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #d3763a, var(--gold));
  border-radius: 999px; padding: 4px 14px; margin-bottom: 8px;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.q-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 18px 14px; margin-bottom: 14px;
}
.q-type { font-size: .72rem; font-weight: 700; color: var(--gold); letter-spacing: .15em; margin-bottom: 8px; }
.q-text {
  font-family: "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-size: 1.12rem; line-height: 1.85; letter-spacing: .03em; min-height: 2.8em;
  overflow-wrap: anywhere;
}
.q-text .ellipsis { color: var(--gold); font-weight: 700; }
.q-prompt { font-size: .82rem; color: var(--ink-soft); margin-top: 10px; }

.options { display: flex; flex-direction: column; gap: 8px; }
.opt-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-height: 48px; font: inherit; font-size: .95rem; color: inherit;
  cursor: pointer; overflow-wrap: anywhere;
}
.opt-btn:not(:disabled):active { transform: scale(.985); }
.opt-btn .opt-key {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--gray-bg); color: var(--ink-soft); font-size: .72rem; font-weight: 700;
  display: grid; place-items: center;
}
.opt-btn.correct { background: var(--green-bg); border-color: var(--green); font-weight: 700; }
.opt-btn.correct .opt-key { background: var(--green); color: #fff; }
.opt-btn.wrong { background: var(--red-bg); border-color: var(--red); }
.opt-btn.wrong .opt-key { background: var(--red); color: #fff; }
.opt-btn.dim { opacity: .45; }
.opt-btn:disabled { cursor: default; }

.feedback {
  background: var(--gold-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px;
  font-size: .86rem; line-height: 1.7; animation: pop .25s ease;
}
.feedback .fb-gain { font-weight: 800; color: var(--green); }
.feedback .fb-miss { font-weight: 800; color: var(--red); }
.feedback .fb-verse { font-family: "Noto Serif TC", Georgia, serif; margin-top: 4px; }
.feedback .fb-ref { color: var(--gold); font-weight: 700; font-size: .8rem; }

.primary-btn {
  width: 100%; margin-top: 14px; padding: 13px; border: none; border-radius: 12px;
  background: var(--gold); color: #fff; font: inherit; font-size: 1.02rem; font-weight: 700;
  letter-spacing: .2em; cursor: pointer; box-shadow: var(--shadow);
}
.primary-btn.share { background: var(--green); }
.primary-btn:active { transform: scale(.98); }
.ghost-btn {
  width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: transparent; color: var(--ink-soft); font: inherit; font-size: .95rem;
  letter-spacing: .15em; cursor: pointer;
}

/* ---------- 結算 ---------- */
.result-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 20px; text-align: center;
}
.result-title { font-size: 1.15rem; font-weight: 800; letter-spacing: .12em; margin-bottom: 10px; }
.result-score { font-size: 2.4rem; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.result-score::after { content: " 分"; font-size: .9rem; color: var(--ink-soft); font-weight: 400; }
.result-sub { font-size: .88rem; color: var(--ink-soft); margin-top: 6px; }
.result-grid { font-size: 1.05rem; letter-spacing: 2px; margin-top: 12px; word-break: break-all; }
.result-rank { font-size: .82rem; color: var(--ink-soft); margin-top: 12px; }
.result-rank b { color: var(--gold); }

/* ---------- 彈窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 14, 5, .55);
  display: grid; place-items: center; z-index: 50; padding: 18px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: var(--card); color: var(--ink); border-radius: 18px; position: relative;
  max-width: 440px; width: 100%; max-height: 82vh; overflow-y: auto;
  padding: 26px 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; right: 12px; border: none; background: none;
  color: var(--ink-soft); font-size: 1.1rem; cursor: pointer; padding: 6px;
}
.modal h2 { font-size: 1.1rem; letter-spacing: .1em; margin-bottom: 14px; }
.modal h3 { font-size: .9rem; letter-spacing: .08em; margin: 14px 0 6px; color: var(--gold); }
.modal p { font-size: .9rem; line-height: 1.75; color: var(--ink-soft); margin-bottom: 8px; }
.modal .rank-list { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.modal .rank-list span { display: flex; justify-content: space-between; padding: 3px 6px; border-radius: 6px; }
.modal .rank-list span.now { background: var(--gold-soft); font-weight: 700; }
.modal .rank-list i { font-style: normal; color: var(--ink-soft); font-size: .78rem; }
.stats-grid { display: flex; justify-content: space-around; text-align: center; margin: 16px 0; }
.stats-grid .num { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
.stats-grid .lbl { font-size: .72rem; color: var(--ink-soft); }
.acc-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: .82rem; }
.acc-row .acc-name { width: 4.4em; flex-shrink: 0; }
.acc-track { flex: 1; height: 14px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.acc-track > div { height: 100%; background: var(--gold); border-radius: 99px; }
.acc-row .acc-num { width: 6em; text-align: right; color: var(--ink-soft); font-size: .76rem; font-variant-numeric: tabular-nums; }
.share-btn {
  width: 100%; margin-top: 14px; padding: 12px; border: none; border-radius: 12px;
  background: var(--green); color: #fff; font: inherit; font-size: 1rem; font-weight: 700; letter-spacing: .15em; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: .9rem; z-index: 99; animation: pop .2s ease; white-space: nowrap; max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
}
@media (min-width: 521px) { body { padding-top: 6px; } }
