:root {
  color-scheme: light;
  --cream-50: #fffdf9;
  --cream-100: #f7f0e5;
  --cream-200: #eadcc8;
  --ink: #28221d;
  --ink-soft: #62584f;
  --blue: #0d4f8b;
  --blue-dark: #073a6a;
  --rust: #b8490c;
  --rust-dark: #8e3508;
  --brass: #a57332;
  --green: #28654f;
  --red: #a13b2f;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(64, 42, 24, 0.12);
  --shadow-small: 0 10px 28px rgba(64, 42, 24, 0.08);
  --radius-large: 32px;
  --radius-medium: 20px;
  --radius-small: 12px;
  --shell: min(1120px, calc(100% - 40px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 16%, rgba(184, 73, 12, 0.08) 0 1px, transparent 2px) 0 0 / 28px 28px,
    linear-gradient(145deg, #fcf8f1 0%, var(--cream-100) 58%, #f3e7d6 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body::before {
  position: fixed;
  z-index: -1;
  top: -240px;
  right: -180px;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(13, 79, 139, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 42px rgba(13, 79, 139, 0.025), 0 0 0 92px rgba(184, 73, 12, 0.02);
  content: "";
}

a {
  color: var(--blue);
  text-underline-offset: 0.18em;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--white);
  background: var(--blue-dark);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 112px;
  padding-block: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
}

.brand__logo {
  width: 72px;
  height: 72px;
  border: 2px solid rgba(165, 115, 50, 0.35);
  border-radius: 50%;
  box-shadow: var(--shadow-small);
}

.brand__words {
  display: grid;
  gap: 1px;
}

.brand__title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand__byline {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.brand__byline strong {
  color: var(--blue);
}

.header-note {
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  font-style: italic;
}

.screen {
  min-height: 610px;
  animation: reveal 360ms ease both;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.72fr);
  gap: 44px 72px;
  align-items: center;
  padding: 64px clamp(32px, 6vw, 76px) 36px;
  overflow: hidden;
  border: 1px solid rgba(116, 79, 38, 0.18);
  border-radius: var(--radius-large);
  background: rgba(255, 253, 249, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--rust);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.6rem, 6.2vw, 5.15rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3.5vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.welcome__lede {
  max-width: 660px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.8vw, 1.28rem);
  line-height: 1.65;
}

.quiz-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 28px 0;
}

.quiz-facts span {
  padding: 7px 12px;
  border: 1px solid var(--cream-200);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--cream-50);
  font-size: 0.88rem;
}

.quiz-facts strong {
  color: var(--blue);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 50px;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 750;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease,
    transform 160ms ease, box-shadow 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.text-button:focus-visible,
.answer-option:has(input:focus-visible) {
  outline: 3px solid rgba(13, 79, 139, 0.28);
  outline-offset: 3px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.button--large {
  min-height: 58px;
  padding-inline: 26px;
}

.button--primary {
  color: var(--white);
  background: var(--blue);
  box-shadow: 0 9px 22px rgba(13, 79, 139, 0.18);
}

.button--primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button--secondary {
  border-color: rgba(13, 79, 139, 0.25);
  color: var(--blue);
  background: rgba(255, 255, 255, 0.72);
}

.button--secondary:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--white);
}

.shared-note {
  margin: 16px 0 0;
  color: var(--green);
  font-size: 0.88rem;
}

.welcome__aside {
  position: relative;
  align-self: stretch;
  min-height: 430px;
}

.logo-medallion {
  position: absolute;
  top: -36px;
  right: -16px;
  width: min(310px, 84%);
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid rgba(165, 115, 50, 0.35);
  border-radius: 50%;
  background: var(--cream-50);
  box-shadow: var(--shadow);
  transform: rotate(2deg);
}

.logo-medallion img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.topic-card {
  position: absolute;
  right: 20px;
  bottom: 2px;
  width: min(340px, 100%);
  padding: 22px 24px;
  border: 1px solid rgba(184, 73, 12, 0.24);
  border-radius: var(--radius-medium);
  background: rgba(255, 250, 242, 0.95);
  box-shadow: var(--shadow-small);
  transform: rotate(-1.5deg);
}

.topic-card__label {
  margin: 0 0 10px;
  color: var(--rust);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topic-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-card li {
  position: relative;
  padding-left: 18px;
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
}

.topic-card li::before {
  position: absolute;
  top: 0.7em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brass);
  content: "";
}

.difficulty-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding-top: 30px;
  border-top: 1px solid var(--cream-200);
}

.difficulty-preview__label {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.difficulty-preview ol {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.difficulty-preview li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.difficulty-preview li::after {
  flex: 1;
  height: 1px;
  margin-left: 3px;
  background: var(--cream-200);
  content: "";
}

.difficulty-preview li:last-child::after {
  display: none;
}

.difficulty-preview li span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--blue);
  font-weight: 800;
}

.quiz {
  max-width: 920px;
  margin-inline: auto;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid rgba(116, 79, 38, 0.18);
  border-radius: var(--radius-large);
  background: rgba(255, 253, 249, 0.9);
  box-shadow: var(--shadow);
}

.quiz__topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.question-count {
  margin: 0 0 2px;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.question-topic {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.difficulty-badge {
  display: grid;
  justify-items: end;
  min-width: 116px;
  padding: 8px 12px;
  border-radius: var(--radius-small);
  color: var(--rust-dark);
  background: #f8e9d9;
  line-height: 1.2;
}

.difficulty-badge span {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.difficulty-badge strong {
  font-size: 0.72rem;
}

.progress {
  height: 7px;
  margin: 20px 0 40px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--cream-200);
}

.progress span {
  display: block;
  width: 10%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rust), var(--brass));
  transition: width 280ms ease;
}

.question-card fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.question-card legend {
  width: 100%;
  margin-bottom: 28px;
  padding: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.22;
}

.answer-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.answer-option {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 13px;
  align-items: center;
  min-height: 78px;
  padding: 13px 16px;
  border: 1px solid var(--cream-200);
  border-radius: var(--radius-small);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease,
    box-shadow 150ms ease;
}

.answer-option:hover {
  border-color: rgba(13, 79, 139, 0.45);
  background: var(--white);
  transform: translateY(-1px);
}

.answer-option:has(input:checked) {
  border-color: var(--blue);
  background: #edf5fb;
  box-shadow: inset 0 0 0 1px var(--blue);
}

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

.answer-letter {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--cream-200);
  border-radius: 50%;
  color: var(--blue);
  background: var(--cream-50);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.answer-option:has(input:checked) .answer-letter {
  border-color: var(--blue);
  color: var(--white);
  background: var(--blue);
}

.answer-text {
  color: var(--ink);
  line-height: 1.35;
}

.quiz-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  margin-top: 38px;
  padding-top: 24px;
  border-top: 1px solid var(--cream-200);
}

.quiz-nav .button:first-child {
  justify-self: start;
}

.quiz-nav .button:last-child {
  justify-self: end;
}

.keyboard-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.results {
  display: grid;
  gap: 28px;
}

.results-hero,
.performance,
.review {
  border: 1px solid rgba(116, 79, 38, 0.18);
  border-radius: var(--radius-large);
  background: rgba(255, 253, 249, 0.9);
  box-shadow: var(--shadow-small);
}

.results-hero {
  position: relative;
  padding: clamp(40px, 7vw, 76px);
  overflow: hidden;
  text-align: center;
}

.results-hero::after {
  position: absolute;
  z-index: 0;
  right: -80px;
  bottom: -130px;
  width: 310px;
  height: 310px;
  border: 42px solid rgba(184, 73, 12, 0.045);
  border-radius: 50%;
  content: "";
}

.results-hero > * {
  position: relative;
  z-index: 1;
}

.score-lockup {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  color: var(--blue);
}

.score-lockup strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(5rem, 15vw, 9rem);
  font-weight: 500;
  letter-spacing: -0.07em;
  line-height: 0.9;
}

.score-lockup span {
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
}

.results-hero h1 {
  margin: 18px auto 0;
  color: var(--rust-dark);
  font-size: clamp(2.1rem, 5vw, 4rem);
}

.results-message {
  max-width: 640px;
  margin: 18px auto 0;
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
}

.results-disclaimer {
  margin: 14px auto 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.performance,
.review {
  padding: clamp(26px, 5vw, 48px);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.section-heading > p {
  max-width: 330px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  text-align: right;
}

.text-button {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--blue);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.performance-card {
  padding: 18px 14px;
  border-radius: var(--radius-small);
  background: var(--cream-100);
  text-align: center;
}

.performance-card span,
.performance-card small {
  display: block;
  color: var(--ink-soft);
}

.performance-card span {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.performance-card strong {
  display: block;
  margin: 8px 0 2px;
  color: var(--blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
}

.performance-card small {
  font-size: 0.72rem;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  overflow: hidden;
  border: 1px solid var(--cream-200);
  border-radius: var(--radius-small);
  background: var(--cream-50);
}

.review-item summary {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 17px 18px;
  cursor: pointer;
  list-style: none;
}

.review-item summary::-webkit-details-marker {
  display: none;
}

.review-status {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  font-weight: 800;
}

.review-item--correct .review-status {
  background: var(--green);
}

.review-item--incorrect .review-status {
  background: var(--red);
}

.review-question {
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-points {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.review-body {
  padding: 0 18px 20px 64px;
  border-top: 1px solid var(--cream-200);
}

.review-answer {
  margin: 16px 0 0;
  font-size: 0.9rem;
}

.review-answer strong {
  color: var(--ink);
}

.review-explanation {
  margin: 15px 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.review-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-sources a {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--blue);
  background: #edf5fb;
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-block: 34px 44px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.site-footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--white);
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

@media (max-width: 820px) {
  .header-note {
    display: none;
  }

  .welcome {
    grid-template-columns: 1fr;
    padding: 44px 34px 30px;
  }

  .welcome__aside {
    min-height: 330px;
  }

  .logo-medallion {
    top: -18px;
    right: 10%;
    width: 240px;
  }

  .topic-card {
    right: auto;
    bottom: 0;
    left: 4%;
  }

  .difficulty-preview {
    grid-template-columns: 1fr;
  }

  .difficulty-preview ol {
    grid-template-columns: repeat(5, auto);
    justify-content: space-between;
  }

  .difficulty-preview li {
    display: grid;
    justify-items: center;
    gap: 5px;
  }

  .difficulty-preview li::after {
    display: none;
  }

  .performance-grid {
    grid-template-columns: repeat(5, minmax(100px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }
}

@media (max-width: 620px) {
  :root {
    --shell: min(100% - 24px, 1120px);
    --radius-large: 24px;
  }

  .site-header {
    min-height: 92px;
  }

  .brand__logo {
    width: 58px;
    height: 58px;
  }

  .brand__title {
    font-size: 0.98rem;
  }

  .welcome {
    gap: 30px;
    padding: 34px 22px 24px;
  }

  h1 {
    font-size: clamp(2.45rem, 14vw, 4rem);
  }

  .welcome__aside {
    min-height: 300px;
  }

  .logo-medallion {
    right: 1%;
    width: 205px;
  }

  .topic-card {
    width: 88%;
    padding: 18px;
  }

  .difficulty-preview ol {
    gap: 4px;
  }

  .difficulty-preview li {
    font-size: 0.65rem;
  }

  .quiz {
    padding: 25px 19px;
  }

  .difficulty-badge {
    min-width: 94px;
  }

  .answer-list {
    grid-template-columns: 1fr;
  }

  .answer-option {
    min-height: 66px;
  }

  .quiz-nav {
    grid-template-columns: 1fr 1fr;
  }

  .keyboard-hint {
    display: none;
  }

  .quiz-nav .button {
    width: 100%;
    padding-inline: 12px;
  }

  .section-heading {
    display: grid;
    align-items: start;
  }

  .section-heading > p {
    text-align: left;
  }

  .review-item summary {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .review-points {
    grid-column: 2;
  }

  .review-body {
    padding-left: 18px;
  }

  .site-footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
