:root {
  /* Colors */
  --primary-color: #1f2041;
  --secondary-color: #4b3f72;

  /* Fonts */
  --primary-font-family: "Poppins", serif;
  --secondary-font-family: "Jersey 15", serif;
  --primary-font-color: #fff;
  --secondary-font-color: #ffc857;
  --large-font-size: 5rem;
  --medium-font-size: 2.2rem;
  --small-font-size: 1.8rem;
}

body {
  display: grid;
  grid-template-rows: 20% 1fr auto;
  align-items: center;
  font-family: var(--primary-font-family);
  background-color: var(--primary-color);
}

.main-header {
  margin-top: 60px;
}

.game-title {
  margin-bottom: 4rem;
  text-align: center;
  font-family: var(--secondary-font-family);
  font-size: var(--large-font-size);
  color: var(--secondary-font-color);
}

.main-container {
  align-self: start;
}

.select-pet-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.section-subtitle {
  padding: 0 16px;
  text-align: center;
  font-size: var(--medium-font-size);
  color: #fff;
}

.pet-card-container {
  overflow: auto;
  max-height: 372px;
}

.pet-card-container::-webkit-scrollbar {
  width: 8px;
}

.pet-card-container::-webkit-scrollbar-track {
  background: #ffc7573b;
  border-radius: 12px;
}

.pet-card-container::-webkit-scrollbar-thumb {
  background: var(--secondary-font-color);
  border-radius: 12px;
}

@supports not selector(::-webkit-scrollbar) {
  .pet-card-container {
    scrollbar-color: var(--secondary-font-color) #ffc7573b;
  }
}

.pet-card {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap-reverse;
  gap: 1rem;
  margin: 1.4rem;
  border-radius: 12px;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  background-color: var(--secondary-color);
  cursor: pointer;
  padding: 2.4rem 1.6rem;

  & > img {
    width: 8rem;
  }
}

.pet-card:hover,
input[type="radio"]:checked + .pet-card {
  outline: 2px solid var(--secondary-font-color);
}

.select-pet-button {
  margin-top: 1.2rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--secondary-font-color);
  border-radius: 12px;
  font-size: var(--small-font-size);
  color: var(--secondary-font-color);
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.3s;

  &:hover {
    background-color: #ffc85738;
  }
}

.instructions {
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  cursor: pointer;
}

.instructions-dialog {
  display: flex;
  justify-content: center;
  position: fixed;
  padding: 40px;
  top: 0;
  left: 0;
  overflow: auto;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  width: 100%;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10;
}

.instructions-container {
  display: flex;
  flex-direction: column;
  max-width: 800px;

  & p:last-of-type {
    padding-bottom: 40px;
  }
}

.instructions-title {
  text-align: center;
}

.instructions-for-winning-list {
  margin-left: 20px;
}

.close-instructions-btn {
  align-self: center;
}

.close-instructions-btn {
  position: fixed;
  bottom: 20px;
}

.error-modal {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  border: none;
  background-color: rgb(0, 0, 0, 0.7);
}

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0 20px;
  border: 1px solid var(--secondary-font-color);
  border-radius: 12px;
  padding: 73px 54px;
  text-align: center;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  background-color: rgb(0, 0, 0, 0.8);
}

.close-error-btn,
.close-instructions-btn {
  padding: 4px 16px;
  border: none;
  border-radius: 12px;
  background-color: var(--secondary-font-color);
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.2s;

  &:hover {
    background-color: var(--primary-color);
    color: var(--secondary-font-color);
  }
}

.map-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.movement-buttons {
  display: grid;
  grid-template-rows: repeat(3, auto);
  grid-template-columns: repeat(3, auto);
  justify-content: center;
  gap: 10px;
  user-select: none;
}

.movement-btn {
  padding: 2px 24px;
  font-size: var(--medium-font-size);
  border: 1px solid var(--primary-font-color);
  border-radius: 20px;
  background-color: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.movement-btn--up {
  grid-column: 2 / 3;
}

.movement-btn--left {
  grid-area: 2 / 1 / 3 / 2;
}

.movement-btn--down {
  grid-area: 3 / 2 / 4 / 3;
}

.movement-btn--right {
  grid-area: 2 / 3 / 3 / 4;
}

.select-attack-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto 40px;
  width: 100%;
  max-width: 1200px;
}

.attack-buttons-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
  margin-top: 1.2rem;
  padding: 0 10px;
}

.attack-button {
  padding: 1rem 1.6rem;
  border: none;
  border-radius: 12px;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  background-color: var(--secondary-color);
  cursor: pointer;

  &:hover {
    outline: 2px solid var(--secondary-font-color);
  }
}

.disabled {
  cursor: no-drop;
  opacity: 0.4;

  &:hover {
    outline: none;
  }
}

.round-number {
  margin-top: 2rem;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
}

.combat-result {
  color: var(--secondary-font-color);
  font-size: var(--small-font-size);
  font-weight: bold;
}

.player-info-container {
  display: flex;
  justify-content: space-evenly;
  margin-top: 2.4rem;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  width: 100%;
}

.player-info {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.mokepon-image {
  width: 80%;
  max-width: 200px;
}

.pet-lives {
  text-align: center;
}

.pet-name {
  text-align: center;
  font-weight: bold;
}

.attack-messages-section {
  margin-top: 8px;
  text-align: center;
}

.result-modal {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  border: none;
  background-color: rgb(0, 0, 0, 0.7);
}

.game-result-container {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  margin: 0 20px;
  gap: 12px;
  border: 1px solid var(--secondary-font-color);
  border-radius: 12px;
  padding: 73px 54px;
  text-align: center;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
  background-color: rgb(0, 0, 0, 0.8);
}

.restart-button {
  padding: 4px 16px;
  border: none;
  border-radius: 12px;
  background-color: var(--secondary-font-color);
  color: var(--primary-color);
  cursor: pointer;

  &:hover {
    background-color: var(--primary-color);
    color: var(--secondary-font-color);
  }
}

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.github-icon {
  width: 36px;
}

.footer-text {
  text-align: center;
  margin: 2rem 0;
  font-size: var(--small-font-size);
  color: var(--primary-font-color);
}

.footer-link {
  color: var(--secondary-font-color);
}

.hidden {
  display: none;
}

@media (width >= 440px) {
  .game-title::after {
    content: "🔥💧🌱";
  }
}

@media (width >= 800px) {
  .pet-card-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    width: inherit;
    max-width: 1024px;
  }

  .mokepon-image {
    max-width: 224px;
  }
}

@media (width >= 1100px) {
  .select-pet-section {
    width: 100%;
  }

  .pet-card-container {
    gap: 12px;
    max-height: 40rem;
  }

  .pet-card {
    flex-direction: column-reverse;
    gap: 1.2rem;
    padding: 3.2rem;
    width: 26rem;
    height: 30rem;

    & > img {
      width: initial;
    }
  }

  .player-info {
    flex-direction: row-reverse;
    gap: 20px;

    &:last-child {
      flex-direction: row;
    }
  }

  .player-stats,
  .enemy-stats {
    position: relative;
  }

  .attack-messages-section {
    position: absolute;
    width: 100%;
  }

  .mokepon-image {
    max-width: 300px;
  }
}

@media (height >= 840px) {
  .pet-card-container {
    max-height: 51.2rem;
  }
}

/* Improvements for touch controls */
@media (hover: none) and (pointer: coarse) {
  .movement-buttons {
    gap: 15px;
    margin-bottom: 20px;
  }

  .movement-btn {
    padding: 12px 30px;
    font-size: 2.5rem;
    touch-action: manipulation;

    & img {
      width: 28px;
    }
  }
}
