/* Palette inspirée du logo : bleu, jaune, vert et noir. */
:root {
  --blue-color: #2f80c9;
  --yellow-color: #fbd83b;
  --green-color: #43ad67;
  --dark-color: #171717;
}

/* Applique un calcul uniforme des dimensions à tous les éléments. */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  overflow: hidden;
}

/* Mise en page générale et centrage du jeu. */
body {
  background-color: var(--blue-color);
  color: var(--dark-color);
  font-family: ui-monospace, "Courier New", monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  margin: 0;
  padding: 6px 12px;
  text-align: center;
}

h1 {
  color: var(--yellow-color);
  font-size: 28px;
  line-height: 1.1;
  margin: 0;
  letter-spacing: 0.5rem;
  text-shadow: 2px 2px 0 var(--dark-color);
  text-transform: uppercase;
}

body > p {
  font-size: 14px;
  margin: 4px 0 6px;
}

h2,
h3 {
  letter-spacing: 0.2rem;
}

/* Sélecteurs permettant de choisir une catégorie et un niveau. */
.game-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: center;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.setting-control label {
  font-weight: bold;
}

.setting-control select {
  background-color: var(--yellow-color);
  border: 2px solid var(--dark-color);
  border-radius: 5px;
  color: var(--dark-color);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  min-height: 34px;
  padding: 4px 8px;
}

/* Zone contenant le dessin du pendu et le mot à découvrir. */
.game-container {
  flex: 1 1 auto;
  min-height: 170px;
  max-height: 250px;
  padding: 8px 30px;
  position: relative;
  margin: 2px auto;
  height: 40dvh;
  width: min(450px, 100%);
}

/* Apparence des lignes constituant la potence et le personnage. */
.figure-container {
  display: block;
  height: 100%;
  max-height: 210px;
  fill: transparent;
  stroke: var(--dark-color);
  stroke-width: 4px;
  stroke-linecap: round;
}

/* Les parties du personnage sont révélées après chaque erreur. */
.figure-part {
  display: none;
}

/* Compteur d'essais placé à droite du dessin. */
.attempts-container {
  color: var(--yellow-color);
  position: absolute;
  top: 10px;
  right: 20px;
  display: flex;
  flex-direction: column;
  text-align: right;
}

/* Nombre de mauvaises propositions encore autorisées. */
.attempts {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
  white-space: nowrap;
}

/* Mot à découvrir, centré sous le dessin. */
.word {
  display: flex;
  justify-content: center;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
}

/* Emplacement visuel réservé à chaque lettre du mot. */
.letter {
  border-bottom: 3px solid var(--yellow-color);
  display: inline-flex;
  font-size: 30px;
  align-items: center;
  justify-content: center;
  margin: 0 3px;
  height: 50px;
  width: 20px;
}

/* Clavier visuel permettant de jouer avec la souris ou au toucher. */
.keyboard {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(13, minmax(30px, 36px));
  justify-content: center;
  margin-top: 5px;
  width: 100%;
}

.keyboard-key {
  background-color: var(--dark-color);
  border: 2px solid var(--yellow-color);
  border-radius: 5px;
  color: var(--yellow-color);
  cursor: pointer;
  font-family: inherit;
  font-size: 17px;
  height: 34px;
  padding: 0;
}

.keyboard-key:hover:not(:disabled),
.keyboard-key:focus-visible {
  background-color: var(--yellow-color);
  color: var(--dark-color);
}

.keyboard-key.correct {
  background-color: var(--green-color);
  border-color: var(--dark-color);
  color: var(--dark-color);
}

.keyboard-key.incorrect {
  background-color: var(--yellow-color);
  color: var(--dark-color);
}

.keyboard-key:disabled {
  cursor: default;
  opacity: 0.75;
}

/* Zone du bouton permettant de révéler une lettre cachée. */
.game-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.hint-button {
  background-color: var(--green-color);
  border: 2px solid var(--dark-color);
  border-radius: 5px;
  color: var(--dark-color);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  min-height: 38px;
  padding: 6px 18px;
}

.hint-button:hover:not(:disabled),
.hint-button:focus-visible {
  background-color: var(--yellow-color);
}

.hint-button:disabled {
  cursor: default;
  opacity: 0.65;
}

/* Arrière-plan de la fenêtre de fin de partie. */
.popup-container {
  background-color: rgba(0, 0, 0, 0.3);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

/* Contenu de la fenêtre de victoire ou de défaite. */
.popup {
  background-color: var(--yellow-color);
  border-radius: 5px;
  box-shadow: 0 15px 10px 3px rgba(0, 0, 0, 0.1);
  max-width: 90%;
  padding: 20px;
  text-align: center;
}

/* Définition pédagogique affichée après la victoire ou la défaite. */
.word-definition {
  line-height: 1.5;
  margin: 12px auto 0;
  max-width: 430px;
}

.popup button {
  cursor: pointer;
  background-color: var(--dark-color);
  color: var(--yellow-color);
  border: 0;
  margin-top: 20px;
  padding: 12px 20px;
  font-size: 16px;
  font-family: inherit;
  border-radius: 5px;
}

.popup button:active {
  transform: scale(0.98);
}

.popup button:focus {
  outline: none;
}

/* Notification temporaire affichée en bas de l'écran. */
.notification-container {
  background-color: var(--green-color);
  color: var(--dark-color);
  border-radius: 10px 10px 0 0;
  padding: 15px 20px;
  position: absolute;
  bottom: -60px;
  transition: transform 0.3s ease-in-out;
}

.notification-container.show {
  transform: translateY(-60px);
}

.notification-container p {
  margin: 0;
}

button,
select {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Ajustements destinés aux téléphones et aux petits écrans. */
@media (max-width: 480px) {
  body {
    justify-content: center;
    padding: 5px 8px;
    text-align: center;
  }

  h1 {
    font-size: 1.45rem;
    letter-spacing: 0.25rem;
  }

  body > p {
    font-size: 12px;
    margin: 3px 0 5px;
  }

  h2,
  h3 {
    letter-spacing: 0.08rem;
  }

  .game-container {
    flex: 0 1 205px;
    min-height: 150px;
    height: 29dvh;
    padding: 4px 10px;
  }

  .figure-container {
    height: 100%;
    width: 140px;
  }

  .attempts-container {
    right: 8px;
    top: 10px;
  }

  .attempts {
    font-size: 14px;
  }

  .word {
    bottom: 1px;
  }

  .letter {
    font-size: 24px;
    height: 42px;
    margin: 0 2px;
    width: 16px;
  }

  .keyboard {
    gap: 3px;
    grid-template-columns: repeat(9, minmax(28px, 34px));
    margin-top: 4px;
  }

  .keyboard-key {
    font-size: 15px;
    height: 32px;
  }

  .hint-button {
    font-size: 14px;
    min-height: 34px;
    padding: 4px 14px;
  }

  .game-settings {
    flex-wrap: nowrap;
    gap: 5px;
    width: 100%;
  }

  .setting-control {
    flex: 1;
    flex-direction: column;
    font-size: 14px;
    gap: 2px;
    min-width: 0;
  }

  .setting-control select {
    font-size: 13px;
    min-height: 32px;
    max-width: 150px;
    width: 100%;
  }

  .popup {
    padding: 18px 14px;
    width: min(360px, 92%);
  }

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

  .notification-container {
    left: 10px;
    right: 10px;
  }
}

@media (max-height: 520px) and (min-width: 481px) {
  h1 {
    font-size: 22px;
  }

  body > p {
    margin: 1px 0 3px;
  }

  .game-container {
    min-height: 145px;
    max-height: 190px;
  }

  .figure-container {
    max-height: 165px;
  }

  .keyboard-key {
    height: 30px;
  }
}
