.hangman-page {
  max-width: 760px;
  margin-inline: auto;
  padding-block: 4px 38px;
}

.hangman-intro {
  margin-bottom: 7px;
}

.hangman-intro h1 {
  margin-bottom: 3px;
  font-size: clamp(32px, 8vw, 42px);
  letter-spacing: -2px;
  line-height: 1.1;
}

.hangman-intro p,
.hangman-how-to-play p {
  margin-bottom: 0;
  color: #6f6b7d;
  font-size: 14px;
  line-height: 1.5;
}

.hangman-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 30px #29234a0a;
}

.hangman-drawing {
  display: block;
  width: min(100%, 150px);
  height: 100px;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.hangman-piece {
  display: none;
}

.hangman-piece.is-visible {
  display: initial;
}

.guess-count,
.hangman-status {
  width: min(100%, 380px);
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.guess-count {
  color: #6f6b7d;
  font-variant-numeric: tabular-nums;
}

.word-display {
  width: min(100%, 380px);
  min-height: 34px;
  display: flex;
  justify-content: center;
  gap: clamp(4px, 2vw, 10px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-letter {
  min-width: 20px;
  display: grid;
  flex: 0 1 36px;
  place-items: center;
  border-bottom: 3px solid #d8d1f4;
  color: var(--purple-dark);
  font-family: "Manrope", sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.letter-controls {
  width: min(100%, 380px);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.letter-button {
  min-width: 0;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #e6e1f4;
  border-radius: 9px;
  background: #f7f5ff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.letter-button.is-guessed {
  border-color: #d7d2e8;
  background: #eeecf5;
  color: var(--ink);
}

.letter-button.is-keyboard-active {
  outline: 3px solid #a391ff;
  outline-offset: 1px;
}

.letter-button:focus-visible,
.restart-button:focus-visible {
  outline: 3px solid #a391ff;
  outline-offset: 2px;
}

.letter-button:disabled {
  cursor: default;
}

.hangman-status {
  min-height: 18px;
}

.restart-button {
  min-width: 160px;
  min-height: 44px;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.hangman-how-to-play {
  margin-top: 20px;
}

.hangman-how-to-play h2 {
  margin-bottom: 6px;
  font-size: 20px;
  letter-spacing: -0.5px;
}

.related-games {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}

.related-games a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--purple-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (min-width: 600px) {
  .hangman-page {
    padding-block: 8px 48px;
  }

  .hangman-panel {
    gap: 7px;
    padding: 12px;
  }

  .hangman-drawing {
    height: 110px;
  }

  .letter-controls {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 6px;
  }

  .letter-button {
    min-height: 44px;
  }
}

@media (max-height: 620px) {
  .hangman-page {
    padding-top: 1px;
  }

  .hangman-intro {
    margin-bottom: 4px;
  }

  .hangman-intro h1 {
    font-size: 30px;
  }

  .hangman-panel {
    gap: 2px;
    padding: 3px 5px;
  }

  .hangman-drawing {
    height: 68px;
  }

  .word-display {
    min-height: 28px;
  }

  .word-letter {
    font-size: 19px;
  }

  .letter-controls {
    gap: 2px;
  }

  .letter-button {
    min-height: 42px;
  }

  .hangman-status {
    min-height: 17px;
    font-size: 12px;
  }

  .restart-button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .letter-button {
    transition: none;
  }
}
