:root {
  color-scheme: light dark;
  --bg: #f4efe6;
  --ink: #1c1915;
  --muted: #5e584e;
  --card: #fffdf8;
  --line: #e3dacb;
  --accent: #7d342b;
  --accent-ink: #fffdf8;
  --correct: #1b5c3a;
  --correct-bg: #e4f3ea;
  --wrong: #7d342b;
  --wrong-bg: #f8e7e3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --ink: #f4efe6;
    --muted: #b7b0a4;
    --card: #221f1b;
    --line: #3c362e;
    --accent: #e7b2a8;
    --accent-ink: #1c1210;
    --correct: #9ed7b6;
    --correct-bg: #173226;
    --wrong: #f0b2a6;
    --wrong-bg: #3a221c;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 "Iowan Old Style", Palatino, Georgia, serif;
}

main {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding:
    calc(1.25rem + env(safe-area-inset-top))
    calc(1rem + env(safe-area-inset-right))
    calc(2.5rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 0.15rem 0 0.35rem;
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  margin: 0 0 0.85rem;
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1.35;
}

.eyebrow,
.meta,
.kicker,
.source,
.loading,
.score p,
.note {
  font-family: system-ui, -apple-system, sans-serif;
}

.eyebrow,
.meta,
.kicker,
.source,
.note {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meta {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.question {
  margin: 0 0 1.25rem;
  padding: 1rem 0 0.25rem;
  border-top: 1px solid var(--line);
}

.kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

button {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 44px;
  margin: 0 0 0.5rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: 16px/1.35 system-ui, -apple-system, sans-serif;
  text-align: left;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice .mark {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.choice.is-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
}

.choice.is-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
}

.choice:disabled:not(.is-correct):not(.is-wrong) {
  opacity: 0.55;
}

.reveal,
.retake {
  font-weight: 650;
  text-align: center;
}

.retake {
  margin: 0.85rem 0 0;
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.feedback {
  margin: 0.35rem 0 0.5rem;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}

.feedback .label,
.feedback .answer,
.feedback .explanation,
.feedback .source {
  margin: 0;
}

.feedback .label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.feedback .answer,
.feedback .explanation {
  margin-top: 0.35rem;
}

.feedback .source {
  margin-top: 0.55rem;
  font-size: 0.85rem;
}

.feedback.is-correct .label {
  color: var(--correct);
}

.feedback.is-wrong .label {
  color: var(--wrong);
}

.score {
  margin-top: 0.5rem;
  padding: 1.1rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.score .score-num {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 2.4rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}

.score-num span {
  color: var(--muted);
  font-size: 1.3rem;
}

.score p {
  margin: 0.45rem 0 0;
}

.note {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.5rem;
  font-family: system-ui, -apple-system, sans-serif;
}

.home-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: -0.15rem;
  padding: 0 0.15rem;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
}

.switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 650;
}

.switcher-face::after {
  content: "▾";
  margin-left: 0.35rem;
  color: var(--muted);
}

.switcher select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}

.switcher:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.home-link:focus-visible,
.views a:focus-visible,
.btn:focus-visible,
.video-card summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1rem;
  color: var(--muted);
  font: 650 0.9rem/1.3 system-ui, -apple-system, sans-serif;
  text-align: center;
}

.video-box video,
.video-box .video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-play {
  /* Top-right pill, clear of the centered poster title and the caption bar. */
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  bottom: auto;
  left: auto;
  width: auto;
  height: auto;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 650 0.95rem/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.22);
}

.video-play:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.video-box.is-missing video,
.video-box.is-missing .video-poster,
.video-box.is-missing .video-play {
  display: none;
}

.video-card {
  margin: 0 0 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.video-card summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font: 650 0.98rem/1.3 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  list-style: none;
}

.video-card summary::-webkit-details-marker {
  display: none;
}

.video-card summary::before {
  content: "▶";
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
}

.video-card[open] summary::before {
  content: "▼";
}

.summary-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.video-card .video-box {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
}

body[data-view="home"] main {
  max-width: 72rem;
}

.home-head {
  margin: 0 0 1.25rem;
}

.home-head .meta {
  margin-bottom: 0;
}

.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 44rem) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.45rem;
  line-height: 1.2;
}

.card .kicker {
  margin-bottom: 0.25rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.9rem;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: 650 0.98rem/1.2 system-ui, -apple-system, sans-serif;
  text-decoration: none;
}

.btn.primary {
  grid-column: 1 / -1;
  min-height: 48px;
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.views {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1rem;
  font-family: system-ui, -apple-system, sans-serif;
}

.views a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.55rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
}

.views a[aria-current="page"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.picker-wrap {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 2;
  margin: 0 0 0.35rem;
  background: var(--bg);
}

.picker-wrap::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: env(safe-area-inset-top);
  background: var(--bg);
}

.picker {
  display: flex;
  gap: 0.4rem;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0.35rem 0 0.55rem;
  scrollbar-width: none;
}

.picker::-webkit-scrollbar {
  display: none;
}

.picker .jump {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
}

.jump.is-done {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
}

.jump.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.question {
  scroll-margin-top: calc(4.75rem + env(safe-area-inset-top));
}

/* Per-question extras: "Watch why" clips (and game links) after an answer. */
.why {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.15rem 0 0.5rem;
}

.why-btn,
.play-link {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 0 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  font: 650 0.95rem/1.2 system-ui, -apple-system, sans-serif;
  text-decoration: none;
}

.why-btn[aria-expanded="true"] {
  border-color: var(--accent);
}

.why-meta {
  margin-left: 0.15rem;
  color: var(--muted);
  font-weight: 500;
}

.play-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.clip-card {
  margin: 0 0 0.75rem;
}

.games {
  margin-top: 0.85rem;
  font-family: system-ui, -apple-system, sans-serif;
}

.games .label {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.games ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.games li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
}

.games li:first-child {
  border-top: 0;
}

.games a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.games a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
