:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #18212f;
  --muted: #657184;
  --line: #d8dde7;
  --accent: #167a74;
  --accent-strong: #0d5f5a;
  --warm: #d98032;
  --danger: #b23b3b;
  --success: #278653;
  --disabled: #e6e9ef;
  --shadow: 0 20px 48px rgba(24, 33, 47, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 122, 116, 0.12), transparent 35%),
    linear-gradient(315deg, rgba(217, 128, 50, 0.14), transparent 38%),
    var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
select {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.game-surface {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(216, 221, 231, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
  letter-spacing: 0;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.controls label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

select,
button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

select {
  padding: 0 38px 0 12px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 700;
}

button {
  cursor: pointer;
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  transform: translateY(-1px);
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(217, 128, 50, 0.38);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  color: #8a94a3;
  background: var(--disabled);
  border-color: var(--disabled);
  transform: none;
}

#new-game {
  padding: 0 18px;
}

.play-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 0;
}

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

.gallows-panel {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  background: #eef7f4;
  border-right: 1px solid var(--line);
}

.gallows {
  width: min(100%, 340px);
  aspect-ratio: 1;
}

.stand,
.body-part {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stand {
  stroke: #46515f;
  stroke-width: 10;
}

.body-part {
  opacity: 0;
  stroke: var(--danger);
  stroke-width: 9;
  transform-origin: center;
  transition: opacity 180ms ease;
}

.body-part.is-visible {
  opacity: 1;
}

.tries {
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

#remaining-tries {
  color: var(--warm);
  font-size: 1.35rem;
}

.game-panel {
  display: grid;
  align-content: center;
  gap: 26px;
  min-height: 520px;
}

.status {
  min-height: 40px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.status.is-win {
  color: var(--success);
}

.status.is-loss {
  color: var(--danger);
}

.clue-card {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 12px 14px;
  color: var(--ink);
  background: #eef7f4;
  border: 1px solid #b8d8d2;
  border-radius: 8px;
}

.clue-label {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.clue-text {
  color: var(--ink);
  font-weight: 750;
  line-height: 1.4;
}

.masked-word {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: clamp(2rem, 7vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  overflow-wrap: anywhere;
  text-align: center;
}

.incorrect-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 10px 12px;
  background: #fff8ef;
  border: 1px solid #f1d7b7;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.incorrect-list {
  color: var(--danger);
  text-align: right;
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(13, minmax(34px, 1fr));
  gap: 8px;
}

.key {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.key:hover:not(:disabled) {
  color: #ffffff;
}

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

.key.is-incorrect {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 560px);
    padding: 10px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .controls {
    width: 100%;
    justify-content: stretch;
  }

  .controls label {
    width: 100%;
  }

  select,
  #new-game {
    flex: 1;
  }

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

  .gallows-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px;
  }

  .gallows {
    width: min(78vw, 260px);
  }

  .game-panel {
    min-height: 0;
    padding: 18px;
    gap: 18px;
  }

  .masked-word {
    min-height: 68px;
  }

  .keyboard {
    grid-template-columns: repeat(7, minmax(36px, 1fr));
  }
}
