:root {
  --rust: #a94a2e;
  --rust-dark: #8a3a22;
  --cream: #f3e9d7;
  --cream-dark: #ece0c9;
  --ink: #3a2418;
  --green: #3f7d55;
  --red: #b23a2e;
  --shadow: 0 2px 10px rgba(58, 36, 24, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Archivo', sans-serif;
  background-image: radial-gradient(circle at 1px 1px, rgba(58,36,24,0.05) 1px, transparent 0);
  background-size: 18px 18px;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2 {
  font-family: 'Playfair Display', serif;
  color: var(--rust-dark);
  margin: 0 0 8px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--rust);
  margin: 0 0 6px;
}

/* Header */
.site-header {
  background: var(--rust);
  color: white;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-badge {
  border: 1.5px solid white;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.brand-name {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { color: white; }
.tab-btn.active {
  background: rgba(255,255,255,0.18);
  color: white;
}

/* Layout */
main.wrap { padding-top: 36px; padding-bottom: 60px; min-height: 60vh; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-sub { color: #6b5544; margin-top: -4px; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.intro-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  text-align: center;
}
.intro-card h1 { font-size: 2rem; }
.blurb { color: #6b5544; font-size: 1.05rem; }
.meta { color: #9a8571; font-size: 0.85rem; margin-bottom: 20px; }

/* Buttons */
.btn {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 12px 26px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, color 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--rust);
  color: white;
}
.btn-primary:hover { background: var(--rust-dark); }
.btn-outline {
  background: transparent;
  border-color: var(--rust);
  color: var(--rust-dark);
}
.btn-outline:hover { background: var(--cream-dark); }
.btn-correct {
  background: #e7f3ea;
  color: var(--green);
  border-color: #bfe0c8;
}
.btn-correct:hover { background: #d8ecdd; }
.btn-wrong {
  background: #f7e6e3;
  color: var(--red);
  border-color: #e6bdb5;
}
.btn-wrong:hover { background: #f2d7d1; }

/* Quiz header + sticky score bar */
.quiz-header { text-align: center; margin-bottom: 20px; }
.quiz-header h1 { font-size: 2rem; }

.score-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--cream);
  padding: 14px 4px;
  margin: 0 -4px 22px;
  border-bottom: 2px solid var(--cream-dark);
}
.progress-track {
  flex: 1;
  height: 8px;
  background: var(--cream-dark);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--rust);
  transition: width 0.25s ease;
}
.progress-label { font-size: 0.85rem; font-weight: 700; color: #6b5544; white-space: nowrap; }
.score-pill {
  background: var(--rust);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.btn-small { padding: 6px 16px; font-size: 0.8rem; white-space: nowrap; }

/* Question list */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}
.qa-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  text-align: left;
  border-left: 5px solid transparent;
  transition: border-color 0.15s;
}
.qa-card.marked-right { border-left-color: var(--green); }
.qa-card.marked-wrong { border-left-color: var(--red); }

.q-number {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--rust);
  margin: 0 0 10px;
}
.q-text {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 18px;
}
.answer-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1.5px dashed var(--cream-dark);
}
.a-label {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: var(--rust);
  margin: 0 0 4px;
}
.a-text {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 18px;
}
.verdict-row { display: flex; gap: 12px; flex-wrap: wrap; }
.qa-card.marked-right .btn-correct,
.qa-card.marked-wrong .btn-wrong {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.hidden { display: none !important; }

/* Results */
.results-card { text-align: center; }
.results-score {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--rust-dark);
  margin: 8px 0;
}
.results-sub { color: #6b5544; margin-bottom: 24px; }
.submit-form { max-width: 380px; margin: 0 auto 24px; text-align: left; }
.submit-form label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--rust-dark);
}
.submit-row { display: flex; gap: 8px; }
.submit-row input {
  flex: 1;
  border: 2px solid var(--cream-dark);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: 'Archivo', sans-serif;
  font-size: 0.95rem;
}
.submit-row input:focus { outline: none; border-color: var(--rust); }
.submit-note { font-size: 0.85rem; color: var(--green); min-height: 1.2em; margin-top: 8px; }
.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Archive */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.archive-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.archive-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(58,36,24,0.12); }
.archive-card .badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--rust);
  background: var(--cream-dark);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}
.archive-card h3 {
  font-family: 'Playfair Display', serif;
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--rust-dark);
}
.archive-card p { margin: 0; font-size: 0.85rem; color: #6b5544; }
.archive-card .arch-date { font-size: 0.75rem; color: #9a8571; margin-top: 10px; }

/* Leaderboard */
.leaderboard-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.leaderboard-controls label { font-weight: 700; font-size: 0.85rem; }
.leaderboard-controls select {
  font-family: 'Archivo', sans-serif;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--cream-dark);
  background: white;
}
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.leaderboard-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--rust);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cream-dark);
}
.leaderboard-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--cream-dark);
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: #9a8571; padding: 24px 0; }

.site-footer {
  text-align: center;
  padding: 30px 20px 40px;
  color: #9a8571;
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .intro-card, .card { padding: 20px; }
  .results-score { font-size: 2.2rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .tabs { gap: 4px; }
  .tab-btn { font-size: 0.78rem; padding: 6px 10px; }
}

/* Home */
.home-logo { text-align: center; margin-bottom: 36px; }
.home-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 2.1rem;
  color: var(--rust-dark);
  margin: 0 0 6px;
}
.home-tagline { color: #6b5544; font-size: 1rem; margin: 0; }

.home-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}
.home-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.home-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(58,36,24,0.12); }
.home-card-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--rust-dark);
  margin: 0 0 6px;
}
.home-card-sub { color: #9a8571; font-size: 0.85rem; margin: 0; }

.home-books-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.badge-soon {
  background: var(--cream-dark);
  color: var(--rust-dark);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.home-books-grid {
  display: grid;
  grid-template-columns: repeat(3, 150px);
  gap: 14px;
  justify-content: center;
}
.home-book-tile {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0.92;
}
.home-book-tile img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: center;
  display: block;
}
.home-book-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--rust-dark);
  margin: 16px 12px 2px;
  line-height: 1.3;
}
.home-book-title span { font-weight: 500; color: #9a8571; font-size: 0.78rem; }
.home-book-stars {
  margin: 2px 12px;
  color: #d99b2b;
  font-size: 0.85rem;
  letter-spacing: 1px;
}
.home-book-stars .star-empty { color: var(--cream-dark); }
.home-book-comment {
  font-family: 'Caveat', cursive;
  font-size: 1.05rem;
  color: #6b5544;
  margin: 4px 12px 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 560px) {
  .home-books-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .home-book-title, .home-book-comment { margin-left: 8px; margin-right: 8px; }
  .home-book-comment { -webkit-line-clamp: 2; font-size: 0.95rem; }
}
