:root {
  color-scheme: light;
  --background: #faf7f5;
  --surface: #ffffff;
  --text: #2d2724;
  --muted: #746a65;
  --border: #e7dfda;
  --soft-background: #fdfbf9;
  --accent: #d97757;
  --accent-strong: #c56648;
  --accent-soft: #f9e8e1;
  --accent-text: #98462f;
  --accent-ink: #21100b;
  --link: #98462f;
  --success: #2d7a4b;
  --error: #a33b46;
  --shadow: 0 8px 24px rgb(93 57 43 / 8%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible + label,
.version-switch:focus-visible,
.transcript-scroll:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.site-header,
main,
footer {
  width: min(100% - 2rem, 88rem);
  margin-inline: auto;
}

.site-header {
  max-width: 56rem;
  padding-block: 1.8rem 1.2rem;
  text-align: center;
}

.site-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.eyebrow,
.problem-label {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.15;
}

.edition {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.28em 0.55em;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.42em;
  font-weight: 650;
  letter-spacing: 0.04em;
  vertical-align: 0.28em;
}

.version-switch {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.version-switch:hover {
  background: var(--accent-soft);
}

.site-header .intro {
  max-width: 40rem;
  margin: 0.55rem auto 0;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  flex: 1;
  padding-block: 0.75rem 3rem;
}

#question-view,
#results-view {
  scroll-margin-top: 1rem;
}

.problem-card {
  max-width: 70rem;
  margin: 0 auto 1.25rem;
  padding: 1rem 1.25rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.problem-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.problem-bar .problem-label {
  grid-column: 2;
  margin: 0;
  color: var(--accent-text);
  text-align: center;
}

.problem-nav-button {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 750;
}

.problem-nav-button:first-child {
  grid-column: 1;
  justify-self: start;
}

.problem-bar-actions {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 0.45rem;
}

.copy-problem-button {
  min-height: 2.4rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.copy-problem-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.problem-nav-button:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-ink);
}

.problem-nav-button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.35;
}

.statement {
  padding: 1rem 0.25rem 0;
  border-top: 1px solid var(--border);
}

.quiz-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.quiz-timer {
  min-width: 4.1rem;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  text-align: center;
}

.review-toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.2rem 0.25rem 0.2rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgb(93 57 43 / 6%);
}

.review-score-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.review-score-label strong {
  color: var(--text);
}

.review-play-again-button {
  padding: 0.3rem 0.7rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}

.review-play-again-button:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.mode-switch {
  display: flex;
  min-width: 0;
  margin: 0;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgb(93 57 43 / 6%);
}

.mode-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mode-label {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.4;
}

.mode-input:checked + .mode-label {
  background: var(--accent);
  color: var(--accent-ink);
}

.transcript-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  align-items: start;
}

.transcript-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.transcript-title {
  margin: 0;
  font-size: 1rem;
}

.transcript-scroll {
  height: clamp(28rem, 62vh, 46rem);
  overflow: auto;
  padding: 1rem;
  background: var(--soft-background);
  overscroll-behavior: contain;
}

.transcript-section + .transcript-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 3px solid var(--accent-soft);
}

.transcript-section-title {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.raw-text {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
}

.guess-button {
  flex: none;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 2px 0 var(--accent-strong);
  color: var(--accent-ink);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.guess-button:hover:not(:disabled) {
  background: var(--accent-strong);
  box-shadow: 0 3px 0 #a95136;
  color: var(--accent-ink);
  transform: translateY(-1px);
}

.guess-button:active:not(:disabled) {
  box-shadow: 0 1px 0 var(--accent-strong);
  transform: translateY(1px);
}

.guess-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.guess-button.is-selected {
  background: var(--accent);
  color: var(--accent-ink);
  opacity: 1;
}

.live-status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.prose {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.72;
}

.prose section + section {
  margin-top: 2.5rem;
}

.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 2rem 0 0.75rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.3;
}

.prose h3 {
  font-size: 1.25rem;
}

.prose h4 {
  font-size: 1.12rem;
}

.prose h5,
.prose h6 {
  font-size: 1rem;
}

.prose p {
  margin: 0 0 1.05rem;
}

.prose ul,
.prose ol {
  padding-left: 1.4rem;
}

.prose li {
  margin-block: 0.3rem;
}

.prose hr {
  margin-block: 2rem;
  border: 0;
  border-top: 1px solid var(--border);
}

.prose code {
  padding: 0.1em 0.25em;
  background: var(--surface);
  font-size: 0.85em;
}

.prose math {
  font-family: "STIX Two Math", "Cambria Math", serif;
}

.prose math[display="block"] {
  display: block;
  margin-block: 1.3rem;
  text-align: center;
}

.results-header {
  max-width: 42rem;
  margin: 0 auto 1.5rem;
  text-align: center;
}

.results-header h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  color: var(--accent-text);
}

.score-summary {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

.score-time {
  margin: 0.45rem 0 0;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.share-x-button,
.copy-result-button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.share-x-button {
  border: 1px solid #1d1d1f;
  background: #1d1d1f;
  color: #ffffff;
}

.share-x-button:hover {
  border-color: #000000;
  background: #000000;
}

.copy-result-button {
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent-text);
}

.copy-result-button:hover {
  background: var(--accent-soft);
}

.share-status {
  min-height: 1.35rem;
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 0.65rem;
}

.restart-button,
.review-button {
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

.restart-button {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
}

.restart-button:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.review-button {
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent-text);
}

.review-button:hover {
  background: var(--accent-soft);
}

footer {
  padding-block: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

footer p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .transcript-grid {
    grid-template-columns: 1fr;
  }

  .transcript-scroll {
    height: min(58vh, 42rem);
    min-height: 24rem;
  }

}

@media (max-width: 480px) {
  .site-header {
    padding-block: 1.35rem 1rem;
  }

  .problem-card {
    padding-inline: 0.85rem;
  }

  .transcript-header {
    padding-left: 0.75rem;
  }

  .guess-button {
    padding-inline: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
