:root {
  --cream: #FBF4E2; --cream-2: #F3EAD2; --green: #15402B; --text: #1D2A22; --soft: #4F5A50;
  --brass: #A67C2D; --hair: #A67C2D80; --error: #8A2B1E;
  --book: "Iowan Old Style", "Palatino Linotype", Palatino, ui-serif, "New York", Georgia, serif;
  --gutter: 20px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--cream); }
body { margin: 0; color: var(--text); font: 400 1.125rem/1.55 var(--book); }
h1, h2, h3, p, dl, dd, ol, ul, fieldset, legend { margin: 0; padding: 0; border: 0; }
ol, ul { list-style: none; }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; touch-action: manipulation; }
button:disabled { opacity: 1; cursor: default; color: var(--soft); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
h2:focus { outline: none; }

header { padding: 18px var(--gutter) 14px; border-bottom: 2px solid var(--brass); text-align: center; }
#site-title { display: inline-flex; align-items: center; gap: 12px; font-size: clamp(1.625rem, 7vw, 2.5rem); font-weight: 500; line-height: 1.1; color: var(--green); letter-spacing: -.005em; }
#site-title img { height: 1.15em; width: auto; display: block; }
body:has(#app[data-current-screen="reading"]) #site-title,
body:has(#app[data-current-screen="questions"]) #site-title { font-size: 1.25rem; }

#app { max-width: 42rem; margin: 0 auto; padding: 28px var(--gutter) 56px; }
h2 { font-size: 1.75rem; font-weight: 500; line-height: 1.2; color: var(--green); }
h3 { font-size: 1.125rem; font-weight: 600; color: var(--green); margin-top: 28px; padding-bottom: 6px; border-bottom: 1px solid var(--hair); }
.lede, #screen-ready p:not([class]):first-of-type { margin-top: 10px; }
.meta { margin-top: 10px; color: var(--soft); font-style: italic; }
#load-error, #questions-error { color: var(--error); margin-bottom: 14px; }

button[id^="btn-"] { width: 100%; min-height: 52px; padding: 0 22px; border-radius: 3px; font-size: 1.1875rem; }
#btn-random, #btn-start, #btn-stop, #btn-submit, #btn-again { background: var(--green); color: var(--cream); }
#btn-random:disabled { background: var(--cream-2); color: var(--soft); }
#btn-daily, #btn-share { border: 1px solid var(--green); color: var(--green); }
#btn-daily:disabled { border-color: var(--hair); color: var(--soft); }
#btn-cancel, #btn-home, #btn-clear { color: var(--green); text-decoration: underline; text-decoration-color: var(--brass); text-underline-offset: 5px; min-height: 44px; }
#btn-clear { color: var(--soft); font-size: 1rem; width: auto; padding: 0; }
section p:has(> button) { margin-top: 12px; }

#difficulty-options { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--hair); }
#difficulty-options legend { font-style: italic; color: var(--soft); margin-bottom: 2px; }
#difficulty-options label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 52px; cursor: pointer; }
#difficulty-options input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
#difficulty-options label:has(input:checked) { color: var(--green); font-weight: 600; box-shadow: inset 0 -3px 0 var(--brass); }
#difficulty-options label:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: -2px; }
#daily-status { margin-top: 10px; color: var(--soft); font-style: italic; font-size: 1rem; text-align: center; }

#screen-reading h2 { text-align: center; font-style: italic; font-size: 1.5rem; }
.clock { text-align: center; color: var(--soft); font-size: 1rem; font-variant-numeric: tabular-nums; margin-top: 2px; }
#timer-status { text-align: center; font-style: italic; font-size: 1rem; color: var(--soft); min-height: 1.55em; }
#passage-text { margin: 8px auto 0; max-width: 34em; font-size: clamp(1.25rem, 5.1vw, 1.4375rem); line-height: 1.62; hyphens: manual; text-wrap: pretty; font-feature-settings: "liga", "kern", "onum"; }
#passage-text p + p { text-indent: 1.4em; }
#btn-stop { margin-top: 26px; }

#questions-list fieldset { padding: 22px 0 16px; border-bottom: 1px solid var(--hair); }
#questions-list legend { float: left; width: 100%; font-size: 1.1875rem; line-height: 1.4; padding-bottom: 10px; }
#questions-list fieldset > div { clear: both; }
#questions-list label { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 11px 8px; border-radius: 3px; cursor: pointer; line-height: 1.35; }
#questions-list label:has(input:checked) { background: var(--cream-2); color: var(--green); font-weight: 600; }
#questions-list input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--green); }
#questions-error { margin-top: 14px; }
#btn-submit { margin-top: 10px; }

#results dl { margin-top: 12px; }
#results dl div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
#results dd { font-weight: 600; color: var(--green); text-align: right; font-variant-numeric: lining-nums tabular-nums; }
#results .headline { flex-direction: column; align-items: center; gap: 0; padding: 14px 0 18px; border-bottom: 2px solid var(--brass); }
#results .headline dd { order: -1; font-size: clamp(4.5rem, 22vw, 6.5rem); font-weight: 500; line-height: 1; }
#results .headline small { font-size: 1.25rem; font-weight: 400; }
#result-band-note { margin-top: 12px; font-size: 1rem; font-style: italic; color: var(--soft); }
#result-note { margin-top: 8px; color: var(--green); font-weight: 600; }
#result-note:empty { display: none; }
label[for="share-text"] { display: block; margin-top: 10px; color: var(--soft); font-style: italic; font-size: 1rem; }
#share-text { display: block; width: 100%; margin-top: 6px; padding: 10px 0 10px 14px; background: none; border: 0; border-left: 2px solid var(--brass); border-radius: 0; resize: none; }
#share-status { display: block; margin-top: 4px; font-style: italic; }
#result-review li { position: relative; padding: 12px 0 12px 30px; border-bottom: 1px solid var(--hair); line-height: 1.45; }
#result-review li::before { position: absolute; left: 2px; font-weight: 700; }
#result-review li[data-correct="true"]::before { content: "\2713"; color: var(--green); }
#result-review li[data-correct="false"]::before { content: "\2717"; color: var(--error); }
#btn-again { margin-top: 18px; }

#progress { margin-top: 44px; padding-top: 22px; border-top: 2px solid var(--brass); }
#progress h2 { font-size: 1.5rem; }
#personal-bests li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--hair); }
#personal-bests span { color: var(--green); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
#history-empty { margin-top: 10px; font-style: italic; color: var(--soft); }
#history-list li { padding: 10px 0; border-bottom: 1px solid var(--hair); font-size: 1rem; }
#storage-status { margin-top: 10px; color: var(--error); font-size: 1rem; }

@media (min-width: 720px) {
  #app { padding-top: 40px; }
  section p:has(> #btn-stop), section p:has(> #btn-submit), section p:has(> #btn-start), section p:has(> #btn-cancel) { text-align: center; }
  #btn-stop, #btn-submit, #btn-start { width: auto; min-width: 280px; }
  #btn-cancel { width: auto; }
}
@media (min-width: 1000px) {
  #app[data-current-screen="setup"] { max-width: 980px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; column-gap: 64px; align-items: start; }
  #app[data-current-screen="setup"] #load-error { grid-column: 1 / -1; }
  #app[data-current-screen="setup"] #progress { margin: 0; padding: 0 0 0 40px; border-top: 0; border-left: 1px solid var(--brass); margin-left: -40px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
