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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    overflow: hidden;
    background-color: #f0f0f0;
    /* Safari/iOS scroll fix */
    position: relative;
}

/* Prevent body scroll when modal is open - REMOVED to allow modal scroll */
/* La estrategia ahora es que el modal maneje su propio scroll */

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header removed */

/* Sponsor Header (ad) */
.ad-header {
    flex-shrink: 0;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 6px 12px 10px;
}

.ad-label {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
    font-weight: 600;
}

.ad-banner {
    height: 60px;
    border-radius: 10px;
    background: #f8f9fa;
    border: 1px dashed #d0d0d0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    font-weight: 600;
}

@media (max-width: 480px) {
    .ad-banner {
        height: 50px;
        font-size: 12px;
    }
}

#map {
    flex: 1;
    width: 100%;
    position: relative;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 99999; /* MUY ALTO para estar por encima de Leaflet */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
    /* Enable touch scrolling */
    -webkit-overflow-scrolling: touch;
    touch-action: auto; /* CAMBIADO: permitir touch events */
    pointer-events: auto;
}

.modal[style*="display: block"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 20px;
    touch-action: auto !important; /* CAMBIADO: permitir touch events */
    pointer-events: auto !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        transform: translateY(20px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content {
    background-color: white;
    position: relative;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: auto;
    /* Touch scrolling fixes for mobile */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    pointer-events: auto !important; /* CRITICAL: Enable all interactions */
    z-index: 100000; /* Ensure it's above everything */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px 15px;
    border-bottom: 2px solid #f0f0f0;
    flex-shrink: 0;
}

.modal-header h2 {
    color: #333;
    font-size: 22px;
    font-weight: 600;
}

.close {
    cursor: pointer;
    font-size: 28px;
    color: #999;
    font-weight: 300;
    line-height: 1;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 20px 30px;
    overflow-y: auto !important;
    overflow-x: hidden;
    flex: 1;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain;
    max-height: calc(90vh - 200px);
    min-height: 100px;
    /* Critical for mobile touch scrolling */
    touch-action: pan-y !important;
    position: relative;
    will-change: scroll-position;
    pointer-events: auto !important; /* CRITICAL: Enable touch events */
    -webkit-transform: translateZ(0); /* Force GPU */
    transform: translateZ(0);
}

.info-item {
    margin: 12px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.info-item label {
    font-weight: 600;
    color: #555;
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    color: #333;
    font-size: 15px;
}

.challenge-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px 30px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background-color: white;
    border-radius: 0 0 12px 12px;
}

.btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(229, 57, 53, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: #e9ecef;
    color: #495057;
}

.btn-secondary:hover {
    background-color: #dee2e6;
}

/* Loading state */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
    .modal-footer {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
        margin: 0 auto;
    }
    
    .modal[style*="display: block"] {
        padding: 10px;
        align-items: flex-start;
    }
    
    .modal-body {
        padding: 15px 20px;
        max-height: calc(95vh - 140px);
        /* CRÍTICO para móvil */
        -webkit-overflow-scrolling: touch !important;
        overflow-y: scroll !important;
        touch-action: pan-y !important;
    }
    
    .modal-header {
        padding: 15px 20px 12px;
        flex-shrink: 0;
    }
    
    .modal-footer {
        padding: 15px 20px;
        flex-shrink: 0;
    }
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    z-index: 100000; /* Por encima de los modales (99999) */
    display: none;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    border-left: 4px solid #28a745;
}

.notification.error {
    border-left: 4px solid #dc3545;
}

.notification.info {
    border-left: 4px solid #17a2b8;
}

    

/* Modal Image Styles */
.modal-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
    z-index: 1500;
    border-top: 1px solid #e0e0e0;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
    color: #666;
    text-decoration: none;
}

.nav-item:hover {
    color: #e53935;
    transform: translateY(-2px);
}

.nav-item.active {
    color: #e53935;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.primary {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    color: white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    margin: -25px 10px 0 10px;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
}

.nav-item.primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(229, 57, 53, 0.5);
}

.nav-item.primary svg {
    width: 28px;
    height: 28px;
    margin-bottom: 0;
}

.nav-item.primary span {
    display: none;
}

/* Adjust map to account for bottom nav */
#map {
    padding-bottom: 70px;
}

/* Pulse animation for location button */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(229, 57, 53, 0.6);
    }
    100% {
        box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
    }
}

.nav-item.primary.locating {
    animation: pulse 1.5s infinite;
}

/* User location marker */
.user-marker {
    background: transparent;
    border: none;
}

.user-marker-circle {
    width: 20px;
    height: 20px;
    background: #e53935;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@media (min-width: 769px) {
    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 20px 20px 0 0;
    }
}

@media (max-width: 768px) {
    .bottom-nav {
        padding: 8px 0;
    }

    .nav-item span {
        font-size: 10px;
    }

    .nav-item svg {
        width: 22px;
        height: 22px;
    }
}

/* Challenge Selector Styles */
.challenge-card {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.challenge-card:hover {
    border-color: #e53935;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.2);
}

.challenge-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    margin-right: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.challenge-info {
    flex: 1;
}

.challenge-info h3 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.challenge-info p {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 13px;
}

.challenge-count {
    display: inline-block;
    background: #f0f0f0;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    color: #555;
    font-weight: 600;
}

.challenge-type-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.challenge-type-pill.free {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #1a5f4a;
}

.challenge-type-pill.premium {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}

.challenge-joined-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.challenge-locked {
    opacity: 0.6;
}

.challenge-locked .challenge-card {
    cursor: not-allowed;
}

.challenge-type-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.challenge-type-pill.free {
    background: #e8f5e9;
    color: #2e7d32;
}

.challenge-type-pill.premium {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #b8860b;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.challenge-joined-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

@media (max-width: 480px) {
    .challenge-card {
        padding: 12px;
    }

    .challenge-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
        margin-right: 12px;
    }

    .challenge-info h3 {
        font-size: 14px;
    }

    .challenge-info p {
        font-size: 12px;
    }
}

/* Progress Screen Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.progress-section {
    margin-bottom: 25px;
}

.progress-section h3 {
    color: #333;
    font-size: 18px;
    margin-bottom: 15px;
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-bar-container.small {
    height: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    border-radius: 12px;
    transition: width 0.8s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    font-weight: 600;
}

.progress-text.small {
    font-size: 11px;
    margin-top: 5px;
}

.challenge-progress {
    background: white;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
}

.challenge-progress-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.challenge-progress-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.challenge-progress-info {
    flex: 1;
}

.challenge-progress-info h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 15px;
    font-weight: 600;
}

.recent-visits {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
}

.visit-item {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid #e53935;
}

.visit-item:last-child {
    margin-bottom: 0;
}

.visit-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}

.visit-info {
    flex: 1;
}

.visit-info h5 {
    margin: 0 0 3px 0;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.visit-info p {
    margin: 0;
    color: #666;
    font-size: 11px;
}

.visit-badge {
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 10px;
    color: #555;
    font-weight: 600;
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-icon {
        font-size: 24px;
    }

    .stat-value {
        font-size: 22px;
    }

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

    .challenge-progress-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* Profile Screen Styles */
.profile-header {
    text-align: center;
    padding: 20px 0;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 20px;
}

.profile-avatar-container {
    position: relative;
    display: inline-block;
    margin-bottom: 15px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 36px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.3);
    border: 4px solid white;
    overflow: hidden; /* CRITICAL: Asegura que la imagen no se salga del círculo */
    position: relative;
}

/* Imagen de perfil dentro del avatar circular */
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cubre todo el área sin distorsión */
    object-position: center; /* Centra la imagen */
    border-radius: 50%; /* Asegura que sea circular */
    position: absolute;
    top: 0;
    left: 0;
}

.profile-avatar-text {
    text-transform: uppercase;
    position: relative; /* Para que quede sobre el fondo */
    z-index: 1;
}

.profile-avatar-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e53935;
    color: #e53935;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.profile-avatar-edit:hover {
    background: #e53935;
    color: white;
    transform: scale(1.1);
}

.profile-photo-upload-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    /* iOS fixes */
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    z-index: 10;
}

.profile-photo-upload-btn:active {
    background: #667eea;
    color: white;
    transform: scale(0.95);
}

.profile-photo-upload-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.profile-photo-upload-btn svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.profile-header h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.profile-level {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.profile-stat-item {
    text-align: center;
    padding: 15px 10px;
    background: #f8f9fa;
    border-radius: 12px;
}

.profile-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #e53935;
    margin-bottom: 5px;
}

.profile-stat-label {
    display: block;
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.achievement-item {
    background: white;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.achievement-item.unlocked {
    border-color: #ffd700;
    background: linear-gradient(135deg, #fff9e6 0%, #fffbf0 100%);
}

.achievement-item.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.achievement-item:hover:not(.locked) {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.achievement-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.achievement-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    display: block;
    margin-bottom: 3px;
}

.achievement-description {
    font-size: 10px;
    color: #666;
}

.profile-info-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
}

.profile-info-item {
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.profile-info-item:last-child {
    border-bottom: none;
}

.profile-info-item label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-info-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    color: #333;
}

.btn-icon {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: #f0f0f0;
}

.settings-list {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 5px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-info {
    flex: 1;
}

.setting-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
}

.setting-description {
    display: block;
    font-size: 12px;
    color: #666;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #e53935;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

@media (max-width: 480px) {
    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 28px;
        overflow: hidden; /* Mantener overflow hidden en móvil */
    }
    
    .profile-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        border-radius: 50%;
    }
    
    .profile-photo-upload-btn {
        width: 36px;
        height: 36px;
        /* Asegurar que sea clickeable en móvil */
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
        touch-action: manipulation;
    }

    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .profile-header h3 {
        font-size: 20px;
    }
}

/* iOS Safari específico - Fix para input file */
@supports (-webkit-touch-callout: none) {
    .profile-photo-upload-btn {
        /* Asegurar que el label sea totalmente clickeable en iOS */
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
        position: absolute;
        bottom: 0;
        right: 0;
        z-index: 11;
    }
    
    input[type="file"] {
        /* Asegurar que el input file funcione en iOS */
        -webkit-appearance: none;
        appearance: none;
    }
}

/* ========================================
   SISTEMA DE BANNERS GEOLOCALIZADOS
   ======================================== */

/* Banner geolocalizado - Layout horizontal con imagen cuadrada */
.geo-banner {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 360px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-left: 4px solid #667eea;
    -webkit-transform: translateX(400px);
    -ms-transform: translateX(400px);
    transform: translateX(400px);
    opacity: 0;
    -webkit-transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    -o-transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    /* Safari specific fixes */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
    /* iOS Safari fixes */
    will-change: transform, opacity;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
}

.geo-banner.show {
    -webkit-transform: translateX(0);
    -ms-transform: translateX(0);
    transform: translateX(0);
    opacity: 1;
}

.geo-banner:hover {
    -webkit-transform: translateX(0) translateY(-4px);
    -ms-transform: translateX(0) translateY(-4px);
    transform: translateX(0) translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

/* Contenedor de imagen cuadrada */
.geo-banner-image-container {
    position: relative;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    /* Fallback para navegadores sin gap */
    margin-right: 14px;
}

/* Imagen cuadrada */
.geo-banner-image {
    width: 100px;
    height: 100px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    /* Safari fix para background-size */
    background-clip: padding-box;
}

/* Icono superpuesto en esquina inferior derecha de la imagen */
.geo-banner-icon {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 36px;
    height: 36px;
    background-color: #667eea;
    border-radius: 50%;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    border: 3px solid white;
    /* Safari fix */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Contenido del banner */
.geo-banner-content {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 0;
    padding-right: 32px;
}

.geo-banner-title {
    font-weight: 700;
    font-size: 15px;
    color: #222;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Safari text rendering fix */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.geo-banner-subtitle {
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
    line-height: 1.4;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Safari text rendering fix */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.geo-banner-distance {
    font-size: 12px;
    color: #999;
    font-weight: 500;
    /* Safari text rendering fix */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Botón cerrar */
.geo-banner-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: #666;
    font-size: 18px;
    cursor: pointer;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    border-radius: 50%;
    -webkit-transition: all 0.2s;
    -o-transition: all 0.2s;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
    /* Safari fixes */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.geo-banner-close:hover {
    background: white;
    color: #333;
    -webkit-transform: scale(1.15);
    -ms-transform: scale(1.15);
    transform: scale(1.15);
}

/* Animación del icono */
@-webkit-keyframes iconPulse {
    0%, 100% { -webkit-transform: scale(1); transform: scale(1); }
    50% { -webkit-transform: scale(1.15); transform: scale(1.15); }
}

@keyframes iconPulse {
    0%, 100% { -webkit-transform: scale(1); transform: scale(1); }
    50% { -webkit-transform: scale(1.15); transform: scale(1.15); }
}

.geo-banner.show .geo-banner-icon {
    -webkit-animation: iconPulse 0.6s ease 0.4s;
    animation: iconPulse 0.6s ease 0.4s;
}

/* Responsive - Móvil */
@media (max-width: 480px) {
    .geo-banner {
        position: fixed !important; /* Force fixed en móvil */
        top: 12px !important;
        right: 12px !important;
        left: 12px !important;
        bottom: auto !important;
        width: auto !important;
        padding: 10px !important;
        /* Fallback para Safari sin soporte de gap */
        gap: 12px;
        z-index: 2500 !important;
        /* iOS Safari specific */
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
        will-change: transform, opacity;
        isolation: isolate;
    }
    
    /* Estado visible en móvil */
    .geo-banner.show {
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        opacity: 1 !important;
    }
    
    /* Fallback para navegadores sin gap */
    .geo-banner-image-container {
        margin-right: 12px;
    }
    
    .geo-banner-image {
        width: 80px;
        height: 80px;
        border-radius: 10px;
        /* iOS fix para background-image */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .geo-banner-icon {
        width: 32px;
        height: 32px;
        font-size: 18px;
        bottom: -5px;
        right: -5px;
        /* iOS fix */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .geo-banner-content {
        padding-right: 28px;
    }
    
    .geo-banner-title {
        font-size: 14px;
    }
    
    .geo-banner-subtitle {
        font-size: 12px;
    }
    
    .geo-banner-distance {
        font-size: 11px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Solo iOS Safari */
    .geo-banner {
        position: -webkit-sticky;
        position: sticky;
        position: fixed;
        top: env(safe-area-inset-top, 20px);
        -webkit-transform: translate3d(400px, 0, 0);
        transform: translate3d(400px, 0, 0);
    }
    
    .geo-banner.show {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
    
    @media (max-width: 480px) {
        .geo-banner {
            top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
            left: 12px !important;
            right: 12px !important;
        }
    }
    
    /* Fix CRÍTICO para modales en iOS */
    .modal {
        -webkit-overflow-scrolling: touch !important;
    }
    
    .modal-content {
        -webkit-overflow-scrolling: touch !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .modal-body {
        -webkit-overflow-scrolling: touch !important;
        overflow-y: scroll !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Force GPU acceleration for smooth scrolling */
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: #999;
}

/* ======================================== */
/* VIEW TOGGLE BUTTON */
/* ======================================== */
.view-toggle-btn {
    position: fixed;
    bottom: 80px; /* Encima del menú inferior (que está a 60px) */
    left: 20px;
    z-index: 1000;
    background: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.view-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.view-toggle-btn:active {
    transform: scale(0.95);
}

.view-toggle-btn svg {
    color: #667eea;
}

/* ======================================== */
/* POI LIST VIEW */
/* ======================================== */
.poi-list-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    z-index: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.poi-list-header {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.poi-list-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

.poi-list-count {
    font-size: 14px;
    opacity: 0.9;
    margin: 0 0 15px 0;
}

.poi-list-filters {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 140px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 500;
    opacity: 0.9;
}

.filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.filter-select option {
    background: #667eea;
    color: white;
    padding: 8px;
}

.poi-list-container {
    padding: 15px;
    padding-bottom: 100px; /* Espacio para la navegación inferior */
}

.poi-list-item {
    background: white;
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
}

.poi-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.poi-list-item:active {
    transform: scale(0.98);
}

.poi-list-item-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #e0e0e0;
}

.poi-list-item.no-image .poi-list-item-image {
    display: none;
}

.poi-list-item-content {
    padding: 15px;
}

.poi-list-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.poi-list-item-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
    flex: 1;
}

.poi-list-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.poi-list-item-distance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f0f0f0;
    color: #666;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.poi-list-item-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.poi-list-item-badge.visited {
    background: #4CAF50;
}

.poi-list-item-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 12px;
}

.poi-list-item-challenge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
}

.poi-list-empty {
    text-align: center;
    padding: 60px 20px;
}

.poi-list-empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.poi-list-empty-text {
    font-size: 18px;
    color: #666;
    margin-bottom: 10px;
}

.poi-list-empty-subtext {
    font-size: 14px;
    color: #999;
}

/* ======================================== */
/* LAZY LOADING INDICATOR */
/* ======================================== */
.load-more-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    gap: 15px;
}

.load-more-indicator p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ======================================== */
/* EMPTY MAP POPUP */
/* ======================================== */
.empty-map-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
}

.empty-map-popup .leaflet-popup-content {
    margin: 0;
    width: auto !important;
}

.empty-map-popup .leaflet-popup-tip {
    background: white;
}

/* ======================================== */
/* EMPTY STATE - NO CHALLENGES JOINED */
/* ======================================== */
.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    padding: 20px;
}

.empty-state-content {
    text-align: center;
    max-width: 400px;
    padding: 40px 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 24px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-state-title {
    font-size: 24px;
    color: #667eea;
    margin-bottom: 16px;
    font-weight: 700;
}

.empty-state-text {
    font-size: 16px;
    color: #666;
    margin-bottom: 28px;
    line-height: 1.6;
}

.empty-state-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.empty-state-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.empty-state-button:active {
    transform: translateY(0);
}

/* ======================================== */
