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

body {
    font-family: 'Noto Sans JP', sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Header */
.header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-bottom: 3px solid #667eea;
}

.top-credit {
    font-size: 16px;
    font-weight: 700;
    color: #1a237e;
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.title {
    font-size: 28px;
    font-weight: 900;
    color: #1a237e;
    margin-bottom: 5px;
    /* text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); */
}

.subtitle {
    font-size: 14px;
    color: #666;
    font-weight: 400;
}

/* Legend */
.legend {
    position: absolute;
    top: 170px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-width: 200px;
    max-width: 220px;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
}

.legend h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1a237e;
    margin: 0;
    /* margin-bottom removed */
    text-align: left;
}

.legend-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #1a237e;
    padding: 0 5px;
    display: none;
    /* Hidden by default on desktop */
}

/* For mobile toggle animation */
.legend.collapsed .legend-items {
    display: none;
}


.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-color {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.legend-label {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

/* Map */
#map {
    position: absolute;
    top: 0;
    /* Cover everything */
    left: 0;
    right: 0;
    bottom: 0;
    /* Full height */
    z-index: 1;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 35, 126, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    margin-top: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Error Message */
.error-message {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: rgba(211, 47, 47, 0.95);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 20px 40px;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-weight: 700;
    text-align: center;
}

/* Time Slider Container */
.time-slider-container {
    position: absolute;
    bottom: 30px;
    /* Raise slightly above footer */
    left: 0;
    right: 0;
    z-index: 1000;
    background: transparent !important;
    padding: 10px 40px;
    box-shadow: none !important;
    border: none !important;
    pointer-events: none;
    /* Allow clicking through empty space */
}

.time-slider-content {
    pointer-events: none;
    /* Allow clicks to pass through container and labels */
    max-width: 800px;
    margin: 0 auto;
    background: transparent !important;
    padding: 15px 40px;
}

/* Leaflet Overrides for Transparency */
.leaflet-bottom,
.leaflet-control {
    background: transparent !important;
    box-shadow: none !important;
}

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.5) !important;
    padding: 0 5px;
    border-radius: 4px;
}



.time-display {
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    /* White text */
    text-align: center;
    margin-bottom: 5px;
    /* Strong black outline for visibility on any background */
    text-shadow:
        2px 2px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

.time-slider {
    pointer-events: auto;
    /* Only the slider interaction is captured */
    width: 100%;
    height: 6px;
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(150, 150, 150, 0.3);
    cursor: pointer;
    transition: opacity 0.2s;
    box-shadow: none;
}

.time-slider:hover {
    opacity: 0.9;
}

.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #D1D5DB;
    cursor: pointer;
    box-shadow: none;
    border: 1px solid #888;
    transition: transform 0.2s;
}

.time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.time-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #D1D5DB;
    cursor: pointer;
    box-shadow: none;
    border: 1px solid #888;
    transition: transform 0.2s;
}

.time-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.time-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 14px;
    color: #fff;
    font-weight: 700;
    /* Strong black outline */
    text-shadow:
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

.slider-instruction {
    text-align: center;
    font-size: 18px;
    color: #333;
    margin-top: 5px;

}

/* Custom Popup Styling */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(102, 126, 234, 0.3);
    padding: 0;
}

.leaflet-popup-content {
    margin: 20px;
    font-family: 'Noto Sans JP', sans-serif;
}

.popup-title {
    font-size: 20px;
    font-weight: 900;
    color: #1a237e;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.popup-temp {
    font-size: 36px;
    font-weight: 900;
    text-align: center;
    margin: 15px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.popup-details {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.popup-detail-item {
    text-align: center;
}

.popup-detail-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 500;
}

.popup-detail-value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.temp-high {
    color: #d32f2f;
}

.temp-low {
    color: #2196f3;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.98);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 15px 20px;
    }

    .title {
        font-size: 20px;
    }

    .subtitle {
        font-size: 12px;
    }

    #map {
        top: 80px;
    }

    .legend {
        top: 90px;
        left: 10px;
        right: 10px;
        padding: 15px;
        max-width: none;
    }

    .legend h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .legend-items {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .legend-color {
        width: 25px;
        height: 18px;
    }

    .legend-label {
        font-size: 11px;
    }

    .error-message {
        top: 100px;
        left: 20px;
        right: 20px;
        transform: none;
        padding: 15px 20px;
        font-size: 14px;
    }

    /* Mobile specific legend styles */
    .legend-toggle {
        display: block;
        /* Show toggle button on mobile */
    }

    .legend-header {
        margin-bottom: 0;
        /* Align perfectly when collapsed */
    }

    .legend-items {
        margin-top: 10px;
    }

    /* Collapsible logic */
    .legend-items.collapsed {
        display: none;
    }

    .toggle-icon {
        display: inline-block;
        transition: transform 0.3s;
    }

    .legend.collapsed .toggle-icon {
        transform: rotate(180deg);
    }

    /* Bigger slider thumb for mobile */
    .time-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .time-slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    .time-slider-container {
        padding: 10px 20px;
        /* More padding on sides */
    }

    /* Popup mobile optimization */
    .leaflet-popup-content {
        margin: 15px;
        max-width: 250px !important;
        /* Force max-width */
    }

    /* Hide specific temperature labels on low zoom */
    .map-low-zoom .temp-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 18px;
    }

    .popup-title {
        font-size: 18px;
    }

    .popup-temp {
        font-size: 28px;
    }

    .popup-detail-value {
        font-size: 16px;
    }
}

/* Temperature Labels */
.temp-label {
    background: transparent !important;
    border: none !important;
}

.temp-label-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 900;
    color: #1a237e;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.3);
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Credit Footer */
.credit-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    padding: 10px 20px;
    text-align: center;
}

.credit-footer p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 400;
    margin: 0;
}

.credit-footer a {
    color: #90caf9;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.credit-footer a:hover {
    color: #64b5f6;
    text-decoration: underline;
}