/* Si vous n'avez pas d'en-tête, plein écran complet : */
#map-viewport {
    width: 100%;
    height: 100%;
    background: #20242c;
    cursor: grab;
    touch-action: none;
    overflow: hidden;
    position: relative;
}

#map-container {
    position: absolute;
    width: 100%;
    height: 100%;
    touch-action: none;
    will-change: transform;
}

/* Hidden hexagons optimization */
.hidden-hexagon {
    visibility: hidden;
    pointer-events: none;
}

@media (max-width: 768px) {
    #map-viewport {
        height: 100vh;
        width: 100vw;
    }
    
    .hexagon-container {
        width: 80px;
        height: 69.3px;
    }
    
    .hexagon span {
        font-size: 12px;
    }
}

.hexagon-container {
    position: absolute;
    width: 100px;
    height: 86.6px; /* 100 * sqrt(3)/2 */
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s ease-in-out;
    pointer-events: auto;
    /* Add GPU acceleration for better performance */
    transform: translateZ(0);
    backface-visibility: hidden;
    /* Add black bold border */
    border: 2px solid #000;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.hexagon {
    width: 100%;
    height: 100%;
    background: #fbd8a4;
    clip-path: inherit;
    transform: scale(0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    /* Add GPU acceleration for better performance */
    transform: translateZ(0);
    backface-visibility: hidden;
    /* Add inner border for better definition */
    border: 1px solid rgba(0, 0, 0, 0.5);
}

.hexagon span {
    pointer-events: none;
    color: #000;
    font-weight: bold;
    font-size: 14px;
}

.hexagon-container:hover {
    filter: brightness(1.2);
    /* Enhance border on hover */
    border: 3px solid #000;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
}

.hexagon-owned {
    background-color: #9aff9a;
    color: #58ff27;
    border-color: #006600;
}

.hexagon-neutral {
    background-color: #fbd8a4;
    color: #8b6b4a;
    border-color: #d4b483;
}

.hexagon-enemy {
    background-color: #e44848;
    color: #ff2020;
    border-color: #990000;
}

.hexagon-ally {
    background-color: #9acdff;
    color: #58b3ff;
    border-color: #0066cc;
}

.hexagon-empty {
    background-color: #FFFFFF;
    color: #bfbfbf;
    border-color: #666666;
}

.hexagon-fog {
    background-color: #989898;
    color: #676767;
    border-color: #333333;
}

/* Map Styles */

/* Special Territories */
.hexagon-special {
  position: relative;
  border: 2px solid;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  animation: special-glow 2s ease-in-out infinite alternate;
}

.hexagon-level-3 {
  border-color: #3b82f6;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
}

.hexagon-level-4 {
  border-color: #fbbf24;
  background: linear-gradient(135deg, #d97706, #fbbf24);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
}

.hexagon-level-5 {
  border-color: #8b5cf6;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.8);
}

@keyframes special-glow {
  from {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  }
  to {
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
  }
}

/* Level Indicator */
.hexagon-level-indicator {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 10;
}

.level-badge {
  background: linear-gradient(135deg, #1f2937, #374151);
  color: #fbbf24;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid #fbbf24;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Enhanced Fog of War */
.hexagon-fog {
  background: linear-gradient(135deg, #1f2937, #374151);
  border: 1px solid #4b5563;
  opacity: 0.7;
  position: relative;
}

.hexagon-fog::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 2px,
    rgba(75, 85, 99, 0.3) 2px,
    rgba(75, 85, 99, 0.3) 4px
  );
  pointer-events: none;
}

/* Improved visibility for owned special territories */
.hexagon-special.hexagon-owned {
  border-color: #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
}

/* Hidden hexagons for viewport optimization */
.hidden-hexagon {
  display: none !important;
}

/* Smooth transitions */
.hexagon-container {
  transition: opacity 0.3s ease-in-out;
}

/* Statistics Panel Scrollbar */
.overflow-y-auto::-webkit-scrollbar {
  width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
  background: #1e293b;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Statistics Panel Animations */
.game-stats-panel.stats-updated {
  animation: stats-pulse 1s ease-in-out;
}

@keyframes stats-pulse {
  0% { 
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }
  70% { 
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
  100% { 
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* Smooth transitions for stat values */
.game-stats-panel [data-stats-target] {
  transition: color 0.3s ease-in-out;
}

.game-stats-panel.stats-updated [data-stats-target] {
  color: #60a5fa !important;
}
