:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #68717c;
  --paper: #f6f1e9;
  --surface: #ffffff;
  --line: #d8d0c5;
  --red: #b51d2a;
  --red-dark: #941521;
  --red-soft: #fae6e8;
  --blue: #243657;
  --blue-soft: #e7eef7;
  --green: #25774d;
  --green-soft: #e2f2e8;
  --gold: #d39225;
  --shadow: 0 18px 52px rgba(41, 35, 26, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(181, 29, 42, 0.08), rgba(36, 54, 87, 0.08)),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

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

button:disabled {
  cursor: default;
  opacity: 0.62;
}

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

.game-surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

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

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

h1,
h2 {
  margin: 0;
  color: #2d3339;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 4rem);
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.35rem);
}

.audio-controls,
.selection-actions,
.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.audio-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.utility-button,
.icon-button,
.start-button,
.next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
}

.utility-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  padding: 0 14px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-weight: 800;
}

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

.setup-panel,
.game-panel,
.result-panel {
  padding: 28px;
}

.setup-top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

#selectedCount {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 12px;
  font-weight: 800;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.mode-tabs button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

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

.word-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.word-select-card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  cursor: pointer;
}

.word-select-card:has(input:checked) {
  border-color: rgba(181, 29, 42, 0.62);
  background: #fff8f8;
}

.word-select-card input {
  margin-top: 5px;
  accent-color: var(--red);
}

.word-select-card strong,
.word-select-card small,
.word-select-card em {
  display: block;
}

.word-select-card strong {
  color: var(--red-dark);
  font-size: 1.3rem;
}

.word-select-card small {
  color: var(--ink);
  font-size: 0.96rem;
}

.word-select-card em {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  text-transform: uppercase;
}

.start-button,
.next-button {
  width: 100%;
  margin-top: 18px;
  border: 0;
  background: var(--red);
  color: #fff;
  padding: 0 20px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(181, 29, 42, 0.2);
}

.start-button:not(:disabled):hover,
.start-button:not(:disabled):focus-visible,
.next-button:hover,
.next-button:focus-visible {
  background: var(--red-dark);
  outline: none;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 16px;
}

.prompt-card {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(36, 54, 87, 0.08), rgba(211, 146, 37, 0.12)),
    #fff;
  padding: 22px;
  text-align: center;
}

.speaker-button {
  display: grid;
  place-items: center;
  width: 110px;
  height: 110px;
  border: 2px solid var(--blue);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
}

.speaker-button::before {
  content: "";
  width: 42px;
  height: 42px;
  background: var(--blue);
  clip-path: polygon(0 32%, 32% 32%, 68% 0, 68% 100%, 32% 68%, 0 68%);
}

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

.prompt-card p {
  margin: 14px 0 0;
  color: var(--muted);
}

.english-prompt {
  color: var(--blue);
  font-size: clamp(2.4rem, 8vw, 5rem);
  font-weight: 900;
  line-height: 1;
}

.feedback {
  min-height: 32px;
  margin: 16px 0;
  color: var(--muted);
  font-weight: 800;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.option-button {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  cursor: pointer;
  font-size: 1.06rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.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: #145432;
}

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

.game-actions {
  margin-top: 18px;
}

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

.game-actions .utility-button {
  min-width: 160px;
}

.game-actions .next-button {
  width: auto;
  min-width: 160px;
  margin-top: 0;
}

.result-actions .next-button {
  width: auto;
  min-width: 220px;
  margin-top: 0;
}

.result-actions .utility-button {
  min-width: 180px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.result-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.result-stats span,
.result-stats strong {
  display: block;
}

.result-stats span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-stats strong {
  color: var(--red);
  font-size: 2rem;
}

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

.mistake-item,
.empty-result,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.mistake-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.mistake-item strong {
  color: var(--green);
}

.mistake-item em {
  color: var(--muted);
  font-style: normal;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .game-header,
  .setup-top {
    align-items: stretch;
    flex-direction: column;
  }

  .audio-controls,
  .selection-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .shell {
    width: 100%;
    padding: 0;
  }

  .game-surface {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .game-header,
  .setup-panel,
  .game-panel,
  .result-panel,
  .footer {
    padding-inline: 18px;
  }

  .audio-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mode-tabs,
  .options-grid,
  .result-stats,
  .mistake-item {
    grid-template-columns: 1fr;
  }

  .word-list {
    grid-template-columns: 1fr;
  }

  .speaker-button {
    width: 96px;
    height: 96px;
  }

  .game-actions,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .game-actions .next-button,
  .game-actions .utility-button,
  .result-actions .next-button,
  .result-actions .utility-button {
    width: 100%;
  }

  .footer {
    flex-direction: column;
  }
}
