:root {
  color-scheme: light;
  --paper: #eee9dc;
  --paper-light: #f7f3e9;
  --ink: #202827;
  --muted: #60635e;
  --line: #777970;
  --accent: #8c3f32;
  --accent-ink: #fffaf0;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius: 3px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  isolation: isolate;
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body[data-screen="home"]::before,
body[data-screen="home"]::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
}

body[data-screen="home"]::before {
  top: 0;
  bottom: 0;
  left: max(24px, calc(50% - 430px));
  border-left: 1px solid rgb(140 63 50 / 0.24);
}

body[data-screen="home"]::after {
  top: 68%;
  right: 0;
  left: 0;
  border-top: 1px solid rgb(32 40 39 / 0.11);
  box-shadow:
    0 32px 0 rgb(32 40 39 / 0.1),
    0 64px 0 rgb(32 40 39 / 0.085),
    0 96px 0 rgb(32 40 39 / 0.07),
    0 128px 0 rgb(32 40 39 / 0.055);
}

button {
  color: inherit;
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

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

.exercise {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(34px, 8vh, 76px) clamp(20px, 5vw, 48px) 40px;
}

header {
  padding-bottom: clamp(24px, 5vh, 42px);
  border-bottom: 1px solid var(--ink);
}

h1 {
  max-width: 100%;
  font-family: var(--serif);
  font-size: clamp(2rem, 5.8vw, 3.35rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.03;
  text-wrap: balance;
}

.home-screen {
  min-height: clamp(360px, 58dvh, 560px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
}

.home-screen p {
  max-width: 26ch;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3.3vw, 2rem);
  line-height: 1.35;
}

.primary-button,
.answer-button {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.primary-button {
  min-height: 52px;
  padding: 13px 24px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.primary-button:active,
.answer-button:active:not(:disabled) {
  transform: translateY(1px);
}

.play-screen {
  padding-top: clamp(26px, 5vh, 44px);
}

.progress {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.question-card {
  min-height: clamp(220px, 34dvh, 330px);
  padding: clamp(28px, 6vw, 52px);
  display: flex;
  align-items: center;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-light);
}

.question-card h2 {
  max-width: 100%;
  font-family: var(--serif);
  font-size: clamp(1.75rem, 4.8vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.18;
  text-wrap: balance;
}

.answer-panel {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.answer-button {
  min-height: 104px;
  padding: 22px;
  background: transparent;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: left;
}

.answer-button:hover:not(:disabled) {
  background: var(--paper-light);
}

.answer-button:disabled {
  cursor: default;
  color: var(--muted);
}

.answer-button.is-correct {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
  color: var(--ink);
}

.answer-button.is-wrong {
  border-color: var(--line);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

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

.feedback-slot {
  min-height: 176px;
}

.feedback h3 {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 600;
}

#feedback-text {
  max-width: 58ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.55;
}

.feedback .primary-button {
  margin-top: 16px;
}

.end-screen {
  padding-top: clamp(42px, 9vh, 84px);
}

.end-screen h2 {
  font-family: var(--serif);
  font-size: clamp(2.25rem, 6vw, 3.75rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.rule-review {
  margin: 38px 0 34px;
  border-top: 1px solid var(--line);
}

.rule-review p {
  padding: 19px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  border-bottom: 1px solid var(--line);
  font-size: 1.08rem;
  line-height: 1.4;
}

.rule-review strong {
  font-family: var(--serif);
  font-size: 1.22rem;
}

.rule-review span {
  color: var(--muted);
}

body[data-screen="play"] .exercise,
body[data-screen="end"] .exercise {
  padding-top: clamp(18px, 3vh, 28px);
  padding-bottom: clamp(14px, 2vh, 22px);
}

body[data-screen="play"] header,
body[data-screen="end"] header {
  padding-bottom: clamp(12px, 2vh, 18px);
}

body[data-screen="play"] h1,
body[data-screen="end"] h1 {
  font-size: clamp(1.7rem, min(3.4vw, 4.2vh), 2.35rem);
  line-height: 1.02;
}

body[data-screen="play"] .play-screen {
  padding-top: clamp(12px, 2vh, 18px);
}

body[data-screen="play"] .progress {
  margin-bottom: 10px;
}

body[data-screen="play"] .question-card {
  min-height: clamp(170px, 28dvh, 230px);
  padding: clamp(22px, 3.5vh, 32px) clamp(24px, 4vw, 42px);
}

body[data-screen="play"] .question-card h2 {
  font-size: clamp(1.65rem, min(3.3vw, 3.8vh), 2.25rem);
}

body[data-screen="play"] .answer-panel {
  margin-top: 10px;
  gap: 10px;
}

body[data-screen="play"] .answer-button {
  min-height: clamp(72px, 11dvh, 88px);
  padding: 16px 20px;
  font-size: clamp(1.25rem, 2.4vw, 1.55rem);
}

body[data-screen="play"] .feedback-slot {
  min-height: clamp(146px, 22dvh, 176px);
}

body[data-screen="play"] .feedback {
  margin-top: clamp(12px, 2vh, 18px);
  padding-top: clamp(12px, 2vh, 18px);
}

body[data-screen="play"] .feedback h3 {
  font-size: 1.4rem;
}

body[data-screen="play"] #feedback-text {
  margin-top: 6px;
  font-size: 1rem;
  line-height: 1.4;
}

body[data-screen="play"] .feedback .primary-button {
  min-height: 44px;
  margin-top: 12px;
  padding: 9px 20px;
}

body[data-screen="end"] .end-screen {
  padding-top: clamp(24px, 5vh, 44px);
}

body[data-screen="end"] .end-screen h2 {
  font-size: clamp(2.1rem, min(5vw, 6vh), 3.35rem);
}

body[data-screen="end"] .rule-review {
  margin: clamp(22px, 4vh, 32px) 0 clamp(20px, 3.5vh, 28px);
}

body[data-screen="end"] .rule-review p {
  padding: clamp(13px, 2.5vh, 18px) 0;
}

@media (max-width: 580px) {
  body[data-screen="home"]::before {
    left: 8px;
  }

  body[data-screen="home"]::after {
    display: none;
  }

  .exercise {
    padding: 28px 18px 32px;
  }

  header {
    padding-bottom: 24px;
  }

  h1 {
    font-size: clamp(1.85rem, 9.4vw, 2.5rem);
  }

  .home-screen {
    min-height: 62dvh;
  }

  .play-screen {
    padding-top: 24px;
  }

  .question-card {
    min-height: 220px;
    padding: 26px 22px;
  }

  .question-card h2 {
    font-size: clamp(1.55rem, 7.2vw, 2.05rem);
  }

  .answer-panel {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .answer-button {
    min-height: 74px;
    padding: 17px 18px;
    font-size: 1.3rem;
  }

  .feedback {
    margin-top: 24px;
    padding-top: 20px;
  }

  .feedback-slot,
  body[data-screen="play"] .feedback-slot {
    min-height: 0;
  }

  body[data-screen="play"] .exercise,
  body[data-screen="end"] .exercise {
    padding: 22px 18px 30px;
  }

  body[data-screen="play"] header,
  body[data-screen="end"] header {
    padding-bottom: 18px;
  }

  body[data-screen="play"] h1,
  body[data-screen="end"] h1 {
    font-size: clamp(1.7rem, 8vw, 2.25rem);
  }

  body[data-screen="play"] .question-card {
    min-height: 200px;
    padding: 24px 22px;
  }

  body[data-screen="play"] .answer-button {
    min-height: 70px;
  }

  .feedback .primary-button,
  .end-screen .primary-button {
    width: 100%;
  }

  .rule-review p {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
