/* ── tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg:            #f6f1e7;
  --bg-tint:       #efe7d8;
  --surface:       #fffdf8;
  --surface-2:     #f9f4ea;
  --line:          #e0d5c0;
  --line-strong:   #cbbb9d;
  --ink:           #241f18;
  --ink-2:         #5c5245;
  --ink-3:         #8a7d6c;
  --accent:        #8a5a2b;
  --accent-soft:   #f0e2cd;
  --accent-ink:    #6d4520;
  --good:          #2f6b46;
  --good-soft:     #dff0e4;
  --bad:           #9b3630;
  --bad-soft:      #f7e0dd;
  --shadow:        0 1px 2px rgba(60,45,20,.06), 0 8px 24px rgba(60,45,20,.07);
  --shadow-lift:   0 2px 4px rgba(60,45,20,.08), 0 18px 40px rgba(60,45,20,.12);
  --radius:        14px;
  --serif:         "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:          "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #14120f;
    --bg-tint:     #1b1814;
    --surface:     #1e1b16;
    --surface-2:   #262119;
    --line:        #362f26;
    --line-strong: #4b4132;
    --ink:         #f2ece0;
    --ink-2:       #c2b8a6;
    --ink-3:       #8e8474;
    --accent:      #d9a066;
    --accent-soft: #3a2c1c;
    --accent-ink:  #f0c893;
    --good:        #6fc08d;
    --good-soft:   #1e3227;
    --bad:         #e08079;
    --bad-soft:    #38201e;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lift: 0 2px 4px rgba(0,0,0,.45), 0 18px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg:          #14120f;  --bg-tint:   #1b1814;  --surface:   #1e1b16;
  --surface-2:   #262119;  --line:      #362f26;  --line-strong:#4b4132;
  --ink:         #f2ece0;  --ink-2:     #c2b8a6;  --ink-3:     #8e8474;
  --accent:      #d9a066;  --accent-soft:#3a2c1c; --accent-ink:#f0c893;
  --good:        #6fc08d;  --good-soft: #1e3227;  --bad:       #e08079;
  --bad-soft:    #38201e;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lift: 0 2px 4px rgba(0,0,0,.45), 0 18px 40px rgba(0,0,0,.5);
}

/* ── base ────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
/* Rules that set `display` beat the UA's [hidden] style, so make hidden win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--accent-soft), transparent 62%),
    radial-gradient(900px 460px at 92% 0%, var(--bg-tint), transparent 60%);
  opacity: .75;
}
main { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 1080px;
       margin: 0 auto; padding: 8px 20px 72px; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -.015em; }
p { margin: 0; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em;
       background: var(--surface-2); border: 1px solid var(--line);
       border-radius: 5px; padding: .1em .38em; }

/* ── chrome ──────────────────────────────────────────────────────────────── */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; max-width: 1080px; margin: 0 auto; width: 100%;
  padding: 18px 20px 6px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { font-size: 22px; }
.brand-text { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: .01em; }
.brand-text em { color: var(--accent); font-style: italic; font-weight: 400; }
.icon-btn {
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 999px; width: 38px; height: 38px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.sitefoot {
  position: relative; z-index: 1; border-top: 1px solid var(--line);
  padding: 22px 20px 34px; text-align: center; color: var(--ink-3); font-size: 13px;
}
.sitefoot p { max-width: 700px; margin: 0 auto; }

/* ── home ────────────────────────────────────────────────────────────────── */
.hero { padding: 40px 0 34px; max-width: 720px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: 11.5px;
  font-weight: 600; color: var(--accent); margin-bottom: 14px;
}
.hero h1 { font-family: var(--serif); font-size: clamp(2.6rem, 6.5vw, 4rem); font-weight: 700; }
.lede { margin-top: 16px; color: var(--ink-2); font-size: 17px; max-width: 62ch; }
.stats { display: flex; flex-wrap: wrap; gap: 30px; margin: 30px 0 0; }
.stats div { margin: 0; }
.stats dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.stats dd { margin: 2px 0 0; font-family: var(--serif); font-size: 30px; font-weight: 700; }

.quiz-grid {
  list-style: none; padding: 0; margin: 8px 0 0;
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}
.quiz-card a {
  display: flex; flex-direction: column; gap: 10px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-decoration: none; box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.quiz-card a:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.qc-top { display: flex; align-items: center; justify-content: space-between; }
.qc-num {
  font-family: var(--serif); font-size: 13px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
}
.qc-emoji { font-size: 22px; }
.quiz-card h2 { font-family: var(--serif); font-size: 27px; font-weight: 700; }
.quiz-card p { color: var(--ink-2); font-size: 14.5px; flex: 1; }
.qc-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.qc-meter { display: flex; gap: 3px; }
.qc-meter i { width: 15px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.qc-meter i.on { background: var(--accent); }
.qc-diff { font-size: 12px; color: var(--ink-3); }
.qc-best {
  align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--good);
  background: var(--good-soft); border-radius: 999px; padding: 3px 10px;
}

/* ── play screen ─────────────────────────────────────────────────────────── */
.play { padding: 22px 0 0; max-width: 800px; margin: 0 auto; }
.play-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.backlink { color: var(--ink-3); text-decoration: none; font-size: 13.5px; }
.backlink:hover { color: var(--ink); }
.play-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap;
}
.chip-quiet { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip-score { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
              font-variant-numeric: tabular-nums; }
.progress { height: 3px; background: var(--line); border-radius: 3px; margin: 14px 0 22px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px;
                 transition: width .35s ease; }

.hymn-slab {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.hymn-id { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.hymn-no {
  flex: none; display: grid; place-items: center; width: 52px; height: 52px;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink);
  font-family: var(--serif); font-size: 22px; font-weight: 700;
}
.hymn-name { font-family: var(--serif); font-size: clamp(1.5rem, 3.6vw, 2.05rem); font-weight: 700; }
.hymn-sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.video-wrap {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
}
.video-wrap iframe, .video-wrap > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-fallback {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 10px;
  text-align: center; background: var(--surface-2); color: var(--ink-2); padding: 20px;
}
.video-fallback a { color: var(--accent-ink); font-weight: 600; }
.videobar { height: 3px; background: var(--line); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.videobar span { display: block; height: 100%; width: 0; background: var(--accent); opacity: .65; }
.videohint { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

.ask { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; margin: 30px 0 14px; }
.options { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.option {
  width: 100%; display: flex; gap: 14px; align-items: flex-start; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; color: inherit; font: inherit;
  box-shadow: var(--shadow); transition: transform .13s ease, border-color .13s ease, box-shadow .13s ease;
}
.option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lift); }
.option:disabled { cursor: default; }
.opt-key {
  flex: none; width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-top: 2px;
}
.opt-body { flex: 1; min-width: 0; }
.opt-ref { display: block; font-size: 12px; font-weight: 700; letter-spacing: .07em;
           text-transform: uppercase; color: var(--accent); margin-bottom: 5px; }
.opt-text { display: block; font-family: var(--serif); font-size: 19.5px; line-height: 1.5; color: var(--ink); }
.opt-mark { flex: none; font-size: 18px; width: 20px; text-align: right; }
.option.is-right { border-color: var(--good); background: var(--good-soft); }
.option.is-right .opt-mark::after { content: "✓"; color: var(--good); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.is-wrong .opt-mark::after { content: "✕"; color: var(--bad); }
.option.is-dim { opacity: .45; }
.play-foot { display: flex; justify-content: flex-end; margin: 20px 0 10px; }
.ghost-btn {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-3); font: inherit; font-size: 13.5px; padding: 7px 16px; cursor: pointer;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--line-strong); }

/* ── results ─────────────────────────────────────────────────────────────── */
.results { padding: 34px 0 0; max-width: 760px; margin: 0 auto; }
.badge { font-size: 60px; line-height: 1; margin-bottom: 10px; }
.results h1 { font-family: var(--serif); font-size: clamp(2.2rem, 5.6vw, 3.2rem); font-weight: 700; }
.scorecard {
  margin: 28px 0; padding: 24px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; align-items: center; gap: 28px; justify-content: space-between;
}
.score-main { display: flex; align-items: baseline; gap: 10px; }
.score-big { font-family: var(--serif); font-size: 68px; font-weight: 700; line-height: 1; color: var(--accent); }
.score-of { color: var(--ink-2); font-size: 15px; }
.score-detail { display: flex; gap: 26px; margin: 0; flex-wrap: wrap; }
.score-detail div { margin: 0; }
.score-detail dt { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.score-detail dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.share { margin: 32px 0; }
.share h2, .review-head { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; }
.share-row { display: flex; flex-wrap: wrap; gap: 10px; }
.share-btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 17px; font-size: 14px; font-weight: 600; color: var(--ink);
  cursor: pointer; font-family: inherit; transition: .15s;
}
.share-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.share-preview {
  margin-top: 14px; padding: 14px 16px; background: var(--surface-2);
  border: 1px dashed var(--line-strong); border-radius: 10px;
  color: var(--ink-2); font-size: 14px; font-style: italic;
}
.review { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: r; }
.review li {
  display: flex; gap: 13px; align-items: flex-start; background: var(--surface);
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 10px; padding: 13px 16px;
}
.review li.ok    { border-left-color: var(--good); }
.review li.miss  { border-left-color: var(--bad); }
.rv-icon { flex: none; font-size: 15px; margin-top: 1px; }
.rv-body { min-width: 0; }
.rv-hymn { display: block; font-weight: 600; font-size: 15px; }
.rv-line { display: block; font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.rv-line b { color: var(--ink); font-weight: 600; }
.rv-link { display: inline-block; margin-top: 5px; font-size: 13px;
           color: var(--accent-ink); text-decoration: none; }
.rv-link:hover { text-decoration: underline; }

.results-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 34px 0 10px; }
.primary-btn, .secondary-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; padding: 12px 24px; font: inherit; font-weight: 600;
  font-size: 15px; cursor: pointer; text-decoration: none; transition: .15s; border: 1px solid transparent;
}
.primary-btn { background: var(--accent); color: #fff8ef; }
:root[data-theme="dark"] .primary-btn { color: #1a1410; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .primary-btn { color: #1a1410; } }
.primary-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.secondary-btn { background: var(--surface); border-color: var(--line); color: var(--ink); }
.secondary-btn:hover { border-color: var(--accent); transform: translateY(-2px); }

.loading, .errorbox { padding: 70px 0; text-align: center; color: var(--ink-3); }

@media (max-width: 560px) {
  .hymn-slab { padding: 15px; }
  .opt-text { font-size: 18px; }
  .score-big { font-size: 54px; }
  .scorecard { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── wide screens: hymn on the left, answers on the right, no scrolling to play ── */
@media (min-width: 1040px) {
  .play { max-width: 1060px; display: grid; align-items: start;
          grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 34px; }
  .play-head, .progress { grid-column: 1 / -1; }
  .hymn-slab { grid-column: 1; position: sticky; top: 18px; }
  .ask       { grid-column: 2; grid-row: 3; margin-top: 0; }
  .options   { grid-column: 2; grid-row: 4; align-content: start; }
  .play-foot { grid-column: 2; grid-row: 5; }
  .hymn-slab { grid-row: 3 / span 3; }
  .opt-text  { font-size: 18px; }
}
