:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #61707f;
  --line: #d9e0e7;
  --primary: #146c94;
  --primary-dark: #0f526f;
  --correct: #147d4f;
  --correct-bg: #e9f8f0;
  --wrong: #b42318;
  --wrong-bg: #fff0ee;
  --focus: #f2b84b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
}

.scorebox {
  min-width: 128px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.top-actions {
  display: grid;
  gap: 8px;
  min-width: 160px;
}

.scorebox small {
  white-space: nowrap;
}

.scorebox span {
  display: block;
  color: var(--primary);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
}

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

.progress-wrap,
.quiz-card,
.results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress-wrap {
  padding: 16px;
  margin-bottom: 16px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf0;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.quiz-card,
.results {
  padding: 24px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.question-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.question-meta .difficulty-badge {
  border-color: transparent;
  color: var(--text);
  font-weight: 700;
}

.difficulty-badge.difficult {
  background: var(--wrong-bg);
  color: var(--wrong);
}

.difficulty-badge.easy {
  background: var(--correct-bg);
  color: var(--correct);
}

#questionText {
  margin-bottom: 20px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.25;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  min-height: 54px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
}

.answer:hover {
  border-color: var(--primary);
}

.answer input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary);
}

.answer.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.answer.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.answer.disabled {
  cursor: default;
}

.option-id {
  font-weight: 700;
  text-transform: uppercase;
}

.feedback {
  margin-top: 18px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  line-height: 1.55;
}

.feedback.success {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.feedback.error {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.feedback strong {
  display: block;
  margin-bottom: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

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

button.secondary {
  color: var(--primary);
  font-weight: 700;
}

.reset-history {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.results {
  margin-top: 16px;
}

.results h2 {
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .app {
    width: 100%;
    padding: 12px 10px 20px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 1.7rem;
    line-height: 1.12;
  }

  .top-actions {
    min-width: 0;
  }

  .scorebox {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
    padding: 12px 14px;
  }

  .scorebox span {
    font-size: 1.8rem;
  }

  .progress-wrap {
    padding: 12px;
    margin-bottom: 10px;
  }

  .progress-meta {
    display: grid;
    gap: 4px;
    font-size: 0.9rem;
  }

  .progress-track {
    height: 10px;
  }

  .quiz-card,
  .results {
    padding: 14px;
  }

  .question-meta {
    gap: 6px;
    margin-bottom: 12px;
  }

  .question-meta span {
    padding: 5px 8px;
    font-size: 0.82rem;
  }

  #questionText {
    margin-bottom: 16px;
    font-size: 1.18rem;
    line-height: 1.32;
  }

  .answers {
    gap: 8px;
  }

  .answer {
    min-height: 58px;
    padding: 13px 12px;
    gap: 10px;
    line-height: 1.35;
  }

  .answer input {
    width: 20px;
    height: 20px;
  }

  .feedback {
    margin-top: 14px;
    padding: 13px;
    line-height: 1.45;
  }

  .actions {
    display: grid;
    gap: 8px;
    margin-top: 14px;
  }

  button {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
  }
}

@media (max-width: 360px) {
  .app {
    padding-inline: 8px;
  }

  .quiz-card,
  .results,
  .progress-wrap {
    border-radius: 6px;
  }

  #questionText {
    font-size: 1.08rem;
  }

  .answer {
    grid-template-columns: 20px 1fr;
    padding: 12px 10px;
    font-size: 0.95rem;
  }
}
