/* Overlay for deck selection (towers and bonuses). Covers the full screen
   before the game starts. Responsive design ensures it scales on
   mobile and desktop. */

#deckOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
}

#deckOverlay.hidden {
  display: none;
}

#deckContent {
  background: rgba(10, 10, 30, 0.85);
  border: 2px solid #00bfff;
  border-radius: 12px;
  padding: 16px;
  /* Ajoute un espace au bas du contenu pour que le bouton sticky ne
     chevauche pas la grille lorsqu'on scrolle. */
  padding-bottom: 60px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-sizing: border-box;
}

#deckTitle {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 12px;
}

#deckRemaining {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  margin-bottom: 10px;
}

.deckGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.deckItem {
  width: 80px;
  height: 100px;
  border: 2px solid #555;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

.deckItem img {
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
  pointer-events: none;
}

@media (max-width: 520px) {
  #deckContent {
    padding: 12px;
    padding-bottom: 64px;
    max-width: calc(100vw - 16px);
    max-height: calc(100svh - 16px);
  }

  #deckTitle {
    font-size: 1.1rem;
  }

  #deckRemaining {
    flex-direction: column;
    gap: 6px;
    align-items: center;
    font-size: 0.95rem;
  }

  .deckGrid {
    gap: 6px;
  }

  .deckItem {
    width: clamp(64px, 18vw, 78px);
    height: clamp(86px, 24vw, 102px);
    padding: 4px;
  }

  .deckItem img {
    max-width: clamp(44px, 14vw, 62px);
    max-height: clamp(44px, 14vw, 62px);
  }

  .deckItem .deckName {
    font-size: 0.66rem;
  }
}

.deckItem .deckName {
  font-size: 0.7rem;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bonus: autoriser un retour à la ligne pour éviter le texte superposé */
.deckItem.bonusItem .deckName {
  white-space: normal;
  line-height: 1.1;
  max-height: 2.2em; /* ~2 lignes */
}

.deckItem .deckCost {
  font-size: 0.6rem;
  color: #aaa;
}

.deckItem.selected {
  border-color: #00ff7f;
  box-shadow: 0 0 6px #00ff7f;
}

.deckItem.disabled {
  opacity: 0.3;
  pointer-events: none;
}

#startBtn {
  /* Le bouton de démarrage reste visible en bas de l'overlay même
     lorsque la liste est longue. Le positionnement sticky le maintient
     collé au bas du conteneur #deckContent sans empiéter sur le
     contenu scrollable. */
  position: sticky;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  margin-top: 12px;
  padding: 8px 20px;
  background: #007bff;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  display: none;
}

#startBtn:disabled {
  opacity: 0.5;
  cursor: default;
}