* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f4f4f9;
  font-family: cursive;
}

.container {
  padding: 10px;
  margin: 20px auto;
  max-width: 1000px;
  width: 90%;
  background-color: #fff;
  border-radius: 15px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

hr {
  border: 1px solid #eee;
}

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #1f7bb6, #27aae1e8);
  color: white;
  border-radius: 10px 10px 0 0;
}

.game-info .category {
  flex: 1;
  text-align: right;
}

.game-info .category span {
  text-transform: capitalize;
  color: #e91e63;
  font-weight: bold;
}

.game-info .game-name {
  color: white;
  font-weight: bold;
  font-size: 24px;
}

.hangman-draw {
  flex: 1;
  background-color: #f8f8f8;
  padding: 20px;
  height: 324px;
  border: 1px solid #ccc;
  border-radius: 5px;
  margin: 20px auto;
}

.hangman-draw .the-draw {
  width: 60px;
  height: 280px;
  border-bottom: 4px solid #222;
  position: relative;
  margin: auto;
  left: -55px;
  display: none;
}

.hangman-draw .the-stand::before {
  content: "";
  position: absolute;
  width: 4px;
  background-color: #222;
  height: 100%;
  left: 50%;
  margin-left: -2px;
  display: none;
}

.hangman-draw .the-hang {
  display: none;
}
.hangman-draw .the-hang::before {
  content: "";
  position: absolute;
  height: 4px;
  background-color: #222;
  width: 100px;
  left: 30px;
  top: 15px;
}

.hangman-draw .the-hang::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 30px;
  background-color: #222;
  left: 130px;
  top: 15px;
}

.hangman-draw .the-rope {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  left: 95px;
  top: 45px;
  border: 4px dashed #222;
  display: none;
}

.hangman-draw .the-man .head {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 4px solid #222;
  left: 105px;
  top: 55px;
  display: none;
}

.hangman-draw .the-man .body {
  position: absolute;
  background-color: #222;
  width: 4px;
  height: 110px;
  top: 102px;
  left: 130px;
  display: none;
}

.hangman-draw .the-man .hands {
  display: none;
}

.hangman-draw .the-man .hands::before {
  content: "";
  position: absolute;
  width: 50px;
  height: 4px;
  background-color: #222;
  left: 85px;
  top: 130px;
  transform: rotate(30deg);
}

.hangman-draw .the-man .hands::after {
  content: "";
  position: absolute;
  width: 50px;
  height: 4px;
  background-color: #222;
  top: 130px;
  left: 130px;
  transform: rotate(-30deg);
}

.hangman-draw .the-man .legs {
  display: none;
}
.hangman-draw .the-man .legs::before {
  content: "";
  position: absolute;
  width: 50px;
  height: 4px;
  background-color: #222;
  left: 85px;
  top: 220px;
  transform: rotate(-30deg);
}

.hangman-draw .the-man .legs::after {
  content: "";
  position: absolute;
  width: 50px;
  height: 4px;
  background-color: #222;
  top: 220px;
  left: 130px;
  transform: rotate(30deg);
}

.hangman-draw.wrong-1 .the-draw {
  display: block;
}
.hangman-draw.wrong-2 .the-stand::before {
  display: block;
}
.hangman-draw.wrong-3 .the-hang {
  display: block;
}
.hangman-draw.wrong-4 .the-rope {
  display: block;
}
.hangman-draw.wrong-5 .head {
  display: block;
}
.hangman-draw.wrong-6 .body {
  display: block;
}
.hangman-draw.wrong-7 .hands {
  display: block;
}
.hangman-draw.wrong-8 .legs {
  display: block;
}

.letters {
  flex: 1;
  text-align: center;
}

.letters.finished {
  pointer-events: none;
}

.letters .letter-box {
  width: 50px;
  height: 50px;
  display: inline-block;
  background: linear-gradient(135deg, #1f7bb6, #27aae1e8);
  color: white;
  font-size: 28px;
  margin-right: 12px;
  margin-bottom: 12px;
  line-height: 55px;
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  border-radius: 10px;
  transition: background-color 0.3s, transform 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.letters .letter-box:hover {
  background-color: #1b79a1;
  background: linear-gradient(135deg, #27aae1e8, #1f7bb6);
  transform: scale(1.1);
}

.letters .letter-box:active {
  transform: scale(0.9);
}

.letters .letter-box.clicked {
  background-color: #222;
  opacity: 0.2;
  pointer-events: none;
}

.letter-guess {
  margin: 10px auto;
  background-color: #f8f8f8;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 104px;
}

.letter-guess span {
  width: 60px;
  height: 60px;
  font-size: 24px;
  margin-right: 10px;
  text-align: center;
  line-height: 60px;
  text-transform: uppercase;
  font-weight: bold;
  background-color: #fdfdfd;
  transition: 0.3s;
  border-radius: 5px;
  border: 2px solid #27aae1;
  border-bottom: 4px solid #27aae1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.letter-guess span.has-space {
  background: none;
  border: none;
  position: relative;
}

.letter-guess span.has-space::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 4px;
  background-color: #222;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 50%);
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  pointer-events: all;
}

.popup.bad,
.popup.good {
  background: linear-gradient(135deg, #1f7bb6, #27a9e1);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 60px 40px;
  width: 80%;
  max-width: 500px;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: bold;
  border: none;
  border-radius: 25px;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  animation: fadeIn 0.6s forwards ease-in-out;
  text-align: center;
}

.popup span.good {
  color: greenyellow;
  font-size: 40px;
}

.popup span.bad {
  color: red;
  font-size: 40px;
}

.popup span.text {
  font-size: 24px;
}

.popup.good span.word {
  color: greenyellow;
  font-weight: bold;
  font-size: 28px;
}

.popup.bad span.word {
  color: red;
  font-weight: bold;
  font-size: 28px;
}

.popup button {
  margin-top: 20px;
  border: none;
  background: white;
  padding: 15px 30px;
  font-size: 18px;
  color: #333;
  font-weight: bold;
  border-radius: 30px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.popup button:hover {
  background-color: #f1f1f1;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.3);
}

/* Fade-in Animation */
@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 1200px) {
  .container {
    padding: 10px;
  }

  .game-info .game-name {
    font-size: 20px;
  }

  .letters .letter-box {
    width: 45px;
    height: 45px;
    font-size: 24px;
  }

  .letter-guess span {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
}

@media (max-width: 900px) {
  .game-info {
    padding: 15px;
  }

  .letters .letter-box {
    width: 40px;
    height: 40px;
    font-size: 22px;
    margin-right: 8px;
    margin-bottom: 8px;
  }

  .letter-guess span {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .letter-guess span.has-space::before {
    width: 15px;
    height: 3px;
  }

  .popup {
    padding: 40px 20px;
  }

  .popup button {
    padding: 10px 20px;
    font-size: 16px;
  }
}

@media (max-width: 635px) {
  .game-info {
    flex-direction: column;
    align-items: center;
    padding: 10px;
  }

  .game-info .game-name {
    font-size: 30px;
  }

  .letters .letter-box {
    width: 35px;
    height: 35px;
    font-size: 18px;
    margin-right: 5px;
    margin-bottom: 5px;
  }

  .letter-guess {
    flex-wrap: wrap;
  }

  .letter-guess span {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .popup {
    width: 90%;
  }

  .popup span.text {
    font-size: 20px;
  }
}

@media (max-width: 435px) {
  .game-info {
    padding: 20px;
  }

  .game-info .game-name {
    font-size: 35px;
  }

  .game-info .category {
    font-size: 20px;
  }

  .row {
    flex-direction: column;
  }

  .hangman-draw {
    width: 100%;
    margin: 0;
  }

  .hangman-draw .the-draw {
    display: block;
    visibility: hidden;
  }

  .hangman-draw.wrong-1 .the-draw {
    visibility: visible;
  }
}
