/* Memorize (/memorize/): Scripture memory games. Same look as /plans/ and /topics/. */
:root {
    --bar: #1e40af; --bar-ink: #fff;
    --bg: #f9fafb; --card: #fff; --ink: #111827; --muted: #4b5563; --line: #e5e7eb;
    --accent: #1d4ed8; --accent-ink: #fff; --accent-soft: #dbeafe;
    --ok: #15803d; --ok-soft: #dcfce7; --bad: #b91c1c; --bad-soft: #fee2e2; --warn: #b45309; --warn-soft: #fef3c7;
    --track: #e5e7eb; --flame: #c2410c; --quote: #1f2937;
}
html.dark {
    --bar: #1e3a8a; --bg: #111827; --card: #1f2937; --ink: #f3f4f6; --muted: #9ca3af; --line: #374151;
    --accent: #60a5fa; --accent-ink: #0b1220; --accent-soft: #1e3a5f;
    --ok: #4ade80; --ok-soft: #14532d; --bad: #f87171; --bad-soft: #450a0a; --warn: #fbbf24; --warn-soft: #422006;
    --track: #374151; --flame: #fb923c; --quote: #e5e7eb;
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* header bar */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-ink);
       display: flex; align-items: center; gap: 12px; padding: 10px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.bar a { color: inherit; text-decoration: none; display: flex; align-items: center; }
.bar img { height: 28px; width: auto; }
.bar-title { font-size: 1rem; font-weight: 600; margin: 0; }
.bar .back { margin-left: auto; font-size: .875rem; padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.14); }
.bar .back:hover { background: rgba(255,255,255,.24); }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; display: grid; gap: 16px; }
#setup, #play { display: grid; gap: 16px; min-width: 0; }
.lede { margin: 0; color: var(--muted); }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
h2 { font-size: 1.1rem; margin: 0; line-height: 1.3; }
.step { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin-right: 6px; border-radius: 50%;
        background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 700; }
p { margin: 0; }
.note { font-size: .875rem; color: var(--muted); }
.note:empty { display: none; }
.note.warn { color: var(--warn); font-weight: 600; }

/* buttons */
button { font: inherit; color: var(--ink); cursor: pointer; }
button:disabled { cursor: default; }
.ghost { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: .875rem; font-weight: 600; min-height: 40px; }
.ghost small { font-weight: 400; color: var(--muted); }
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.primary { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 12px;
           padding: 14px 20px; font-size: 1.05rem; font-weight: 700; min-height: 54px; width: 100%; }
.primary:hover { filter: brightness(1.08); }
.secondary { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px 20px; font-size: 1rem; font-weight: 600; min-height: 54px; width: 100%; }
.secondary:hover { border-color: var(--accent); color: var(--accent); }

/* step 1: sources */
.options { display: grid; gap: 8px; }
.opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%; min-height: 56px;
       padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); }
.opt strong { font-size: 1rem; }
.opt small { color: var(--muted); font-size: .85rem; }
.opt:hover { border-color: var(--accent); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt[aria-pressed="true"] strong::before { content: "\2713\00a0"; color: var(--accent); }
.topic-search { display: grid; gap: 6px; padding-top: 4px; }
.topic-search label { font-weight: 600; font-size: .9rem; }
.topic-search input { width: 100%; font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
                      background: var(--card); color: var(--ink); min-height: 48px; }
.results { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.results button { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; width: 100%; text-align: left;
                  padding: 12px 14px; min-height: 48px; border: 0; background: var(--card); }
.results button:hover, .results button:focus-visible { background: var(--accent-soft); }
.results small { color: var(--muted); white-space: nowrap; }

/* step 2: games */
.level { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.level-label { font-weight: 600; font-size: .9rem; margin-right: 2px; }
.seg { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; min-height: 44px; font-weight: 600; }
.seg small { font-weight: 400; color: var(--muted); }
.seg[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg[aria-pressed="true"] small { color: inherit; opacity: .85; }
.games { display: grid; gap: 8px; }
.game { display: grid; gap: 2px; text-align: left; width: 100%; padding: 12px 14px; min-height: 64px; border: 1px solid var(--line);
        border-radius: 12px; background: var(--card); }
.game:hover:not(:disabled) { border-color: var(--accent); }
.game:disabled { opacity: .55; }
.game strong { font-size: 1.02rem; }
.game span { color: var(--muted); font-size: .875rem; }
.game .best { color: var(--ok); font-weight: 600; font-size: .8rem; }
.kinds { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 8px 14px 10px; display: grid; gap: 2px; min-width: 0; }
.kinds legend { font-size: .85rem; font-weight: 600; padding: 0 6px; }
.kinds label { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: .9rem; }
.kinds input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.kinds .off { color: var(--muted); }

/* playing */
.play-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tally { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.flame { color: var(--flame); display: inline-flex; align-items: center; gap: 4px; }
.flame svg { width: 18px; height: 18px; fill: currentColor; }
.flame.cold { color: var(--muted); }
.progress { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
#stage { display: grid; gap: 16px; min-width: 0; }
.q { display: grid; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.q, .end { scroll-margin-top: 64px; }
.q:focus { outline: none; }
.kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.prompt { font-size: 1.15rem; font-weight: 700; }
.refline { font-weight: 700; color: var(--accent); font-size: 1.05rem; }
.verse { font: 1.2rem/1.7 Georgia, "Times New Roman", serif; color: var(--quote); border-left: 4px solid var(--accent-soft);
         padding: 2px 0 2px 14px; overflow-wrap: anywhere; }
.blank { display: inline-block; min-width: 3.6em; text-align: center; border-bottom: 2px solid var(--muted); color: var(--muted); letter-spacing: .08em; line-height: 1.2; }
.blank.current { border-bottom-color: var(--accent); color: var(--accent); background: var(--accent-soft); border-radius: 4px 4px 0 0; padding: 0 4px; }
.filled { color: var(--ok); font-weight: 600; }
.answer { background: var(--ok-soft); color: var(--ok); font-weight: 700; border-radius: 4px; padding: 0 3px; }
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px; text-align: left;
          border: 2px solid var(--line); border-radius: 12px; background: var(--card); font-size: 1.05rem; font-weight: 500; }
.choice kbd { flex: none; display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 8px; font: 700 .85rem system-ui, sans-serif;
              background: var(--accent-soft); color: var(--accent); }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { color: var(--ink); opacity: .6; }
.choice.right { border-color: var(--ok); background: var(--ok-soft); opacity: 1; font-weight: 700; }
.choice.right kbd { background: var(--ok); color: var(--card); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); opacity: 1; }
.choice.wrong kbd { background: var(--bad); color: var(--card); }
.choice.right::after { content: "\2713"; margin-left: auto; color: var(--ok); font-weight: 700; }
.choice.wrong::after { content: "\2717"; margin-left: auto; color: var(--bad); font-weight: 700; }

/* build the verse */
.built { min-height: 5.5em; padding: 12px 14px; border: 2px dashed var(--line); border-radius: 12px; font: 1.1rem/1.7 Georgia, "Times New Roman", serif;
         color: var(--ok); overflow-wrap: anywhere; }
.built:empty::before { content: "Your verse appears here"; color: var(--muted); font: .9rem system-ui, sans-serif; }
.built.done { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 46px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); font-size: 1rem; font-weight: 600; }
.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip:disabled { opacity: .3; }
.chip.shake { border-color: var(--bad); background: var(--bad-soft); }
.meta { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) {
    .chip.shake, .choice.wrong { animation: shake .35s; }
}
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* the reveal */
.reveal { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.status { font-size: 1.1rem; font-weight: 700; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.fact { color: var(--quote); overflow-wrap: anywhere; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .95rem; }
.confirm .ref { font-weight: 700; }
.confirm a { font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

/* the end */
.end { display: grid; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 16px; text-align: center; }
.end:focus { outline: none; }
.big { font-size: 3rem; font-weight: 800; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.big small { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.newbest { display: inline-block; justify-self: center; background: var(--ok-soft); color: var(--ok); font-weight: 700; padding: 3px 12px; border-radius: 999px; font-size: .9rem; }
.review { text-align: left; display: grid; gap: 6px; }
.review h3 { font-size: .95rem; margin: 0; }
.review ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.review li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.end .actions { display: grid; gap: 10px; }

.credits { max-width: 640px; margin: 0 auto; padding: 8px 16px 32px; font-size: .8rem; color: var(--muted); text-align: center; }
.credits a { text-decoration: underline; text-underline-offset: 2px; }

@media (min-width: 520px) {
    .games { grid-template-columns: 1fr 1fr; }
    .end .actions { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .progress > i { transition: none; } }
