:root {
  color-scheme: light;
  --paper: #f6f2eb;
  --surface: #fffdf9;
  --ink: #292625;
  --muted: #68615d;
  --line: #d8d0c7;
  --accent: #6f1d2b;
  --accent-dark: #561520;
  --success: #2f6247;
  --error: #9b352d;
  --radius: 12px;
  --shadow: 0 14px 36px rgba(69, 49, 42, 0.09);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  color: var(--ink);
  background: var(--paper);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-shell {
  width: min(100% - 32px, 780px);
  margin: auto;
  padding: 48px 0;
}

.screen {
  width: 100%;
}

[hidden] {
  display: none !important;
}

.opening-screen,
.final-screen {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(32px, 7vw, 68px);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

.course-label,
.scenario-label {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

h1,
.final-screen h2 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 8vw, 4rem);
  line-height: 1;
  letter-spacing: -0.025em;
}

.subtitle {
  max-width: 34rem;
  margin-bottom: 34px;
  color: var(--accent);
  font-size: clamp(1rem, 2.7vw, 1.18rem);
  font-weight: 700;
  line-height: 1.45;
}

.instructions,
.final-message {
  max-width: 58ch;
  margin-bottom: 32px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.button-primary,
.button-next {
  color: #fffaf6;
  background: var(--accent);
}

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

.button-secondary {
  color: var(--accent);
  background: transparent;
}

.button-secondary:hover {
  color: #fffaf6;
  background: var(--accent);
}

.button:active,
.choice:active {
  transform: translateY(1px);
}

.button:focus-visible,
.choice:focus-visible,
.wordmark:focus-visible,
.rule-link:focus-visible {
  outline: 3px solid #bd7b42;
  outline-offset: 4px;
}

.game-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.wordmark {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  font-weight: 700;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

.progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.scenario-card {
  min-height: 310px;
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.scenario-card:focus {
  outline: none;
}

.scenario-text {
  max-width: 59ch;
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 4vw, 1.8rem);
  line-height: 1.45;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.choice {
  min-height: 112px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 14px;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.choice:hover:not(:disabled) {
  border-color: var(--accent);
}

.choice:disabled {
  cursor: default;
  opacity: 0.72;
}

.choice.is-selected {
  border-color: var(--accent);
  opacity: 1;
}

.choice.is-correct {
  border-color: var(--success);
  background: #f0f7f2;
}

.choice.is-incorrect {
  border-color: var(--error);
  background: #fbf0ee;
}

.choice-letter {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.choice-text {
  font-weight: 700;
  line-height: 1.45;
}

.feedback {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.feedback-result {
  margin-bottom: 8px;
  font-weight: 800;
}

.feedback-result.correct {
  color: var(--success);
}

.feedback-result.incorrect {
  color: var(--error);
}

.feedback-explanation {
  max-width: 63ch;
  margin-bottom: 12px;
  line-height: 1.58;
}

.rule-link {
  color: var(--accent);
  font-weight: 700;
  text-underline-offset: 3px;
}

.button-next {
  margin: 18px 0 0 auto;
}

.final-score {
  margin: 18px 0 24px;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.25rem, 12vw, 5.75rem);
  font-weight: 700;
  line-height: 1;
}

.final-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

footer {
  padding: 18px 24px 24px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .game-shell {
    width: min(100% - 24px, 780px);
    padding: 24px 0;
  }

  .opening-screen,
  .final-screen,
  .scenario-card {
    padding: 28px 22px;
  }

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

  .choice {
    min-height: 94px;
  }

  .button-next {
    width: 100%;
  }

  .final-actions {
    flex-direction: column;
  }

  .final-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .button,
  .choice {
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 80ms ease;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #7c716a;
    --muted: #49423e;
  }
}
