:root {
    --bg-main: #0f172a;
    --bg-panel: #1e293b;
    --bg-card: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --border: #475569;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --border-radius: 8px;
    
    /* Pilot colors */
    --color-pilot-1: #ef4444;
    --color-pilot-2: #3b82f6;
    --color-pilot-3: #22c55e;
    --color-pilot-4: #eab308;
    --color-pilot-5: #a855f7;
    --color-pilot-6: #f97316;
    --color-pilot-7: #14b8a6;
    --color-pilot-8: #ec4899;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 580px; /* Increased default width for table */
    min-width: 300px;
    max-width: 800px;
    height: 100%;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    box-shadow: var(--shadow);
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed {
    /* Set by JS dynamically, fallback to hide completely */
    margin-left: -580px;
}

.sidebar.collapsed + #sidebar-resizer {
    display: none;
}

/* Resizer */
.resizer {
    width: 6px;
    background-color: transparent;
    cursor: col-resize;
    z-index: 20;
    transition: background-color 0.2s;
}
.resizer:hover, .resizer.dragging {
    background-color: var(--accent);
}

/* Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    left: 580px; /* Adjusted dynamically in JS */
    z-index: 30;
    background-color: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 4px 4px 0;
    width: 24px;
    height: 40px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: left 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: var(--border);
}

.sidebar-header {
    margin-bottom: 24px;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Controls */
.control-group {
    margin-bottom: 24px;
}

.control-group h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.task-controls {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    width: 100%;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}
.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background-color: var(--border);
}
.btn-secondary.danger:hover {
    background-color: var(--danger);
    border-color: var(--danger);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-card);
    transition: background-color 0.2s;
}
.btn-icon:hover {
    background-color: var(--border);
}

/* Pilot Stats Table */
.pilot-stats-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.pilot-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pilot-list-header h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0;
}

.sort-select {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px;
    font-size: 0.75rem;
}

select optgroup {
    background-color: var(--bg-panel);
    color: var(--accent);
    font-weight: 700;
    font-style: normal;
}

select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}


.table-container {
    flex: 1;
    overflow-y: auto;
}

.pilot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.pilot-table th {
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    text-align: left;
    padding: 8px 4px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    z-index: 2;
}

.pilot-table th .unit {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.pilot-table td {
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.pilot-table th:first-child,
.pilot-table td:first-child {
    min-width: 130px;
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pilot-row {
    transition: background-color 0.1s;
    cursor: pointer;
}

.pilot-row:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.pilot-row.expanded {
    background-color: rgba(255, 255, 255, 0.02);
}

.pilot-details-row {
    background-color: rgba(15, 23, 42, 0.3);
}

.pilot-details-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px 12px;
    padding: 8px 12px;
    background: rgba(30, 41, 59, 0.25);
    border-radius: 4px;
    margin: 4px 8px 8px 8px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pilot-details-content .detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pilot-details-content .detail-item strong {
    color: var(--text-main);
    font-weight: 500;
    margin-right: 8px;
}

.pilot-details-content .detail-item span {
    font-weight: 600;
}

.pilot-color-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.stat-value {
    font-family: monospace;
    font-size: 0.85rem;
}

.tactics-row {
    background-color: rgba(0, 0, 0, 0.2);
}
.tactics-row td {
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.tactics-row strong {
    color: var(--text-main);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
    height: 100%;
}

/* Map Layout */
.map-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

#map {
    flex: 1;
    width: 100%;
    min-height: 150px;
}

.leaflet-container {
    background: var(--bg-main);
}

/* Vertical Resizer between Map and Side View */
#vertical-resizer {
    height: 6px;
    background-color: var(--border);
    cursor: row-resize;
    z-index: 20;
    transition: background-color 0.2s;
}
#vertical-resizer:hover, #vertical-resizer.dragging {
    background-color: var(--accent);
}

/* Side View Panel */
#side-view-container {
    height: 200px; /* Default height */
    min-height: 100px;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
#side-view-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Timeline Panel */
.timeline-panel {
    height: 90px;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px 24px 22px 24px;
    z-index: 10;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.playback-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 12px;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}
.speed-control select {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
}

.time-display {
    font-family: monospace;
    font-size: 1.125rem;
    font-weight: 600;
    background-color: var(--bg-card);
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--border);
    min-width: 100px;
    text-align: center;
}

.scrubber-container {
    width: 100%;
}
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 8px; cursor: pointer;
    background: var(--bg-card); border-radius: 4px; border: 1px solid var(--border);
}
input[type=range]::-webkit-slider-thumb {
    height: 20px; width: 20px; border-radius: 50%;
    background: var(--accent); cursor: pointer; -webkit-appearance: none;
    margin-top: -7px; box-shadow: 0 0 4px rgba(0,0,0,0.5); transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type=range]:disabled::-webkit-slider-thumb { background: var(--text-muted); cursor: not-allowed; }

.pilot-marker-icon { background: none; border: none; }
.pilot-marker-dot {
    width: 36px; height: 36px; position: absolute; top: -18px; left: -18px;
    transform-origin: 50% 50%;
    transition: transform 0.1s linear; /* Smooth heading rotation transition */
}
.pilot-marker-label {
    position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.7); color: white; padding: 2px 6px; border-radius: 4px;
    font-size: 10px; font-weight: bold; white-space: nowrap;
}
.liftsink-active .pilot-marker-label {
    display: none !important;
}

/* Custom styling for Leaflet controls to match premium dark/glassmorphic theme */
.leaflet-control-layers {
    background: rgba(30, 41, 59, 0.8) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    color: var(--text-main) !important;
    font-family: inherit !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}
.leaflet-control-layers-toggle {
    filter: invert(1); /* Invert icon color to white for dark mode */
}
.leaflet-control-layers-expanded {
    padding: 8px 12px !important;
}
.leaflet-control-layers label {
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    cursor: pointer;
    margin-bottom: 4px;
}
.leaflet-control-scale {
    margin-bottom: 12px !important;
    margin-left: 12px !important;
}
.leaflet-control-scale-line {
    background: rgba(30, 41, 59, 0.6) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--border) !important;
    border-top: none !important;
    color: var(--text-main) !important;
    font-family: inherit !important;
    font-size: 9px !important;
    font-weight: bold !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.btn-side-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(30, 41, 59, 0.75);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-side-overlay:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}
.btn-side-overlay:active {
    transform: scale(0.95);
}

/* Track Loader — full-screen photo overlay */
.track-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(to bottom, rgba(5, 10, 25, 0.35) 0%, rgba(5, 10, 25, 0.55) 100%),
        url('PXL_20240905_014351886.jpg') center center / cover no-repeat;
    transition: opacity 0.6s ease;
}
.track-loader.hidden {
    opacity: 0;
    pointer-events: none;
}
.track-loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    background: rgba(10, 18, 40, 0.65);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border-radius: 16px;
    padding: 36px 48px;
    min-width: 320px;
    max-width: 90vw;
    color: #fff;
    text-align: center;
}
.track-loader-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.track-loader-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: rgba(255,255,255,0.8);
    min-height: 20px;
}
#track-loader-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}
.loader-bar-bg {
    width: 100%;
    height: 5px;
    background: rgba(255,255,255,0.15);
    border-radius: 99px;
    overflow: hidden;
}
.loader-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent, #3b82f6), #60a5fa);
    border-radius: 99px;
    transition: width 0.15s ease-out;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.6);
}
.loader-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top: 2px solid #60a5fa;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Right Stats Panel */
.right-panel-toggle {
    position: fixed;
    right: 16px;
    top: 16px;
    z-index: 999;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(8px);
}

.right-panel-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.right-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    height: 100vh;
    z-index: 1001; /* Overlay map controls and toggle buttons */
    background: rgba(15, 23, 42, 0.92); /* slate-900 with opacity */
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateX(0);
}

.right-panel.collapsed {
    transform: translateX(100%);
}

.right-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.right-panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.btn-close-panel {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    line-height: 1;
}

.btn-close-panel:hover {
    color: var(--text-main);
}

.right-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Custom scrollbar for right panel content */
.right-panel-content::-webkit-scrollbar {
    width: 6px;
}
.right-panel-content::-webkit-scrollbar-track {
    background: transparent;
}
.right-panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.right-panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.panel-section {
    background: rgba(30, 41, 59, 0.4); /* subtle slate-800 card */
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
}

.panel-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    margin-top: 0;
}

/* Stats Summary Card */
.stats-summary-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.correlation-coef {
    font-size: 2rem;
    font-weight: 700;
    color: #a5b4fc; /* light indigo */
    font-family: var(--font-mono);
    line-height: 1.2;
}

.correlation-desc {
    font-size: 0.875rem;
    color: var(--text-main);
    margin-top: 6px;
    font-weight: 500;
}

/* Optimal Insight Card */
.optimal-insight-card {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(202, 138, 4, 0.1) 100%);
    border: 1px solid rgba(234, 179, 8, 0.25);
}

.optimal-insight-card h4 {
    margin: 0 0 6px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fde047; /* yellow-300 */
}

.optimal-insight-card p {
    margin: 0;
    font-size: 0.825rem;
    color: var(--text-main);
    line-height: 1.4;
}

.optimal-insight-card.hidden {
    display: none;
}

/* Stats Panel Tabs */
.stats-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}
.btn-tab {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-tab:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}
.btn-tab.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

/* Chart Wrapper */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resizer-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background-color 0.2s;
}

.resizer-left:hover, .resizer-left.dragging {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* Correlation Table */
.correlation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.correlation-table th, .correlation-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.correlation-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.correlation-table tr:last-child td {
    border-bottom: none;
}

.correlation-table td.coef-val {
    font-family: var(--font-mono);
    font-weight: 600;
}

.strength-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.725rem;
    font-weight: 600;
}

.strength-strong {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.strength-moderate {
    background-color: rgba(234, 179, 8, 0.15);
    color: #fde047;
}

.strength-weak {
    background-color: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
}

/* Custom Leaflet Popup Styling */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.95) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border);
    border-radius: 6px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}
.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid var(--border);
}
.leaflet-popup-content {
    font-family: inherit;
    font-size: 0.825rem;
    line-height: 1.4;
    margin: 12px 16px !important;
}
.leaflet-popup-content strong {
    color: var(--primary);
}
.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-muted) !important;
    padding: 8px 8px 0 0 !important;
}
.leaflet-container a.leaflet-popup-close-button:hover {
    color: var(--text-main) !important;
}

/* Active Task Title Badge */
.active-task-title {
    margin-top: 14px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent); /* blue accent color */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    display: none; /* hidden by default, shown when task loaded */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

/* Settings Gear Button */
.btn-settings-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s ease;
}
.btn-settings-toggle:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.08);
    transform: rotate(45deg);
}

/* Settings Modal Backdrop overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.75); /* transparent slate-900 */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.25s ease;
}
.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* Modal Content Card */
.modal-content {
    background: rgba(30, 41, 59, 0.85); /* slate-800 with alpha */
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5), 0 10px 10px -5px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalScaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Modal Header */
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}
.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
}
.btn-close-modal:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.08);
}

/* Modal Body */
.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Modal settings section cards */
.settings-section {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 16px;
}
.settings-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    margin-top: 0;
}

/* Custom Map Type Switcher Leaflet Control */
.custom-map-type-toggle {
    margin-bottom: 12px !important;
    margin-right: 12px !important;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border-radius: 8px;
    border: 2px solid #ffffff;
    overflow: hidden;
    width: 74px;
    height: 74px;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.custom-map-type-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    border-color: var(--accent);
}
.map-type-thumbnail-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}
#map-type-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.map-type-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(2px);
    color: #ffffff;
    font-size: 9px;
    font-weight: bold;
    text-align: center;
    padding: 3px 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    letter-spacing: 0.03em;
}

/* Side View Toolbars overlay */
.side-view-tools {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 10;
    pointer-events: auto;
}
/* Reset button inside toolbar should flow inline, not be absolutely positioned */
.side-view-tools .btn-side-overlay {
    position: static;
    padding: 4px 10px;
    font-size: 0.75rem;
}

.side-view-zoom-group {
    display: flex;
    align-items: center;
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    gap: 4px;
}
.zoom-label {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    user-select: none;
    margin-right: 2px;
}
.zoom-btn {
    position: static !important; /* Override position absolute on .btn-side-overlay */
    padding: 2px 8px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 3px !important;
    line-height: 1;
}
.zoom-btn:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #ffffff !important;
}/* Coin Animation */
@keyframes coinPop {
    0% { transform: translateY(0) scale(0.5); opacity: 1; }
    50% { transform: translateY(-40px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

.coin-popup {
    position: absolute;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #ffd700 30%, #b8860b 80%);
    border: 2px solid #daa520;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8), inset 0 0 5px rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
    pointer-events: none;
    z-index: 10000;
    animation: coinPop 0.8s ease-out forwards;
}
