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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
}

.header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 12px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.header p {
    opacity: 0.9;
    font-size: 0.8rem;
}

.map-container {
    position: relative;
    height: calc(100vh - 90px);
    margin: 5px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-btn {
    background: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-btn {
    background-image: url('../img/location-arrow.png');
    background-size: 18px 24px;
    background-repeat: no-repeat;
    background-position: center;
    font-size: 0;
}

.oldcity-btn {
    background-image: url('../img/old_city_icon.png');
    background-size: 23px 22px;
    background-repeat: no-repeat;
    background-position: center;
    font-size: 0;
}

.showall-btn {
    background-image: url('../img/show_all_icon.png');
    background-size: 18px 24px;
    background-repeat: no-repeat;
    background-position: center;
    font-size: 0;
}

.info-panel {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 150px;
    overflow-y: auto;
}

.info-panel.active {
    transform: translateY(0);
}

.info-panel h3 {
    color: #2c3e50;
    margin-bottom: 6px;
    font-size: 1rem;
}

.info-panel p {
    color: #555;
    font-size: 0.85rem;
    line-height: 1.3;
}

/* POPUP ЦЕНТРИРОВАНИЕ - ПРАВИЛЬНАЯ ВЕРСИЯ */
.map-container .mapboxgl-popup {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1001 !important;
    margin: 0 !important;
}

.mapboxgl-popup-content {
    border-radius: 8px !important;
    padding: 12px !important;
    max-width: 300px !important;
    width: 280px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
}

.mapboxgl-popup-tip {
    display: none !important;
}

.mapboxgl-popup-close-button {
    font-size: 24px;
    font-weight: 500;
    color: #000;
    top: 5px;
    right: 10px;
    width: 32px;
    height: 32px;
    line-height: 32px;
}

.popup-title {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.popup-description {
    color: #555;
    font-size: 0.8rem;
    line-height: 1.3;
}

.popup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.popup-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}

.audio-btn {
    background: #3498db;
    color: white;
}

.audio-btn:hover {
    background: #2980b9;
}

.audio-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.details-btn {
    background: #27ae60;
    color: white;
}

.details-btn:hover {
    background: #229954;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 8px;
}

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

.loading p {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

/* PC Portrait Mode */
@media (min-width: 768px) {
    body {
        background: #2c3e50;
        display: flex;
        flex-direction: column;
        align-items: center;
        min-height: 100vh;
        padding: 20px 0;
    }

    .header,
    .map-container {
        width: 100%;
        max-width: 375px;
        margin: 0 auto;
    }

    .header {
        border-radius: 15px 15px 0 0;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }

    .map-container {
        border-radius: 0 0 15px 15px;
        box-shadow: 0 4px 25px rgba(0,0,0,0.3);
        border: 2px solid rgba(255,255,255,0.1);
    }
}

@media (max-width: 320px) {
    .header {
        padding: 8px;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .map-container {
        height: calc(100vh - 80px);
        margin: 3px;
    }

    .control-btn {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .info-panel {
        padding: 10px;
        max-height: 120px;
    }
    
    .mapboxgl-popup-content {
        width: 260px !important;
        max-width: 260px !important;
    }
}

@media (max-width: 600px) {
    .mapboxgl-popup-close-button {
        font-size: 20px;
        font-weight: 600;
        color: red;
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        line-height: 28px;
        touch-action: manipulation;
        user-select: none;
    }
@media (max-width: 768px) {
    .mapboxgl-ctrl-group {
        display: none !important;
    }
}	
}
.route-btn {
    background: #d0391a;
    color: white;
}

.route-btn:hover {
    background: #d0391a;
}

.popup-buttons {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.popup-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    white-space: nowrap;
}