/* ==========================================
   MODAL DES JEUX — v2.1
   · Site visible (flou léger) sur les côtés
   · Taille adaptative sm / md / lg
   ========================================== */

/* ── Wrapper principal ── */
.game-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-sizing: border-box;
  /* Marges horizontales généreuses → site visible sur les côtés */
  padding: 20px 10vw;
}

.game-modal.active {
  display: flex;
  opacity: 1;
}

/* ── Overlay : flou doux, site LISIBLE derrière ── */
.game-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 20, 0.30);
  backdrop-filter: blur(4px) saturate(0.8) brightness(0.88);
  -webkit-backdrop-filter: blur(4px) saturate(0.8) brightness(0.88);
  transition: backdrop-filter 0.3s ease, background 0.3s ease;
}

/* ── Panneau flottant ── */
.game-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 40px);
  max-width: 900px;
  margin: auto;
  background: #111827;
  border-radius: 18px;
  box-shadow:
    0 0 0 1px rgba(99, 102, 241, 0.3),
    0 8px 40px rgba(0, 0, 0, 0.65),
    0 24px 80px rgba(0, 0, 0, 0.45);
  border: 1.5px solid rgba(99, 102, 241, 0.4);
  overflow: hidden;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.32s cubic-bezier(0.34, 1.45, 0.64, 1) both;
  transform-origin: center center;
}

/* ── Tailles adaptatives ── */

/* Interface de sélection (2 cartes) */
.game-modal-content.modal-size-sm {
  max-width: 700px;
  max-height: 560px;
}

/* Écran d'attente / config 4 joueurs */
.game-modal-content.modal-size-md {
  max-width: 880px;
  max-height: 700px;
}

/*
 * Partie en cours : plateau (689px) + chat (260px) + gaps (~40px) = ~990px min.
 * min(1080px, 82vw) → laisse ~9vw de site visible de chaque côté.
 */
.game-modal-content.modal-size-lg {
  max-width: min(1080px, 82vw);
  max-height: calc(100vh - 40px);
}

/* Réduire le padding latéral pour lg afin d'avoir plus de place pour le jeu */
.game-modal:has(.modal-size-lg) {
  padding: 20px 6vw;
}

/* ── Animation d'entrée ── */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.93) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Bouton fermer ── */
.game-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: #cbd5e1;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.2s, border-color 0.2s, transform 0.25s, color 0.2s;
}
.game-modal-close:hover {
  background: rgba(239, 68, 68, 0.75);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fff;
  transform: rotate(90deg) scale(1.1);
}

/* ── Conteneur iframe ── */
#gameModalContainer {
  width: 100%;
  height: 100%;
  flex: 1;
  overflow: hidden;
  background: transparent;
  min-height: 0;
}
#gameModalContainer iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Indicateur jeu minimisé ── */
#minimized-game-indicator {
  display: none;
  cursor: pointer;
}

/* ── Vignette douce sur les bords ── */
.game-modal::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: radial-gradient(
    ellipse 78% 83% at 50% 50%,
    transparent 52%,
    rgba(5, 8, 20, 0.28) 100%
  );
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .game-modal-content.modal-size-lg {
    max-width: 86vw;
  }
  .game-modal:has(.modal-size-lg) {
    padding: 16px 7vw;
  }
}

@media (max-width: 900px) {
  .game-modal { padding: 12px 4vw; }
  .game-modal-content,
  .game-modal-content.modal-size-sm,
  .game-modal-content.modal-size-md,
  .game-modal-content.modal-size-lg {
    max-width: 94vw;
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }
}

@media (max-width: 600px) {
  .game-modal { padding: 0; }
  .game-modal-content,
  .game-modal-content.modal-size-sm,
  .game-modal-content.modal-size-md,
  .game-modal-content.modal-size-lg {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  .game-modal-close {
    top: 10px; right: 10px;
    width: 34px; height: 34px; font-size: 18px;
  }
}
