html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  touch-action: none;
  background-color: #054017;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Grille 12x12 adaptée au ratio des cartes */
#tapis {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(12, 1fr);
  gap: 6px; /* Espace réduit pour donner plus de place aux cartes */
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  padding: 50px 10px 10px 10px; /* Espace réservé en haut pour le sélecteur */
}

/* Slots : Force le ratio 2:3 tout en bornant la taille maximale */
.slot {
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  max-width: 90px; /* Limite la largeur max pour éviter les cartes géantes */
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0 auto; /* Centre le slot dans sa cellule de grille */
}
/* Cartes : Remplissent l'emplacement à 100% */
.card {
  width: 100%;
  height: 100%;
  border-radius: 5px;
  position: absolute;
  user-select: none;
  touch-action: none;
  cursor: grab;
  
  /* 'Contain' s'assure que toute l'image est visible, 'Cover' peut recadrer. Contain est plus lisible ici. */
  background-size: contain; 
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

.card:active {
  cursor: grabbing;
}

.card.selected {
  outline: 3px solid #FFD700;
  box-shadow: 0 0 10px #FFD700;
  transform: translateY(-4px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 999 !important;
}

/* Sélecteur de jeu */
#game-selector-container {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
}

#game-select {
  background: #222;
  color: #fff;
  border: 1px solid #555;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Alerte mode portrait */
#orientation-warning {
  display: none;
  position: fixed;
  inset: 0;
  background: #111111;
  color: #ffffff;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 1.2rem;
}

@media (orientation: portrait) {
  #orientation-warning { display: flex; }
  #tapis { display: none; }
}

/* Toast pop-up */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 20px));
  background: #008000;
  color: white;
  padding: 14px 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.toast.hidden {
  display: none;
}

/* Modale / Dialog */
.custom-modal {
  border: none;
  border-radius: 8px;
  padding: 0;
  width: 90%;
  max-width: 450px; 
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
}

.custom-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-header {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  border-bottom: 1px solid #eee;
  color: white;
}

.modal-header i {
  font-size: 1.3rem;
}

.modal-body {
  padding: 20px;
  color: #000080;
  font-size: 1.1rem;
  line-height: 1.4;
}

.modal-footer {
  padding: 10px 20px;
  text-align: right;
  border-top: 1px solid #eee;
  background-color: #e6e6e6;
}

.btn-modal {
  padding: 8px 20px;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  color: white;
}

.modal-blue .modal-header, .modal-blue .btn-modal { background-color: #000080; }
.modal-blue .btn-modal:active { background-color: #27ae60; }

.modal-orange .modal-header, .modal-orange .btn-modal { background-color: #ffad33; }
.modal-orange .btn-modal:active { background-color: #d35400; }

.modal-red .modal-header, .modal-red .btn-modal { background-color: red; }
.modal-red .btn-modal:active { background-color: #c0392b; }