/* ============================================
   MISSILE TRAJECTORY SIMULATOR — DARK THRILLER THEME
   James Bond / Military Command Console UX
   ============================================ */

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

body {
    font-family: 'Courier New', monospace;
    background: #0a0a0f;
    color: #c8d6e5;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

/* --- Sidebar: Dark Command Console --- */
#sidebar {
    width: 360px;
    min-width: 360px;
    padding: 16px;
    overflow-y: auto;
    background: #0d1117;
    border-right: 1px solid #1e3a4f;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* subtle scanline effect */
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 136, 0.015) 2px,
        rgba(0, 255, 136, 0.015) 4px
    );
}

#sidebar h1 {
    color: #ff3333;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 14px;
    border-bottom: 1px solid #ff3333;
    padding-bottom: 8px;
    font-family: 'Courier New', monospace;
}

#theme-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 500;
    background: rgba(13, 17, 23, 0.85);
    border: 2px solid #4a9eff;
    color: #4a9eff;
    font-size: 28px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    backdrop-filter: blur(6px);
    transition: background 0.15s, color 0.15s;
}

#theme-toggle:hover {
    background: #4a9eff;
    color: #0d1117;
}

#sidebar section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#sidebar label {
    color: #4a9eff;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    font-weight: 600;
}

#sidebar select,
#sidebar input[type="text"] {
    background: #161b22;
    border: 1px solid #30363d;
    color: #c8d6e5;
    font-family: 'Courier New', monospace;
    padding: 8px;
    border-radius: 4px;
    font-size: 14px;
}

#sidebar select:focus,
#sidebar input[type="text"]:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 6px rgba(74, 158, 255, 0.3);
}

.input-row {
    display: flex;
    gap: 6px;
}

.input-row input { flex: 1; }

/* --- Buttons Base --- */
button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

#search-btn {
    background: #1e3a4f;
    color: #4a9eff;
    border: 1px solid #4a9eff;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
}

#search-btn:hover {
    background: #4a9eff;
    color: #0d1117;
}

#pin-btn {
    background: transparent;
    border: 1px solid #4a9eff;
    color: #4a9eff;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}

#pin-btn.active {
    background: #4a9eff;
    color: #0d1117;
}

#pin-btn:hover {
    background: rgba(74, 158, 255, 0.2);
}

/* --- Example address chips --- */
#search-examples {
    margin-top: 6px;
    font-size: 11px;
    color: #6c757d;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.example-addr {
    background: transparent;
    border: 1px solid #2a3f55;
    color: #4a9eff;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.example-addr:hover {
    background: rgba(74, 158, 255, 0.12);
}

/* --- Site footer --- */
#site-footer {
    text-align: center;
    padding: 4px 0 10px;
    font-size: 11px;
    font-weight: bold;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#site-footer a {
    color: #4a9eff;
    text-decoration: none;
}

#site-footer a:hover {
    text-decoration: underline;
}

/* --- Simulate Button: Red Alert --- */
#simulate-btn {
    background: #cc0000;
    color: white;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 16px;
    padding: 12px;
    border: 2px solid #ff0000;
    animation: pulse-border 2s infinite;
}

#simulate-btn:disabled {
    background: #1a1a2e;
    border-color: #333;
    color: #555;
    cursor: not-allowed;
    animation: none;
}

@keyframes pulse-border {
    0%, 100% { border-color: #ff0000; box-shadow: 0 0 5px rgba(255,0,0,0.3); }
    50% { border-color: #ff4444; box-shadow: 0 0 15px rgba(255,0,0,0.5); }
}

/* --- Search Results: Dark --- */
#search-results {
    list-style: none;
    max-height: 180px;
    overflow-y: auto;
    font-size: 13px;
}

#search-results-hint {
    font-size: 11px;
    color: #4a9eff;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 8px 2px;
    opacity: 0.8;
}

#search-results li {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #1e3a4f;
    color: #c8d6e5;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

#search-results li::before {
    content: '\25B6';
    color: #4a9eff;
    font-size: 10px;
    flex-shrink: 0;
}

#search-results li::after {
    content: 'TAP TO SELECT';
    color: #4a9eff;
    font-size: 9px;
    letter-spacing: 1px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.6;
}

#search-results li:hover,
#search-results li:active {
    background: #1e3a4f;
}

#search-results li:active {
    background: #2a4a6f;
}

/* --- Info panels --- */
#missile-info, #launch-coords, #target-info {
    font-size: 13px;
    color: #6c8fa0;
    padding: 6px 0;
}

/* --- Map Container & Split View --- */
#map-container {
    flex: 1;
    position: relative;
}

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

#impact-map {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 100%;
}

#map-container.split-view #map {
    width: 55%;
    height: 100%;
    float: left;
}

#map-container.split-view #impact-map {
    display: block;
    position: relative;
    width: 45%;
    height: 100%;
    float: right;
    border-left: 2px solid #ff0000;
}

.maplibregl-canvas {
    outline: none;
}

/* --- Impact View Toggle Button --- */
.impact-view-toggle {
    position: absolute;
    top: 55px;
    right: 10px;
    z-index: 10;
    background: rgba(13, 17, 23, 0.9);
    color: #4a9eff;
    border: 1px solid #4a9eff;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 3px;
}

.impact-view-toggle:hover {
    background: #4a9eff;
    color: #0d1117;
}

/* --- Target Crosshair (animated) --- */
.target-crosshair {
    width: 40px;
    height: 40px;
    position: relative;
}

.crosshair-ring {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 32px;
    height: 32px;
    border: 2px solid #ff3333;
    border-radius: 50%;
    animation: crosshair-pulse 1.5s infinite;
}

.crosshair-dot {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 4px;
    height: 4px;
    background: #ff0000;
    border-radius: 50%;
}

.crosshair-line {
    position: absolute;
    background: rgba(255, 51, 51, 0.6);
}

.crosshair-h {
    top: 19px;
    left: 0;
    width: 40px;
    height: 2px;
}

.crosshair-v {
    top: 0;
    left: 19px;
    width: 2px;
    height: 40px;
}

@keyframes crosshair-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

/* --- Target Pin (Google Maps-style drop pin) --- */
.target-pin {
    position: relative;
    width: 24px;
    height: 36px;
    animation: pin-drop 0.4s ease-out;
}

.pin-head {
    position: absolute;
    top: 0;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ff0000;
    border: 2px solid #cc0000;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.6);
}

.pin-head::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.9;
}

.pin-stem {
    position: absolute;
    bottom: 0;
    left: 11px;
    width: 2px;
    height: 14px;
    background: linear-gradient(to bottom, #cc0000, transparent);
}

.pin-shadow {
    position: absolute;
    bottom: -3px;
    left: 4px;
    width: 16px;
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    filter: blur(2px);
}

@keyframes pin-drop {
    0% { transform: translateY(-20px); opacity: 0; }
    60% { transform: translateY(2px); opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

/* --- Launch Marker: Pulsing Red --- */
.launch-pulse {
    position: relative;
    width: 20px;
    height: 20px;
}

.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #ff0000;
    border-radius: 50%;
    animation: launch-ping 2s infinite;
}

.pulse-dot {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 8px;
    height: 8px;
    background: #ff0000;
    border-radius: 50%;
    box-shadow: 0 0 6px #ff0000;
}

@keyframes launch-ping {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* --- Launch Site Labels (all-sites mode) --- */
.launch-label .maplibregl-popup-content {
    background: rgba(13, 17, 23, 0.85);
    color: #ff4444;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border: 1px solid #ff4444;
    border-radius: 3px;
    box-shadow: 0 0 6px rgba(255, 68, 68, 0.3);
}
.launch-label .maplibregl-popup-tip { border-top-color: #ff4444; }

/* --- Missile Icon --- */
.missile-icon {
    position: relative;
    width: 12px;
    height: 12px;
}

.missile-dot {
    width: 10px;
    height: 10px;
    background: #ff0000;
    border-radius: 50%;
    box-shadow: 0 0 8px #ff0000, 0 0 20px rgba(255,0,0,0.4);
}

.missile-trail {
    position: absolute;
    top: 3px;
    right: 10px;
    width: 20px;
    height: 4px;
    background: linear-gradient(to left, #ff0000, transparent);
    border-radius: 2px;
}

/* --- Trajectory Chart Container: Dark Glass --- */
#trajectory-chart-container {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    height: 220px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #1e3a4f;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 1000;
}

#trajectory-chart-container canvas {
    width: 100% !important;
    height: 150px !important;
}

/* --- Close Buttons: Dark Red --- */
#close-chart, #close-impact {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #cc0000;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #ff0000;
}

#close-chart:hover, #close-impact:hover {
    background: #ff0000;
}

/* --- Results Section --- */
#results-section h2 {
    font-size: 15px;
    color: #4a9eff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#results-content {
    font-size: 13px;
    line-height: 1.6;
}

#results-content .result-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #1e3a4f;
}

#results-content .result-label { color: #4a9eff; }
#results-content .result-value { font-weight: 600; color: #ff6b6b; font-family: 'Courier New', monospace; }

#results-content .damage-severe { color: #ff0000; }
#results-content .damage-moderate { color: #ff6b35; }
#results-content .damage-light { color: #ffcc00; }

/* --- Animation Controls: Dark --- */
#animation-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

#play-pause-btn {
    background: #1e3a4f;
    color: #4a9eff;
    border: 1px solid #4a9eff;
    width: 32px;
    height: 32px;
    font-size: 14px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#play-pause-btn:hover {
    background: #4a9eff;
    color: #0d1117;
}

#speed-slider {
    width: 80px;
    cursor: pointer;
    accent-color: #4a9eff;
}

#animation-status {
    font-size: 12px;
    color: #00ff88;
    font-family: 'Courier New', monospace;
}

/* --- Missile Marker --- */
.missile-marker {
    font-size: 20px;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
    transition: none;
}

/* --- MapLibre Tooltip: HUD Style --- */
.missile-tooltip .maplibregl-popup-content {
    background: rgba(0, 20, 40, 0.85);
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 4px 8px;
    border: 1px solid #0066ff;
    border-radius: 2px;
    box-shadow: none;
    pointer-events: none;
}

.maplibregl-popup-tip {
    display: none;
}

.maplibregl-popup-close-button {
    display: none;
}

/* --- Impact Diagram Container: Dark --- */
#impact-diagram-container {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    height: 280px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #1e3a4f;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 1001;
    transition: height 0.3s ease, top 0.3s ease, bottom 0.3s ease;
}

#impact-diagram-container.expanded {
    top: 16px;
    bottom: 16px;
    height: auto;
}

#impact-diagram-container.expanded #impact-canvas {
    height: calc(100% - 60px);
}

#impact-diagram-container h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #4a9eff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#impact-canvas {
    width: 100%;
    height: 200px;
}

#shielding-summary {
    font-size: 13px;
    color: #6c8fa0;
    margin-top: 6px;
}

/* Expand button for cross-section */
#expand-impact {
    position: absolute;
    top: 8px;
    right: 80px;
    background: #1e3a4f;
    color: #4a9eff;
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid #4a9eff;
}

#expand-impact:hover {
    background: #4a9eff;
    color: #0d1117;
}

/* Zoom controls for cross-section */
.zoom-controls {
    position: absolute;
    top: 8px;
    right: 170px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#zoom-out-btn,
#zoom-in-btn {
    background: #1e3a4f;
    color: #4a9eff;
    font-size: 14px;
    font-weight: bold;
    padding: 2px 8px;
    border: 1px solid #4a9eff;
    cursor: pointer;
    line-height: 1.2;
}

#zoom-out-btn:hover:not(:disabled),
#zoom-in-btn:hover:not(:disabled) {
    background: #4a9eff;
    color: #0d1117;
}

#zoom-out-btn:disabled,
#zoom-in-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

#zoom-level-label {
    font-size: 11px;
    font-family: monospace;
    color: #4a9eff;
    cursor: pointer;
    user-select: none;
    min-width: 36px;
    text-align: center;
}

#zoom-level-label:hover {
    color: #fff;
    text-decoration: underline;
}

/* Reopen cross-section button (floating on map) */
#reopen-impact {
    display: none;
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 999;
    background: rgba(13, 17, 23, 0.9);
    color: #4a9eff;
    border: 1px solid #4a9eff;
    padding: 8px 14px;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#reopen-impact:hover {
    background: #4a9eff;
    color: #0d1117;
}

/* --- Out-of-Range Warning: Dark Red --- */
#range-warning {
    background: rgba(204, 0, 0, 0.15);
    border: 1px solid #cc0000;
    border-left: 4px solid #ff0000;
    color: #ff6b6b;
    padding: 10px 12px;
    margin: 8px 0;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
}

#range-warning strong {
    color: #ff0000;
    font-size: 14px;
}

/* --- Saved Addresses --- */
#saved-addresses {
    margin-top: 4px;
}

#saved-addresses label {
    font-size: 10px;
    color: #4a9eff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.saved-addr {
    padding: 8px 12px;
    font-size: 12px;
    color: #8899aa;
    cursor: pointer;
    border-bottom: 1px solid #1e3a4f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

.saved-addr::before {
    content: '\25B6';
    color: #4a9eff;
    font-size: 9px;
    flex-shrink: 0;
}

.saved-addr:hover,
.saved-addr:active {
    background: #161b22;
    color: #c8d6e5;
}

/* --- Disabled missile option --- */
#missile-select option:disabled {
    color: #555 !important;
    font-style: italic;
}

/* --- Shielding Banner (prominent line-of-sight indicator) --- */
#shielding-banner {
    display: none;
    padding: 22px 18px;
    margin: 12px 0;
    border-radius: 8px;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    animation: shielding-flash 2s ease-in-out;
}

#shielding-banner.exposed {
    display: block;
    background: rgba(220, 53, 69, 0.25);
    border: 3px solid #dc3545;
    color: #ff4444;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.4);
}

#shielding-banner.shielded {
    display: block;
    background: rgba(40, 167, 69, 0.2);
    border: 3px solid #28a745;
    color: #4cff72;
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.4);
}

#shielding-banner .banner-icon {
    font-size: 52px;
    display: block;
    margin-bottom: 10px;
}

#shielding-banner .banner-detail {
    font-size: 26px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    opacity: 0.85;
    margin-top: 10px;
}

@keyframes shielding-flash {
    0% { opacity: 0; transform: scale(0.95); }
    30% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

/* --- Mobile Tab Bar (hidden on desktop) --- */
#mobile-tab-bar {
    display: none;
}

/* --- Mobile Simulate FAB (hidden on desktop) --- */
#mobile-sim-fab {
    display: none;
}

/* --- Missile range prompt --- */
#missile-range-prompt {
    color: #ff4444;
    font-size: 12px;
    margin-top: 4px;
    padding: 6px 8px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.35);
    border-radius: 4px;
    line-height: 1.4;
}

@keyframes section-flash {
    0%, 100% { box-shadow: none; }
    25%, 75% { box-shadow: 0 0 0 2px #ff3333, 0 0 12px rgba(255, 51, 51, 0.4); }
}

.section-flash {
    animation: section-flash 1.5s ease;
    border-radius: 4px;
}

/* --- Utility --- */
.hidden { display: none !important; }

@keyframes overlay-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-14px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Shielding Center-Screen Overlay --- */
#shielding-overlay {
    position: fixed;
    top: 38%;
    left: calc(50% + 160px); /* centered in map area (sidebar ~320px) */
    transform: translateX(-50%);
    z-index: 1100;
    width: min(420px, 90vw);
    padding: 28px 32px 24px;
    border-radius: 10px;
    background: rgba(10, 12, 20, 0.93);
    backdrop-filter: blur(8px);
    font-family: 'Courier New', monospace;
    text-align: center;
    animation: overlay-in 0.3s ease-out;
    pointer-events: all;
}

#shielding-overlay.hidden {
    display: none;
}

#shielding-overlay.exposed {
    border: 3px solid #dc3545;
    color: #ff4444;
    box-shadow: 0 0 40px rgba(220, 53, 69, 0.5);
}

#shielding-overlay.shielded {
    border: 3px solid #28a745;
    color: #4cff72;
    box-shadow: 0 0 40px rgba(40, 167, 69, 0.5);
}

#shielding-overlay-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    padding: 0;
}

#shielding-overlay-close:hover {
    opacity: 1;
}

#shielding-overlay .overlay-icon {
    display: block;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

#shielding-overlay .overlay-body {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#shielding-overlay .overlay-detail {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.8;
    text-transform: none;
    letter-spacing: 0;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    /* Mobile tab bar */
    #mobile-tab-bar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 3000;
        height: 44px;
        background: #0d1117;
        border-bottom: 2px solid #1e3a4f;
    }

    .m-tab {
        flex: 1;
        background: transparent;
        color: #6c8fa0;
        border: none;
        border-right: 1px solid #1e3a4f;
        border-radius: 0;
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        padding: 6px 4px;
        font-family: 'Courier New', monospace;
        cursor: pointer;
        line-height: 1.2;
    }

    .m-tab:last-child { border-right: none; }

    .m-tab.active {
        background: rgba(74, 158, 255, 0.15);
        color: #4a9eff;
        border-bottom: 2px solid #4a9eff;
    }

    .m-tab.m-tab-locked {
        opacity: 0.35;
        cursor: default;
    }

    /* Theme toggle moves below tab bar */
    #theme-toggle {
        top: 52px;
        right: 8px;
        z-index: 2500;
        font-size: 20px;
        padding: 5px 10px;
    }

    #app {
        flex-direction: column;
        position: relative;
        padding-top: 44px;
    }

    #sidebar {
        position: fixed;
        top: 44px;
        left: 0;
        right: 0;
        width: 100%;
        min-width: unset;
        max-height: calc(100vh - 44px);
        z-index: 1500;
        border-right: none;
        border-bottom: 2px solid #1e3a4f;
        padding: 12px 16px;
        gap: 12px;
        transition: transform 0.3s ease;
    }

    #sidebar.collapsed {
        transform: translateY(-100%);
    }

    #sidebar h1 {
        font-size: 12px;
        padding-bottom: 6px;
    }

    #map-container {
        width: 100%;
        height: calc(100vh - 44px);
        min-height: unset;
    }

    /* Floating simulate button on map */
    #mobile-sim-fab {
        position: absolute;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 900;
        background: #cc0000;
        color: white;
        border: 2px solid #ff0000;
        padding: 10px 24px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 2px;
        text-transform: uppercase;
        font-family: 'Courier New', monospace;
        border-radius: 24px;
        box-shadow: 0 4px 16px rgba(255, 0, 0, 0.4);
        white-space: nowrap;
        display: none;
        animation: pulse-border 2s infinite;
    }

    #mobile-sim-fab.fab-visible {
        display: block;
    }

    /* Larger touch targets */
    #sidebar select,
    #sidebar input[type="text"] {
        padding: 12px 10px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    button {
        padding: 12px 18px;
        font-size: 15px;
    }

    #search-btn {
        padding: 12px 14px;
        font-size: 13px;
    }

    #simulate-btn {
        padding: 14px;
        font-size: 15px;
    }

    #search-results li {
        padding: 12px 12px;
        font-size: 14px;
    }

    #search-results li::after {
        content: 'TAP';
        font-size: 10px;
    }

    .saved-addr {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Overlays on mobile */
    #trajectory-chart-container {
        bottom: 8px;
        left: 8px;
        right: 8px;
        height: 180px;
    }

    #trajectory-chart-container canvas {
        height: 120px !important;
    }

    #impact-diagram-container {
        bottom: 8px;
        left: 8px;
        right: 8px;
        height: 240px;
    }

    #impact-canvas {
        height: 160px;
    }

    /* On mobile, split view shows one map at a time (toggled) */
    #map-container.split-view #map {
        width: 100%;
        height: 100%;
        float: none;
    }

    #map-container.split-view #impact-map {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        float: none;
        border-left: none;
        border-top: none;
        z-index: 5;
        display: none;
    }

    #map-container.split-view #impact-map.mobile-active {
        display: block;
    }

    /* Reopen button replaced by X-Section tab on mobile */
    #reopen-impact {
        display: none !important;
    }

    /* Expand button on mobile */
    #expand-impact {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Close buttons larger for touch */
    #close-chart, #close-impact {
        padding: 8px 14px;
        font-size: 14px;
    }

    /* Shielding banner */
    #shielding-banner {
        font-size: 28px;
        padding: 16px 14px;
    }

    #shielding-banner .banner-icon { font-size: 40px; }
    #shielding-banner .banner-detail { font-size: 20px; }

    /* Info panels */
    #missile-info, #launch-coords, #target-info {
        font-size: 12px;
    }

    /* Impact view toggle */
    .impact-view-toggle {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Cross-section fullscreen on mobile */
    #map-container.cross-section-active #impact-diagram-container {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        border-radius: 0;
        z-index: 10;
    }

    #map-container.cross-section-active #impact-canvas {
        height: calc(100% - 90px);
    }

    #map-container.cross-section-active #map,
    #map-container.cross-section-active #impact-map {
        visibility: hidden;
    }

    #shielding-overlay {
        left: 50%; /* full-width center on mobile — no sidebar */
        top: 30%;
        width: min(380px, 92vw);
        padding: 22px 24px 20px;
    }
}

/* ============================================
   LIGHT MODE — Tactical Desert HUD
   ============================================ */

body.light-mode {
    background: #f5f0e8;
    color: #2d2926;
}

body.light-mode #sidebar {
    background: #ece5d8;
    border-right-color: #c8b89a;
    border-bottom-color: #c8b89a;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(139, 69, 19, 0.025) 2px,
        rgba(139, 69, 19, 0.025) 4px
    );
}

body.light-mode #sidebar h1 {
    color: #8b0000;
    border-bottom-color: #8b0000;
}

body.light-mode #sidebar label {
    color: #1a5276;
}

body.light-mode #sidebar select,
body.light-mode #sidebar input[type="text"] {
    background: #fff8f0;
    border-color: #c8b89a;
    color: #2d2926;
}

body.light-mode #sidebar select:focus,
body.light-mode #sidebar input[type="text"]:focus {
    border-color: #1a5276;
    box-shadow: 0 0 6px rgba(26, 82, 118, 0.25);
}

body.light-mode #search-btn {
    background: #d4c9b5;
    color: #1a5276;
    border-color: #1a5276;
}

body.light-mode #search-btn:hover {
    background: #1a5276;
    color: #fff;
}

body.light-mode #pin-btn {
    border-color: #1a5276;
    color: #1a5276;
}
body.light-mode #pin-btn.active {
    background: #1a5276;
    color: #fff;
}

body.light-mode #simulate-btn {
    background: #8b0000;
    border-color: #cc0000;
}

body.light-mode #simulate-btn:disabled {
    background: #d4c9b5;
    border-color: #c8b89a;
    color: #999;
    animation: none;
}

body.light-mode #search-results li {
    border-bottom-color: #c8b89a;
    color: #2d2926;
}

body.light-mode #search-results li:hover,
body.light-mode #search-results li:active {
    background: #d4c9b5;
}

body.light-mode #search-results-hint,
body.light-mode #search-results li::before,
body.light-mode #search-results li::after {
    color: #1a5276;
}

body.light-mode #missile-info,
body.light-mode #launch-coords,
body.light-mode #target-info {
    color: #5c4033;
}

body.light-mode #results-section h2 { color: #1a5276; }
body.light-mode #results-content .result-label { color: #1a5276; }
body.light-mode #results-content .result-value { color: #8b0000; }
body.light-mode #results-content .result-row { border-bottom-color: #c8b89a; }

body.light-mode #shielding-banner.exposed {
    background: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
    color: #c0392b;
    box-shadow: 0 0 14px rgba(220, 53, 69, 0.2);
}

body.light-mode #shielding-banner.shielded {
    background: rgba(40, 167, 69, 0.1);
    border-color: #28a745;
    color: #1e7e34;
    box-shadow: 0 0 14px rgba(40, 167, 69, 0.2);
}

body.light-mode #theme-toggle {
    background: rgba(245, 240, 232, 0.9);
    border-color: #1a5276;
    color: #1a5276;
}

body.light-mode #theme-toggle:hover {
    background: #1a5276;
    color: #fff;
}

body.light-mode #mobile-tab-bar {
    background: #ece5d8;
    border-bottom-color: #c8b89a;
}

body.light-mode .m-tab { color: #5c4033; border-right-color: #c8b89a; }
body.light-mode .m-tab.active {
    background: rgba(26, 82, 118, 0.12);
    color: #1a5276;
    border-bottom-color: #1a5276;
}

body.light-mode #mobile-sim-fab {
    background: #8b0000;
    border-color: #cc0000;
}

body.light-mode #missile-range-prompt {
    color: #c0392b;
    background: rgba(139, 0, 0, 0.07);
    border-color: rgba(139, 0, 0, 0.3);
}

body.light-mode #trajectory-chart-container,
body.light-mode #impact-diagram-container {
    background: rgba(236, 229, 216, 0.97);
    border-color: #c8b89a;
}

body.light-mode #impact-diagram-container h3 { color: #1a5276; }

body.light-mode #close-chart,
body.light-mode #close-impact {
    background: #8b0000;
    border-color: #cc0000;
}

body.light-mode #expand-impact {
    background: #d4c9b5;
    color: #1a5276;
    border-color: #1a5276;
}

body.light-mode #expand-impact:hover {
    background: #1a5276;
    color: #fff;
}

body.light-mode #zoom-out-btn,
body.light-mode #zoom-in-btn {
    background: #d4c9b5;
    color: #1a5276;
    border-color: #1a5276;
}

body.light-mode #zoom-out-btn:hover:not(:disabled),
body.light-mode #zoom-in-btn:hover:not(:disabled) {
    background: #1a5276;
    color: #fff;
}

body.light-mode #zoom-level-label {
    color: #1a5276;
}

body.light-mode #zoom-level-label:hover {
    color: #0d1117;
}

body.light-mode #reopen-impact {
    background: rgba(236, 229, 216, 0.97);
    color: #1a5276;
    border-color: #1a5276;
}

body.light-mode #reopen-impact:hover {
    background: #1a5276;
    color: #fff;
}

body.light-mode #animation-status { color: #1e7e34; }

body.light-mode #play-pause-btn {
    background: #d4c9b5;
    color: #1a5276;
    border-color: #1a5276;
}

body.light-mode #play-pause-btn:hover {
    background: #1a5276;
    color: #fff;
}

body.light-mode .saved-addr {
    border-bottom-color: #c8b89a;
    color: #5c4033;
}

body.light-mode .saved-addr:hover,
body.light-mode .saved-addr:active {
    background: #d4c9b5;
    color: #2d2926;
}

body.light-mode .saved-addr::before { color: #1a5276; }

body.light-mode #range-warning {
    background: rgba(139, 0, 0, 0.06);
    border-color: #8b0000;
    color: #8b0000;
}

body.light-mode #range-warning strong { color: #8b0000; }

body.light-mode .impact-view-toggle {
    background: rgba(236, 229, 216, 0.97);
    color: #1a5276;
    border-color: #1a5276;
}

body.light-mode .impact-view-toggle:hover {
    background: #1a5276;
    color: #fff;
}

body.light-mode .missile-tooltip .maplibregl-popup-content {
    background: rgba(236, 229, 216, 0.92);
    color: #1e7e34;
    border-color: #1a5276;
}

body.light-mode .launch-label .maplibregl-popup-content {
    background: rgba(236, 229, 216, 0.92);
    color: #8b0000;
    border-color: #8b0000;
}

body.light-mode #shielding-overlay {
    background: rgba(245, 240, 232, 0.95);
}

body.light-mode #shielding-overlay.exposed {
    border-color: #dc3545;
    color: #c0392b;
    box-shadow: 0 0 30px rgba(220, 53, 69, 0.25);
}

body.light-mode #shielding-overlay.shielded {
    border-color: #28a745;
    color: #1e7e34;
    box-shadow: 0 0 30px rgba(40, 167, 69, 0.2);
}

body.light-mode .example-addr {
    border-color: #c8b89a;
    color: #1a5276;
}

body.light-mode .example-addr:hover {
    background: rgba(26, 82, 118, 0.1);
}

body.light-mode #site-footer {
    color: #5c4033;
}

body.light-mode #site-footer a {
    color: #1a5276;
}
