:root {
  color-scheme: light;
  --ink: #27221d;
  --muted: #685f56;
  --paper: #fffdf8;
  --cream: #f7efe1;
  --line: #dfd0bd;
  --orange: #cc5d25;
  --orange-dark: #9d3f17;
  --green: #2d7c51;
  --green-soft: #e4f2e8;
  --red: #b34137;
  --red-soft: #f7e6e4;
  --blue: #2f5d78;
  --shadow: 0 18px 48px rgba(86, 58, 30, 0.13);
  background: #f4eadb;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(204, 93, 37, 0.15), transparent 30rem),
    linear-gradient(180deg, #fbf6ed 0%, #f3e7d6 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 20;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-160%);
}

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

.site-header {
  display: flex;
  width: min(1160px, calc(100% - 2rem));
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto;
  padding: 1.15rem 0 0;
}

.site-title {
  color: var(--ink);
  font-weight: 850;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-header nav a {
  display: inline-flex;
  border-radius: 999px;
  color: #5d5247;
  padding: 0.5rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 750;
  text-decoration: none;
}

.site-header nav a[aria-current="page"],
.site-header nav a:hover {
  background: var(--paper);
  color: var(--orange-dark);
  box-shadow: 0 4px 15px rgba(84, 58, 27, 0.08);
}

.site-main {
  width: calc(100% - 2rem);
  margin: 0 auto;
}

.site-footer {
  width: min(1160px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0 0 2.5rem;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.quiz-app {
  width: min(1160px, 100%);
  margin: 2rem auto;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.quiz-app h1,
.quiz-app h2,
.quiz-app h3,
.quiz-app p {
  margin-top: 0;
}

.quiz-app h1,
.quiz-app h2,
.quiz-app h3 {
  color: var(--ink);
  font-family: inherit;
  font-weight: 850;
  letter-spacing: 0;
}

.quiz-app h1 {
  margin-bottom: 1rem;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1.03;
}

.quiz-app h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.18;
}

.quiz-app h3 {
  margin-bottom: 0.35rem;
  font-size: 1.08rem;
}

.quiz-app a {
  color: var(--orange-dark);
}

.quiz-app button,
.quiz-app select,
.quiz-app input,
.quiz-app textarea {
  font: inherit;
}

.quiz-app button:focus-visible,
.quiz-app a:focus-visible,
.quiz-app select:focus-visible,
.quiz-app input:focus-visible,
.quiz-app textarea:focus-visible,
.quiz-app summary:focus-visible {
  outline: 3px solid rgba(47, 93, 120, 0.55);
  outline-offset: 3px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.72rem 1.15rem;
  text-decoration: none;
  font-weight: 760;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

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

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}

.button-primary:hover {
  border-color: var(--orange-dark);
  background: var(--orange-dark);
}

.button-secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.kicker {
  margin-bottom: 0.4rem;
  color: var(--orange-dark);
  font-size: 0.83rem;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero,
.category-intro,
.quiz-shell,
.result-shell,
.loading,
.error-box {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, 0.92fr);
  overflow: hidden;
}

.category-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  min-height: 480px;
  overflow: hidden;
}

.category-intro-image {
  min-height: 340px;
  background: #d78538;
}

.category-intro-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-intro-copy {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  padding: clamp(1.6rem, 5vw, 4.3rem);
}

.category-intro-copy h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4vw, 3.6rem);
  overflow-wrap: anywhere;
}

.review-modal {
  min-height: 480px;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(34, 25, 16, 0.08);
}

.review-modal-card {
  width: min(680px, 100%);
  padding: clamp(1.4rem, 4vw, 2.6rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.review-modal-card h1 {
  margin-top: 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.review-question {
  margin: 1.5rem 0 0.8rem;
  font-weight: 800;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.hero-copy {
  align-self: center;
  padding: clamp(1.6rem, 5vw, 4.3rem);
}

.logo {
  display: block;
  width: 92px;
  height: auto;
  margin-bottom: 1.25rem;
}

.lead {
  max-width: 650px;
  margin-bottom: 1.7rem;
  color: var(--muted);
  font-size: 1.12rem;
}

.intro-credit {
  max-width: 650px;
  margin: -0.8rem 0 1.7rem;
  color: var(--ink);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.note {
  margin: 1.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-visual {
  position: relative;
  min-height: 470px;
  background: #d78538;
}

.hero-visual > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-facts {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  border-radius: 14px;
  background: rgba(34, 25, 16, 0.86);
  color: #fff;
  padding: 0.8rem;
  backdrop-filter: blur(8px);
}

.hero-facts span {
  text-align: center;
  font-size: 0.78rem;
}

.hero-facts strong {
  display: block;
  font-size: 1.35rem;
}

.category-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1.4rem;
}

.category-preview article {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf1;
}

.category-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.category-preview span {
  display: block;
  padding: 0.7rem;
  font-size: 0.85rem;
  font-weight: 780;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.loading,
.error-box {
  padding: 2.5rem;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 0.6rem;
  border: 3px solid var(--line);
  border-top-color: var(--orange);
  border-radius: 50%;
  vertical-align: -4px;
  animation: spin 750ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.quiz-shell,
.result-shell {
  background: linear-gradient(145deg, #fffdf8 0%, #fbf3e6 100%);
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem clamp(1rem, 4vw, 2.2rem);
}

.category-label {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: #24643f;
  padding: 0.34rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 820;
}

.question-position {
  display: inline-block;
  margin-left: 0.55rem;
  color: var(--muted);
  font-weight: 700;
}

.progress {
  height: 10px;
  overflow: hidden;
  background: #eadcc9;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), #f0aa3d);
  transition: width 180ms ease;
}

.question-card {
  padding: clamp(1.2rem, 4vw, 2.4rem);
}

.question-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.question-number {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 850;
}

.question-image {
  display: block;
  width: 100%;
  max-height: 360px;
  margin: 0.2rem 0 1.2rem;
  border-radius: 14px;
  object-fit: cover;
}

.answer-area {
  margin-top: 1.2rem;
}

.options {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  border: 0;
  padding: 0;
}

.option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf1;
  padding: 0.85rem 1rem;
  cursor: pointer;
}

.option:hover,
.option:has(input:checked) {
  border-color: var(--orange);
  background: #fff4df;
}

.option input {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
}

.option-key {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  color: var(--orange-dark);
  font-weight: 850;
}

.match-list {
  display: grid;
  gap: 0.85rem;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf1;
  padding: 0.85rem;
}

.match-row strong {
  display: block;
}

.match-row select,
.text-answer input,
.text-answer textarea {
  width: 100%;
  border: 1px solid #cdbba6;
  border-radius: 10px;
  background: #fff;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
}

.text-answer {
  display: grid;
  gap: 0.5rem;
}

.text-answer small {
  color: var(--muted);
}

.inline-error {
  margin: 1rem 0 0;
  color: var(--red);
  font-weight: 760;
}

.question-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding: 1.15rem clamp(1rem, 4vw, 2.2rem);
}

.answered-count {
  color: var(--muted);
  font-weight: 720;
}

.result-hero {
  padding: clamp(1.6rem, 5vw, 3.5rem);
  text-align: center;
}

.score-ring {
  display: inline-grid;
  width: 164px;
  height: 164px;
  place-items: center;
  margin-bottom: 1.1rem;
  border: 12px solid rgba(204, 93, 37, 0.18);
  border-top-color: var(--orange);
  border-right-color: var(--green);
  border-radius: 50%;
  background: #fffaf1;
}

.score-ring strong {
  display: block;
  font-size: 3rem;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-weight: 800;
}

.result-section {
  padding: 0 clamp(1.2rem, 4vw, 2.4rem) 2rem;
}

.category-result-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
}

.category-result {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 1rem;
}

.category-result span {
  display: block;
  min-height: 2.4em;
  color: var(--muted);
  font-weight: 760;
}

.category-result strong {
  display: block;
  margin: 0.4rem 0;
  font-size: 1.35rem;
}

.mini-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadcc9;
}

.mini-bar span {
  display: block;
  min-height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.solution-list {
  display: grid;
  gap: 0.8rem;
}

.solution {
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 8px solid var(--red);
  border-radius: 12px;
  background: var(--paper);
}

.solution.is-correct {
  border-left-color: var(--green);
}

.solution summary {
  cursor: pointer;
  padding: 1rem 1.1rem;
  font-weight: 780;
}

.solution summary span {
  display: inline-flex;
  margin-right: 0.5rem;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  padding: 0.18rem 0.55rem;
  font-size: 0.78rem;
}

.solution.is-correct summary span {
  background: var(--green-soft);
  color: var(--green);
}

.solution-body {
  display: grid;
  gap: 0.85rem;
  border-top: 1px solid var(--line);
  padding: 1rem 1.1rem 1.2rem;
}

.solution-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.answer-box {
  border-radius: 10px;
  background: #fbf1e4;
  padding: 0.8rem;
}

.answer-box strong {
  display: block;
  margin-bottom: 0.25rem;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  border-top: 1px solid var(--line);
  padding: 1.2rem;
}

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

.noscript {
  width: min(700px, calc(100% - 2rem));
  margin: 2rem auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 1rem;
}

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

  .category-intro {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    min-height: 340px;
    order: -1;
  }

  .category-preview,
  .category-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header nav,
  .site-header nav a {
    width: 100%;
  }

  .site-header nav a {
    justify-content: center;
  }

  .quiz-app {
    margin-top: 1rem;
  }

  .hero-copy {
    padding: 1.35rem;
  }

  .hero-visual {
    min-height: 260px;
  }

  .category-intro-image {
    min-height: 250px;
  }

  .hero-facts {
    grid-template-columns: 1fr;
    position: static;
    border-radius: 0;
  }

  .category-preview,
  .category-result-grid,
  .solution-columns,
  .match-row {
    grid-template-columns: 1fr;
  }

  .category-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .category-preview article {
    min-width: 0;
  }

  .category-preview img {
    aspect-ratio: 16 / 10;
  }

  .category-preview span {
    min-height: 0;
    padding: 0.55rem;
    font-size: 0.78rem;
    line-height: 1.25;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  .quiz-topbar,
  .question-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .question-heading {
    grid-template-columns: 1fr;
  }

  .question-number {
    width: 42px;
    height: 42px;
  }

  .button {
    width: 100%;
  }
}

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

  .button,
  .progress-fill {
    transition: none;
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .site-footer,
  .result-actions {
    display: none;
  }

  .site-main {
    width: 100%;
  }
}
