:root {
  color-scheme: light;
  --paper: #f7f1e7;
  --surface: #ffffff;
  --ink: #20242a;
  --muted: #66707c;
  --line: #d8d2c8;
  --blue: #243657;
  --blue-soft: #e3e9f4;
  --red: #b5333f;
  --red-soft: #f7e0e2;
  --green: #23705b;
  --green-soft: #dff0e9;
  --gold: #d59628;
  --shadow: 0 18px 46px rgba(32, 36, 42, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

.shell {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 44px);
}

.game-surface {
  min-height: calc(100vh - clamp(36px, 6vw, 88px));
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--blue);
  font-size: clamp(2.6rem, 6vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  color: var(--blue);
  font-size: 1.05rem;
  letter-spacing: 0;
}

.score-strip,
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 8px;
}

.score-strip div,
.result-stats div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.score-strip span,
.result-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.score-strip strong,
.result-stats strong {
  display: block;
  margin-top: 2px;
  color: var(--blue);
  font-size: 1.55rem;
  line-height: 1.1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 0.42fr) minmax(420px, 1fr);
  gap: 16px;
  align-items: start;
}

.panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mode-panel {
  padding: 16px;
}

.question-panel {
  min-height: 620px;
  padding: clamp(18px, 3vw, 28px);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-tabs button,
.reset-button,
.next-button,
.group-button,
.option-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.mode-tabs button {
  min-height: 42px;
  padding: 0 10px;
  font-weight: 800;
}

.mode-tabs button.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

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

.group-button {
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: 10px 12px;
  text-align: left;
}

.group-button strong {
  color: var(--blue);
  font-size: 0.95rem;
  line-height: 1.2;
}

.group-button span {
  color: var(--muted);
  font-size: 0.83rem;
}

.group-button.is-active {
  border-color: var(--red);
  background: var(--red-soft);
}

.reset-button,
.next-button {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 850;
}

.reset-button {
  width: 100%;
  margin-top: 14px;
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.reset-button:hover,
.reset-button:focus-visible {
  background: #172844;
  outline: none;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.letter-card {
  display: grid;
  place-items: center;
  min-height: 270px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.question-letter {
  color: var(--red);
  font-size: clamp(7.2rem, 18vw, 12rem);
  font-weight: 950;
  line-height: 0.92;
}

.question-group {
  align-self: start;
  min-height: 28px;
  margin-top: -24px;
  color: var(--blue);
  font-size: 1.05rem;
  font-weight: 850;
}

.feedback {
  min-height: 36px;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 850;
}

.feedback.is-correct {
  color: var(--green);
}

.feedback.is-wrong {
  color: var(--red);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.option-button {
  display: grid;
  place-items: center;
  min-height: 72px;
  padding: 8px;
  color: var(--blue);
  font-size: clamp(1.25rem, 2.7vw, 1.85rem);
  font-weight: 900;
}

.option-button:hover,
.option-button:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
  outline: none;
}

.option-button.is-correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.option-button.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.next-button {
  width: 100%;
  margin-top: 14px;
  border-color: var(--red);
  background: var(--red);
  color: white;
}

.next-button:hover,
.next-button:focus-visible {
  background: #992935;
  outline: none;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(260px, 0.42fr) minmax(360px, 1fr);
  gap: 16px;
  margin-top: 16px;
  padding: 18px;
}

.mistake-list {
  display: grid;
  gap: 8px;
}

.mistake-row,
.perfect {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 10px 12px;
}

.mistake-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr;
  gap: 10px;
  align-items: center;
}

.mistake-row strong {
  color: var(--red);
  font-size: 1.5rem;
  line-height: 1;
}

.mistake-row span,
.mistake-row small,
.perfect {
  color: var(--muted);
  font-weight: 760;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(220px, 0.74fr) minmax(360px, 1.26fr);
  }

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

  .mistake-list {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .game-header,
  .result-panel {
    grid-template-columns: 1fr;
  }

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

  .score-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .score-strip div,
  .result-stats div {
    min-height: 56px;
    padding: 8px 10px;
  }

  .score-strip strong,
  .result-stats strong {
    font-size: 1.28rem;
  }

  .mode-panel {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .question-panel {
    min-height: auto;
    padding: 14px;
  }

  .letter-card {
    min-height: 150px;
    margin-top: 12px;
  }

  .question-letter {
    font-size: clamp(5.4rem, 24vw, 7rem);
  }

  .options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-button {
    min-height: 62px;
  }

  .mistake-row {
    grid-template-columns: 40px 1fr;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: clamp(2.3rem, 13vw, 3.4rem);
  }
}
