html {
  zoom: 0.90;
}

/* ─── DESIGN TOKENS ─────────────────────────────────────────────────────── */
:root {
  --ink: #1a1614;
  --parchment: #f5f0e8;
  --cream: #faf7f2;
  --rust: #b5451b;
  --rust-light: #f0d9d0;
  --gold: #c8922a;
  --gold-light: #f5e8ce;
  --forest: #2a5c45;
  --forest-light: #d0e8de;
  --slate: #3d4f5c;
  --mist: #e8eef2;
  --border: #d5cbbf;
  --shadow: rgba(26, 22, 20, .12);
}

/* ─── RESET & BASE ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 4rem;
  position: relative;
  overflow-x: hidden;
}

/* subtle grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ─── HEADER BANNER ─────────────────────────────────────────────────────── */
header {
  width: 100%;
  background: var(--ink);
  color: var(--parchment);
  padding: 2.2rem 2rem 1.8rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--rust), var(--gold), var(--rust));
}

.header-eyebrow {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .4rem;
}

header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.15;
  color: var(--cream);
  margin-bottom: .3rem;
}

.header-sub {
  font-size: .82rem;
  color: #a89e90;
  font-weight: 300;
}

/* ─── MAIN WRAPPER ──────────────────────────────────────────────────────── */
main {
  width: min(740px, 96%);
  margin-top: 2.4rem;
  position: relative;
  z-index: 1;
}

/* ─── SCREENS ───────────────────────────────────────────────────────────── */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeUp .4s ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── SETUP SCREEN ──────────────────────────────────────────────────────── */
.card {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.4rem 2.6rem;
  box-shadow: 0 4px 24px var(--shadow);
}

.card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.55rem;
  margin-bottom: .4rem;
  color: var(--ink);
}

.card p {
  font-size: .88rem;
  color: #6b6157;
  line-height: 1.6;
  margin-bottom: 1.6rem;
}

.section-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.6rem;
}

.chip {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  padding: .28rem .7rem;
  border-radius: 99px;
  background: var(--gold-light);
  color: var(--gold);
  border: 1px solid #e8d5a8;
}

.q-selector {
  margin-bottom: 1.8rem;
}

.q-selector label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: .8rem;
}

.q-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-bottom: .9rem;
}

.preset-btn {
  padding: .6rem .3rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--parchment);
  color: var(--slate);
  cursor: pointer;
  transition: all .18s;
  text-align: center;
}

.preset-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-light);
}

.preset-btn.selected {
  border-color: var(--rust);
  background: var(--rust-light);
  color: var(--rust);
}

.custom-row {
  display: flex;
  align-items: center;
  gap: .7rem;
}

.custom-row input[type="range"] {
  flex: 1;
  accent-color: var(--rust);
  height: 4px;
}

.q-count-display {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rust);
  min-width: 2.5rem;
  text-align: right;
}

.start-btn {
  width: 100%;
  padding: .95rem;
  font-family: 'DM Serif Display', serif;
  font-size: 1.08rem;
  letter-spacing: .03em;
  background: var(--rust);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s, transform .12s;
  position: relative;
  overflow: hidden;
}

.start-btn:hover {
  background: #9c3a15;
  transform: translateY(-1px);
}

.start-btn:active {
  transform: translateY(0);
}

/* ─── PROGRESS BAR ──────────────────────────────────────────────────────── */
.progress-wrap {
  margin-bottom: 1.4rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
  font-size: .78rem;
}

.progress-label {
  font-weight: 600;
  color: var(--slate);
}

.progress-fraction {
  color: #8c8075;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--rust), var(--gold));
  border-radius: 99px;
  transition: width .4s cubic-bezier(.4, 0, .2, 1);
}

/* ─── QUIZ CARD ─────────────────────────────────────────────────────────── */
.quiz-card {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 28px var(--shadow);
}

.quiz-card-header {
  padding: .7rem 1.4rem;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-tag {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
}

.q-number {
  font-size: .7rem;
  font-weight: 500;
  color: #7a7068;
}

.quiz-card-body {
  padding: 1.8rem 2rem 1.4rem;
}

.question-text {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 1.4rem;
}

/* ─── CHOICES ────────────────────────────────────────────────────────────── */
.choices {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: 1.2rem;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  padding: .85rem 1rem;
  background: var(--parchment);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s;
  width: 100%;
  position: relative;
}

.choice-btn:not(.answered):hover {
  border-color: var(--gold);
  background: var(--gold-light);
  transform: translateX(3px);
}

.choice-letter {
  font-weight: 700;
  font-size: .78rem;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--slate);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background .15s, color .15s;
}

.choice-text {
  flex: 1;
}

/* Answered states */
.choice-btn.correct {
  border-color: var(--forest);
  background: var(--forest-light);
  cursor: default;
  animation: popIn .25s ease;
}

.choice-btn.correct .choice-letter {
  background: var(--forest);
  color: #fff;
}

.choice-btn.incorrect {
  border-color: var(--rust);
  background: var(--rust-light);
  cursor: default;
  animation: shake .3s ease;
}

.choice-btn.incorrect .choice-letter {
  background: var(--rust);
  color: #fff;
}

.choice-btn.revealed {
  border-color: var(--forest);
  background: var(--forest-light);
  cursor: default;
}

.choice-btn.revealed .choice-letter {
  background: var(--forest);
  color: #fff;
}

.choice-btn.answered {
  cursor: default;
}

@keyframes popIn {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.02) translateX(3px);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* ─── FEEDBACK PANEL ─────────────────────────────────────────────────────── */
.feedback-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s ease, opacity .3s ease;
  opacity: 0;
}

.feedback-panel.show {
  max-height: 400px;
  opacity: 1;
}

.feedback-inner {
  border-top: 1px solid var(--border);
  padding: 1rem 1.4rem 1.1rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.feedback-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: .05rem;
}

.feedback-verdict {
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: .25rem;
}

.feedback-verdict.v-correct {
  color: var(--forest);
}

.feedback-verdict.v-incorrect {
  color: var(--rust);
}

.feedback-explanation {
  font-size: .83rem;
  color: #5a5248;
  line-height: 1.6;
}

/* ─── QUIZ NAV ───────────────────────────────────────────────────────────── */
.quiz-nav {
  display: flex;
  justify-content: flex-end;
  padding: .9rem 1.4rem 1.2rem;
  border-top: 1px solid var(--border);
}

.next-btn {
  padding: .6rem 1.6rem;
  font-family: 'DM Serif Display', serif;
  font-size: .95rem;
  background: var(--ink);
  color: var(--cream);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .3s, transform .3s, background .15s;
}

.next-btn.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.next-btn:hover {
  background: #3d3530;
}

/* ─── SCORE SCREEN ───────────────────────────────────────────────────────── */
.score-screen {
  text-align: center;
}

.score-ring-wrap {
  margin: 0 auto 2rem;
  width: 160px;
  height: 160px;
  position: relative;
}

.score-ring-wrap svg {
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 14;
}

.score-ring-fill {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  stroke: var(--rust);
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4, 0, .2, 1) .3s, stroke .3s;
}

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-pct {
  font-family: 'DM Serif Display', serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
}

.score-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8c8075;
  margin-top: .2rem;
}

.score-headline {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  margin-bottom: .4rem;
}

.score-sub {
  font-size: .88rem;
  color: #6b6157;
  margin-bottom: 2rem;
}

/* Section breakdown */
.breakdown {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.breakdown-title {
  background: var(--ink);
  color: var(--gold);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .6rem 1rem;
}

.breakdown-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}

.breakdown-row:last-child {
  border-bottom: none;
}

.breakdown-section {
  flex: 1;
  color: var(--slate);
}

.breakdown-score {
  font-weight: 700;
  color: var(--ink);
  min-width: 50px;
  text-align: right;
}

.breakdown-bar-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  max-width: 120px;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--rust);
  transition: width 1s ease .5s;
}

.score-actions {
  display: flex;
  gap: .8rem;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: .7rem 1.5rem;
  font-family: 'DM Serif Display', serif;
  font-size: .95rem;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid;
  transition: all .17s;
}

.action-btn.primary {
  background: var(--rust);
  border-color: var(--rust);
  color: #fff;
}

.action-btn.primary:hover {
  background: #9c3a15;
}

.action-btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--slate);
}

.action-btn.secondary:hover {
  border-color: var(--slate);
}

/* ─── LIVE SCOREBOARD ────────────────────────────────────────────────────── */
.live-score {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.ls-box {
  flex: 1;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem .8rem;
  text-align: center;
}

.ls-num {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  line-height: 1;
}

.ls-num.correct-c {
  color: var(--forest);
}

.ls-num.incorrect-c {
  color: var(--rust);
}

.ls-num.remaining-c {
  color: var(--gold);
}

.ls-label {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8c8075;
  margin-top: .15rem;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  html {
    zoom: 0.80;
  }
  .card,
  .quiz-card-body {
    padding: 1.4rem;
  }

  .q-presets {
    grid-template-columns: repeat(2, 1fr);
  }

  .question-text {
    font-size: 1rem;
  }

  .breakdown-bar-track {
    display: none;
  }
}
.question-set-select {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid #d6cfc8;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #2c2420;
  background: #fff;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238c8075' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  margin-top: 0.4rem;
}

.question-set-select:focus {
  outline: none;
  border-color: #2a5c45;
  box-shadow: 0 0 0 3px rgba(42, 92, 69, 0.12);
}