* {
  box-sizing: border-box;
}

:root {
  --paper: #f5e6ba;
  --paper-panel: rgba(248, 241, 218, 0.88);
  --paper-deep: #efe1b8;
  --ink: #29231d;
  --ink-soft: #594f43;
  --ink-muted: #655b4f;
  --line: #cbb993;
  --line-soft: #dfd1ad;
  --burgundy: #741d20;
  --burgundy-hover: #8b282b;
  --burgundy-deep: #4d1517;
  --green: #405847;
  --green-hover: #506c58;
  --header: #211b17;
  --content-width: 1200px;
  --space-section: clamp(26px, 3vw, 36px);
}

html {
  min-height: 100%;
  scrollbar-gutter: stable;
  overflow-y: scroll;
  scroll-behavior: smooth;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--paper);
  background-image: url("../images/natural-paper.png");
  background-repeat: repeat;
  background-size: auto;
  background-position: 0 0;
  background-attachment: scroll;
}

main,
#quizMain {
  flex: 1 0 auto;
}

a {
  color: var(--burgundy);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--burgundy-deep);
}

:focus-visible {
  outline: 3px solid #a54535;
  outline-offset: 3px;
}

.container {
  width: min(100% - 44px, var(--content-width));
  margin-inline: auto;
}

.muted {
  color: var(--ink-muted);
}

.skip-link {
  position: fixed;
  z-index: 50;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  border-radius: 6px;
  padding: 9px 13px;
  color: #fff;
  background: var(--burgundy-deep);
  font-weight: 700;
}

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

/* Header and navigation */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  color: #f3ead7;
  background: var(--header);
  box-shadow: 0 2px 9px rgba(27, 20, 15, 0.22);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-block: 12px;
}

.home-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: #f3ead7;
  text-decoration: none;
}

.site-logo {
  display: block;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid rgba(243, 234, 215, 0.42);
  border-radius: 7px;
}

.site-name,
.footer-site-name {
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

.site-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 7px 11px;
  border-radius: 7px;
  color: #eee5d5;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
}

.nav-link.is-active {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: #d3a16e;
  text-underline-offset: 6px;
}

.nav-link:focus-visible,
.home-link:focus-visible {
  outline-color: #e1b778;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid #8e8170;
  border-radius: 999px;
  color: var(--ink);
  background: #f8f0d9;
  box-shadow: 0 2px 0 rgba(47, 35, 25, 0.16);
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.btn:hover {
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(47, 35, 25, 0.2);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn:focus-visible,
.link-btn:focus-visible,
button.answer:focus-visible {
  outline: 3px solid #9a4132;
  outline-offset: 3px;
}

.btn-primary {
  color: #fff;
  background: var(--burgundy);
  border-color: var(--burgundy-deep);
  box-shadow: 0 2px 0 var(--burgundy-deep);
}

.btn-primary:hover {
  color: #fff;
  background: var(--burgundy-hover);
  border-color: var(--burgundy-deep);
}

.btn-secondary {
  color: #fff;
  background: var(--green);
  border-color: #304537;
  box-shadow: 0 2px 0 #304537;
}

.btn-secondary:hover {
  color: #fff;
  background: var(--green-hover);
  border-color: #304537;
}

.btn-sm {
  min-height: 40px;
  padding: 9px 14px;
  font-size: 14px;
}

.link-btn {
  padding: 4px 0;
  border: 0;
  border-radius: 3px;
  color: #762326;
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Homepage hero and leaderboard */

.hero {
  padding: clamp(34px, 4vw, 48px) 0 22px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.85fr);
  align-items: start;
  gap: clamp(22px, 3.5vw, 38px);
}

.above-title {
  margin: 0 0 10px;
  color: #51473c;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.hero-title {
  margin: 0 0 16px;
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 4.2vw, 48px);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.hero-subtitle {
  max-width: 55ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 17px;
}

.hero-actions,
.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
}

.hero-actions {
  margin: 26px 0 30px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.meta-card {
  flex: 1 1 190px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(248, 241, 218, 0.72);
}

.meta-label {
  color: #625646;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.meta-value {
  margin-top: 3px;
  font-weight: 700;
}

.leaderboard {
  overflow: hidden;
  color: #2a241e;
  background: #f3e8c4;
  border: 1px solid #805628;
  border-radius: 17px;
  box-shadow: 0 9px 22px rgba(50, 38, 26, 0.12);
}

.leaderboard-inner {
  padding: 17px;
}

.leaderboard-pill {
  display: inline-flex;
  align-items: center;
  margin-bottom: 13px;
  padding: 6px 11px;
  border: 1px solid #bfae88;
  border-radius: 999px;
  color: #332a22;
  background: #faf4e3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.leaderboard-head,
.lb-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.leaderboard-head {
  padding: 9px 11px;
  border: 1px solid #bfae88;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.35);
  font-size: 13px;
  font-weight: 800;
}

.leaderboard-list {
  overflow: hidden;
  margin: 9px 0 0;
  padding: 0;
  border: 1px solid #bfae88;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  list-style: none;
}

.lb-row {
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.18);
}

.lb-row + .lb-row {
  border-top: 1px solid #cbb993;
}

.lb-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
}

.lb-quiz {
  margin-top: 1px;
  color: #605549;
  font-size: 12px;
}

.lb-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 5px 9px;
  border: 1px solid #c5b28c;
  border-radius: 999px;
  background: #faf4e3;
  font-weight: 800;
}

.lb-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid rgba(116, 29, 32, 0.38);
  border-radius: 8px;
  color: #562022;
  background: rgba(116, 29, 32, 0.12);
  font-weight: 900;
}

.leaderboard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
}

.leaderboard-note {
  color: #5e5448;
  font-size: 12px;
}

/* Shared sections, cards and information panels */

.section {
  margin-top: 0;
  padding: var(--space-section) 0;
}

.section-title,
.panel-title,
.cta-title {
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

.section-title {
  margin: 0 0 8px;
  font-size: clamp(25px, 3vw, 30px);
  line-height: 1.3;
}

.section-subtitle {
  max-width: 70ch;
  margin: 0 0 22px;
  color: var(--ink-soft);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 18px;
}

.panel,
.card {
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: var(--paper-panel);
  box-shadow: 0 4px 13px rgba(54, 41, 26, 0.07);
}

.panel {
  padding: clamp(17px, 2.5vw, 23px);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 19px;
  line-height: 1.4;
}

.panel > :last-child,
.card > :last-child {
  margin-bottom: 0;
}

.checklist {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-soft);
}

.checklist li {
  margin: 6px 0;
  padding-left: 2px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 16px;
}

.card {
  display: flex;
  min-width: 0;
  min-height: 205px;
  flex-direction: column;
  padding: 18px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
}

.card-text {
  margin: 0 0 12px;
  color: var(--ink-soft);
}

.card-meta {
  margin: auto 0 12px;
  padding-top: 9px;
  color: #63594d;
  font-size: 13px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #bfb295;
  border-radius: 999px;
  color: #393229;
  background: #f5edd8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

/* Call to action */

.cta {
  padding: 22px 0 42px;
}

.cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px 30px;
  padding: clamp(19px, 3vw, 26px);
  border: 1px solid #bfae88;
  border-radius: 18px;
  color: #241a12;
  background: #c49355;
  box-shadow: 0 9px 22px rgba(50, 38, 26, 0.16);
}

.cta-title {
  margin: 0 0 5px;
  font-size: 21px;
  line-height: 1.4;
}

.cta-inner p {
  margin: 0;
  max-width: 55ch;
  color: #392819;
}

.cta-actions {
  flex: 0 0 auto;
}

/* Footer: brand and useful navigation */

footer {
  margin-top: 24px;
  color: #f0e8d9;
  background: var(--header);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(170px, 0.7fr);
  gap: 28px;
  padding-block: 27px 22px;
}

.footer-site-name {
  margin-bottom: 7px;
  color: #f5ead5;
  font-size: 19px;
  font-weight: 700;
}

footer .muted {
  color: #d1c4af;
}

.footer-grid p {
  max-width: 42ch;
  margin: 0;
}

.footer-title {
  margin-bottom: 8px;
  color: #f5ead5;
  font-weight: 800;
}

.footer-links {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  display: inline-block;
  padding-block: 2px;
  color: #e0d5c4;
  text-decoration: none;
}

.footer-links a:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-block: 13px 17px;
  border-top: 1px solid rgba(245, 234, 213, 0.18);
  text-align: center;
}

/* Quiz */

.quiz-intro {
  margin: 0 0 14px;
}

.quiz-intro a {
  font-weight: 700;
}

.quiz-container {
  width: min(100% - 44px, 820px);
  margin-inline: auto;
}

.quiz-container .panel {
  padding: clamp(16px, 3vw, 25px);
}

.quiz-hud {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 20px;
  margin: 0 0 15px;
  color: #3e352b;
  font-weight: 700;
}

.time-bar-track {
  height: 11px;
  overflow: hidden;
  margin-bottom: 17px;
  border: 1px solid #b5a78c;
  border-radius: 999px;
  background: rgba(55, 43, 30, 0.12);
}

#timeBar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--burgundy);
  transition: width 0.3s ease;
}

.quiz-name-row {
  margin-bottom: 15px;
}

.quiz-name-row label {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
}

.input {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #988b74;
  border-radius: 9px;
  color: var(--ink);
  background: #f8f1df;
  font: inherit;
}

.input.light {
  width: min(100%, 360px);
}

.input::placeholder {
  color: #6d6254;
}

.input:focus-visible,
#contact_form input:focus-visible,
#contact_form textarea:focus-visible {
  outline: 3px solid #9a4132;
  outline-offset: 2px;
}

#questionText {
  max-width: 62ch;
  margin: 16px 0 14px;
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2vw, 21px);
  font-weight: 700;
  line-height: 1.5;
}

#questionText:focus {
  outline: 3px solid #9a4132;
  outline-offset: 5px;
  border-radius: 2px;
}

#answers {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 13px;
}

button.answer {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid #a99b81;
  border-radius: 10px;
  color: #302920;
  background: rgba(252, 248, 235, 0.92);
  font: inherit;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

button.answer:hover:not(:disabled) {
  background: #fffaf0;
  border-color: #83745d;
}

button.answer:disabled {
  cursor: default;
}

button.answer.is-correct {
  border-color: #396747;
  color: #203c2a;
  background: #e0eadb;
}

button.answer.is-wrong {
  border-color: #8b292d;
  color: #641c20;
  background: #f2dfd8;
}

#feedback {
  min-height: 1.6em;
  margin: 0 0 12px;
  color: #51473b;
}

#feedback:empty {
  display: none;
}

.quiz-actions,
.quiz-done-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: 7px;
}

.quiz-actions {
  justify-content: space-between;
}

.quiz-actions .btn {
  white-space: normal;
}

/* Contact form */

.contact-container {
  width: min(100% - 44px, 720px);
  margin-inline: auto;
}

.contact-panel {
  padding: clamp(17px, 3vw, 24px);
}

.contact-notice,
.form-status {
  padding: 11px 13px;
  border: 1px solid #c6ad7b;
  border-radius: 8px;
  color: #453722;
  background: #f3e9cd;
}

.contact-notice {
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 10px;
}

.form-field {
  min-width: 0;
}

.form-field label,
.label {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
}

#contact_form input:not([type="submit"]):not([type="reset"]),
#contact_form textarea,
.textarea {
  display: block;
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid #988b74;
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255, 252, 242, 0.94);
  font: inherit;
}

#contact_form textarea,
.textarea {
  min-height: 150px;
  resize: vertical;
}

.field-error {
  display: block;
  margin-top: 4px;
  color: #7b2024;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* Breakpoints */

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 0.85fr);
    gap: 22px;
  }

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

  .footer-grid {
    gap: 22px;
  }
}

@media (max-width: 700px) {
  .container,
  .quiz-container,
  .contact-container {
    width: min(100% - 36px, var(--content-width));
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 7px 12px;
    padding-block: 9px 10px;
  }

  .home-link {
    min-height: 38px;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
    gap: 3px;
  }

  .nav-link {
    min-height: 38px;
    padding: 6px 9px;
  }

  .hero-grid,
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }

  .leaderboard {
    max-width: 560px;
  }

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

  .card {
    min-height: 0;
  }

  .cta-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .container,
  .quiz-container,
  .contact-container {
    width: min(100% - 28px, var(--content-width));
  }

  .site-name {
    font-size: 13px;
    letter-spacing: 0.025em;
  }

  .footer-site-name {
    font-size: 15px;
    white-space: nowrap;
  }

  .site-logo {
    width: 32px;
    height: 32px;
  }

  .nav-link {
    min-height: 36px;
    padding: 5px 6px;
    font-size: 12px;
  }

  .hero-title {
    font-size: 34px;
  }

  .hero-actions,
  .cta-actions {
    width: 100%;
  }

  .hero-actions .btn,
  .cta-actions .btn {
    flex: 1 1 auto;
  }

  .meta-card {
    flex-basis: 100%;
  }

  .leaderboard-inner {
    padding: 13px;
  }

  .section {
    padding-block: 28px;
  }

  .panel,
  .card {
    padding: 16px;
  }

  .quiz-hud {
    gap: 6px 12px;
    font-size: 14px;
  }

  .quiz-actions {
    align-items: stretch;
  }

  .quiz-actions .btn,
  .form-actions .btn {
    flex: 1 1 145px;
  }

  .card-actions {
    align-items: flex-start;
  }

  .badge {
    border-radius: 9px;
  }

  .footer-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
    gap: 16px;
    padding-block: 23px 18px;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
