/* ==================== PWA & Fullscreen Support ==================== */
:root {
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}

/* Prevent overscroll/bounce on iOS */
html {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* PWA Standalone mode adjustments */
.pwa-standalone #topbar {
    padding-top: var(--sat);
    height: calc(40px + var(--sat));
}

.pwa-standalone #map {
    margin-top: calc(40px + var(--sat));
    height: calc(100vh - 40px - var(--sat));
}

.pwa-standalone .mode-banner {
    top: calc(40px + var(--sat));
}

/* Prevent pull-to-refresh and overscroll effects */
body {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure map container fills properly in standalone */
.leaflet-container {
    background: #0a0f1e !important;
    touch-action: manipulation;
}

/* Handle notch areas for iOS */
@supports (padding: max(0px)) {
    .pwa-standalone #topbar {
        padding-left: max(12px, var(--sal));
        padding-right: max(12px, var(--sar));
    }

    .pwa-standalone #hud-panel {
        padding-bottom: max(0px, var(--sab));
    }
}

/* ==================== Common ==================== */
body { margin: 0; padding: 0; font-family: 'Exo 2', Arial, sans-serif; }
#map { height: calc(100vh - 40px); width: 100vw; margin-top: 40px; }

/* ==================== Game Icons ==================== */
.base-icon,.enemy-base-icon,.conquered-base-icon,.enemy-conquered-base-icon,.outpost-icon,.enemy-outpost-icon,.radar-icon,.enemy-radar-icon,.gate-icon,.enemy-gate-icon,.mine-icon,.enemy-mine-icon,.neutral-mine-icon,.turret-icon,.enemy-turret-icon,.decoy-icon,.jammer-icon,.enemy-jammer-icon,.barracks-icon,.enemy-barracks-icon {
    --_sz: calc(32px * var(--marker-scale, 1));
    background-size: var(--_sz) var(--_sz) !important;
    width: var(--_sz) !important;
    height: var(--_sz) !important;
    margin-left: calc(var(--_sz) / -2) !important;
    margin-top: calc(var(--_sz) / -2) !important;
    line-height: var(--_sz);
    border-radius: 50%;
    text-align: center;
    z-index: 100;
    will-change: transform, opacity;
}

.base-icon:hover,.conquered-base-icon:hover,.outpost-icon:hover,.radar-icon:hover,.gate-icon:hover,.mine-icon:hover,.turret-icon:hover,.decoy-icon:hover,.jammer-icon:hover,.barracks-icon:hover,
.enemy-base-icon:hover,.enemy-conquered-base-icon:hover,.enemy-outpost-icon:hover,.enemy-radar-icon:hover,.enemy-gate-icon:hover,.enemy-mine-icon:hover,.enemy-turret-icon:hover,.enemy-jammer-icon:hover,.enemy-barracks-icon:hover {
    filter: brightness(1.3);
}
.neutral-mine-icon:hover {
    filter: brightness(1.1);
}

.base-icon,.enemy-base-icon {
    background-image: url('/static/icons/base.svg');
}

.conquered-base-icon,.enemy-conquered-base-icon {
    background-image: url('/static/icons/conquered-base.svg');
}

.outpost-icon,.enemy-outpost-icon {
    background-image: url('/static/icons/outpost.svg');
}

.radar-icon,.enemy-radar-icon {
    background-image: url('/static/icons/radar.svg');
}

.gate-icon,.enemy-gate-icon {
    background-image: url('/static/icons/gate.svg');
}

.mine-icon,.enemy-mine-icon,.neutral-mine-icon {
    background-image: url('/static/icons/mine.svg');
}

.turret-icon,.enemy-turret-icon {
    background-image: url('/static/icons/turret.svg');
}

.decoy-icon {
    background-image: url('/static/icons/base.svg');
    opacity: 0.5;
}

.jammer-icon,.enemy-jammer-icon {
    background-image: url('/static/icons/jammer.svg');
}

.barracks-icon,.enemy-barracks-icon {
    background-image: url('/static/icons/barracks.svg');
}

/* Player-colored markers via CSS variable --mc */
.base-icon,.conquered-base-icon,.outpost-icon,.radar-icon,.gate-icon,.mine-icon,.decoy-icon,.jammer-icon,.barracks-icon {
    background-color: var(--mc, #22c55e);
    border: 2px solid var(--mc, #22c55e);
    box-shadow: 0 0 8px var(--mc, #22c55e), inset 0 0 6px rgba(255,255,255,0.15);
}
.enemy-base-icon,.enemy-conquered-base-icon,.enemy-outpost-icon,.enemy-radar-icon,.enemy-gate-icon,.enemy-mine-icon,.enemy-jammer-icon,.enemy-barracks-icon {
    background-color: var(--mc, #ef4444);
    border: 2px solid var(--mc, #ef4444);
    box-shadow: 0 0 8px var(--mc, #ef4444), inset 0 0 6px rgba(255,255,255,0.15);
}
.turret-icon {
    background-color: #1a4a6e;
    border: 2px solid var(--mc, #00b4ff);
    box-shadow: 0 0 8px var(--mc, #00b4ff), inset 0 0 6px rgba(255,255,255,0.15);
}
.enemy-turret-icon {
    background-color: #1a4a6e;
    border: 2px solid var(--mc, #ef4444);
    box-shadow: 0 0 8px var(--mc, #ef4444), inset 0 0 6px rgba(255,255,255,0.15);
}
.neutral-mine-icon {
    background-color: #888;
    border: 2px solid #aaa;
    box-shadow: 0 0 6px rgba(150,150,150,0.4), inset 0 0 6px rgba(255,255,255,0.1);
}

/* Jammed marker indicator */
.marker-jammed {
    animation: jammedPulse 1.5s ease-in-out infinite !important;
    filter: saturate(0.3) brightness(0.7) !important;
    will-change: box-shadow;
}
@keyframes jammedPulse {
    0%, 100% { box-shadow: 0 0 6px 2px rgba(255, 68, 68, 0.3); }
    50% { box-shadow: 0 0 14px 4px rgba(255, 68, 68, 0.7); }
}

/* Planning mode marker states */
.marker-source {
    animation: source-pulse 1.4s ease-in-out infinite !important;
}
@keyframes source-pulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(48, 160, 255, 0.85)) brightness(1.15); }
    50%       { filter: drop-shadow(0 0 22px rgba(48, 160, 255, 1))    brightness(1.3);  }
}

.marker-dest-friendly {
    animation: dest-friendly-pulse 1.6s ease-in-out infinite !important;
}
@keyframes dest-friendly-pulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.8)) brightness(1.1); }
    50%       { filter: drop-shadow(0 0 24px rgba(76, 175, 80, 1))   brightness(1.3); }
}

.marker-dest-enemy {
    animation: dest-enemy-pulse 1.6s ease-in-out infinite !important;
}
@keyframes dest-enemy-pulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.8)) brightness(1.1); }
    50%       { filter: drop-shadow(0 0 24px rgba(239, 68, 68, 1))   brightness(1.3); }
}

.marker-dest-gate {
    animation: dest-gate-pulse 1.6s ease-in-out infinite !important;
}
@keyframes dest-gate-pulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.8)) brightness(1.1); }
    50%       { filter: drop-shadow(0 0 24px rgba(168, 85, 247, 1))   brightness(1.3); }
}

.marker-dimmed {
    opacity: 0.18 !important;
    filter: grayscale(0.85) brightness(0.55) !important;
    transition: opacity 0.3s, filter 0.3s;
}

/* Map border vignette during modes */
body.map-mode-planning #map::after,
body.map-mode-attacking #map::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    animation-duration: 2s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}
body.map-mode-planning #map::after {
    animation-name: map-border-pulse-blue;
}
@keyframes map-border-pulse-blue {
    0%, 100% { box-shadow: inset 0 0 0 2px rgba(48, 160, 255, 0.45), inset 0 0 40px rgba(48, 160, 255, 0.07); }
    50%       { box-shadow: inset 0 0 0 3px rgba(48, 160, 255, 0.85), inset 0 0 60px rgba(48, 160, 255, 0.13); }
}
body.map-mode-attacking #map::after {
    animation-name: map-border-pulse-red;
}
@keyframes map-border-pulse-red {
    0%, 100% { box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.45), inset 0 0 40px rgba(239, 68, 68, 0.07); }
    50%       { box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.85), inset 0 0 60px rgba(239, 68, 68, 0.13); }
}

/* Turret firing animation */
@keyframes turretFire {
    0%, 100% { box-shadow: 0 0 6px 2px rgba(0, 180, 255, 0.4); }
    50% { box-shadow: 0 0 25px 10px rgba(0, 220, 255, 1); }
}
.turret-icon.anim-turret-fire {
    animation: turretFire 0.3s ease-out;
}

/* Own marker gentle pulse — removed, player-color box-shadow already provides glow */

.ship-icon,.enemy-ship-icon{
    --_ssz: calc(16px * var(--marker-scale, 1));
    background-color: var(--sc, gray);
    background-image: url('/static/icons/ship.svg');
    background-size: var(--_ssz) var(--_ssz) !important;
    width: var(--_ssz) !important;
    background-repeat: no-repeat;
    height: var(--_ssz) !important;
    margin-left: calc(var(--_ssz) / -2) !important;
    margin-top: calc(var(--_ssz) / -2) !important;
    line-height: var(--_ssz);
    border-radius: 50%;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 0 6px 2px var(--sc, transparent);
    transition: transform 200ms linear;
    will-change: transform;
}

/* ==================== Topbar ==================== */
#topbar {
    font-family: 'Orbitron', 'Exo 2', sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: linear-gradient(180deg, #0a0a0a 0%, #050510 100%);
    border-bottom: 1px solid rgba(48, 160, 255, 0.2);
    box-shadow: 0 2px 12px rgba(48, 160, 255, 0.15);
    color: white;
    z-index: 10000;
}

#topbar > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 100%;
}

#topbar h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#topbar > div h1, h2, ul {
    margin: 0;
    list-style-type: none;
    padding: 0;
    font-size: 18px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#gold {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.45), 0 0 16px rgba(255, 215, 0, 0.15);
}

.income-text {
    font-size: 12px;
    color: #22c55e;
    font-weight: 600;
    margin-left: 4px;
}

.gold-icon::before {
    content: "\26C1";
    margin-right: 4px;
    font-size: 14px;
}

.mute-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: border-color 0.2s, opacity 0.2s;
    line-height: 1;
}
.mute-btn:hover {
    border-color: rgba(48, 160, 255, 0.5);
}
.mute-btn.muted {
    opacity: 0.4;
}

/* ==================== Buttons ==================== */
.btn-popup-action {
    border-radius: 4px;
    background-color: #30a0ff;
    color: white;
    border: none;
    padding: 8px 12px;
    width: 100%;
    margin: 4px 0;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
    font-family: 'Exo 2', sans-serif;
    font-size: 12px;
}

.btn-popup-action:hover {
    background-color: #2080dd;
    box-shadow: 0 0 12px rgba(48, 160, 255, 0.4);
}

.btn-popup-action:active {
    transform: scale(0.95);
}

.btn-popup-secondary {
    background-color: #1a3a5c;
    border: 1px solid #30a0ff44;
}

.btn-popup-secondary:hover {
    background-color: #244a6c;
}

.popup-btn-row {
    display: flex;
    gap: 4px;
}

.popup-btn-row .btn-popup-action {
    flex: 1;
    width: auto;
}

/* ==================== Leaflet Controls ==================== */
.leaflet-control-zoom {
    border: none;
    box-shadow: 0 0 10px rgba(48, 160, 255, 0.5);
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    background-color: #1a1a1a !important;
    color: #ffffff !important;
    transition: background-color 0.3s ease;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background-color: #30a0ff !important;
}

/* ==================== Popups ==================== */
.leaflet-popup-content-wrapper {
    background-color: rgba(10, 10, 10, 0.93);
    color: #ffffff;
    border-radius: 8px;
    border: 1px solid rgba(48, 160, 255, 0.25);
    box-shadow: 0 0 20px rgba(48, 160, 255, 0.25), 0 4px 16px rgba(0,0,0,0.5);
    animation: popupOpen 0.2s ease-out;
    max-width: 240px;
}

@keyframes popupOpen {
    0% { transform: scale(0.92); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.leaflet-popup-tip {
    background-color: rgba(10, 10, 10, 0.93);
}

.leaflet-popup-content {
    margin: 10px;
    font-family: 'Exo 2', sans-serif;
    font-size: 13px;
}

.leaflet-popup-content h3 {
    font-family: 'Orbitron', 'Exo 2', sans-serif;
    font-size: 13px;
    letter-spacing: 1px;
}

.leaflet-popup-content button {
    background-color: #30a0ff;
    color: white;
    border: none;
    padding: 6px 10px;
    margin-top: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    font-family: 'Exo 2', sans-serif;
    font-size: 12px;
}

.leaflet-popup-content button:hover {
    background-color: #2080dd;
    box-shadow: 0 0 12px rgba(48, 160, 255, 0.4);
}

.leaflet-popup-content button:active {
    transform: scale(0.95);
}

/* Convert-to grid for outpost popup */
.convert-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 6px;
}
.convert-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 4px;
    padding: 6px 2px 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    font-family: 'Exo 2', sans-serif;
    width: auto;
    margin-top: 0;
}
.convert-btn:hover {
    background-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 8px rgba(48, 160, 255, 0.3);
}
.convert-btn:active {
    transform: scale(0.93);
}
.convert-btn-disabled {
    opacity: 0.4;
}
.convert-btn-icon {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.popup-svg-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    filter: brightness(0) invert(1);
}
.convert-btn-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
    font-weight: bold;
}
.convert-btn .cost-text {
    font-size: 9px;
    margin-top: 1px;
}

/* ==================== Game Alert ==================== */
.game-alert {
    position: fixed;
    right: 20px;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 10001;
    animation: alertFadeInOut 3s ease-in-out forwards;
    font-family: 'Exo 2', sans-serif;
    font-size: 13px;
    max-width: 350px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-alert-error { background-color: rgba(220, 38, 38, 0.93); }
.game-alert-error::before { content: "\2716 "; }
.game-alert-success { background-color: rgba(22, 163, 74, 0.93); }
.game-alert-success::before { content: "\2714 "; }
.game-alert-info { background-color: rgba(37, 99, 235, 0.93); }
.game-alert-info::before { content: "\2139 "; }
.game-alert-warning { background-color: rgba(217, 119, 6, 0.93); }
.game-alert-warning::before { content: "\26A0 "; }

@keyframes alertFadeInOut {
    0%, 100% { opacity: 0; transform: translateX(20px); }
    10%, 85% { opacity: 1; transform: translateX(0); }
}

/* ==================== Button Loading ==================== */
.btn-loading {
    opacity: 0.6;
    cursor: wait !important;
    pointer-events: none;
}

/* ==================== Confirm Modal Danger ==================== */
.confirm-danger {
    background-color: #dc2626 !important;
}
.confirm-danger:hover {
    background-color: #b91c1c !important;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.5) !important;
}

/* ==================== Action Animations ==================== */
@keyframes spawn-in {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}
@keyframes flash-green {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5) saturate(2) hue-rotate(-30deg); }
}
@keyframes flash-red {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5) saturate(2) hue-rotate(30deg); }
}
.anim-spawn-in { animation: spawn-in 0.4s ease-out; }
.anim-pulse { animation: pulse 0.5s ease-in-out; }
.anim-flash-green { animation: flash-green 0.5s ease-in-out; }
.anim-flash-red { animation: flash-red 0.5s ease-in-out; }

/* Contested / pending battle state */
.marker-contested {
    animation: contested-pulse 0.6s ease-in-out infinite !important;
    filter: brightness(1.3) saturate(0.5) !important;
}
@keyframes contested-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
    50% { box-shadow: 0 0 18px 6px rgba(255, 100, 100, 0.7); }
}

/* ==================== Event Log ==================== */
.event-log {
    position: fixed;
    top: 50px;
    right: 10px;
    width: 300px;
    max-height: 400px;
    z-index: 9999;
    font-family: 'Exo 2', sans-serif;
    transition: all 0.3s ease;
}
.event-log.collapsed .event-log-content { display: none; }
.event-log.collapsed { width: auto; }
.event-log-toggle {
    background-color: rgba(10, 10, 10, 0.85);
    color: white;
    border: 1px solid rgba(48, 160, 255, 0.3);
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    float: right;
    transition: box-shadow 0.2s;
}
.event-log-toggle:hover {
    box-shadow: 0 0 8px rgba(48, 160, 255, 0.3);
}
.event-log:not(.collapsed) .event-log-toggle { display: none; }
.event-log-content {
    background-color: rgba(10, 10, 10, 0.88);
    border: 1px solid rgba(48, 160, 255, 0.25);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(48, 160, 255, 0.05), 0 4px 12px rgba(0,0,0,0.3);
}
.event-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(48, 160, 255, 0.2);
}
.event-log-header h3 {
    margin: 0;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.event-log-entries {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
}
.event-entry {
    padding: 5px 8px;
    margin-bottom: 3px;
    border-radius: 3px;
    font-size: 12px;
    color: #ccc;
    border-left: 3px solid #555;
    animation: eventSlideIn 0.25s ease-out;
}
@keyframes eventSlideIn {
    0% { transform: translateX(30px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}
.event-entry .event-time {
    color: #666;
    font-size: 10px;
    margin-right: 6px;
}
.event-entry-build { border-left-color: #22c55e; }
.event-entry-send { border-left-color: #3b82f6; }
.event-entry-combat { border-left-color: #ef4444; }
.event-entry-capture { border-left-color: #eab308; }
.event-entry-lost { border-left-color: #dc2626; }

/* ==================== Modals ==================== */
.troop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    animation: modalBgFade 0.2s ease-in-out;
}

@keyframes modalBgFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.troop-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(10, 10, 10, 0.95);
    padding: 20px;
    border-radius: 8px;
    min-width: 300px;
    box-shadow: 0 0 30px rgba(48, 160, 255, 0.3), 0 0 60px rgba(48, 160, 255, 0.1);
    border: 1px solid rgba(48, 160, 255, 0.3);
    animation: modalContentIn 0.25s ease-out;
}

@keyframes modalContentIn {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.troop-modal h3 {
    color: white;
    margin: 0 0 20px 0;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1em;
    letter-spacing: 1px;
}

.troop-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.troop-input-container input[type="range"] {
    flex: 1;
    height: 6px;
    background: rgba(48, 160, 255, 0.3);
    border-radius: 3px;
    outline: none;
}

.troop-input-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #30a0ff;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.troop-input-container input[type="range"]::-webkit-slider-thumb:hover {
    background: #2080dd;
    box-shadow: 0 0 8px rgba(48, 160, 255, 0.5);
}

.troop-input-container input[type="number"] {
    width: 70px;
    padding: 5px;
    border: 1px solid rgba(48, 160, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border-radius: 4px;
    text-align: center;
    font-family: 'Exo 2', sans-serif;
}

.troop-quick-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
}
.btn-quick {
    background: rgba(48, 160, 255, 0.15);
    color: #30a0ff;
    border: 1px solid rgba(48, 160, 255, 0.3);
    padding: 3px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    font-family: 'Exo 2', sans-serif;
}
.btn-quick:hover {
    background: rgba(48, 160, 255, 0.3);
    box-shadow: 0 0 8px rgba(48, 160, 255, 0.3);
}
.btn-quick:active {
    transform: scale(0.95);
}

.troop-info {
    color: #aaa;
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.9em;
}

.troop-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.troop-modal-buttons button {
    min-width: 100px;
}

.troop-modal-buttons .cancel {
    background-color: #666;
}

.troop-modal-buttons .cancel:hover {
    background-color: #555;
    box-shadow: 0 0 8px rgba(100, 100, 100, 0.3);
}

/* ==================== Z-Index Layers ==================== */
.base-icon, .enemy-base-icon, .conquered-base-icon, .enemy-conquered-base-icon, .outpost-icon, .enemy-outpost-icon, .radar-icon, .enemy-radar-icon, .turret-icon, .enemy-turret-icon, .decoy-icon, .jammer-icon, .enemy-jammer-icon {
    z-index: 100 !important;
}

.ship-icon, .enemy-ship-icon {
    z-index: 1000 !important;
}

.leaflet-marker-pane {
    z-index: 600;
}

/* ==================== HUD Collapse Button ==================== */
#hud-collapse-btn {
    position: fixed;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid rgba(48, 160, 255, 0.4);
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.95) 0%, rgba(5, 5, 16, 0.98) 100%);
    color: #30a0ff;
    font-size: 16px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    transition: all 0.25s ease;
}
#hud-collapse-btn:hover {
    background: linear-gradient(135deg, rgba(48, 160, 255, 0.2) 0%, rgba(10, 10, 10, 0.98) 100%);
    border-color: #30a0ff;
    box-shadow: 0 0 16px rgba(48, 160, 255, 0.5);
}
#hud-collapse-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* Standalone collapse button - always available for collapsing/expanding HUD */
/* Desktop: always show integrated button, hide standalone */
.hud-collapse-integrated {
    display: flex !important;
}
#hud-collapse-btn {
    display: none;
}
/* When HUD is collapsed, show standalone button */
#hud-collapse-btn.visible {
    display: flex;
}

.hud-collapse-section {
    border-top: 1px solid rgba(48, 160, 255, 0.15) !important;
    border-bottom: none !important;
    padding-top: 8px !important;
    padding-bottom: 0 !important;
}

.hud-collapse-integrated {
    display: none;
}

#hud-panel {
    transition: transform 0.3s ease, opacity 0.3s ease;
}
#hud-panel.collapsed {
    transform: translateY(-50%) translateX(-100%);
    opacity: 0;
    pointer-events: none;
}


/* ==================== Pregame / Lobby ==================== */
#pregame {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #0a0f1e 0%, #1a2332 50%, #0a0f1e 100%);
    font-family: 'Exo 2', sans-serif;
    color: #ccc;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#pregame > .lobby-container {
    margin-top: auto;
    margin-bottom: auto;
    flex-shrink: 0;
}

.lobby-container {
    width: 100%;
    max-width: 700px;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.92) 0%, rgba(5, 5, 16, 0.95) 100%);
    border: 2px solid rgba(48, 160, 255, 0.25);
    border-radius: 12px;
    box-shadow: inset 0 0 30px rgba(48, 160, 255, 0.08), 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.lobby-header {
    padding: 20px 24px 16px;
    border-bottom: 2px solid rgba(48, 160, 255, 0.2);
    text-align: center;
}

.lobby-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: 0;
    text-shadow: 0 0 20px rgba(48, 160, 255, 0.4);
}

.lobby-subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: rgba(48, 160, 255, 0.7);
    letter-spacing: 2px;
    margin-top: 4px;
}

.lobby-share {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(48, 160, 255, 0.1);
}

.lobby-share-label {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lobby-share-input {
    flex: 1;
    background: rgba(20, 20, 30, 0.8);
    border: 1px solid rgba(48, 160, 255, 0.2);
    border-radius: 4px;
    color: #aaa;
    font-size: 12px;
    padding: 6px 10px;
    font-family: 'Exo 2', sans-serif;
    outline: none;
}

.lobby-share-input:focus {
    border-color: #30a0ff;
}

.lobby-btn-icon {
    background: rgba(20, 20, 30, 0.8);
    border: 1px solid rgba(48, 160, 255, 0.3);
    border-radius: 4px;
    color: #ccc;
    font-size: 14px;
    padding: 5px 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.lobby-btn-icon:hover {
    border-color: #30a0ff;
    color: #fff;
    background: rgba(48, 160, 255, 0.15);
}

.lobby-body {
    padding: 16px 24px;
}

.lobby-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.lobby-panel {
    background: rgba(20, 20, 30, 0.4);
    border: 1px solid rgba(48, 160, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
}

.lobby-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(48, 160, 255, 0.08);
    border-bottom: 1px solid rgba(48, 160, 255, 0.15);
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(48, 160, 255, 0.8);
}

.lobby-badge {
    background: rgba(48, 160, 255, 0.2);
    color: #30a0ff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-family: 'Exo 2', sans-serif;
    font-weight: 600;
}

/* Player list */
.player-list {
    padding: 8px;
    min-height: 120px;
}

.player-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.2s;
}

.player-entry:hover {
    background: rgba(48, 160, 255, 0.05);
}

.player-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.player-name {
    flex: 1;
    font-size: 14px;
    color: #ddd;
    font-weight: 600;
}

.player-host-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.player-ready-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-ready-badge.ready {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.player-ready-badge.not-ready {
    color: #888;
    background: rgba(100, 100, 100, 0.15);
    border: 1px solid rgba(100, 100, 100, 0.3);
}

.player-bot-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.player-kick-btn {
    background: none;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    font-size: 12px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.player-kick-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.player-list-empty {
    color: #555;
    font-size: 12px;
    text-align: center;
    padding: 30px 10px;
    font-style: italic;
}

/* Settings panel */
.settings-panel {
    padding: 12px;
}

.setting-row {
    margin-bottom: 14px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: block;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-input {
    width: 100%;
    background: rgba(20, 20, 30, 0.8);
    border: 1px solid rgba(48, 160, 255, 0.2);
    border-radius: 4px;
    color: #ddd;
    font-size: 14px;
    padding: 6px 10px;
    font-family: 'Exo 2', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.setting-input::-webkit-inner-spin-button,
.setting-input::-webkit-outer-spin-button {
    opacity: 1;
}

.setting-input:focus {
    border-color: #30a0ff;
}

.setting-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.setting-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(48, 160, 255, 0.2);
    border-radius: 3px;
    outline: none;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #30a0ff;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(48, 160, 255, 0.5);
}

.setting-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.setting-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.setting-value {
    font-size: 12px;
    color: #30a0ff;
    font-weight: 600;
    min-width: 65px;
    text-align: right;
}

.setting-divider {
    border-top: 1px solid rgba(48, 160, 255, 0.15);
    margin: 10px 0 6px;
}

.setting-row-checkbox {
    margin-bottom: 8px;
}

.setting-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #c0d8ef;
    cursor: pointer;
    user-select: none;
}

.setting-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #30a0ff;
    cursor: pointer;
    flex-shrink: 0;
}

.setting-checkbox:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.setting-checkbox:disabled + span {
    opacity: 0.6;
}

.setting-sub-option {
    padding-left: 24px;
}

/* Lobby actions */
.lobby-actions {
    padding: 16px 24px;
    border-top: 2px solid rgba(48, 160, 255, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.join-section {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 400px;
}

.lobby-name-input {
    flex: 1;
    background: rgba(20, 20, 30, 0.8);
    border: 1px solid rgba(48, 160, 255, 0.3);
    border-radius: 6px;
    color: #ddd;
    font-size: 14px;
    padding: 10px 14px;
    font-family: 'Exo 2', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.lobby-name-input:focus {
    border-color: #30a0ff;
    box-shadow: 0 0 12px rgba(48, 160, 255, 0.2);
}

.player-actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.lobby-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-family: 'Exo 2', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.lobby-btn-primary {
    background: #30a0ff;
    color: #fff;
}

.lobby-btn-primary:hover {
    background: #2080cf;
    box-shadow: 0 0 16px rgba(48, 160, 255, 0.4);
}

.lobby-btn-ready {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.lobby-btn-ready:hover {
    background: rgba(34, 197, 94, 0.3);
}

.lobby-btn-ready.is-ready {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

.lobby-btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.lobby-btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.lobby-btn-start {
    background: linear-gradient(135deg, #30a0ff, #2060ff);
    color: #fff;
    border: none;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    letter-spacing: 2px;
    padding: 10px 28px;
    box-shadow: 0 0 16px rgba(48, 160, 255, 0.3);
}

.lobby-btn-start:hover:not(:disabled) {
    box-shadow: 0 0 24px rgba(48, 160, 255, 0.5);
    transform: scale(1.02);
}

.lobby-btn-start:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.bot-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.bot-controls-label {
    font-size: 11px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lobby-btn-bot {
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(167, 139, 250, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.3);
    color: #a78bfa;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.lobby-btn-bot:hover {
    background: rgba(167, 139, 250, 0.25);
}

.lobby-btn-bot-extreme {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.1);
}

.lobby-btn-bot-extreme:hover {
    background: rgba(248, 113, 113, 0.25);
}

.lobby-home-link {
    color: #555;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
}

.lobby-home-link:hover {
    color: #30a0ff;
}

/* Color Picker */
.color-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
}

.color-picker-label {
    color: #8899aa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 4px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    outline: none;
}

.color-swatch:hover:not(:disabled) {
    transform: scale(1.2);
    box-shadow: 0 0 12px currentColor;
}

.color-swatch.color-selected {
    border-color: #fff;
    box-shadow: 0 0 10px currentColor;
    transform: scale(1.15);
}

.color-swatch.color-taken {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Ended game */
.lobby-ended {
    text-align: center;
    padding: 40px 20px;
}

.ended-trophy {
    font-size: 64px;
    margin-bottom: 16px;
}

.lobby-ended h2 {
    color: #ffd700;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    letter-spacing: 2px;
    margin: 0;
}

/* Responsive lobby */
@media (max-width: 600px) {
    .lobby-columns {
        grid-template-columns: 1fr;
    }

    .lobby-container {
        margin: 10px;
    }

    .lobby-header {
        padding: 14px 16px 12px;
    }

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

    .lobby-share {
        padding: 8px 16px;
    }

    .lobby-body {
        padding: 12px 16px;
    }

    .lobby-actions {
        padding: 12px 16px;
    }

    .join-section {
        flex-direction: column;
    }
}

.text-center {
    text-align: center;
}

/* ==================== Scoreboard ==================== */
#scoreboard {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(10, 10, 10, 0.88);
    border: 1px solid rgba(48, 160, 255, 0.25);
    border-radius: 6px;
    padding: 8px 12px;
    z-index: 9999;
    font-family: 'Exo 2', sans-serif;
    min-width: 160px;
    box-shadow: inset 0 0 15px rgba(48, 160, 255, 0.05), 0 4px 12px rgba(0,0,0,0.3);
}
#scoreboard h4 {
    margin: 0 0 6px 0;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.score-entry {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #ccc;
    padding: 2px 0;
}
.score-entry.score-self {
    font-weight: bold;
}
.score-entry .score-value {
    color: #ffd700;
}

/* ==================== Popup Enhancements ==================== */
.troop-count-friendly { color: #22c55e; font-weight: bold; }
.troop-count-enemy { color: #ef4444; font-weight: bold; }
.troop-count-zero { color: #666; font-weight: bold; }
.defense-bonus { color: #eab308; font-size: 12px; }
.btn-popup-disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
    pointer-events: none;
}
.cost-text { font-size: 11px; color: #ffd700; }
.cost-cant-afford { color: #ef4444; }

/* ==================== Battle Outcome Overlay ==================== */
.battle-overlay {
    position: absolute;
    z-index: 10002;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: battleOverlayAnim 2.5s ease-out forwards;
}
.battle-overlay-icon {
    font-size: 48px;
    text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
    animation: battleIconPop 0.4s ease-out;
}
.battle-overlay-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px currentColor, 0 2px 4px rgba(0,0,0,0.8);
    margin-top: 4px;
}
.battle-overlay-detail {
    font-family: 'Exo 2', sans-serif;
    font-size: 12px;
    color: #ccc;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    margin-top: 2px;
}
.battle-victory { color: #22c55e; }
.battle-defeat { color: #ef4444; }
.battle-reinforced { color: #3b82f6; }
.battle-captured { color: #eab308; }

@keyframes battleOverlayAnim {
    0% { opacity: 1; transform: translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-60px); }
}
@keyframes battleIconPop {
    0% { transform: scale(0) rotate(-15deg); }
    50% { transform: scale(1.4) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Battle shockwave ring */
.battle-shockwave {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 3px solid currentColor;
    z-index: 10001;
    pointer-events: none;
    animation: shockwaveExpand 1s ease-out forwards;
}
@keyframes shockwaveExpand {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) scale(18); opacity: 0; }
}

/* Second shockwave for more drama */
.battle-shockwave-inner {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 10001;
    pointer-events: none;
    animation: shockwaveExpand 0.6s ease-out forwards;
}

/* Screen shake */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-3px, 2px); }
    20% { transform: translate(3px, -2px); }
    30% { transform: translate(-2px, 3px); }
    40% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(2px, -2px); }
    70% { transform: translate(-1px, 1px); }
    80% { transform: translate(1px, -1px); }
}
.screen-shake {
    animation: screenShake 0.35s ease-out;
}

/* Battle flash overlay */
.battle-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10003;
    animation: battleFlash 0.3s ease-out forwards;
}
.battle-flash-victory { background: rgba(34, 197, 94, 0.08); }
.battle-flash-defeat { background: rgba(239, 68, 68, 0.08); }
.battle-flash-captured { background: rgba(234, 179, 8, 0.08); }
@keyframes battleFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ==================== HUD Panel ==================== */
#hud-panel {
    position: fixed;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 9999;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.92) 0%, rgba(5, 5, 16, 0.95) 100%);
    border: 2px solid rgba(48, 160, 255, 0.25);
    border-radius: 10px;
    padding: 12px 8px;
    box-shadow: inset 0 0 30px rgba(48, 160, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.6);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
#hud-panel::-webkit-scrollbar { width: 3px; }
#hud-panel::-webkit-scrollbar-track { background: transparent; }
#hud-panel::-webkit-scrollbar-thumb { background: rgba(48, 160, 255, 0.3); border-radius: 2px; }
.hud-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.hud-section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(48, 160, 255, 0.6);
    text-align: center;
    margin-bottom: 2px;
}
.hud-section:not(:last-child) {
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(48, 160, 255, 0.15);
}
.hud-btn {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid rgba(48, 160, 255, 0.3);
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.9) 0%, rgba(10, 10, 20, 0.95) 100%);
    color: #ccc;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.25s ease;
    padding: 0;
    line-height: 1;
    font-family: 'Exo 2', sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.hud-btn:active {
    transform: scale(0.95);
    transition-duration: 0.05s;
}
.hud-btn:hover {
    transform: scale(1.1);
    border-color: #30a0ff;
    background: linear-gradient(135deg, rgba(48, 160, 255, 0.15) 0%, rgba(20, 20, 30, 0.95) 100%);
    box-shadow: 0 0 16px rgba(48, 160, 255, 0.6), 0 0 32px rgba(48, 160, 255, 0.25);
    color: #fff;
    animation: hudBtnGlow 1.5s ease-in-out infinite;
}
.hud-btn::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 12px);
    white-space: nowrap;
    background: rgba(10, 10, 10, 0.95);
    color: #ddd;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-family: 'Exo 2', sans-serif;
    letter-spacing: 0.5px;
    border: 1px solid rgba(48, 160, 255, 0.4);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
}
.hud-btn:hover::after {
    opacity: 1;
    transform: translateX(0);
}
.hud-btn.active {
    background: linear-gradient(135deg, rgba(48, 160, 255, 0.35) 0%, rgba(30, 100, 200, 0.25) 100%);
    border-color: #30a0ff;
    color: #30a0ff;
    box-shadow: 0 0 16px rgba(48, 160, 255, 0.6), 0 0 32px rgba(48, 160, 255, 0.25), inset 0 0 20px rgba(48, 160, 255, 0.15);
    animation: hudBtnGlow 1.5s ease-in-out infinite;
}
@keyframes hudBtnGlow {
    0%, 100% { box-shadow: 0 0 16px rgba(48, 160, 255, 0.6), 0 0 32px rgba(48, 160, 255, 0.25); }
    50% { box-shadow: 0 0 24px rgba(48, 160, 255, 0.8), 0 0 48px rgba(48, 160, 255, 0.35); }
}
.hud-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==================== Markers Panel ==================== */
.markers-panel {
    position: fixed;
    left: 80px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    max-height: 500px;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.92) 0%, rgba(5, 5, 16, 0.95) 100%);
    border: 2px solid rgba(48, 160, 255, 0.3);
    border-radius: 10px;
    box-shadow: inset 0 0 30px rgba(48, 160, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 9998;
    transition: all 0.3s ease;
    font-family: 'Exo 2', sans-serif;
}
.markers-panel.collapsed {
    transform: translateY(-50%) translateX(-100%);
    opacity: 0;
    pointer-events: none;
}
.markers-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid rgba(48, 160, 255, 0.2);
}
.markers-panel-header h3 {
    margin: 0;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.panel-close {
    background: none;
    border: none;
    color: #ccc;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.panel-close:hover {
    color: #ef4444;
}
.markers-panel-content {
    max-height: 420px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
}
.marker-item {
    background: rgba(20, 20, 30, 0.6);
    border: 1px solid rgba(48, 160, 255, 0.2);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.marker-item:hover {
    background: rgba(48, 160, 255, 0.15);
    border-color: #30a0ff;
    box-shadow: 0 0 12px rgba(48, 160, 255, 0.3);
    transform: translateX(4px);
}
.marker-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.marker-item-type {
    font-weight: bold;
    font-size: 13px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.marker-item-type-icon {
    margin-right: 6px;
}
.marker-item-troops {
    font-size: 12px;
    color: #22c55e;
    font-weight: bold;
}
.marker-item-icon {
    font-size: 24px;
    opacity: 0.7;
}
.markers-panel-content::-webkit-scrollbar {
    width: 6px;
}
.markers-panel-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
.markers-panel-content::-webkit-scrollbar-thumb {
    background: rgba(48, 160, 255, 0.3);
    border-radius: 3px;
}
.markers-panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(48, 160, 255, 0.5);
}

/* ==================== Mode Banner ==================== */
.mode-banner {
    position: fixed;
    top: 40px;
    left: 0;
    width: 100%;
    height: 36px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-sizing: border-box;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.mode-banner.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}
.mode-planning {
    background: rgba(48, 160, 255, 0.22);
    color: #60bcff;
    border-bottom: 2px solid rgba(48, 160, 255, 0.8);
    box-shadow: 0 3px 16px rgba(48, 160, 255, 0.35);
    text-shadow: 0 0 10px rgba(48, 160, 255, 0.6);
}
.mode-attacking {
    background: rgba(239, 68, 68, 0.22);
    color: #ff7070;
    border-bottom: 2px solid rgba(239, 68, 68, 0.8);
    box-shadow: 0 3px 16px rgba(239, 68, 68, 0.35);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}
.mode-banner button {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid currentColor;
    color: inherit;
    padding: 4px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Exo 2', sans-serif;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.mode-banner button:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Push event log below mode banner when active */
.map-mode-planning .event-log,
.map-mode-attacking .event-log {
    top: 86px;
}

/* ==================== Troop Count Labels ==================== */
.troop-count-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}
.troop-count-label span {
    display: block;
    font-family: 'Exo 2', sans-serif;
    font-size: calc(10px * var(--marker-scale, 1));
    font-weight: 700;
    color: #fff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 4px rgba(0,0,0,0.8);
    white-space: nowrap;
    pointer-events: none;
    line-height: 1;
}
.troop-count-ally span {
    color: #86efac;
    font-size: calc(9px * var(--marker-scale, 1));
}

/* ==================== Marker Tooltips ==================== */
.marker-tooltip {
    background-color: rgba(10, 10, 10, 0.9) !important;
    color: #ddd !important;
    border: 1px solid rgba(48, 160, 255, 0.3) !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-family: 'Exo 2', sans-serif !important;
    font-size: 11px !important;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
}
.marker-tooltip::before {
    border-top-color: rgba(10, 10, 10, 0.9) !important;
}

/* ==================== Click Marker ==================== */
.click-marker {
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #5ebbff 0%, #2196F3 60%, rgba(33, 150, 243, 0) 100%);
    border-radius: 50%;
    box-shadow: 0 0 6px 2px rgba(33, 150, 243, 0.5);
    animation: click-marker-pulse 1.5s ease-in-out infinite;
}
@keyframes click-marker-pulse {
    0%, 100% { box-shadow: 0 0 6px 2px rgba(33, 150, 243, 0.5); }
    50% { box-shadow: 0 0 10px 4px rgba(33, 150, 243, 0.7); }
}

/* ==================== Build Popup ==================== */
.build-popup {
    text-align: center;
}

/* ==================== Popup Divider ==================== */
.popup-divider {
    border: none;
    border-top: 1px solid rgba(48, 160, 255, 0.2);
    margin: 5px 0;
}

/* ==================== Defense Badge ==================== */
.defense-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 4px 0;
}
.defense-high { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.defense-mid { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.defense-low { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

/* ==================== Teleport Beam Animation ==================== */
.teleport-beam {
    position: absolute;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(168, 85, 247, 0.8) 10%,
        rgba(168, 85, 247, 1) 50%,
        rgba(168, 85, 247, 0.8) 90%,
        transparent 100%);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.8), 0 0 20px rgba(168, 85, 247, 0.5);
    transform-origin: left center;
    pointer-events: none;
    z-index: 10001;
    animation: teleportBeamPulse 0.8s ease-out forwards;
}

@keyframes teleportBeamPulse {
    0% { opacity: 0; height: 2px; }
    10% { opacity: 1; height: 6px; }
    20% { height: 4px; }
    70% { opacity: 1; }
    100% { opacity: 0; height: 2px; }
}

.teleport-flash {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.9) 0%, rgba(168, 85, 247, 0.4) 40%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10002;
    animation: teleportFlashExpand 0.8s ease-out forwards;
}

@keyframes teleportFlashExpand {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* ==================== Turret Missile Animation ==================== */
.turret-missile {
    position: absolute;
    font-size: 20px;
    filter: drop-shadow(0 0 8px rgba(0, 200, 255, 0.9))
            drop-shadow(0 0 4px rgba(255, 255, 255, 0.8))
            drop-shadow(0 0 12px rgba(0, 150, 255, 0.6));
    pointer-events: none;
    z-index: 10003;
    will-change: left, top;
}

.turret-explosion {
    position: absolute;
    font-size: 24px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10004;
    animation: turretExplosion 0.6s ease-out forwards;
}

.turret-explosion-big {
    font-size: 36px;
    animation: turretExplosionBig 0.6s ease-out forwards;
}

@keyframes turretExplosion {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

@keyframes turretExplosionBig {
    0% { transform: translate(-50%, -50%) scale(0.5) rotate(0deg); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1.5) rotate(90deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.5) rotate(180deg); opacity: 0; }
}

/* ==================== Custom Scrollbar ==================== */
.event-log-entries::-webkit-scrollbar {
    width: 6px;
}
.event-log-entries::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
.event-log-entries::-webkit-scrollbar-thumb {
    background: rgba(48, 160, 255, 0.3);
    border-radius: 3px;
}
.event-log-entries::-webkit-scrollbar-thumb:hover {
    background: rgba(48, 160, 255, 0.5);
}
/* Firefox */
.event-log-entries {
    scrollbar-width: thin;
    scrollbar-color: rgba(48, 160, 255, 0.3) rgba(0, 0, 0, 0.2);
}

/* ==================== Prefers Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {
    .marker-jammed,
    .marker-source,
    .marker-dest-friendly,
    .marker-dest-enemy,
    .marker-dest-gate,
    .marker-contested,
    .marker-selected,
    .hud-btn:hover,
    .hud-btn.active {
        animation: none !important;
    }
    body.map-mode-planning #map::after,
    body.map-mode-attacking #map::after {
        animation: none !important;
    }
}

/* ==================== Long-Press Context Menu ==================== */
.marker-context-menu {
    position: fixed;
    z-index: 10005;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid rgba(48, 160, 255, 0.35);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(48, 160, 255, 0.15);
    padding: 4px 0;
    min-width: 140px;
    font-family: 'Exo 2', sans-serif;
    animation: contextMenuIn 0.15s ease-out;
}
@keyframes contextMenuIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.context-menu-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: #ddd;
    font-family: 'Exo 2', sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}
.context-menu-item:hover,
.context-menu-item:active {
    background: rgba(48, 160, 255, 0.15);
    color: #fff;
}
.context-menu-item-danger {
    color: #ef4444;
}
.context-menu-item-danger:hover,
.context-menu-item-danger:active {
    background: rgba(239, 68, 68, 0.15);
    color: #ff6b6b;
}

/* ==================== Scoreboard Panel Transition ==================== */
#scoreboard {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#scoreboard.scoreboard-hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

/* ==================== Responsive (MUST BE AT END) ==================== */
@media (max-width: 768px) {
    #topbar h2 {
        font-size: 11px;
        letter-spacing: 0.5px;
    }
    #topbar > div {
        padding: 0 8px;
    }
    .topbar-right {
        gap: 6px;
    }
    .income-text {
        font-size: 10px;
    }
    .gold-icon::before {
        font-size: 12px;
        margin-right: 2px;
    }
    .mute-btn {
        padding: 2px 5px;
        font-size: 13px;
    }
.gold-label {
        display: none;
    }

    .btn-popup-action {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Compact event log on mobile */
    .event-log {
        max-height: 130px;
    }

    .event-log-entries {
        max-height: 90px;
    }

    .event-entry {
        padding: 4px 6px;
        margin-bottom: 2px;
        font-size: 11px;
    }

    .event-entry .event-time {
        font-size: 9px;
    }

    /* Show integrated collapse button on mobile */
    .hud-collapse-integrated {
        display: flex !important;
    }

    /* Smaller HUD on mobile */
    #hud-panel {
        left: 6px !important;
        gap: 6px !important;
        padding: 6px 5px !important;
        border-width: 1px !important;
        border-radius: 6px !important;
    }

    .hud-section {
        gap: 5px !important;
    }

    .hud-section-title {
        font-size: 7px !important;
        letter-spacing: 0.5px !important;
        margin-bottom: 1px !important;
    }

    .hud-section:not(:last-child) {
        padding-bottom: 5px !important;
    }

    .hud-collapse-section {
        padding-top: 5px !important;
    }

    .hud-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
        border-width: 1px !important;
        border-radius: 5px !important;
    }

    .hud-btn::after {
        font-size: 9px !important;
        padding: 3px 6px !important;
        left: calc(100% + 4px) !important;
    }

    /* Adjust standalone collapse button */
    #hud-collapse-btn {
        left: 6px !important;
        width: 34px !important;
        height: 34px !important;
        font-size: 16px !important;
        border-width: 1px !important;
        border-radius: 5px !important;
    }

    /* Adjust markers panel for mobile */
    .markers-panel {
        left: 38px !important;
        width: 220px !important;
        max-height: 380px !important;
        border-width: 1px !important;
    }

    .markers-panel-header {
        padding: 8px 10px !important;
    }

    .markers-panel-header h3 {
        font-size: 10px !important;
    }

    .panel-close {
        font-size: 20px !important;
        width: 20px !important;
        height: 20px !important;
    }

    .marker-item {
        padding: 7px 9px !important;
        margin-bottom: 6px !important;
    }

    .marker-item-type {
        font-size: 11px !important;
    }

    .marker-item-troops {
        font-size: 10px !important;
    }

    .marker-item-icon {
        font-size: 18px !important;
    }

    /* Mobile popup fixes */
    .leaflet-popup-content { margin: 10px; font-size: 12px; }
    .leaflet-popup-content button { padding: 5px 8px; font-size: 11px; margin-top: 6px; }
    .leaflet-popup-content h3 { font-size: 13px; }

    /* Topbar padding on mobile */
    #topbar > div {
        padding: 0 max(8px, var(--sal)) 0 max(8px, var(--sar));
    }

    /* Mode banner: bigger cancel button, no overlap with events */
    .mode-banner {
        height: 44px;
        padding: 0 8px;
        font-size: 10px;
        letter-spacing: 0.5px;
    }
    .mode-banner button {
        padding: 6px 16px;
        font-size: 13px;
        border-width: 2px;
    }

    /* Push event log below mode banner when active */
    .map-mode-planning .event-log,
    .map-mode-attacking .event-log {
        top: 94px;
    }
}

/* Extra small mobile */
@media (max-width: 480px) {
    /* Extra compact event log on extra small screens */
    .event-log {
        max-height: 110px;
    }

    .event-log-entries {
        max-height: 75px;
    }

    .event-entry {
        padding: 3px 5px;
        font-size: 10px;
    }

    .event-entry .event-time {
        font-size: 8px;
        margin-right: 4px;
    }

    #hud-panel {
        left: 4px !important;
        gap: 5px !important;
        padding: 5px 4px !important;
    }

    .hud-section {
        gap: 4px !important;
    }

    .hud-section-title {
        font-size: 6px !important;
    }

    .hud-section:not(:last-child) {
        padding-bottom: 4px !important;
    }

    .hud-collapse-section {
        padding-top: 4px !important;
    }

    .hud-btn {
        width: 34px !important;
        height: 34px !important;
        font-size: 14px !important;
    }

    #hud-collapse-btn {
        left: 4px !important;
        width: 30px !important;
        height: 30px !important;
        font-size: 14px !important;
    }

    .markers-panel {
        left: 32px !important;
        width: calc(100vw - 42px) !important;
        max-width: 240px !important;
        max-height: 320px !important;
    }

    .markers-panel-header {
        padding: 6px 8px !important;
    }

    .markers-panel-header h3 {
        font-size: 9px !important;
    }

    .marker-item {
        padding: 6px 8px !important;
        margin-bottom: 5px !important;
    }

    .marker-item-type {
        font-size: 10px !important;
    }

    .marker-item-troops {
        font-size: 9px !important;
    }

    .marker-item-icon {
        font-size: 16px !important;
    }

    /* Mobile popup fixes */
    .leaflet-popup-content { margin: 8px; font-size: 11px; }
    .leaflet-popup-content button { padding: 4px 6px; font-size: 10px; margin-top: 4px; }
}

/* ==================== Bulk Select ==================== */
.marker-selected {
    outline: 3px solid #30a0ff !important;
    outline-offset: 2px;
    filter: drop-shadow(0 0 10px rgba(48, 160, 255, 0.8)) brightness(1.2) !important;
    animation: selectedPulse 1s ease-in-out infinite !important;
}
@keyframes selectedPulse {
    0%, 100% { outline-color: rgba(48, 160, 255, 0.6); }
    50% { outline-color: rgba(48, 160, 255, 1); }
}
.leaflet-selection-box {
    border: 2px dashed #30a0ff;
    background: rgba(48, 160, 255, 0.1);
    pointer-events: none;
    z-index: 9999;
}
/* Show bulk select on all devices */
#hudBulkSelect { display: flex !important; }

/* ==================== Game Ended Banner ==================== */
.game-ended-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 36px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(10, 10, 10, 0.9);
    border-top: 2px solid #ffd700;
    color: #ffd700;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==================== Spy Panel ==================== */
.spy-panel {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.92) 0%, rgba(20, 5, 30, 0.95) 100%);
    border: 2px solid rgba(168, 85, 247, 0.3);
    border-radius: 10px;
    box-shadow: inset 0 0 30px rgba(168, 85, 247, 0.08), 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 9998;
    transition: all 0.3s ease;
    font-family: 'Exo 2', sans-serif;
}
.spy-panel.collapsed {
    transform: translateY(-50%) translateX(120%);
    opacity: 0;
    pointer-events: none;
}
.spy-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid rgba(168, 85, 247, 0.2);
}
.spy-panel-header h3 {
    margin: 0;
    color: #c084fc;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.spy-panel-content {
    padding: 12px 16px;
    color: #ccc;
    font-size: 13px;
}
.spy-no-active {
    text-align: center;
    padding: 8px 0;
}
.spy-no-active p {
    color: #888;
    margin: 0 0 12px 0;
}
.spy-train-btn {
    background: #a855f7 !important;
    border: none;
    color: white;
}
.spy-train-btn:hover {
    background: #9333ea !important;
}
.spy-status-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.spy-status-transit {
    color: #60a5fa;
}
.spy-status-infiltrating {
    color: #a855f7;
}
.spy-target-info {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 10px;
    font-size: 12px;
}
.spy-target-info .target-label {
    color: #888;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.spy-target-info .target-value {
    color: #e2e8f0;
    font-weight: 600;
}
.spy-progress {
    margin: 10px 0;
}
.spy-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(168, 85, 247, 0.15);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}
.spy-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #a855f7, #c084fc);
    border-radius: 3px;
    transition: width 1s linear;
}
.spy-progress-text {
    font-size: 10px;
    color: #888;
    text-align: right;
}
.spy-operations {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}
.spy-op-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 6px;
    background: rgba(168, 85, 247, 0.1);
    color: #e2e8f0;
    cursor: pointer;
    font-family: 'Exo 2', sans-serif;
    font-size: 12px;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.spy-op-btn:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.25);
    border-color: #a855f7;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.3);
}
.spy-op-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.spy-op-btn .op-cost {
    color: #ffd700;
    font-size: 11px;
}
.spy-op-btn .op-locked {
    color: #ef4444;
    font-size: 10px;
}
.spy-recall-btn {
    margin-top: 10px;
    width: 100%;
    padding: 6px 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    cursor: pointer;
    font-family: 'Exo 2', sans-serif;
    font-size: 11px;
    transition: all 0.2s ease;
}
.spy-recall-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

@media (max-width: 768px) {
    .spy-panel {
        right: 8px;
        width: 240px;
    }
    .spy-panel-header h3 {
        font-size: 11px;
    }
}

/* ==================== Investments Panel ==================== */
.investments-panel {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    max-height: 70vh;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.92) 0%, rgba(5, 20, 30, 0.95) 100%);
    border: 2px solid rgba(48, 160, 255, 0.3);
    border-radius: 10px;
    box-shadow: inset 0 0 30px rgba(48, 160, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 9998;
    transition: all 0.3s ease;
    font-family: 'Exo 2', sans-serif;
    display: flex;
    flex-direction: column;
}
.investments-panel.collapsed {
    transform: translateY(-50%) translateX(120%);
    opacity: 0;
    pointer-events: none;
}
.investments-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px solid rgba(48, 160, 255, 0.2);
    flex-shrink: 0;
}
.investments-panel-header h3 {
    margin: 0;
    color: #60a5fa;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.investments-panel-content {
    padding: 8px 12px;
    color: #ccc;
    font-size: 13px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}
.investments-panel-content::-webkit-scrollbar { width: 4px; }
.investments-panel-content::-webkit-scrollbar-track { background: transparent; }
.investments-panel-content::-webkit-scrollbar-thumb { background: rgba(48, 160, 255, 0.3); border-radius: 2px; }
.inv-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #60a5fa;
    margin: 8px 0 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(48, 160, 255, 0.15);
}
.inv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.inv-item:last-child { border-bottom: none; }
.inv-item-info { flex: 1; min-width: 0; }
.inv-item-name {
    font-size: 12px;
    color: #e2e8f0;
    font-weight: 600;
}
.inv-item-detail {
    font-size: 10px;
    color: #888;
    margin-top: 1px;
}
.inv-buy-btn {
    flex-shrink: 0;
    margin-left: 8px;
    padding: 4px 10px;
    border: 1px solid rgba(48, 160, 255, 0.3);
    border-radius: 5px;
    background: rgba(48, 160, 255, 0.1);
    color: #ffd700;
    cursor: pointer;
    font-family: 'Exo 2', sans-serif;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
}
.inv-buy-btn:hover {
    background: rgba(48, 160, 255, 0.25);
    border-color: #30a0ff;
    box-shadow: 0 0 8px rgba(48, 160, 255, 0.3);
}
.inv-buy-btn.inv-cant-afford {
    opacity: 0.4;
    color: #ef4444;
}
@media (max-width: 768px) {
    .investments-panel {
        right: 8px;
        width: 240px;
    }
    .investments-panel-header h3 {
        font-size: 11px;
    }
}

/* ==================== Diplomacy / Pact System ==================== */
.pact-badge {
    display: inline-block;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 8px;
    vertical-align: middle;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.pact-badge-alliance {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
}
.pact-badge-truce {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.4);
}

.score-pact-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    vertical-align: middle;
    opacity: 0.8;
}
.pact-alliance { color: #22c55e; }
.pact-truce { color: #60a5fa; }
.pact-pending { color: #f59e0b; }

/* Diplomacy Panel */
.diplomacy-panel {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.92) 0%, rgba(5, 5, 16, 0.95) 100%);
    border: 2px solid rgba(48, 160, 255, 0.3);
    border-radius: 10px;
    box-shadow: inset 0 0 30px rgba(48, 160, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 9998;
    transition: all 0.3s ease;
    font-family: 'Exo 2', sans-serif;
}
.diplomacy-panel.collapsed {
    opacity: 0;
    transform: translateY(-50%) translateX(30px);
    pointer-events: none;
}
.diplomacy-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(48, 160, 255, 0.2);
}
.diplomacy-panel-header h3 {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #30a0ff;
}
.diplomacy-panel-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    padding: 8px 12px;
}
.diplomacy-panel-content::-webkit-scrollbar { width: 4px; }
.diplomacy-panel-content::-webkit-scrollbar-track { background: transparent; }
.diplomacy-panel-content::-webkit-scrollbar-thumb { background: rgba(48, 160, 255, 0.3); border-radius: 2px; }

.dip-section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(48, 160, 255, 0.6);
    margin: 8px 0 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(48, 160, 255, 0.15);
}
.dip-section-title:first-child {
    margin-top: 0;
}
.dip-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    border-radius: 6px;
    transition: background 0.15s;
}
.dip-player-row:hover {
    background: rgba(48, 160, 255, 0.06);
}
.dip-player-info {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}
.dip-player-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dip-player-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dip-player-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

.pact-action-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    font-family: 'Exo 2', sans-serif;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    transition: filter 0.15s;
    white-space: nowrap;
}
.pact-action-btn:hover {
    filter: brightness(1.2);
}
.pact-action-alliance {
    background: #22c55e;
}
.pact-action-truce {
    background: #3b82f6;
}
.pact-action-accept {
    background: #22c55e;
}
.pact-action-danger {
    background: #ef4444;
}

.ship-ally {
    opacity: 0.85;
}

.allied-marker-section {
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 700;
    color: #22c55e;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid rgba(34, 197, 94, 0.3);
    margin-top: 4px;
}

@media (max-width: 768px) {
    .diplomacy-panel {
        right: 8px;
        width: 240px;
    }
    .diplomacy-panel-header h3 {
        font-size: 11px;
    }
}
