:root {
  --ink: #231f20;
  --muted: #766d64;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: #eadcc4;
  --red: #b80f1b;
  --red-dark: #851018;
  --gold: #f0b643;
  --green: #167d5a;
  --blue: #1f5f8b;
  --shadow: 0 18px 46px rgba(72, 44, 18, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(184, 15, 27, 0.08), rgba(240, 182, 67, 0.12)),
    var(--paper);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow,
.section-name {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.22;
}

h1 {
  font-size: clamp(24px, 4vw, 36px);
}

h2 {
  font-size: clamp(20px, 3vw, 28px);
}

.score-pill {
  min-width: 86px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
}

.mode-control {
  display: grid;
  gap: 8px;
  min-width: min(100%, 480px);
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: #efe3cf;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segment {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
}

.segment.is-active {
  color: white;
  background: var(--red);
}

.mode-help {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

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

.quiz-card,
.result-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 30px);
}

.quiz-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.progress-text {
  min-width: 56px;
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  margin: 20px 0;
  background: #f0e2c9;
  border-radius: 999px;
}

.progress-fill {
  width: 10%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width 180ms ease;
}

.answers {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.answer {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.answer:hover {
  border-color: var(--gold);
  background: #fff7e5;
}

.answer.is-selected {
  border-color: var(--blue);
  background: #edf7ff;
}

.answer.is-correct {
  border-color: var(--green);
  background: #edf9f3;
}

.answer.is-wrong {
  border-color: var(--red);
  background: #fff0f0;
}

.answer-letter {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #f5ead8;
  font-weight: 900;
}

.answer-text {
  line-height: 1.42;
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 4px solid var(--green);
  background: #f3fbf7;
  border-radius: 6px;
  line-height: 1.55;
}

.feedback.is-wrong {
  border-left-color: var(--red);
  background: #fff4f4;
}

.actions,
.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
}

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

.button.primary {
  color: white;
  background: var(--red);
}

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

.button.secondary {
  color: var(--red-dark);
  border-color: var(--line);
  background: #fff8eb;
}

.button.ghost {
  color: var(--muted);
  background: transparent;
}

.result-card {
  text-align: center;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0 8px;
}

.result-grid div {
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.result-grid span {
  display: block;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900;
  color: var(--red);
}

.result-grid small {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 680px) {
  .topbar,
  .toolbar,
  .quiz-head,
  .actions,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .score-pill,
  .progress-text {
    width: 100%;
    text-align: center;
  }

  .segmented,
  .mode-control,
  .result-grid {
    width: 100%;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }
}
