:root {
  box-sizing: border-box;
  color: #1f2937;
  font: 1rem/1.5 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
}

.page-header {
  width: min(100% - 2rem, 48rem);
  margin: 1.5rem auto 0;
}

.page-header nav,
.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

main {
  width: min(100% - 2rem, 48rem);
  margin: 2rem auto 4rem;
}

.page-header + main {
  margin-top: 1.5rem;
}

h1 {
  margin: 0 0 1.5rem;
}

.home-page {
  margin-top: 4rem;
}

.home-page h1 {
  margin-bottom: 1rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.2;
}

.home-intro {
  max-width: 36rem;
  margin: 0 0 2rem;
  color: #475569;
  font-size: 1.0625rem;
}

.home-links {
  align-items: center;
}

.home-primary {
  padding: 0.625rem 1rem;
  border: 1px solid currentColor;
  border-radius: 0.375rem;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.home-primary:hover {
  background: #f8fafc;
}

.home-primary:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

form {
  display: grid;
  gap: 1.25rem;
}

fieldset + fieldset {
  margin-top: 0.625rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  width: 100%;
  padding: 0;
  font-weight: 600;
}

.answer-option {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin: 0.375rem 0;
  font-size: 0.9375rem;
  cursor: pointer;
}

.answer-option:has(input.correct-answer:checked) {
  color: #166534;
}

.answer-option:has(input.incorrect-answer:checked) {
  color: #991b1b;
}

.answer-option input[type="radio"] {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin: 0.25rem 0 0;
}

fieldset:disabled .answer-option {
  pointer-events: none;
  cursor: default;
}

fieldset:disabled .answer-option input[type="radio"] {
  display: none;
}

fieldset:disabled .answer-option::before {
  flex: none;
  width: 1rem;
  margin-top: 0.25rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
  content: "";
}

fieldset:disabled .answer-option:not(:has(input:checked)) {
  opacity: 0.6;
}

fieldset:disabled .answer-option:has(input.correct-answer) {
  opacity: 1;
}

fieldset:disabled .answer-option:has(input.correct-answer)::before {
  color: #16a34a;
  content: "✓";
}

fieldset:disabled .answer-option:has(input.incorrect-answer:checked)::before {
  color: #dc2626;
  content: "✗";
}

button {
  justify-self: center;
  margin-top: 1.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid currentColor;
  border-radius: 0.25rem;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

button:hover {
  text-decoration: underline;
}

button:focus-visible,
.answer-option:has(input:focus-visible) {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.exam-summary {
  margin-top: 1.25rem;
  text-align: center;
}

.exam-summary p {
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.exam-summary nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.explanation {
  display: none;
  margin-top: 0.25rem;
  color: #475569;
  font-size: 0.875rem;
}

fieldset:has(input.incorrect-answer:checked) .explanation {
  display: block;
}

.stats-section {
  margin-top: 2rem;
}

.stats-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
}

.stats-section p {
  margin: 0 0 0.75rem;
  color: #475569;
  font-size: 0.875rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 0.875rem);
  gap: 0.25rem;
}

.stats-cell {
  display: block;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 2px;
  background: #e6e9ed;
}

.stats-cell--wrong-1 {
  background: #f7d8d0;
}

.stats-cell--wrong-2 {
  background: #eaa89b;
}

.stats-cell--wrong-3 {
  background: #c96f64;
}

.stats-cell--right-1 {
  background: #d9ecdb;
}

.stats-cell--right-2 {
  background: #9bcaa6;
}

.stats-cell--right-3 {
  background: #57996f;
}

.stats-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
  color: #475569;
  font-size: 0.875rem;
}

.stats-legend-scale {
  display: flex;
  gap: 0.25rem;
}

.stats-note {
  color: #475569;
  font-size: 0.875rem;
}
