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

:root {
    --bg: #0a0a0a;
    --surface: rgba(255, 255, 255, 0.06);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-dim: rgba(255, 255, 255, 0.35);
    --accent: #3b82f6;
    --accent-muted: rgba(59, 130, 246, 0.8);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Header */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.header-right {
    display: flex;
    gap: 6px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--surface);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background 0.15s;
}

.icon-btn:hover {
    background: var(--surface-hover);
}

/* Map */

#map-container {
    flex: 1;
    position: relative;
    margin: 4px 12px;
    border-radius: var(--radius);
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    background: #111;
}

/* Leaflet overrides */

.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.6) !important;
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: rgba(255, 255, 255, 0.5) !important;
}

.leaflet-control-zoom a {
    background: rgba(20, 20, 20, 0.85) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(40, 40, 40, 0.9) !important;
}

/* Overlays */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    background: rgba(0, 0, 0, 0.5);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 24px 32px;
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.overlay-content p {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

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

.progress-bar-track {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.15s linear;
}

.percent {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
    margin-bottom: 0 !important;
}

/* Controls */

#controls {
    flex-shrink: 0;
    padding: 10px 16px 8px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
}

/* Region picker */

#region-picker {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#region-picker::-webkit-scrollbar {
    display: none;
}

.region-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.group-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    white-space: nowrap;
}

.region-btn {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1.5px solid transparent;
    border-radius: 20px;
    padding: 8px 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
}

.region-btn:hover {
    background: var(--surface-hover);
    color: rgba(255, 255, 255, 0.7);
}

.region-btn.selected {
    background: var(--accent-muted);
    color: #fff;
    border-color: var(--accent);
}

/* Mode picker */

#mode-picker {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 6px 0;
}

.mode-btn {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.mode-btn:hover {
    background: var(--surface-hover);
}

.mode-btn.selected {
    background: var(--accent);
    color: #fff;
}

/* Animation controls */

#animation-controls {
    padding: 8px 0 4px;
}

#animation-controls.hidden {
    display: none;
}

#scrubber-container {
    padding: 10px 0;
    cursor: pointer;
}

#scrubber-track {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

#scrubber-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.05s linear;
}

#scrubber-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: left 0.05s linear, transform 0.15s;
}

#scrubber-container:active #scrubber-thumb {
    transform: translate(-50%, -50%) scale(1.3);
}

.anim-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s;
}

.play-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.play-btn .hidden {
    display: none;
}

.speed-picker {
    display: flex;
    gap: 4px;
}

.speed-btn {
    font-size: 0.6875rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.speed-btn:hover {
    color: rgba(255, 255, 255, 0.6);
}

.speed-btn.selected {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* Ad container */

#ad-container {
    flex-shrink: 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* Info modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    background: #1a1a1a;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.info-section {
    margin-bottom: 20px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.info-section p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.info-section.source p {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Responsive */

@media (max-width: 600px) {
    header {
        padding: 8px 12px 6px;
    }

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

    #map-container {
        margin: 4px 8px;
    }

    #controls {
        padding: 8px 12px 6px;
    }

    .region-btn {
        font-size: 0.6875rem;
        padding: 7px 12px;
    }
}
