html, body {
  max-width: 100vw;
  width: 100vw;
  overflow-x: hidden !important; /* Solo horizontal bloqueado */
  overflow-y: auto !important; /* PERMITIR SCROLL VERTICAL */
  position: relative;
}

body {
  font-family: 'Arial', sans-serif;
  margin: 0;
  padding: 0;
  height: auto; /* QUITAR ALTURA FIJA */
  box-sizing: border-box;
}

#container {
  position: relative;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important; /* Solo horizontal bloqueado */
  overflow-y: visible !important; /* PERMITIR CONTENIDO VERTICAL */
  background-color: #ffffff;
  opacity: 0.8;
   margin: 0 auto; /* AÑADIR */
    padding: 1rem; 
    box-sizing: border-box;
}

#map-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto; /* CENTRAR */
    box-sizing: border-box; /* AÑADIR */
    overflow: hidden; /* CAMBIAR A HIDDEN */
    aspect-ratio: none;
  aspect-ratio: 4/3;
}

#mexico-map {
 width: 100%;
    height: 100%;
    max-width: 100%;
    display: block; /* AÑADIR */
    box-sizing: border-box; /* AÑADIR */
    touch-action: pan-y;
    transition: transform 0.75s ease;
    transform-origin: center;
    overflow: visible;
}

#mexico-map path {
  fill: #E6E6E6; /* Gris medio claro para contraste con fondo blanco */
  stroke: #000000; /* Negro para bordes más visibles */
  stroke-width: 0.8px;
  transition: all 0.3s ease;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.1));
}

#mexico-map path:hover {
  fill: #f5e336; /* Dorado más oscuro para mejor visibilidad */
  stroke: #4A4A4A; /* Gris oscuro para bordes en hover */
  stroke-width: 1px;
  cursor: pointer;
  filter: drop-shadow(2px 2px 4px rgba(196,165,95,0.4));
}

.state {
  fill: #ffffff; /* White fill */
  stroke: #333333; /* Dark gray border */
  stroke-width: 0.5px;
  transition: all 0.3s ease;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.1));
}

.state:hover {
  fill: #f5f5f5; /* Light gray on hover */
  stroke-width: 1px;
  filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.15));
}

.state.active {
  fill: #8B7355; /* Marrón para estado activo */
  stroke: #4A4A4A;
  stroke-width: 1px;
  filter: drop-shadow(3px 3px 5px rgba(139,115,85,0.4));
}

/* Update hover state if tooltip is showing */
.state.hover {
  fill: #B3935C; /* Dorado medio para estado con tooltip */
  stroke-width: 1.5px;
  filter: drop-shadow(0 0 5px rgba(179,147,92,0.3));
}

.resetButton {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  padding: 10px 18px;
  background: #4a89dc;
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  z-index: 10;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.resetButton:hover {
  background: #3b7dd8;
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

#state-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

#state-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.overlay-content {
  background-color: rgba(255,255,255, 0.8);
  width: 80%;
  max-width: 800px;
  max-height: 80vh;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow-y: auto;
}

.close-overlay {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #555;
}

#overlay-state-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

#overlay-state-content img {
  width: 100%;
  max-height: 300px;
  border-radius: 5px;
  object-fit: cover;
}

.overlay-state-title {
    font-size: 2.3rem;
    text-align: center;
    color: #C4A55F;
    margin-bottom: 10px;
    padding-bottom: 10px;
    text-decoration: underline;
    text-decoration-color: #333;
    width: 100%;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1); /* Añade profundidad */
    font-weight: 600; /* Hace el texto un poco más grueso */
}

.overlay-state-subtitle {
    font-size: 1.5rem;
    text-align: center;
    color: #666;
    margin-bottom: 5px;
    font-weight: normal;
}

#overlay-state-facts {
    list-style-type: none;
    padding: 0;
    margin-top: 20px;
}

#overlay-state-facts li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    position: relative;
    padding-left: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
}

#overlay-state-facts li::before {
    content: "−";
    position: absolute;
    left: 0;
    color: #C4A55F;
    font-weight: bold;
}

.tooltip {
  position: absolute;
  padding: 8px;
  background: rgba(0,0,0,0.8);
  color: white;
  border-radius: 4px;
  pointer-events: none;
  font-size: 14px;
  z-index: 100;
}

/* INSTRUCCIONES DEL MAPA - ESTILOS MEJORADOS */
.map-instructions {
    text-align: center;
    font-size: 1rem;
    color: #666;
    margin: 1rem 0 2rem 0;
    padding: 1rem;
    background: rgba(196, 165, 95, 0.05);
    border: 1px solid rgba(196, 165, 95, 0.2);
    border-radius: 8px;
    font-weight: 500;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
    display: block; /* Asegurar que se muestre */
    opacity: 1; /* Asegurar visibilidad */
    visibility: visible; /* Asegurar visibilidad */
}

/* Mejorar el contenedor del mapa */
#map-container {
    width: 100%;
    height: 600px;
    border-radius: 12px;
    background: #ffffff;
    opacity:0.8;
    
    overflow: visible;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
}

/* Título del mapa */
#container{
    text-align: center;
    color: #000000;
    font-size: 1rem;
    font-weight: 700;
    margin: 3rem 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}

/* CONTROLES DE ZOOM - NUEVOS ESTILOS */
.map-zoom-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.zoom-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.zoom-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.zoom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(240, 240, 240, 0.9);
}

.zoom-btn i {
    pointer-events: none;
}

/* Estilos específicos por botón */
.zoom-in {
    font-weight: bold;
}

.zoom-out {
    font-weight: bold;
}

.zoom-reset {
    border-top: 2px solid #eee;
    margin-top: 4px;
}

.zoom-reset:hover:not(:disabled) {
    background: #C4A55F;
    color: white;
}

/* DESHABILITAR ZOOM CON RUEDA EN EL SVG */
#mexico-map {
    width: 100%;
    height: 100%;
    touch-action: pan-y; /* Solo permite scroll vertical */
    transition: transform 0.75s ease;
    max-width: 100%;
    transform-origin: center;
    overflow: visible;
}

/* Responsive para instrucciones */
@media (max-width: 768px) {
    .map-instructions {
        font-size: 1rem;
        margin: 0.5rem 1rem 1.5rem 1rem;
        padding: 0.8rem;
    }
    
    .map-instructions::before {
        font-size: 1rem;
    }
    
    #container {
        padding: 0.5rem; /* MENOS PADDING EN MÓVIL */
        margin: 0;
        width: 100vw;
        max-width: 100vw;
    }
}

@media (max-width: 480px) {
    .map-instructions {
        font-size: 0.9rem;
        padding: 0.6rem;
        margin: 0.5rem 0.5rem 1rem 0.5rem;
    }
    
    #container {
        font-size: 1rem;
        letter-spacing: 1px;
    }
}

@media screen and (min-width: 1024px) {
    #mexico-map {
        transform: scale(0.75); /* Reduce el mapa al 75% de su tamaño original */
        transform-origin: center center; /* Asegura que la escala se aplique desde el centro */
        margin: 0 auto; /* Centra el mapa */
    }

    #map-container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 600px; /* Asegura espacio suficiente para el mapa escalado */
        flex-direction: column;
    }

    .map-instructions {
        top: 40px;
        font-size: 1rem;
    }
}

/* Fix adicional para overflow en móviles */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        overflow-y: auto !important; /* PERMITIR SCROLL VERTICAL */
        width: 100vw;
        max-width: 100vw;
        height: auto; /* ALTURA AUTOMÁTICA */
    }
    
    #container {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        overflow-y: visible; /* PERMITIR CONTENIDO VERTICAL */
        padding: 0.5rem;
        box-sizing: border-box;
    }
    
    #map-container {
        width: 100%;
        max-width: 100%;
        height: 400px;
        overflow: visible; /* PERMITIR TOOLTIPS Y OVERLAYS */
        margin: 1rem 0;
    }
    
    #mexico-map {
        width: 100%;
        height: 100%;
        max-width: 100%;
        overflow: visible; /* MANTENER VISIBLE */
    }
    
    .map-instructions {
        margin: 0.5rem 0.25rem 1rem 0.25rem;
        padding: 0.8rem;
        font-size: 0.9rem;
    }
}

/* Responsive para controles de zoom */
@media (max-width: 768px) {
    .map-zoom-controls {
        top: 15px;
        right: 15px;
        gap: 6px;
    }
    
    .zoom-btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .map-zoom-controls {
        top: 10px;
        right: 10px;
        gap: 4px;
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }
}