* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; height: 100vh; background: #1a1a2e; color: #e0e0e0; }

#sidebar {
    width: 350px; min-width: 350px; height: 100vh; overflow-y: auto;
    background: #16213e; padding: 16px; display: flex; flex-direction: column; gap: 10px;
    z-index: 1000; transition: transform 0.3s ease;
}
#sidebar h1 { font-size: 18px; color: #e94560; text-align: center; }
#sidebar h2 { font-size: 12px; color: #a0a0b0; text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }

/* Mode selector - checkboxes */
.poi-toggles { display: flex; flex-direction: column; gap: 4px; }
.poi-toggle {
    display: flex; align-items: center; gap: 8px; font-size: 12px;
    padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: background 0.15s;
}
.poi-toggle:hover { background: rgba(255,255,255,0.06); }
.poi-toggle input { accent-color: #e94560; }
.poi-toggle .poi-color { width: 10px; height: 10px; border-radius: 50%; }
.poi-toggle .poi-count { color: #666; font-size: 10px; margin-left: auto; }
.poi-sub-legend { font-size: 9px; padding: 2px 0 4px 24px; color: #999; display: flex; gap: 8px; }

/* Sliders — checkbox + icon + label + range + value */
.slider-group { display: flex; flex-direction: column; gap: 3px; }
.slider-item {
    display: flex; align-items: center; gap: 4px; font-size: 11px;
    background: rgba(255,255,255,0.03); padding: 3px 6px; border-radius: 6px;
    transition: opacity 0.2s;
}
.slider-item input[type=checkbox] { accent-color: #e94560; flex-shrink: 0; width: 14px; height: 14px; }
.slider-item .icon { font-size: 13px; width: 18px; text-align: center; flex-shrink: 0; }
.slider-item label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.slider-item input[type=range] { width: 60px; accent-color: #e94560; flex-shrink: 0; }
.slider-item .wv { width: 16px; text-align: center; font-weight: bold; color: #e94560; font-size: 10px; flex-shrink: 0; }

#reset-btn {
    background: #e94560; color: white; border: none; padding: 5px 10px;
    border-radius: 6px; cursor: pointer; font-size: 11px; align-self: center;
}
#reset-btn:hover { background: #c73a52; }

/* Legend */
.legend-gradient {
    height: 10px; border-radius: 5px; margin: 4px 0;
    background: linear-gradient(to right, hsl(0,80%,45%), hsl(60,80%,45%), hsl(120,80%,45%));
}
.legend-labels { display: flex; justify-content: space-between; font-size: 9px; color: #666; }

/* Loading */
.poi-status { font-size: 10px; color: #666; text-align: center; }
.poi-status.loading { color: #e94560; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

/* Rankings */
#rankings { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rank-item {
    display: flex; align-items: center; gap: 6px; padding: 5px 8px;
    border-radius: 6px; cursor: pointer; font-size: 11px; transition: background 0.15s;
}
.rank-item:hover { background: rgba(255,255,255,0.08); }
.rank-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.rank-name { flex: 1; }
.rank-score { font-weight: bold; min-width: 28px; text-align: right; }
.rank-num { color: #555; width: 16px; font-size: 10px; }

#map { flex: 1; height: 100vh; }

#toggle-sidebar {
    display: none; position: fixed; bottom: 16px; left: 16px; z-index: 1001;
    background: #e94560; color: white; border: none; width: 44px; height: 44px;
    border-radius: 50%; font-size: 20px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Popup */
.loc-popup { font-family: -apple-system, sans-serif; min-width: 280px; }
.loc-popup h3 { font-size: 14px; margin-bottom: 2px; color: #1a1a2e; }
.loc-popup .score-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px; color: white;
    font-weight: bold; font-size: 12px; margin-bottom: 4px;
}
.popup-region { font-size: 10px; color: #888; margin-bottom: 4px; }
.bar-row { display: flex; align-items: center; gap: 3px; margin: 1px 0; font-size: 10px; }
.bar-icon { width: 16px; text-align: center; }
.bar-label { width: 110px; color: #555; font-size: 9px; }
.bar-track { flex: 1; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-val { width: 16px; text-align: right; font-weight: bold; color: #333; }
.bar-detail { font-size: 9px; color: #777; padding: 1px 0 3px 20px; line-height: 1.3; }
.bar-detail.internet-type { color: #4a9eff; font-weight: 600; }
.loc-meta { margin-top: 6px; font-size: 10px; color: #555; border-top: 1px solid #ddd; padding-top: 4px; }
.loc-meta div { margin: 1px 0; }
.loc-meta strong { color: #333; }

/* Cluster overrides */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: transparent !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: transparent !important; }
.poi-cluster-icon {
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: white; font-weight: bold; font-size: 11px;
    border: 2px solid rgba(255,255,255,0.8); box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Attraction icon markers */
.attraction-icon {
    display: flex; align-items: center; justify-content: center;
    text-align: center; cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
    transition: transform 0.15s ease;
}
.attraction-icon:hover { transform: scale(1.3); }

/* Hazard toggles */
.hazard-toggles { display: flex; flex-direction: column; gap: 4px; }
.hazard-toggle {
    display: flex; align-items: center; gap: 8px; font-size: 12px;
    padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: background 0.15s;
}
.hazard-toggle:hover { background: rgba(255,255,255,0.06); }
.hazard-toggle input { accent-color: #e94560; }
.hazard-toggle .hazard-color { width: 10px; height: 10px; border-radius: 50%; }
.hazard-toggle .hazard-count { color: #666; font-size: 10px; margin-left: auto; }
.hazard-legend {
    display: none; font-size: 10px; padding: 4px 8px; border-radius: 6px;
    background: rgba(255,255,255,0.03); margin-top: 4px;
}
.hazard-legend.visible { display: flex; flex-direction: column; gap: 6px; }

/* Earthquake wave animation */
.eq-impact-label {
    background: rgba(20, 20, 40, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 10px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    color: #e0e0e0;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    pointer-events: none;
    animation: impact-appear 0.4s ease-out forwards;
}
.eq-impact-label.eq-impact-critical {
    border: 2px solid #ff1744;
    background: rgba(60, 0, 0, 0.95);
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.4), 0 2px 12px rgba(0,0,0,0.5);
    animation: impact-appear 0.4s ease-out forwards, death-pulse 1.5s ease-in-out 0.4s infinite;
}
.eq-impact-label.eq-impact-severe {
    border: 2px solid #ff6d00;
    background: rgba(50, 30, 0, 0.95);
    box-shadow: 0 0 14px rgba(255, 109, 0, 0.3), 0 2px 12px rgba(0,0,0,0.5);
}
@keyframes impact-appear {
    0% { transform: scale(0.5) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes death-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 23, 68, 0.4); }
    50% { box-shadow: 0 0 35px rgba(255, 23, 68, 0.7); }
}
.eq-impact-label .impact-mag {
    font-weight: bold;
    font-size: 14px;
}
.eq-impact-label .impact-deaths {
    color: #e74c3c;
    font-weight: bold;
}
.eq-impact-critical .impact-deaths {
    font-size: 15px;
    color: #ff1744;
}
/* Epicenter marker */
.eq-epicenter-icon {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px; font-weight: bold;
    animation: epicenter-glow 1.5s ease-in-out infinite alternate;
}
@keyframes epicenter-glow {
    from { box-shadow: 0 0 10px rgba(255,255,255,0.3), 0 0 20px var(--eq-color, #e74c3c); }
    to   { box-shadow: 0 0 20px rgba(255,255,255,0.5), 0 0 40px var(--eq-color, #e74c3c); }
}
/* Wave legend */
.wave-legend {
    position: fixed; bottom: 20px; right: 20px; z-index: 1500;
    background: rgba(16, 21, 38, 0.92); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px; padding: 10px 14px;
    font-family: -apple-system, sans-serif; font-size: 11px; color: #ccc;
    pointer-events: none;
    animation: impact-appear 0.3s ease-out forwards;
}
.wave-legend div { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.wave-legend .wl-line { width: 20px; height: 3px; border-radius: 2px; }
.hazard-legend span { display: flex; align-items: center; gap: 3px; }
.hazard-legend .dot { width: 8px; height: 8px; border-radius: 50%; }
.locations-toggle { margin: 6px 0 2px; }

/* Hazard sub-legends */
.hazard-sub-legend {
    display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 9px; color: #bbb;
    padding: 4px 0;
}
.hazard-sub-legend span { display: flex; align-items: center; gap: 3px; }
.hazard-sub-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Health disease legend */
.health-disease-legend {
    display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 9px; color: #bbb;
    padding: 4px 0;
}
.health-disease-legend span { display: flex; align-items: center; gap: 3px; }
.health-disease-legend .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Severity bar (used in flood, landslide, crime, health popups) */
.severity-bar {
    height: 6px; background: #333; border-radius: 3px; margin: 4px 0; overflow: hidden;
}
.severity-fill {
    height: 100%; border-radius: 3px; transition: width 0.3s;
}

/* Crime foreigner badge */
.crime-foreigner-badge {
    display: inline-block; background: #e040fb; color: #fff; font-size: 10px;
    padding: 1px 6px; border-radius: 4px; font-weight: bold; margin: 3px 0;
}

/* ==================== VOLCANO POPUP & ANIMATION ==================== */
.volcano-popup { font-family: -apple-system, sans-serif; min-width: 260px; }
.volcano-popup-title { font-size: 14px; font-weight: bold; color: #ff5722; }
.volcano-popup-info { font-size: 11px; color: #555; margin: 2px 0; }
.volcano-popup-zones { font-size: 10px; color: #888; margin: 4px 0; }

.volcano-eruption-history { margin-top: 6px; }
.eruption-table { width: 100%; font-size: 10px; border-collapse: collapse; }
.eruption-table th { text-align: left; color: #888; font-weight: normal; padding: 2px 4px; border-bottom: 1px solid #ddd; }
.eruption-table td { padding: 2px 4px; }
.eruption-info { color: #777; font-size: 9px; padding: 2px 4px 6px !important; line-height: 1.3; }

.eruption-btn {
    background: #ff5722; color: white; border: none; border-radius: 4px;
    padding: 2px 6px; font-size: 9px; cursor: pointer; white-space: nowrap;
}
.eruption-btn:hover { background: #e64a19; }

.volcano-threatened { font-size: 10px; color: #888; margin-top: 6px; line-height: 1.4; }

/* Eruption animation */
.eruption-epicenter {
    font-size: 28px; text-shadow: 0 0 20px #ff5722, 0 0 40px #ff1744;
    animation: eruption-pulse 1s ease-in-out infinite alternate;
}
@keyframes eruption-pulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.2); filter: brightness(1.4); }
}

.eruption-legend {
    background: rgba(16, 21, 38, 0.92); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px; padding: 10px 14px;
    font-family: -apple-system, sans-serif; font-size: 11px; color: #ccc;
    animation: impact-appear 0.3s ease-out forwards;
}
.eruption-legend div { margin: 2px 0; }

/* Volcano impact labels */
.volcano-impact-label {
    background: rgba(20, 20, 40, 0.92);
    border: 1px solid rgba(255, 152, 0, 0.4);
    border-radius: 8px; padding: 6px 10px;
    font-family: -apple-system, sans-serif; font-size: 12px; color: #e0e0e0;
    white-space: nowrap; box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    pointer-events: none; animation: impact-appear 0.4s ease-out forwards;
}

/* Volcano affected city labels */
.volcano-city-label {
    background: rgba(20, 15, 30, 0.94);
    border-radius: 8px; padding: 6px 10px;
    font-family: -apple-system, sans-serif; font-size: 11px; color: #e0e0e0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    pointer-events: none; animation: impact-appear 0.4s ease-out forwards;
    max-width: 220px; white-space: normal;
}
.volcano-city-label.critical { border: 1px solid rgba(255, 23, 68, 0.6); }
.volcano-city-label.heavy { border: 1px solid rgba(255, 152, 0, 0.5); }
.volcano-city-label.light { border: 1px solid rgba(255, 193, 7, 0.4); }
.vcl-row { font-size: 10px; color: #aaa; margin: 1px 0; }
.vcl-info { font-size: 9px; color: #888; margin-top: 3px; line-height: 1.3; }

/* ==================== TYPHOON POPUP & ANIMATION ==================== */
.typhoon-popup { font-family: -apple-system, sans-serif; min-width: 240px; }
.typhoon-popup-title { font-size: 14px; font-weight: bold; }
.typhoon-popup-info { font-size: 11px; color: #555; margin: 2px 0; }
.typhoon-popup-deaths { font-size: 11px; color: #c0392b; font-weight: bold; margin: 2px 0; }
.typhoon-popup-desc { font-size: 10px; color: #555; margin-top: 4px; }

.typhoon-city-impact { margin-top: 6px; }
.city-impact-table { width: 100%; font-size: 10px; border-collapse: collapse; }
.city-impact-table th { text-align: left; color: #888; font-weight: normal; padding: 2px 4px; border-bottom: 1px solid #ddd; }
.city-impact-table td { padding: 2px 4px; }

.typhoon-animate-btn {
    display: block; width: 100%; margin-top: 6px; padding: 4px;
    background: #9b59b6; color: white; border: none; border-radius: 4px;
    font-size: 10px; cursor: pointer;
}
.typhoon-animate-btn:hover { background: #8e44ad; }

/* Typhoon animation */
.typhoon-moving-icon {
    font-size: 32px; text-shadow: 0 0 15px #9b59b6, 0 0 30px #7b1fa2;
    animation: typhoon-spin 2s linear infinite;
}
@keyframes typhoon-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.typhoon-anim-legend {
    background: rgba(16, 21, 38, 0.92); border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: 10px; padding: 10px 14px;
    font-family: -apple-system, sans-serif; font-size: 11px; color: #ccc;
    animation: impact-appear 0.3s ease-out forwards;
}
.typhoon-anim-legend div { margin: 2px 0; }

.typhoon-impact-label {
    background: rgba(20, 10, 40, 0.92);
    border: 1px solid rgba(155, 89, 182, 0.4);
    border-radius: 8px; padding: 6px 10px;
    font-family: -apple-system, sans-serif; font-size: 12px; color: #e0e0e0;
    white-space: nowrap; box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    pointer-events: none; animation: impact-appear 0.4s ease-out forwards;
}

/* ==================== FLOOD & LANDSLIDE POPUPS ==================== */
.flood-popup, .landslide-popup, .crime-popup, .health-popup,
.crime-stat-popup, .health-stat-popup {
    font-family: -apple-system, sans-serif; min-width: 220px;
}

@media (max-width: 768px) {
    #sidebar { position: fixed; top: 0; left: 0; width: 300px; height: 100vh; transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #toggle-sidebar { display: block; }
    #map { width: 100vw; }
}
#sidebar::-webkit-scrollbar, #rankings::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb, #rankings::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
