.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%) scale(0.9);
  width: min(700px, 95vw); 
  max-height: 85vh;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 60;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.panel-fullscreen { width: 96vw; height: 92vh; max-height: 92vh; }

/* Sur PC, on décale le panneau à gauche */
@media (min-width: 900px) {
  .panel { left: 20px; transform: translate(0, -50%) scale(0.9); }
  .panel.active { transform: translate(0, -50%) scale(1); }
  .panel-fullscreen { left: 2vw; transform: translate(0, -50%) scale(1); }
}

/* EN-TÊTE COLLANT */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #d9c9a3;
  border-bottom: 2px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.panel-header h2 { 
  font-size: 18px; 
  display: flex; 
  align-items: center; 
  color: var(--text); 
  flex: 1; /* Prend l'espace, mais laisse la place au bouton */
  margin-right: 10px;
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; /* Si c'est trop long, met des ... */
}

.panel-close {
  background: #BDAA6A; 
  color: #6d482b; 
  width: 32px; 
  height: 32px;
  min-width: 32px; /* NE SE COMPRESSE PAS */
  min-height: 32px;
  border-radius: 50%;
  border: 2px solid #6d482b; 
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0; /* Empêche la croix d'être écrasée */
}
.panel-close:hover { transform: scale(1.1); background: #a67c52; color: white;}

.panel-body {
  flex: 1;
  overflow-y: auto; 
  padding: 10px; 
  display: flex;
  flex-direction: column;
  gap: 8px; 
}

.panel-body img {
  max-height: 60px; 
  width: auto;
}

/* --- STATS ROW --- */
.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.4);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}
.stat-row span { flex: 1; color: var(--text); }
.stat-row img { width: 24px; height: 24px; object-fit: contain; } 

.stat-value {
  font-weight: bold;
  color: white;
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
}

/* --- ÉQUIPE --- */
.member {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(255,255,255,0.4);
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  font-size: 13px;
}
.member div { display: flex; gap: 4px;}
.member.me { opacity: 0.8; background: rgba(46, 125, 50, 0.2); }
.badge { background: var(--accent); color: white; font-size: 12px; padding: 2px 8px; border-radius: 4px; }
.mp-btn {
  background: var(--accent);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  cursor: pointer;
}
.mp-btn:hover { background: var(--accent-dark); }

/* --- CARTE DE L'ÎLE (CORRIGÉE POUR LE SCROLL ET LES TUILES CARRÉES) --- */
.map-body {
  background: #1a7a8c; /* Océan */
  padding: 0;
  display: flex;
  flex-direction: column;
}

.map-scroll-wrapper {
  width: 100%;
  height: 100%;
  overflow: auto; /* Permet de scroller */
  background: #1a7a8c; 
}

.map-grid-container {
  display: grid;
  /* 20 colonnes de 60px = 1200px de large */
  grid-template-columns: repeat(20, 60px); 
  grid-auto-rows: 60px; 
  gap: 0; 
  padding: 40px; /* Marge autour de l'île */
  
  /* Très important : centre la grille si elle est plus petite que l'écran, sinon permet le scroll */
  margin: auto; 
  width: max-content; 
}

.map-ocean {
  width: 60px;
  height: 60px;
  background: #1a7a8c; 
}

.map-tile {
  width: 60px; 
  height: 60px; 
  background: #BDAA6A; /* Sable */
  padding: 2px; /* Petit espace pour faire le chemin de sable */
  box-sizing: border-box;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), z-index 0s;
  border-radius: 4px; 
  transform: translateZ(0); 
  overflow: hidden;
}

.map-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover; 
  display: block; 
  border-radius: inherit; 
  pointer-events: none;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.map-tile:hover { filter: brightness(1.1); z-index: 10; }
.map-tile.zoomed {
  transform: scale(2.2); 
  z-index: 999; 
  filter: brightness(1.1) drop-shadow(0px 15px 25px rgba(0,0,0,0.8));
  border-radius: 8px !important; 
  padding: 0; 
}
.map-tile.revealed {
  filter: brightness(0.9) contrast(1.1); 
  cursor: default;
  border-radius: 4px;
}

/* --- PALMARÈS --- */
#panel-hunting { width: min(500px, 95vw); }
.hunting-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.4);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  font-size: 13px;
}
.hunting-item img { width: 24px; height: 24px; object-fit: contain; }