* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --map-aspect: 2000 / 1001;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    overflow: hidden;
    height: 100vh;
}

.map-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.map-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: filter 0.3s ease;
}

.map-wrapper.dimmed {
    filter: brightness(0.95);
}

@media (min-width: 992px) {
    body {
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .map-container {
        width: 100%;
        height: auto;
        overflow: visible;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .map-wrapper {
        width: 100%;
        height: auto;
        aspect-ratio: var(--map-aspect);
    }
}

#worldMap {
    width: 100%;
    height: 100%;
    max-width: none;
}

#worldMap svg {
    width: 100%;
    height: 100%;
    display: block;
}

.city-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 6;
}

.city-connector {
    stroke: #FFC107;
    stroke-width: 0.8;
    vector-effect: non-scaling-stroke;
}

.country-connector-dot {
    fill: #FFC107;
    vector-effect: non-scaling-stroke;
}

.city-connector.hidden {
    opacity: 0;
}

/* Estilos para países del mapa SVG */
#worldMap path {
    fill: #dfe3e8;
    stroke: #ffffff;
    stroke-width: 0.3;
    transition: fill 0.2s ease;
}

#worldMap path.highlighted {
    fill: #dfe3e8;
    stroke: #ffffff;
    stroke-width: 0.5;
}

#worldMap path.dimmed {
    fill: #dfe3e8;
    opacity: 1;
}

/* Marcadores de países */
.country-pin {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.3s ease;
    --label-offset-x: 8px;
    --label-offset-y: -100%;
    --badge-gap: 6px;
}

.country-stack {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    transform: translate(var(--label-offset-x), var(--label-offset-y));
    pointer-events: none;
}

.country-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.country-marker {
    position: relative;
}

.country-label {
    position: relative;
    font-size: 11px;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: -2px;
    white-space: nowrap;
    pointer-events: none;
}

.country-badges {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--badge-gap);
    pointer-events: none;
}

.country-badges .city-badge {
    position: relative;
    transform: none;
    pointer-events: auto;
}

.country-badges .city-badge:hover {
    transform: scale(1.12);
}

.country-badges .city-badge.hidden {
    transform: scale(0.8);
}

.country-pin[data-country="GUATEMALA"] {
    --label-offset-x: -130px;
    --label-offset-y: -70%;
}

.country-pin[data-country="PERU"] {
    --label-offset-x: -120px;
    --label-offset-y: 80%;
}

.country-pin[data-country="ECUADOR"] {
    --label-offset-x: -120%;
    --label-offset-y: -40%;
}

.country-pin[data-country="TANZANIA"] {
    --label-offset-x: 80px;
    --label-offset-y: -45%;
}

@media (max-width: 1279px) {
    .country-pin[data-country="GUATEMALA"] {
        --label-offset-x: 10px;
        --label-offset-y: -150%;
    }

    .country-pin[data-country="PERU"] {
        --label-offset-x: 20%;
        --label-offset-y: 20%;
    }

    .country-pin[data-country="ECUADOR"] {
        --label-offset-x: -100%;
        --label-offset-y: -40%;
    }

    .country-pin[data-country="TANZANIA"] {
        --label-offset-x: 40px;
        --label-offset-y: -30%;
    }
}

@media (max-width: 768px) {
    .country-pin[data-country="GUATEMALA"] {
        --label-offset-x: 50px;
        --label-offset-y: -150%;
    }

    .country-pin[data-country="PERU"] {
        --label-offset-x: 160%;
        --label-offset-y: -140%;
    }

    .country-pin[data-country="ECUADOR"] {
        --label-offset-x: -120%;
        --label-offset-y: -200%;
    }

    .country-pin[data-country="TANZANIA"] {
        --label-offset-x: 40px;
        --label-offset-y: -30%;
    }
}

.country-pin[data-country="COSTA RICA"] {
    --label-offset-x: 38px;
    --label-offset-y: -70%;
}

.country-pin[data-country="COSTA RICA"] .country-header,
.country-pin[data-country="TANZANIA"] .country-header {
    flex-direction: row-reverse;
}

@media (max-width: 1279px) {

    .country-pin[data-country="GUATEMALA"] .country-header,
    .country-pin[data-country="PERU"] .country-header {
        flex-direction: row-reverse;
    }
}



.country-pin.hidden {
    opacity: 0;
}

/* Capa de ciudades */
.cities-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.city-badge {
    position: absolute;
    background: white;
    border: none;
    border-radius: 12px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    pointer-events: auto;
    transform: translate(-50%, -50%);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.city-badge:hover {
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    filter: brightness(1.05);
}

.city-badge.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.8);
}

.city-badge.active-country {
    opacity: 1;
    pointer-events: auto;
}

/* Popup Overlay */
.popup-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    background-color: rgba(90, 100, 116, 0.4);
    backdrop-filter: blur(0.6px);
}

.popup-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.popup-container {
    position: absolute;
    max-width: 320px;
    width: min(60vw, 320px);
    max-height: 85vh;
    overflow: visible;
    transform: translate(-50%, -100%) scale(0.98);
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
}

.popup-surface {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 6px 16px rgba(0, 0, 0, 0.18);
    overflow: visible;
}

.popup-city-badge {
    position: absolute;
    top: -70px;
    left: -70px;
    width: 140px;
    height: 140px;
    z-index: 4;
    pointer-events: none;
}

.popup-city-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 1099px) {
    .popup-city-badge {
        width: 60px;
        height: 60px;
        top: -30px;
        left: -30px;
    }
}

.popup-container::after {
    content: '';
    position: absolute;
    left: var(--popup-tail-x, 50%);
    bottom: -11px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid #ffffff;
    filter: none;
}

.popup-overlay.active .popup-container {
    transform: translate(-50%, -100%) scale(1);
    opacity: 1;
}

.popup-overlay.flipped .popup-container {
    transform: translate(-50%, 0) scale(1);
}

.popup-overlay.flipped .popup-container::after {
    top: -11px;
    bottom: auto;
    border-top: none;
    border-bottom: 12px solid #ffffff;
}

@media (min-width: 992px) {
    .popup-overlay.centered .popup-container,
    .popup-overlay.centered.active .popup-container {
        transform: translate(-50%, -50%) scale(1);
    }

    .popup-overlay.centered .popup-container::after {
        display: none;
    }
}

@media (max-width: 1279px) {
    .popup-overlay.shift-right[data-country="GUATEMALA"] .popup-container {
        transform: translate(0, -100%) scale(1);
    }

    .popup-overlay.shift-right[data-country="GUATEMALA"].flipped .popup-container {
        transform: translate(0, 0) scale(1);
    }

    .popup-overlay.shift-right[data-country="GUATEMALA"] .popup-container::after {
        left: 12px;
        transform: none;
    }
}

@media (max-width: 1099px) {
    .popup-overlay.shift-right[data-country="ECUADOR"] .popup-container {
        transform: translate(0, -100%) scale(1);
    }

    .popup-overlay.shift-right[data-country="ECUADOR"].flipped .popup-container {
        transform: translate(0, 0) scale(1);
    }

    .popup-overlay.shift-right[data-country="ECUADOR"] .popup-container::after {
        left: 12px;
        transform: none;
    }
}

@media (max-width: 899px) {
    .popup-overlay.shift-right[data-country="PERU"] .popup-container {
        transform: translate(0, -100%) scale(1);
    }

    .popup-overlay.shift-right[data-country="PERU"].flipped .popup-container {
        transform: translate(0, 0) scale(1);
    }

    .popup-overlay.shift-right[data-country="PERU"] .popup-container::after {
        left: 12px;
        transform: none;
    }
}

.popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(42, 49, 57, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    line-height: 1;
}

.popup-close:hover {
    background: rgba(42, 49, 57, 1);
    transform: scale(1.08);
}

.popup-content {
    display: flex;
    flex-direction: column;
}

.popup-image {
    width: 100%;
    height: 140px;
    overflow: hidden;
    background: #e5e7eb;
}

.popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.popup-info {
    padding: 24px 28px 28px;
}

.popup-info h2 {
    font-size: 20px;
    color: #1f2937;
    margin-bottom: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-info p {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.65;
    margin-bottom: 22px;
}

.popup-button {
    display: inline-block;
    background: #FFC107;
    color: #1f2937;
    text-decoration: none;
    padding: 11px 26px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(255, 193, 7, 0.3);
    text-transform: capitalize;
}

.popup-button:hover {
    background: #FFB300;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 193, 7, 0.4);
}

/* Mobile Country Badges Panel */
.mobile-country-badges-panel {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid #dbe4ef;
    box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.12);
    z-index: 1001;
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
}

.mobile-country-badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.mobile-country-badge {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d7dde8;
    border-radius: 999px;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.mobile-country-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}

.mobile-country-badge:active {
    transform: scale(0.98);
}

.mobile-country-badge.active {
    background: #1f2937;
    border-color: #1f2937;
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(31, 41, 55, 0.25);
}

/* Mobile City Selection Modal */
.mobile-city-selection-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    pointer-events: none;
}

.mobile-city-selection-modal.active {
    pointer-events: auto;
}

.mobile-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
    height: 100%;
}

.mobile-city-selection-modal.active .mobile-modal-overlay,
.mobile-city-info-modal.active .mobile-modal-overlay {
    opacity: 1;
}

.mobile-city-selection-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: fit-content;
    display: flex;
    flex-direction: column;
}

.mobile-city-selection-modal.active .mobile-city-selection-content {
    transform: translateY(0);
}

.mobile-city-selection-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.mobile-city-selection-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-city-selection-header .mobile-modal-close {
    position: static;
    width: 32px;
    height: 32px;
    font-size: 20px;
}

.mobile-city-selection-list {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-city-option {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-city-option-name {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Mobile City Info Modal */
.mobile-city-info-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2001;
    pointer-events: none;
}

.mobile-city-info-modal.active {
    pointer-events: auto;
}

.mobile-city-info-content {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    background: white;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-city-info-modal.active .mobile-city-info-content {
    transform: translateY(0);
}

.mobile-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(42, 49, 57, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    line-height: 1;
}

.mobile-modal-close:hover {
    background: rgba(42, 49, 57, 1);
    transform: scale(1.08);
}

.mobile-city-info-image {
    width: 100%;
    height: 240px;
    position: relative;
    overflow: visible;
    background: #e5e7eb;
    flex-shrink: 0;
}

.mobile-city-info-image.empty {
    background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
}

.mobile-city-info-image-media {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.mobile-city-info-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-city-info-image.empty .mobile-city-info-image-media img {
    display: none;
}

.mobile-city-info-badge {
    position: absolute;
    right: 24px;
    bottom: -24px;
    width: 80px;
    height: 80px;
    z-index: 3;
    pointer-events: none;
}

.mobile-city-info-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mobile-city-info-main {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 18px;
}

.mobile-city-info-body {
    padding: 56px 24px 24px;
}

.mobile-city-info-body h2 {
    font-size: 22px;
    color: #1f2937;
    margin-bottom: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-city-info-body p {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.7;
    margin-bottom: 24px;
}

.mobile-city-switcher {
    flex-shrink: 0;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-switcher-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-switcher-label {
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    font-weight: 700;
    color: #64748b;
}

.mobile-switcher-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mobile-switch-chip {
    border: 1px solid #d7dde8;
    border-radius: 999px;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: #f8fafc;
    color: #1f2937;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.mobile-switch-chip:active {
    transform: scale(0.98);
}

.mobile-country-chip.active {
    background: #1f2937;
    border-color: #1f2937;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(31, 41, 55, 0.22);
}

.mobile-city-chip {
    border-color: var(--chip-color, #4b5563);
    color: var(--chip-color, #4b5563);
    background: #ffffff;
}

.mobile-city-chip.active {
    background: var(--chip-color, #4b5563);
    border-color: var(--chip-color, #4b5563);
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(31, 41, 55, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .map-container {
        height: 100vh;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .map-wrapper {
        flex: 1;
        width: 100%;
        aspect-ratio: auto;
        height: auto;
        min-height: 0;
    }

    /* Ocultar badges de ciudades del mapa */
    .country-badges {
        display: none !important;
    }

    /* Ocultar popup normal en mobile */
    .popup-overlay {
        display: none !important;
    }

    /* Mostrar panel de badges de países */
    .mobile-country-badges-panel {
        display: block;
        position: relative;
        flex-shrink: 0;
        height: fit-content;
    }

    /* Mostrar modales cuando estén activos */
    .mobile-city-selection-modal.active,
    .mobile-city-info-modal.active {
        display: block;
    }

    .popup-container {
        width: 95%;
        max-height: 90vh;
    }

    .popup-image {
        height: 220px;
    }

    .popup-info {
        padding: 20px;
    }

    .popup-info h2 {
        font-size: 18px;
    }

    .popup-info p {
        font-size: 13px;
    }

    .popup-city-badge {
        width: 56px;
        height: 56px;
        top: -28px;
        left: -28px;
    }

    .mobile-city-info-badge {
        right: 32px;
        bottom: -32px;
        width: 78px;
        height: 78px;
    }

    .city-badge {
        font-size: 10px;
        padding: 4px 10px;
    }

    .country-label {
        font-size: 10px;
    }
}
