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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #000010;
    color: #fff;
    overflow: hidden;
}

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Header */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(0, 0, 16, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

#logo {
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

#header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #ffd700;
}

#header-links {
    display: flex;
    gap: 12px;
    align-items: center;
}

#header-links a {
    color: #aaa;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

#header-links a:hover {
    color: #fff;
}

#lang-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

#lang-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Panels */
.panel {
    position: fixed;
    background: rgba(0, 0, 16, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 16px;
    z-index: 50;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

.panel h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #ffd700;
}

.panel h4 {
    font-size: 12px;
    font-weight: 600;
    margin: 16px 0 8px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Layer Panel */
#layer-panel {
    top: 64px;
    left: 16px;
    min-width: 180px;
}

#layer-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    transition: opacity 0.2s;
}

#layer-panel label:hover {
    opacity: 0.8;
}

#layer-panel input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #ffd700;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.color-dot.baseline {
    background: #ffb347;
    box-shadow: 0 0 6px #ffb347;
}

.color-dot.new {
    background: #00aaff;
    box-shadow: 0 0 6px #00aaff;
}

.color-dot.lit {
    background: #ff44ff;
    box-shadow: 0 0 6px #ff44ff;
}

.color-dot.heatmap {
    background: linear-gradient(90deg, #ff6600, #ffff00);
}

/* Time Slider Panel */
#time-panel {
    top: 220px;
    left: 16px;
    min-width: 180px;
}

#time-slider-container {
    margin-bottom: 12px;
}

#time-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #ffd700;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    transition: transform 0.1s;
}

#time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#time-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #ffd700;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

#time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

#time-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

#time-current-date {
    font-weight: 600;
    color: #ffd700;
}

#time-lamp-count {
    font-size: 12px;
    color: #00aaff;
}

#time-controls {
    display: flex;
    gap: 8px;
}

#time-controls button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

#time-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

#time-controls button.playing {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
    color: #ffd700;
}

#time-controls button svg {
    flex-shrink: 0;
}

/* Stats Panel */
#stats-panel {
    top: 64px;
    right: 16px;
    min-width: 200px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.stat-row span:last-child {
    font-weight: 600;
    color: #ffd700;
}

.stat-row.updated span:last-child {
    font-weight: 400;
    color: #888;
    font-size: 12px;
}

#stat-new {
    color: #00aaff !important;
}

#leaderboard {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboard-toggle {
    display: none;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffd700;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-top: 8px;
    transition: all 0.2s;
}

#leaderboard-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

#leaderboard-toggle.expanded {
    margin-bottom: 8px;
}

#leaderboard li {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 13px;
}

#leaderboard li .rank {
    color: #888;
    width: 20px;
}

#leaderboard li .user {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
}

#leaderboard li .user:hover {
    color: #00aaff;
}

#leaderboard li .count {
    color: #00aaff;
    font-weight: 500;
    margin-left: 8px;
}

/* Loading */
#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 200;
    color: #888;
}

#loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 215, 0, 0.2);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* MapLibre overrides */
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
    bottom: 8px;
}

.maplibregl-ctrl-attrib {
    background: rgba(0, 0, 16, 0.7) !important;
    color: #888 !important;
    font-size: 11px !important;
}

.maplibregl-ctrl-attrib a {
    color: #aaa !important;
}

.maplibregl-popup-content {
    background: rgba(0, 0, 16, 0.95);
    color: #fff;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    max-width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.maplibregl-popup-close-button {
    color: #888;
    font-size: 18px;
    padding: 4px 8px;
}

.maplibregl-popup-close-button:hover {
    color: #fff;
    background: transparent;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
    border-top-color: rgba(0, 0, 16, 0.95);
}

.popup-title {
    font-weight: 600;
    color: #ffd700;
    margin-bottom: 8px;
}

.popup-tags {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    margin-bottom: 12px;
}

.popup-tags .key {
    color: #888;
}

.popup-tags .value {
    color: #fff;
}

.popup-link {
    display: inline-block;
    color: #00aaff;
    text-decoration: none;
    font-size: 12px;
}

.popup-link:hover {
    text-decoration: underline;
}

.popup-new-badge {
    display: inline-block;
    background: #00ff88;
    color: #000;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 600px) {
    #layer-panel {
        top: 64px;
        left: 8px;
        right: auto;
        bottom: auto;
        min-width: auto;
    }

    #time-panel {
        top: auto;
        bottom: 8px;
        left: 8px;
        right: 8px;
        min-width: auto;
    }

    #time-panel h3 {
        display: none;
    }

    #time-display {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    #stats-panel {
        top: 64px;
        right: 8px;
        left: auto;
        min-width: auto;
        max-width: 160px;
        bottom: auto;
    }

    .panel {
        padding: 10px;
        font-size: 12px;
    }

    .panel h3 {
        margin-bottom: 8px;
        font-size: 12px;
    }

    #leaderboard-section {
        display: none;
    }

    #leaderboard-section.expanded {
        display: block;
    }

    #leaderboard-section h4 {
        display: block;
        margin-top: 0;
    }

    #leaderboard-toggle {
        display: block;
    }

    #time-controls button {
        padding: 6px;
    }

    #time-slider-container {
        margin-bottom: 8px;
    }
}
