/* 聖經數數看 */
:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2b2620;
  --muted: #786e60;
  --line: #e6dccb;
  --accent: #8a3b2a;      /* 深紅褐，像皮面聖經 */
  --accent-ink: #ffffff;
  --gold: #b8892f;
  --mark: #f6e3a8;
  --good: #2f7a4f;
  --warn: #b5532f;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .07);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1915;
    --paper: #26221d;
    --ink: #efe8dc;
    --muted: #a99e8d;
    --line: #3a342c;
    --accent: #d27a5f;
    --accent-ink: #1c1915;
    --gold: #d9ad55;
    --mark: #5a4a22;
    --good: #6cc28f;
    --warn: #e58a66;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
}
.wrap { max-width: 760px; margin: 0 auto; padding: 32px 16px 48px; }

/* 標頭 */
.masthead { text-align: center; margin-bottom: 24px; }
.eyebrow { margin: 0; color: var(--gold); font-weight: 700; letter-spacing: .12em; font-size: 13px; }
.masthead h1 { margin: 4px 0 6px; font: 900 clamp(34px, 7vw, 48px)/1.15 var(--serif); letter-spacing: .06em; }
.tagline { margin: 0; color: var(--muted); }

/* 卡片 */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { margin: 0 0 12px; font: 700 20px/1.4 var(--serif); }
.screen { display: none; }
.screen.is-active { display: block; animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 規則 */
.rules { margin: 0 0 16px; padding-left: 1.4em; }
.rules li { margin: 4px 0; }
.score-table { display: grid; gap: 8px; margin-bottom: 20px; }
.score-table div {
  display: flex; gap: 12px; align-items: baseline;
  background: var(--bg); border-radius: 10px; padding: 10px 14px;
}
.score-table span { color: var(--muted); font-size: 14px; min-width: 2.5em; }

/* 表單 */
label { display: block; font-weight: 700; margin-bottom: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type="text"], input[type="number"] {
  flex: 1 1 180px;
  min-width: 0;
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type="number"] { font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-weight: 700; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.form-msg { margin: 8px 0 0; color: var(--warn); min-height: 1.4em; font-size: 14px; }

.btn {
  font: inherit; font-weight: 700;
  border: 0; border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }

/* 猜題 */
.label { margin: 0; color: var(--muted); text-align: center; font-size: 14px; }
.word {
  margin: 2px 0 20px; text-align: center;
  font: 900 clamp(40px, 10vw, 60px)/1.2 var(--serif);
  letter-spacing: .08em; color: var(--accent);
}
.verses { display: grid; gap: 14px; margin-bottom: 22px; }
@media (min-width: 640px) { .verses { grid-template-columns: 1fr 1fr; } }
.verse {
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg);
}
.verse-tag { margin: 0; font-size: 13px; color: var(--gold); font-weight: 700; letter-spacing: .06em; }
.verse-ref { margin: 2px 0 6px; font-weight: 700; }
.verse-text { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.85; }
.verse-text mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }

/* 結果 */
.answer {
  margin: 0 0 12px; text-align: center;
  font: 900 clamp(52px, 13vw, 76px)/1.1 var(--serif);
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.answer small, .score small { font-size: .38em; margin-left: 4px; color: var(--muted); font-weight: 700; }
.compare { display: flex; justify-content: center; gap: 12px; margin-bottom: 16px; }
.compare div { background: var(--bg); border-radius: 10px; padding: 8px 18px; text-align: center; min-width: 110px; }
.compare span { display: block; font-size: 13px; color: var(--muted); }
.compare b { font-size: 22px; font-variant-numeric: tabular-nums; }
.meter { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 0 0 18px; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 99px; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.result-score { text-align: center; margin-bottom: 18px; }
.score { margin: 0; font: 900 44px/1.1 var(--sans); font-variant-numeric: tabular-nums; }
.rating { margin: 6px 0 2px; font: 700 22px/1.4 var(--serif); color: var(--gold); }
.rating-note { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* 紀錄榜 */
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-head .card-title { margin-bottom: 4px; }
.board-sub { margin: 0; color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.word-cell { font-weight: 700; font-family: var(--serif); }
td.time { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; min-width: 42px; text-align: center; padding: 1px 8px; border-radius: 99px; font-weight: 700; background: var(--bg); }
.pill.hi { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill.lo { color: var(--muted); }
tr.is-me td { background: color-mix(in srgb, var(--gold) 12%, transparent); }
.rank-col { width: 3.5em; }
.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--bg); color: var(--muted);
}
.rank.medal-1 { background: #d9a930; color: #fff; }
.rank.medal-2 { background: #a7aab0; color: #fff; }
.rank.medal-3 { background: #b9774a; color: #fff; }
.hero-board { border-top: 4px solid var(--gold); }
.hero-flag {
  display: inline-block; margin: 10px 0 0; padding: 4px 14px;
  border-radius: 99px; font-weight: 700;
  background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold);
}
.hero-flag[hidden] { display: none; }
.empty { text-align: center; color: var(--muted); padding: 20px; }

.foot { text-align: center; color: var(--muted); font-size: 13px; }
.foot p { margin: 4px 0; }
.foot a { color: var(--accent); }

@media (max-width: 520px) {
  .card { padding: 18px 16px; }
  .row .btn { flex: 1 1 100%; }
  th, td { padding: 8px 5px; }
  td.time { line-height: 1.35; }
  td.time .d, td.time .t { display: block; }
  .rank-col { width: 2.6em; }
}
@media (prefers-reduced-motion: reduce) {
  .screen.is-active { animation: none; }
  .meter-fill { transition: none; }
}
