/* ==========================================
   MODAL HEADER (Version Positioning Fix)
   ========================================== */

/* Container for the stacked title */
.modal-brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Balanced padding */
  padding: 25px 20px 20px; 
  /* CHANGE: Increased gap from 4px to 12px to push credits down */
  gap: 12px; 
  position: relative;
  flex-shrink: 0;
  
  /* Background & Border (Moved here from your lower code for organization) */
  background: rgba(0, 0, 0, 0.4); 
  border-bottom: 1px solid rgba(255, 193, 7, 0.3); 
}

/* The Main Project Name */
.main-title {
  font-family: 'GothamSS', sans-serif;
  font-weight: 900;
  font-size: 36px !important; /* Kept your larger size preference */
  color: #ffc107;
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1; /* Tighter line height for the title itself */
  text-shadow: 0 0 15px rgba(255, 193, 7, 0.4);
  text-align: center;
}

/* Your Credit Line */
.main-subtitle-credits {
  font-family: 'GothamSS', sans-serif;
  font-weight: 700;
  font-size: 10px; 
  color: rgba(255, 255, 255, 0.5); /* Slightly brighter for better "sit" */
  letter-spacing: 3px; /* Wider spacing looks more "premium" */
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px; 
  text-shadow: none;
  
  /* CHANGE: Force it slightly further down explicitly */
  margin-top: 2px; 
}

/* ==========================================
   TRAJECTORY STEPPER BUTTONS (Zoom Style Sync)
   ========================================== */

.traj-step-btn {
    /* Exact Background and Border from Zoom Icons */
    background-color: rgba(20, 20, 20, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    
    /* Font Styling */
    font-family: 'GothamSS', sans-serif;
    font-weight: 900;
    font-size: 14px; 
    
    /* Layout: THE SQUARE FIX */
    width: 36px !important;  
    height: 36px !important;
    aspect-ratio: 1 / 1 !important; /* Forces a perfect square */
    flex-shrink: 0 !important;      /* Prevents the buttons from squishing */
    padding: 0 !important;          /* Removes padding that affects squareness */
    
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    
    /* Interactions */
    transition: background-color 0.1s, color 0.1s, transform 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: 0; 
}

/* Hover State (Desktop Only) */
@media (hover: hover) {
    .traj-step-btn:hover {
        background-color: #ffc107 !important;
        color: black !important;
        border-color: #ffc107 !important;
    }
}

/* Pressed State (Physical Feedback) */
.traj-step-btn:active,
.traj-step-btn.pressed {
    background-color: #ffc107 !important;
    color: black !important;
    border-color: #ffc107 !important;
    transform: scale(0.95) !important;
    box-shadow: none !important;
}

/* Ensure the step groups are aligned correctly */
.traj-step-group {
    display: flex;
    gap: 8px; /* Slightly wider gap for accessibility */
    align-items: center;
}


#trajToggleBtn.active {
    background-color: #ffc107 !important;
    color: black !important;
    border-color: #ffc107 !important;
}



/* ==========================================
   TRAJECTORY BUTTON - EXACT HUD CLONE
   ========================================== */

/* SVG Handling */
#trajToggleBtn svg {
    display: block;
    pointer-events: none;
}

/* Base State (Exact HUD Clone) */
#trajToggleBtn {
    background-color: rgba(20, 20, 20, 0.95) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    touch-action: manipulation; /* Removes 300ms browser delay */
    -webkit-tap-highlight-color: transparent; /* Optional: removes tap highlight box */
    user-select: none; /* Prevents text selection on rapid taps */
    transition: background-color 0.1s, color 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Hover State (Exact HUD Clone) */
@media (hover: hover) {
    #trajToggleBtn:not(.active):hover {
        background-color: rgba(60, 60, 60, 1) !important;
        color: #ffc107 !important;
    }
}

/* Active State (Exact HUD Clone) */
#trajToggleBtn.active {
    background-color: #ffc107 !important;
    color: black !important;
    border-color: #ffc107 !important;
}

/* Visual feedback on press (Exact HUD Clone) */
#trajToggleBtn:active {
    transform: scale(0.95);
}

/* ==========================================
   TRAJECTORY SLIDER - VISUAL RESTORATION
   ========================================== */

.traj-slider-container {
    position: fixed !important; /* Locks to screen glass, ignores map movement */
    bottom: 40px; 
    left: 50%;
    transform: translateX(-50%);
    width: 600px !important;       
    max-width: 95vw; 
    box-sizing: border-box !important;
    
    background: rgba(15, 15, 15, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid #ffc107;
    border-radius: 4px;
    
    padding: 12px 10px !important; 
    
    /* CHANGED: Lowered to 400.
       This places it BELOW the Target Panel (3000) to prevent stacking conflicts. */
    z-index: 400 !important; 
    
    pointer-events: auto;
}

/* Forces slider track to expand between button groups */
.traj-controls-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    height: 36px; 
    gap: 12px;
}

.traj-slider-inner {
    position: relative;
    flex: 1 !important; /* CRITICAL: Forces track to fill middle */
    display: flex;
    align-items: center;
    min-width: 100px;
}

#trajectoryRange {
    width: 100% !important;
    margin: 0;
    cursor: pointer;
    accent-color: #ffc107;
    display: block;
    height: 30px; /* Larger hit area for fingers */
    touch-action: none;
}

/* Hide old text displays for good */
.traj-current-val-display, .traj-meter-display {
    display: none !important;
}

/* Ensure step buttons stay tactical squares */
.traj-step-group {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

/* ==========================================
   GLOBAL SETTINGS
   ========================================== */
* {
  box-sizing: border-box;
}

:root {
  --bg: #1d1f27;
  --panel-border: rgba(255, 255, 255, 0.1);
  --grid-color: rgba(255, 255, 255, 1.0);
  --major-width: 2px; 
  --minor-width: 1px;
  color-scheme: dark; /* Force dark system controls */
}

/* --- Flag Styles --- */
.faction-flag {
  width: 28px;
  height: auto;
  margin-right: 8px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  vertical-align: middle;
}

/* Ensure flex alignment in the dropdown items */
.dropdown-item {
  display: flex;
  align-items: center;
}

/* Ensure flex alignment in the main button */
#factionBtn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

#factionBtn .icon {
  margin-left: auto;
}

@font-face {
  font-family: 'GothamSS';
  src: url('../fonts/Gotham.otf') format('opentype');
  font-weight: 900;
  font-style: normal;
}

/* Chrome/Blink rendering fixes */
.marker-label, 
.hll-grid-label,  
.data-value {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
    /* STOPS Pull-to-Refresh on Android */
    overscroll-behavior-y: none; 
    
    /* STOPS the whole page from bouncing on iOS */
    overflow: hidden; 
    
    /* STOPS double-tap to zoom on buttons */
    touch-action: none;

    /* Fixes the "Address Bar" jumping issue */
    height: 100dvh; 
}

body {
  margin: 0; height: 100dvh; width: 100vw;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-family: sans-serif;
  user-select: none;           
  -webkit-user-select: none;   
  -moz-user-select: none;      
  -ms-user-select: none;       
}

.shell {
  width: 100%; height: 100%; padding: 20px;
  box-sizing: border-box; display: flex; flex-direction: column;
}

/* ==========================================
   MAP CONTAINER & STAGE
   ========================================== */
.map-wrap {
  position: relative; width: 100%; height: 100%;
  background: #000;
  border: 1px solid var(--panel-border);
  border-radius: 4px; overflow: hidden; 
  
  /* FIX 1: Performance Isolation */
  /* Tells browser this container is isolated, preventing layout thrashing */
  contain: layout paint style; 

  /* --- CUSTOM CURSOR --- */
  /* 16 16 sets the "hotspot" (click point) to the center of a 32x32 image. */
  /* Change 'png' to 'webp' if your file is .webp */
  /* cursor: url('../images/ui/garrison_lining_dot_2.png') 16 16, auto; */
}

/* Ensure the cursor changes to a grabbing hand when you click/drag */
.map-wrap:active {
  cursor: grabbing;
}

/* ==========================================
   MAP CONTAINER & STAGE
   ========================================== */
/* --- FIX 3: Performance Safety --- */
.map-stage {
  transform-origin: 0 0; 
  position: absolute; 
  top: 0; 
  left: 0;
  transition: opacity 0.4s ease-in-out;
  
  /* --- FIX: REMOVE THESE LINES --- */
  /* will-change: transform; */
  /* -webkit-backface-visibility: hidden; */
  /* backface-visibility: hidden; */
  
  /* Modern browsers handle 2D transforms efficiently on the CPU/Compositor 
     without forcing a dedicated high-memory layer. */
}

/* ==========================================
   DESKTOP SMOOTH ZOOM FIX (Safe for Mobile)
   ========================================== */
/* 1025px ensures this NEVER runs on phones (even Pro Max in landscape) */
@media (min-width: 1025px) {
  
  /* 1. Hardware Acceleration Removed (Fixes Mobile Chrome Checkerboarding) */
  /* Modern Chrome auto-promotes transform elements without will-change */
  
  .marker, .hll-grid-line {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0); 
  }

  /* 2. Smooth Zoom Transitions (Desktop Only) */
  /* We move the transition logic HERE so mobile doesn't crash trying to animate huge textures */
  .map-stage.zoom-transition {
    transition: transform 0.25s cubic-bezier(0.1, 0.2, 0.1, 1.0) !important;
  }

  .label-layer.zoom-transition .hll-grid-label {
    transition: transform 0.25s cubic-bezier(0.1, 0.2, 0.1, 1.0) !important;
    /* will-change: transform; REMOVED - causes checkerboarding on mobile Chrome */
  }

  /* FIX: Smooth out BOTH position and scale */
  .map-stage.zoom-transition .marker-label {
    transition: 
        transform 0.25s cubic-bezier(0.1, 0.2, 0.1, 1.0),
        top 0.25s cubic-bezier(0.1, 0.2, 0.1, 1.0) !important;
        
    /* Tells the GPU to get ready to animate these properties */
    will-change: transform, top; 
  }

  /* FIX: Smooth out the arrow fading too */
  .map-stage.zoom-transition .marker-label::after {
    transition: opacity 0.25s cubic-bezier(0.1, 0.2, 0.1, 1.0) !important;
  }
}

.map-image {
  display: block; 
  pointer-events: none; 
  max-width: none; 
  max-height: none;
  /* FIX 2: Reduce Scaling Cost */
  /* CHANGE: high-quality causes checkerboarding on mobile zoom. Use auto. */
  image-rendering: auto;
  /* Ensure no hardware acceleration hints are accidentally applied */
  transform: none;
  transition: opacity 0.3s ease-in-out;
  background-color: black; /* Prevents white flashes */
}

/* ==========================================
   GRID SYSTEM
   ========================================== */
.grid-layer {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2;
}

.keypad-grid {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; opacity: 0;
  transition: opacity 0.2s ease-in-out;
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.7) var(--minor-width), transparent var(--minor-width)),
    linear-gradient(to bottom, rgba(0,0,0,0.7) var(--minor-width), transparent var(--minor-width));
  
  shape-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- GRID LINES (FIXED: No Dark Overlaps) --- */
.hll-grid-line {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    
    /* 1. White Core */
    background-color: #ffffff !important;
    
    /* 2. No standard border */
    border: none !important; 
    
    /* 3. THE FIX: Use a subtle hard shadow instead of a fuzzy one */
    /* We reduce opacity to 0.5 so the overlap isn't as harsh */
    box-shadow: 
        1px 0 0 rgba(0, 0, 0, 0.5),
        -1px 0 0 rgba(0, 0, 0, 0.5),
        0 1px 0 rgba(0, 0, 0, 0.5),
        0 -1px 0 rgba(0, 0, 0, 0.5) !important;
        
    /* Optional: Mix-blend-mode can help lines merge, 
       but 'normal' is usually safest for UI overlays */
    mix-blend-mode: normal; 
}

/* Ensure JS thickness logic works */
.hll-grid-line.vertical {
    width: var(--major-width, 1px);
    height: 100%;
    transform-origin: top left; /* Sharp rendering */
}

.hll-grid-line.horizontal {
    height: var(--major-width, 1px);
    width: 100%;
    transform-origin: top left;
}

/* ==========================================
   LABELS (Sticky Axis)
   ========================================== */
.label-layer {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 10; overflow: hidden;
}

/* ==========================================
   LABELS (Sticky Axis)
   ========================================== */
.hll-grid-label {
  position: absolute;
  top: 0; left: 0;
  font-family: 'GothamSS', sans-serif; 
  font-weight: 900; 
  font-size: 24px;
  color: #ffffff;
  
  /* --- THE FIX --- */
  /* 1. Remove the old shadow hack */
  text-shadow: none !important;
  
  /* 2. Add a real vector stroke (Black, 3px thick) */
  -webkit-text-stroke: 3px #000000;
  
  /* 3. CRITICAL: Draw the stroke BEHIND the white fill */
  /* Without this, the black line will cover half your white text */
  paint-order: stroke fill;
  /* ---------------- */
  
  display: flex; align-items: center; justify-content: center;
  width: 0; height: 0; pointer-events: none; z-index: 3;
  transform-origin: center center;
  transition: none !important;
}

/* ==========================================
   PERFORMANCE FIX: GPU LABEL SCALING
   ========================================== */

/* Apply variables to the container so all children inherit instantly */
#markers {
    /* Set default values to prevent pop-in */
    --label-arrow-op: 0;
    --label-top: 0%;
    --label-transform: translate(-50%, -100%) scale(1);
}

.marker-label {
    /* REMOVE manual transitions here if any exist to ensure instant sync */
    transition: none !important; 
    
    /* READ values from the parent container */
    top: var(--label-top, 50%) !important;
    transform: var(--label-transform, translate(-50%, -100%) scale(1)) !important;
    
    /* Keep existing styles */
    position: absolute;
    left: 50%;
    will-change: transform, top; /* Hint for Firefox */
}

.marker-label::after {
    /* READ opacity from parent */
    opacity: var(--label-arrow-op, 0) !important;
    transition: none !important;
}

/* ==========================================
   MARKERS
   ========================================== */
.markers-layer {
  position: absolute; top: 0; left: 0; 
  /* We will set width/height in JS to match the map image exactly */
  /* width: 100%; height: 100%;  <-- These will be overridden by JS */
  
  pointer-events: none;
  z-index: 110; 
  text-rendering: geometricPrecision;
  shape-rendering: geometricPrecision;
  
  /* FIX: Clip dashed lines at the edge of the map */
  overflow: hidden !important;
}

.marker {
  position: absolute;
  pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
}

/* --- ARTILLERY ICONS (Dynamic Scaling Fix) --- */
.marker.point {
    /* 1. DYNAMIC SIZING */
    width: var(--dynamic-icon-size, 32px) !important;
    height: var(--dynamic-icon-size, 32px) !important;
    
    /* 2. INSTANT CENTERING */
    margin-left: calc(var(--dynamic-icon-size, 32px) / -2) !important;
    margin-top: calc(var(--dynamic-icon-size, 32px) / -2) !important;
    
    /* 3. PERFORMANCE: NO TRANSITIONS */
    transition: none !important; 
    
    /* 4. ALIGNMENT & LAYER */
    z-index: 100; /* Stays above labels */
    display: flex; 
    align-items: center; 
    justify-content: center;
    position: absolute;
    pointer-events: auto; /* Keeps them clickable for gun switching */
}

.arty-icon {
    /* Force the image to fill the dynamic container completely */
    width: 100% !important; 
    height: 100% !important;
    
    display: block; 
    pointer-events: none;
    
    /* Rotation transition remains */
    transition: transform 0.2s ease-out;
    
    outline: 1px solid transparent;
    image-rendering: auto; 
}

.marker.dimmed-gun { opacity: 1.0 !important; transition: opacity 0.2s ease; filter: none !important; }

/* Ensure the active gun is above the trajectory line (100) */
.marker.active-gun { 
    z-index: 105 !important; 
}

/* Ensure the tiny X stays at the absolute top */
.impact-marker {
    z-index: 110 !important;
}


/* Context Menu Styling */
#artilleryContextMenu {
    font-family: 'GothamSS', sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#artilleryContextMenu .context-menu-item {
    transition: background-color 0.1s ease;
}

#artilleryContextMenu .context-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Dropdown separator styling */
.dropdown-separator {
    background-color: rgba(255, 255, 255, 0.2) !important;
    height: 1px !important;
    margin: 4px 8px !important;
}

/* Keep the trajectory line and circles at 100 */
.trajectory-visual, 
.impact-circles-svg {
    z-index: 100 !important;
}

/* --- UNSELECTED GUNS (Dimmed State) --- */
.marker.dimmed-gun {
    /* Sit below the active gun (105) and trajectory (100) */
    z-index: 90 !important; 
    
    opacity: 1.0 !important; 
    
    /* No grayscale - full color */
    filter: none !important; 
    
    /* REMOVED TRANSITION: Instant state change */
    transition: none !important;
}


.marker.strongpoint { 
    background: none; border: none; border-radius: 0;
    display: flex; justify-content: center; align-items: center;
    position: absolute; overflow: visible;
    transform-origin: center center; box-sizing: border-box; 
    /* Lower than the line (was 25) */
    z-index: 10 !important; 
}

.marker.strongpoint .marker-visual {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 50%; box-sizing: border-box; 
    /* Draw outline INSIDE the circle (do not grow the circle outward) */
    border: none;
    background-color: transparent; 
    background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1) 16px, #000000 16px, #000000 18px);
    pointer-events: none; z-index: 1; 
    box-shadow:
      inset 0 0 0 8px #000000,
      0 0 4px rgba(0,0,0,0.5);
}

.marker-label {
  z-index: 15 !important; 
  
  /* Font Settings */
  font-size: 42px; 
  font-family: 'GothamSS', sans-serif; 
  font-weight: 700; 
  color: white;
  
  /* Box Settings */
  padding: 2px 6px; 
  background-color: rgba(20, 20, 20, 0.70); 
  border-radius: 2px;
  
  /* Layout */
  text-align: center; 
  white-space: nowrap; 
  pointer-events: none;

  /* --- CHROME BLUR FIX START --- */
  
  /* 1. Force High-Quality Font Rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; /* Crucial for sharp text */

  /* 2. Prevent Bitmap Caching (Stop GPU Blur) */
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  
  /* FIX: REMOVE THIS LINE to prevent memory exhaustion */
  /* will-change: transform; */
  
  /* --- CHROME BLUR FIX END --- */
}

.marker-label::after {
    content: ''; 
    position: absolute; 
    top: 100%; 
    left: 50%; 
    transform: translateX(-50%);
    
    /* Your custom size (Keep this) */
    border-left: 20px solid transparent;   
    border-right: 20px solid transparent;  
    border-top: 20px solid rgba(20, 20, 20, 0.70); 
    
    opacity: var(--arrow-opacity, 0); 
    
    /* --- DELETE THIS LINE TO STOP FLICKER --- */
    /* transition: opacity 0.2s; */
}

/* --- CONTROLS DRAWER --- */
.controls-drawer {
  /* Position absolute at bottom to allow sliding off screen */
  position: relative; 
  /* CHANGE: Force full width to remove side gaps */
  width: 100%; 
  max-width: 100%; 
  
  /* Animation settings */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0); /* Default: Open */
  
  /* Flex to center the content */
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none; /* Let clicks pass through invisible areas */
    /* CHANGE: High Z-Index to beat the HUD */
    z-index: 1000 !important; 
    
    background-color: rgba(0,0,0,0);
}

/* CLOSED STATE: Slide down 100% (flush with bottom) */
.controls-drawer.closed,
.controls-drawer.hidden-by-default {
  /* CHANGE: Removed " + 20px" so it tucks away perfectly */
  transform: translateY(100%);
}

/* ==========================================
   UNIFIED UI THEME (Exact Color Match Fix)
   ========================================== */

/* Define the exact shared background color here */
:root {
    --drawer-bg: #181818; 
}

/* LAYER 1: The Drawer Tab (Lowest) */
.drawer-tab {
    position: absolute;
    top: -31px !important;
    height: 32px;
    width: 80px;
    
    /* Z-INDEX 1200: Lower than the Panel */
    z-index: 1200 !important; 
    
    /* EXACT COLOR MATCH */
    background-color: var(--drawer-bg) !important;
    
    /* Borders */
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: none !important;
    
    /* Shape */
    border-radius: 10px 10px 0 0 !important;
    cursor: pointer;
    pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    
    /* REMOVE SHADOWS to flatten the look */
    box-shadow: none !important;
}

/* LAYER 2: The Main Panel (Middle) */
.controls-content {
    position: relative;
    top: 1px;
    
    /* Z-INDEX 1300: Higher than Tab */
    z-index: 1300 !important; 
    
    /* EXACT COLOR MATCH */
    background-color: var(--drawer-bg) !important;
    
    display: flex; justify-content: center;
    width: 100%; max-width: 600px;
    margin: 0 auto; padding: 8px 12px; gap: 10px;
    
    /* Borders */
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

/* LAYER 2.5: The "Eraser" Patch */
.controls-content::before {
    content: "";
    position: absolute;
    
    /* Position slightly higher to cover the seam aggressively */
    top: -3px; 
    left: 50%;
    transform: translateX(-50%);
    
    /* Width matches the inner width of the tab (80px - borders) */
    width: 78px; 
    
    /* Taller height to ensure full coverage */
    height: 6px; 
    
    /* EXACT COLOR MATCH */
    background-color: var(--drawer-bg);
    
    z-index: 1301;
}

/* --- 4. THE ARROW (White) --- */
.tab-arrow {
  color: transparent; 
  display: block;
  width: 8px;
  height: 8px;
  
  /* WHITE lines to match sidebar icons */
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  
  /* Orientation: Down */
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.3s ease;
}

/* Arrow Orientation: Up (Closed) */
.controls-drawer.closed .tab-arrow {
  transform: rotate(225deg) translateY(-2px);
}

/* ==========================================
   UI CONTROLS
   ========================================== */
/* 1. RAISE THE MAIN UI CONTAINER (Map/Faction/Gun Panel) */
.main-ui-overlay {
  position: absolute; 
  bottom: 0; /* CHANGE: Was 20px. Now 0 to dock it to the edge. */
  left: 50%; 
  transform: translateX(-50%);
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 5px;
  
  /* CRITICAL CHANGE: Increased to 3000 to beat EVERYTHING */
  z-index: 3000 !important; 
  
  pointer-events: none; /* Lets clicks pass through empty spaces */
}

/* SCALE BAR & ZOOM INDICATOR */
.scale-container { 
  width: 100%; 
  max-width: 400px;
  display: flex; 
  justify-content: center; 
  align-items: flex-end; 
  margin-bottom: 35px;    
  position: relative; 
  padding: 0; 
  
  /* THE FIX: Let touches pass through the empty space around the bar */
  pointer-events: none !important; 
}

.scale-wrapper { 
  display: flex; flex-direction: column; align-items: center; 
  width: 0px; transition: width 0.1s linear; 
}

.scale-bar-graphic {
  position: relative; height: 8px; width: 100%;
  box-sizing: border-box; 
  /* FIX: Sharp white border, no fuzzy shadow */
  border: 1px solid #ffffff; 
  background: linear-gradient(to right, #ffffff 50%, #000000 50%);
  box-shadow: none !important;
}

.scale-lbl {
  position: absolute; bottom: 0; transform: translateX(-50%);
  font-family: "GothamSS", sans-serif; font-weight: 900; 
  font-size: 12px; color: #ffffff; white-space: nowrap; 
  line-height: 1;
  /* FIX: Use stroke instead of shadow */
  text-shadow: none !important;
  -webkit-text-stroke: 2px #000000;
  paint-order: stroke fill;
}

.scale-tick { 
  position: absolute; bottom: -6px; width: 2px; height: 14px; 
  z-index: 5; background: #fff; box-shadow: 0 0 1px black;
}
.t-start { left: 0; transform: translateX(-50%); }
.t-mid   { left: 50%; transform: translateX(-50%); }
.t-end   { right: 0; transform: translateX(50%); }

.scale-labels { 
  position: relative; width: 100%; height: 16px; margin-top: 4px; 
}

.l-start { left: 0%; }
.l-mid { left: 50%; }
.l-end { left: 100%; }

/* ZOOM INDICATOR */
.zoom-indicator-inline {
  /* CHANGE: Moved further right (was -40px) to prevent overlap */
  position: absolute; right: -70px; bottom: 15px; margin-right: 0px; 
  pointer-events: none; 
}

#zoomIndicator {
    text-align: left !important;
    font-size: 16px !important;
    display: block !important;
    line-height: 1 !important;
    color: #fff;
    
    /* --- THE FIXES --- */
    /* 1. Force the font to be thick/heavy so the white shows through */
    font-family: 'GothamSS', sans-serif !important;
    font-weight: 900 !important; 

    /* 2. Remove Shadow */
    text-shadow: none !important;
    
    /* 3. Use a thinner stroke (1.5px) for this small text */
    /* 2px was too thick for 16px text */
    -webkit-text-stroke: 2px #000000;
    paint-order: stroke fill;
}

.controls-row {
  display: flex; align-items: stretch; gap: 10px;
  background: rgba(0,0,0,0.8); padding: 8px 12px; border-radius: 4px;
  width: 100%;
}

/* ==========================================
   LOADING OVERLAY
   ========================================== */
.loading-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  z-index: 4000; transition: opacity 0.3s ease-out; opacity: 1; pointer-events: auto;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 40px; height: 40px; border: 4px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%; border-top-color: #fff;
  animation: spin 1s ease-in-out infinite; margin-bottom: 12px;
}
.loading-text {
  color: white; font-size: 16px; font-family: 'GothamSS', sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Ensure SVG icons scale with font-size and inherit color */
svg.icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  display: block; /* Removes baseline gap issues */
}

/* --- MODAL FOOTER ICON SIZE INCREASE --- */

/* Target icons only inside modal footer */
.modal-footer .footer-btn .icon {
    /* Increased from 20px/22px to 28px for better visibility */
    width: 28px !important;
    height: 28px !important;
    
    /* Ensure colors and strokes stay consistent */
    fill: none !important;
    stroke: currentColor !important;
    vector-effect: non-scaling-stroke !important;
}

/* Specific fix for the 'dots' in the calculator icon to make them bigger too */
.modal-footer .footer-btn .icon circle {
    fill: currentColor !important;
    stroke: none !important;
    r: 1.2; /* Slightly larger dots for larger icon */
}

/* Desktop: Adjust spacing for the larger icons */
@media (min-width: 769px) {
    .modal-footer .footer-btn .icon {
        margin-right: 15px !important; /* More breathing room for bigger icon */
    }
    
    .modal-footer .footer-btn {
        padding: 0 30px !important; /* Wider buttons to accommodate size */
    }
}


/* --- DESKTOP WHITE BLOCK FIX --- */

/* Mobile PLACE button — slightly smaller, same position */
#mobilePlaceBtn {
  position: absolute;
  bottom: 230px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #28a745;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  font-family: 'GothamSS', sans-serif;
  font-weight: 900;
  font-size: 14px;         /* smaller */
  padding: 11px 30px;      /* smaller */
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  z-index: 510;
  pointer-events: auto;
  white-space: nowrap;
}
#mobilePlaceBtn:active,
#mobilePlaceBtn.pressed {
  transform: translateX(-50%) translateY(4px) scale(0.95) !important;
  background-color: #ffc107 !important;
  color: black !important;
}

/* ==============================================================
   MOBILE PLACEMENT CROSSHAIR ONLY (Custom Artillery)
   Live HUD is completely untouched
   ============================================================== */

#mobileCrosshair.placement-mode {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;   /* single clean translate */
  width: 68px !important;
  height: 68px !important;
  z-index: 200 !important;
  pointer-events: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  filter: drop-shadow(0 0 12px #ffc107);
}

#mobileCrosshair.placement-mode .garrisonCrosshairImg {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Hide rings ONLY during placement (does not affect live HUD) */
#mobileCrosshair.placement-mode #mobileRingContainer,
#mobileCrosshair.placement-mode .m-ring {
  display: none !important;
}

/* CLEAN CUSTOM ARTILLERY - No square border */
.marker.custom-artillery {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* ACTIVE GUN - Clean without yellow glow */
.marker.custom-artillery.active-gun .arty-icon {
    filter: invert(1);
    transform: scale(1.08);               /* slight pop */
    transition: filter 0.2s ease, transform 0.15s ease;
}

/* Dimmed guns stay clean */
.marker.custom-artillery.dimmed-gun .arty-icon {
    filter: none;
    transform: scale(1);
}
@media (min-width: 769px) {
  /* 1. Force the icon to be an outline, not a solid block */
  .modal-footer .footer-btn .icon {
    position: static !important;
    transform: none !important;
    fill: none !important; /* This stops the white background block */
    stroke: currentColor !important; /* This ensures the lines are visible */
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px !important;
    display: inline-block !important;
  }

  /* 2. Specific fix for the tiny dots inside the calculator */
  .modal-footer .footer-btn .icon circle {
    fill: currentColor !important; /* Only the dots should be solid */
    stroke: none !important;
  }

  /* 3. Ensure the button doesn't force absolute centering on desktop */
  .modal-footer .footer-btn:first-child {
    width: auto !important;
    flex: 0 1 auto !important;
    padding: 0 20px !important;
  }
}

/* --- DESKTOP FOOTER: UNIFIED SPACING & SIZE --- */
@media (min-width: 769px) {
  
  /* Target BOTH buttons explicitly to override any specific previous rules */
  .modal-footer .footer-btn,
  .modal-footer .footer-btn:first-child, 
  .modal-footer .footer-btn:last-child {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: 54px !important;
    width: auto !important;
    
    /* THE FIX: Identical spacing for BOTH buttons */
    padding-left: 15px !important;  /* Edge -> Icon */
    gap: 15px !important;           /* Icon -> Text */
    padding-right: 25px !important; /* Text -> Edge */
  }

  /* 1. Calculator Icon (Keep it slightly larger as requested before) */
  #btnOpenManualCalc .icon {
    position: static !important;
    width: 32px !important;  
    height: 32px !important; 
    margin: 0 !important; 
    display: inline-block !important;
    vertical-align: middle;
  }

  /* 2. More Projects Icon (Standard Size) */
  #btnOtherProjects .icon {
    position: static !important;
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    display: inline-block !important;
    vertical-align: middle;
  }
}

/* ==========================================
   SHOOTING PULSE (Smaller Sonic Boom - Safe)
   ========================================== */

@keyframes shot-ripple {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5); 
        opacity: 0;
    }
}

.shot-pulse {
    position: absolute;
    width: 50px;  
    height: 50px;
    border-radius: 50%;
    
    /* Sharp White Ring Gradient */
    background: radial-gradient(
        circle, 
        transparent 55%, 
        rgba(255, 255, 255, 1.0) 60%, 
        rgba(255, 255, 255, 1.0) 65%, 
        transparent 70%
    );
    
    border: none;
    box-shadow: none;
    
    pointer-events: none;
    z-index: 200 !important; 
    
    /* REMOVED 'will-change' to prevent checkerboarding on Android/Chrome */
    /* Modern devices can handle this simple transform without the hint. */
    
    animation: shot-ripple 0.3s ease-out forwards;
}

/* ==========================================
   ERROR FEEDBACK ANIMATION
   ========================================== */

/* Margin-based shake (Safe for Mobile layers) */
@keyframes shake-red-safe {
    0%, 100% { margin-left: 0; }
    20% { margin-left: -4px; border-color: #ff4444; color: #ff4444; }
    40% { margin-left: 4px; border-color: #ff4444; color: #ff4444; }
    60% { margin-left: -4px; border-color: #ff4444; color: #ff4444; }
    80% { margin-left: 4px; border-color: #ff4444; color: #ff4444; }
}

.btn-error {
    animation: shake-red-safe 0.5s cubic-bezier(.36,.07,.19,.97) both;
    /* Force colors */
    border-color: #ff4444 !important;
    color: #ff4444 !important;
    /* Ensure relative positioning for margins to work */
    position: relative; 
}

/* Hide the default tooltip if the error is active 
   (Prevents double text on Desktop) */
.btn-error::before,
.btn-error::after {
    display: none !important;
}

/* ==========================================
   ALLOW 2-LINE TEXT WRAPPING
   ========================================== */

/* --- UNIFY THE BASE BUTTON COLOR --- */
.btn-map-select {
  /* Allow height to grow for 2 lines */
  height: auto !important; 
  
  /* Force a minimum height that fits 2 lines of text */
  min-height: 56px !important;
  
  /* Vertical Padding helps when text wraps */
  padding: 4px 10px;
  
  /* Use Flexbox to vertically center single-line text (like 'Germany') */
  display: flex;
  align-items: center; 
  justify-content: space-between;
  
  /* Optional: Ensure text wrapping for long map names */
  white-space: normal;
  line-height: 1.2;
  text-align: left;
  
  /* CHANGE: Replace the gradient with a solid charcoal to match the menu */
  background: rgba(29, 31, 39, 0.9) !important; 
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-left: 3px solid #ffc107; 
  border-radius: 0 3px 3px 0; 
  
  /* Keep your existing Gotham font styles */
  color: white;
  font-family: 'GothamSS', sans-serif; 
  font-weight: 900;
  font-size: 13px; 
  text-transform: uppercase; 
  letter-spacing: 0.5px;
  cursor: pointer; 
  pointer-events: auto;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  transition: background 0.2s ease;
}

/* 2. Text Labels: Fix Wrapping Logic */
#currentMapName,
#factionLabel,
#gunLabel {
  /* ENABLE WRAPPING but keep words intact */
  white-space: normal;       /* Allow wrapping */
  
  /* CRITICAL FIX: Stop breaking words like "BRITI-SH" */
  word-break: normal;        
  overflow-wrap: break-word; /* Only break if a single word is wider than the box */
  
  /* Layout improvements */
  line-height: 1.1;       
  text-align: left;          /* Or 'center' if you prefer */
  margin-right: 4px;         /* Reduced margin to give text more space */
  display: block; 
  flex: 1;
}

/* Active state for faction button when dropdown is open */
.btn-map-select.active {
    background-color: rgba(45, 48, 60, 1) !important; /* Slightly lighter when menu is open */
}

button.btn-map-select:active {
  background: rgba(60, 60, 60, 1);
}

select.btn-map-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 8px center;
  background-size: 14px; padding-right: 28px; height: 100%;
}

select.btn-map-select option {
  background-color: #1d1f27; color: #ffffff; padding: 12px;
}

.btn-map-select.compact {
  min-width: auto; padding: 12px 15px; font-size: 14px; gap: 15px;
  border-left: 1px solid rgba(255,255,255,0.2); 
  height: 32px;
}

.btn-map-select .icon {
  font-size: 14px; color: rgba(255,255,255,0.5);
  transition: color 0.2s, transform 0.2s ease; display: inline-block;
}

.btn-map-select.active .icon { transform: rotate(180deg); color: white; }
@media (hover: hover) {
  .btn-map-select:hover .icon { color: white; }
}

/* ==========================================
   MAP SELECTOR GRID (FIXED)
   ========================================== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex; justify-content: center; align-items: center;
  z-index: 3000; transition: opacity 0.2s ease-in-out; opacity: 0; pointer-events: none;
  /* FIX 4: Disable Backdrop Filter on Mobile (GPU Hog) */
  /* Default: No Blur (Mobile Safe) */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

/* FIX 4: Desktop Only: Re-enable Blur */
@media (min-width: 769px) {
    /* Desktop Only: Re-enable Blur */
    .modal-overlay {
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
    }
}

.modal-content {
  background-color: #15171e; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; width: 90%; max-width: 1100px; height: 85%; /* Increased height slightly */
  overflow-y: hidden; box-shadow: 0 0 30px rgba(0,0,0,0.9);
  display: flex; flex-direction: column;
  transform: translateY(20px); transition: transform 0.2s ease-in-out;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

/* ==========================================
   MODAL HEADERS (UPDATED X POSITION)
   ========================================== */

.modal-brand-header {
  position: relative; /* REQUIRED to anchor the X button */
  padding: 25px 20px;
  background: rgba(0, 0, 0, 0.4); 
  border-bottom: 1px solid rgba(255, 193, 7, 0.3); 
  
  font-family: 'GothamSS', sans-serif;
  font-weight: 900;
  font-size: 32px; 
  color: #ffc107; 
  
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 15px rgba(255, 193, 7, 0.4); 
  flex-shrink: 0;
}

.modal-subtitle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 100%;
}

.modal-search-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
}

#mapSearchInput {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 4px;
  padding: 10px 40px 10px 15px;
  color: white;
  font-family: 'GothamSS', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s;
}

#mapSearchInput:focus {
  border-color: #ffc107;
  background: rgba(0, 0, 0, 0.6);
}

.search-clear-btn {
  position: absolute;
  right: 12px; /* Move to right edge since search icon is removed */
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  display: none; /* Hidden by default */
  line-height: 1;
  transition: color 0.2s;
}

@supports (-moz-appearance: none) {
  .search-clear-btn {
    top: 45%; /* Adjust for Firefox */
  }
}

.search-clear-btn:hover {
  color: #ff4444;
}

/* Show the clear button only when there is text in the input */
#mapSearchInput:not(:placeholder-shown) ~ .search-clear-btn {
  display: block;
}

.modal-sub-header {
  padding: 15px 25px;
  background: rgba(255, 255, 255, 0.03); 
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; 
  justify-content: center; 
  align-items: center;
  flex-shrink: 0;
}

.modal-subtitle {
  font-family: 'GothamSS', sans-serif; 
  font-size: 14px; 
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7); 
  text-transform: uppercase; 
  letter-spacing: 1.5px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.arrow-down {
  color: #ffc107;
  font-size: 12px;
  opacity: 0.8;
}

.close-btn {
  position: absolute; 
  right: 15px;         /* Move to corner */
  top: 10px;           /* Pin to top */
  transform: none;     /* Remove the centering transform */
  
  background: none; 
  border: none; 
  color: rgba(255, 255, 255, 0.4); 
  font-size: 32px; 
  line-height: 1; 
  cursor: pointer; 
  padding: 0;
  transition: all 0.2s ease;
  z-index: 2000;       /* Ensure it sits on top of everything */
}

/* Hover effect */
.close-btn:hover { 
  color: #ff4444; 
  transform: scale(1.1); /* Subtle zoom only */
}

.map-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  /* CHANGE: Use grid-auto-rows to ensure all rows are exactly the same height */
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  grid-auto-rows: min-content; 
  align-content: start; /* Forces the grid to the top of the container */
  gap: 15px;
  width: 100%;
  box-sizing: border-box;
}

/* ==========================================
   MAP SELECTOR GRID IMAGE FIX              */
/* ========================================== */
.map-card {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background: #111;
    
    /* FIX: Ensure border exists but is transparent so it doesn't jump */
    border: 3px solid transparent; 
    
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    
    /* FIX: Add box-shadow to the transition so the glow fades in/out smoothly */
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.map-card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 1 !important; /* Force visibility */
    transition: transform 0.3s ease;
}

/* --- DESKTOP HOVER: YELLOW HIGHLIGHT --- */
@media (hover: hover) and (min-width: 769px) {
    /* When hovering ANY card that is NOT currently selected */
    .map-card:not(.active):hover {
        border-color: #ffc107; /* Tactical Yellow */
        box-shadow: 0 0 15px rgba(255, 193, 7, 0.4); /* Yellow Glow */
        transform: translateY(-2px); /* Subtle lift effect */
        z-index: 5; /* Ensure glow sits on top of neighbors */
    }

    /* Optional: When hovering the ALREADY SELECTED (Green) card */
    .map-card.active:hover {
        /* Keep Green Border */
        border-color: #28a745 !important; 
        /* Add Green Glow instead of Yellow */
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.5); 
        transform: translateY(-2px);
    }
}

/* Ensure the green highlight beats everything */
.map-card.active {
    border-color: #28a745 !important;
}


.map-card-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95), transparent);
  color: white; padding: 8px 10px;
  font-family: 'GothamSS', sans-serif; font-size: 13px; font-weight: 700;
  text-transform: uppercase; pointer-events: none; text-shadow: 0 1px 2px black;
}

/* 3. NEW: Modal Footer */
.modal-footer {
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-shrink: 0; /* Prevents shrinking */
}

/* 4. NEW: Footer Buttons */
.footer-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
  font-family: 'GothamSS', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.footer-btn .icon {
  font-size: 16px;
  filter: grayscale(1); /* Muted icon */
}

.footer-btn:hover {
  background: rgba(255, 193, 7, 0.1);
  border-color: #ffc107;
  color: #ffc107;
  box-shadow: 0 0 15px rgba(255, 193, 7, 0.1);
}

.footer-btn:hover .icon {
  filter: none; /* Color icon on hover */
}

/* Optional: Different style for "Other Projects" if you want */
.footer-btn.secondary {
  border-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================
   CUSTOM DROPDOWNS
   ========================================== */
.custom-dropdown {
  position: relative; 
  height: auto; 
  display: flex; 
  flex-direction: column;
  /* Above the 'Eraser' patch and Tab */
  z-index: 1400 !important;
}

/* --- UNIFY THE DROPDOWN MENU COLOR --- */
.dropdown-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  min-width: 150px;
  
  /* MATCH: Use the exact same color as the button */
  background-color: rgba(29, 31, 39, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  
  /* FIX 4: Disable Backdrop Filter on Mobile (GPU Hog) */
  /* Default: No Blur (Mobile Safe) */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
  z-index: 9999 !important;
  opacity: 1; transform: translateY(0); transition: opacity 0.15s, transform 0.15s;
  pointer-events: auto;
}

/* FIX 4: Desktop Only: Re-enable Blur */
@media (min-width: 769px) {
    /* Desktop Only: Re-enable Blur */
    .dropdown-menu {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

.dropdown-menu.hidden {
  opacity: 0; pointer-events: none; transform: translateY(10px);
}

.dropdown-item {
  padding: 12px 15px; color: white; font-family: 'GothamSS', sans-serif;
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: background 0.1s; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.dropdown-item:last-child { border-bottom: none; }
/* --- HOVER STATE UNIFICATION --- */
.dropdown-item:hover,
button.btn-map-select:hover {
  /* Use a lighter grey for the hover highlight */
  background-color: rgba(60, 64, 75, 1) !important;
  color: #ffc107; /* Tactical yellow text on hover */
}

.dropdown-item:hover { border-left-color: #ffffff; }
button.btn-map-select:hover { border-left-color: #ffffff; }

/* ==========================================
   TRAJECTORY & TARGETING (SHARP FIX)
   ========================================== */

/* 1. Trajectory Line */
.trajectory-visual {
  /* Set much higher to clear everything */
  z-index: 100 !important; 
  position: absolute;
  pointer-events: none;
}

.trajectory-visual line {
    /* The variable MUST come first */
    stroke-width: var(--dynamic-stroke, 3px) !important; 
    stroke: #ff0000; 
    stroke-linecap: butt; 
    shape-rendering: geometricPrecision;
    vector-effect: non-scaling-stroke !important; 
}

/* THE SVG CIRCLES */
.impact-circles-svg {
  position: absolute;
  z-index: 100 !important;
  pointer-events: none;
  
  /* FIX: Ensure the SVG coordinate 0,0 is treated as the center */
  overflow: visible;
  transform: translate(0, 0); /* Reset any accidental shifts */
}

/* Ensure the circles inside the SVG are centered on 0,0 */
.impact-circles-svg circle {
  cx: 0;
  cy: 0;
}

/* ==========================================
   IMPACT POINT "X" (Longer & Sharp)
   ========================================== */
.impact-marker {
    position: absolute; 
    width: 12px;  
    height: 12px;
    
    /* CRITICAL FIX: This shifts the element back by half its width/height 
       to put the intersection of the X exactly on the coordinate */
    transform: translate(-50%, -50%) !important; 
    
    pointer-events: none;
    z-index: 120 !important;
    opacity: 0.9;
}

.impact-marker::before,
.impact-marker::after {
    content: ''; 
    position: absolute; 
    top: 50%; 
    left: 0; 
    width: 100%; 
    height: 1px; /* Keeping it needle thin */
    background-color: #ffc107;
    box-shadow: none; 
}

.impact-marker::before { transform: translateY(-50%) rotate(45deg); }
.impact-marker::after  { transform: translateY(-50%) rotate(-45deg); }

/* Ruler tick marks (The Balls) */
.trajectory-visual .ruler-tick {
    fill: #ff4444; /* Tactical Red */
    stroke: #ffffff; /* White outline for contrast */
    stroke-width: 1px;
    /* Optional: add a slight outer glow to make it stand out more */
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.8));
}

/* Ruler distance labels */
.trajectory-visual .ruler-text {
  fill: #000000;
  font-size: 10px;
  font-family: 'Roboto-Black', sans-serif;
  font-weight: 900;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
  dominant-baseline: middle; /* Helps with rotation centering */
  paint-order: stroke;
  stroke: rgba(0,0,0,0.5); /* Adds a thin outline for better contrast on any map */
  stroke-width: 0.5px;
  display: none; /* Hide meter text since we're only showing mil boxes now */
}

/* Ruler MIL Label Container */
.ruler-mil-label {
    position: absolute;
    z-index: 105;
    font-family: 'GothamSS', sans-serif;
    padding: 3px 6px; /* Slightly more vertical padding */
    background-color: rgba(20, 20, 20, 0.85);
    border-radius: 2px;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -100%);
    margin-top: -10px;
    display: flex;
    flex-direction: column; /* Stack mil over meters */
    align-items: center;
    gap: 0px;
}

/* The MIL Number (Yellow) */
.ruler-mil-label .mil-value {
    font-size: 14px;
    font-weight: 700;
    color: #ffc107;
    line-height: 1.1;
}

/* THE FIX: The Meter Subtext (Small White) */
.ruler-mil-label .meter-subtext {
    font-size: 7px;
    font-weight: 400;
    color: #ffffff; /* White text */
    opacity: 0.9;
    line-height: 1;
    margin-top: 1px;
}

/* The Arrow for the MIL Label */
.ruler-mil-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(20, 20, 20, 0.85);
}

/* Ruler toggle button states */
#rulerToggleBtn.active {
  background-color: #ffc107;
  color: #000;
}

#rulerToggleBtn:not(.active) {
  background-color: #1d1f27;
  color: white;
}

/* Hidden ruler elements */
.trajectory-visual.ruler-hidden .ruler-tick,
.trajectory-visual.ruler-hidden .ruler-text,
.trajectory-visual.ruler-hidden .ruler-mil-text {
  display: none;
}

/* 2. Impact Circles Common */
.deadzone-circle, 
.dispersion-circle, 
.blast-circle {
    stroke-width: var(--dynamic-circle-stroke, 2px) !important;
    vector-effect: non-scaling-stroke !important;
    shape-rendering: geometricPrecision;
    z-index: 30; 
}

/* 3. Specifics */
.deadzone-circle {
    /* RESTORE FILL */
    fill: rgba(255, 0, 0, 0.3) !important;
    vector-effect: non-scaling-stroke !important;
}

.dispersion-circle {
    stroke-width: var(--dynamic-circle-stroke, 2px) !important;
    stroke: rgba(0, 0, 0, 0.6);
    stroke-dasharray: calc(var(--dynamic-circle-stroke, 2px) * 2);
    /* RESTORE FILL */
    fill: rgba(255, 0, 0, 0.15) !important; 
    vector-effect: non-scaling-stroke !important;
}

/* --- THE FIX FOR BLURRY RED CIRCLE --- */
.blast-circle {
    stroke: none; 
    /* RESTORE SOLID FILL */
    fill: rgba(255, 0, 0, 0.5) !important;
    vector-effect: non-scaling-stroke !important;
}

/* --- TACTICAL PANEL (INVERTED) --- */
.target-data-panel {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Stretch rows to full width */
    
    background-color: rgba(15, 15, 15, 0.95);
    /* FIX 4: Disable Backdrop Filter on Mobile (GPU Hog) */
    /* Default: No Blur (Mobile Safe) */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: 3px solid #ffc107; /* Yellow Top Bar */
    border-radius: 4px;
    
    min-width: 300px;
    z-index: 2500;
    pointer-events: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    
    /* CRITICAL: Allow watermark to "hang" outside */
    overflow: visible !important; 
    /* Push panel down so watermark doesn't hit screen edge */
    margin-top: 25px;
}

/* FIX 4: Desktop Only: Re-enable Blur */
@media (min-width: 769px) {
    /* Desktop Only: Re-enable Blur */
    .target-data-panel {
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
    }
}

/* Force standard hidden behavior without transitions */
.target-data-panel.hidden { 
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* --- ROW 1: THE BIG NUMBER --- */
.panel-row.main-row {
    padding: 10px 0 5px 0;
    text-align: center;
    background: linear-gradient(to bottom, rgba(255,255,255,0.02), transparent);
}

.solution-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- ROW 2: THE CONTEXT --- */
.panel-row.context-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px 10px 15px; /* More padding on bottom */
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.2); /* Slightly darker bottom */
}

.data-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1; 
}

/* --- UTILITIES --- */
.panel-horiz-divider {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.panel-watermark {
    /* Maintain your topside positioning */
    position: absolute;
    bottom: calc(100%); 
    
    /* FORCE HORIZONTAL CENTER */
    left: 50% !important;
    transform: translateX(-50%) !important;
    
    /* Ensure it doesn't wrap and stays in a single line */
    width: max-content;
    white-space: nowrap;
    
    /* Spacing from the yellow border */
    padding-bottom: 3px; 
    
    text-align: center;
    font-family: 'GothamSS', sans-serif;
    font-weight: 900;
    font-size: 10px;
    letter-spacing: 1px;
    
    color: rgba(46, 45, 45, 0.6);
    text-transform: uppercase;
    
    pointer-events: none;
    user-select: none;
}

/* Bullet Style */
.watermark-bullet {
    color: #ffc107 !important; /* Tactical Yellow */
    margin: 0 4px;
    font-size: 12px;
    vertical-align: middle;
}

/* --- TYPOGRAPHY --- */
.lbl-main {
    font-size: 9px !important; /* Slightly smaller than before */
    letter-spacing: 1.5px !important;
    opacity: 0.5;
    font-family: 'GothamSS', sans-serif;
    font-weight: 700;
    margin-bottom: 0px;
}

.val-huge {
    /* Reduced from 52px to 44px */
    font-size: 44px !important; 
    
    /* Ensure the line-height is tight so the box doesn't grow vertically */
    line-height: 0.9 !important; 
    
    /* Keep your existing style preferences */
    font-family: 'GothamSS', sans-serif;
    font-weight: 900;
    color: #ffc107;
    text-shadow: 0 0 25px rgba(255, 193, 7, 0.3);
    margin-top: 5px; 
}

.lbl-tiny {
    font-family: 'GothamSS', sans-serif;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 3px;
}

/* Ensure val-mid is the master controller for size/weight */
.val-mid {
    font-family: 'GothamSS', sans-serif;
    font-size: 16px !important; /* Desktop Size */
    font-weight: 900 !important;
    color: white;
}

/* Ensure colors inherit the size/weight from val-mid */
.val-mid.text-green, 
.val-mid.text-yellow {
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
}

/* --- FONT ENFORCER --- */
/* This forces all text inside the panel to use your custom font */
.target-data-panel,
.target-data-panel span,
.target-data-panel div {
    font-family: 'GothamSS', sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- OPTIONAL: Refined Weights --- */
/* Ensure labels are thick enough to be readable */
.lbl-tiny, .lbl-main {
    font-weight: 700 !important;
    letter-spacing: 1px !important;
}

/* Ensure numbers are extra heavy */
.val-mid, .val-huge {
    font-weight: 900 !important;
}

.text-yellow { color: #ffc107; }
.text-green { color: #28a745; }
.text-red { color: #ff4444; }

/* ==========================================
   VERTICAL ZOOM SLIDER
   ========================================== */
.zoom-slider-container {
  position: absolute; right: 40px; top: 50%; transform: translateY(-50%);
  
  /* UPDATED: Increased height */
  height: 475px; 
  
  width: 40px; 
  display: flex; flex-direction: column;
  align-items: center; gap: 20px; z-index: 100; 
  
  /* THE FIX: Let touches pass through the gaps between buttons */
  pointer-events: none !important; 
}

.zoom-slider-track {
  position: relative; flex: 1; 
  width: 24px; 
  background-color: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 0; cursor: pointer;
  
  pointer-events: auto !important; /* Allow clicking the slider track */
}

.zoom-slider-fill {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 0%; 
  background-color: #ffc107; border-radius: 0; pointer-events: none;
}

.zoom-slider-handle {
  position: absolute; left: 50%; bottom: 0%; transform: translate(-50%, 50%); 
  width: 24px; height: 16px; background-color: #ffffff;
  border: 2px solid #000000; border-radius: 0; 
  cursor: grab; touch-action: none; 
  
  pointer-events: auto !important; /* Allow grabbing the handle */
  /* CHANGE: Removed box-shadow */
  box-shadow: none !important;
}

.zoom-slider-handle:active {
  cursor: grabbing; background-color: #ffc107; border-color: #fff;
}

.zoom-icons {
  display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center;
}

.zoom-icons span {
  width: 32px; height: 32px; background-color: rgba(20, 20, 20, 0.95);
  pointer-events: auto !important; /* Allow clicking the buttons (+, -, etc.) */
  color: white; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 0; 
  display: flex; align-items: center; justify-content: center;
  font-family: 'GothamSS', sans-serif; font-weight: 900; font-size: 20px;
  cursor: pointer; user-select: none; transition: background-color 0.1s;
  -webkit-tap-highlight-color: transparent; 
  /* CHANGE: Removed box-shadow */
  box-shadow: none !important;
}

@media (hover: hover) {
  .zoom-icons span:hover {
    background-color: #ffc107; color: black; border-color: #ffc107;
  }
}

.zoom-icons span:active,
.zoom-icons span.pressed {
  background-color: #ffc107 !important; color: black !important;
  border-color: #ffc107 !important; transform: scale(0.95);
  /* CHANGE: Force shadow removal on press */
  box-shadow: none !important;
}

/* Ensure the Ruler icon inside the zoom slider looks correct */
#rulerToggleBtn svg {
    display: block;
    pointer-events: none;
}

/* 1. Base State (Off) */
#rulerToggleBtn {
    background-color: rgba(20, 20, 20, 0.95) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    touch-action: manipulation; /* Removes 300ms browser delay */
    -webkit-tap-highlight-color: transparent; /* Optional: removes tap highlight box */
    user-select: none; /* Prevents text selection on rapid taps */
    transition: background-color 0.1s, color 0.1s;
}

/* 2. Hover State (Only applies when NOT active to show it's clickable) */
@media (hover: hover) {
    #rulerToggleBtn:not(.active):hover {
        background-color: rgba(60, 60, 60, 1) !important;
        color: #ffc107 !important;
    }
}

/* 3. Active State (ON - Always Yellow) */
#rulerToggleBtn.active {
    background-color: #ffc107 !important;
    color: black !important;
    border-color: #ffc107 !important;
}

/* 4. Active + Hover (Slightly darker yellow so you see click happened) */
@media (hover: hover) {
    #rulerToggleBtn.active:hover {
        background-color: #e5ad06 !important; /* Slightly darker gold */
    }
}

/* Specific Modal Size for Calc - FIX: Remove fixed height */
.calc-content {
  max-width: 400px !important;
  height: auto !important; /* Shrinks to fit content */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* Faction Bar */
.calc-faction-bar {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.2s;
}
.calc-faction-bar:hover { background: rgba(255, 255, 255, 0.1); }

.calc-faction-label {
  font-family: 'GothamSS', sans-serif;
  font-size: 10px; color: rgba(255,255,255,0.5);
  margin-right: 10px;
}
.calc-faction-text {
  font-family: 'GothamSS', sans-serif;
  font-weight: 900; color: white;
  flex: 1;
}
.btn-swap {
  background: none; border: none; color: #ffc107;
  font-size: 18px; cursor: pointer;
}

/* Screen Area */
.calc-screen {
  background: #000;
  padding: 20px;
  border-bottom: 4px solid #ffc107;
}

.screen-row { 
  display: flex; 
  flex-direction: column; 
  align-items: center; /* CHANGED: Centers items horizontally (was flex-end) */
  justify-content: center;
  margin-bottom: 15px; 
  text-align: center; /* Ensures text stays centered */
}
.screen-label { font-family: 'GothamSS', sans-serif; font-size: 10px; color: #888; margin-bottom: 4px; }
/* Screen Input (Target Distance) - Reduced Size */
.screen-input {
  font-family: 'GothamSS', sans-serif; 
  font-weight: 900;
  font-size: 36px; /* Reduced from 48px to 36px */
  color: white; 
  line-height: 1;
}

.screen-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 15px 0; }

/* Screen Results Area */
.screen-results { 
  display: flex; 
  /* Center the single item horizontally */
  justify-content: center; 
  align-items: center;
  width: 100%;
}

.res-box { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  text-align: center;
  /* CHANGED: Let it take full width (was 48%) */
  width: 100%; 
}

/* Ensure labels are centered */
.res-label { 
  font-family: 'GothamSS', sans-serif; 
  font-size: 10px; 
  color: #888; 
  margin-bottom: 5px; 
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Result Value Container - Fixed Height to prevent jumping */
.res-value { 
  font-family: 'GothamSS', sans-serif; 
  font-weight: 900; 
  line-height: 1; 
  
  /* THE FIX: Force a minimum height equal to font size */
  min-height: 48px; 
  display: block; /* Required for min-height to work */
}

/* Elevation (Yellow) - Big */
.text-yellow.res-value {
  font-size: 48px; 
}

/* Error State (Red) - Ensure it matches the height */
.text-red.res-value {
  font-size: 48px; /* Match yellow size so layout doesn't shift */
  color: #ff4444;
}

.text-yellow { color: #ffc107; text-shadow: 0 0 10px rgba(255, 193, 7, 0.3); }
.text-green { color: #28a745; text-shadow: 0 0 10px rgba(40, 167, 69, 0.3); }

/* Keypad Grid */
.calc-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.1); /* Grid lines color */
  padding-top: 1px;
}

.key {
  background: #1d1f27;
  border: none;
  height: 70px;
  color: white;
  font-family: 'GothamSS', sans-serif;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s;
}

.key:active { background: #333; }
.key.action { background: #252830; font-size: 20px; }
.key.action.red { color: #ff4444; }

/* Add to your CSS file */
.key.pressed {
  background-color: #ffc107 !important; /* Yellow flash */
  color: #000 !important;
  transform: scale(0.95);
}

/* --- LIVE CURSOR HUD STYLES --- */

/* 1. The Toggle Button (Matches Ruler Button Logic) */
#hudToggleBtn svg {
    display: block;
    pointer-events: none;
}

#hudToggleBtn {
    background-color: rgba(20, 20, 20, 0.95) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    touch-action: manipulation; /* Removes 300ms browser delay */
    -webkit-tap-highlight-color: transparent; /* Optional: removes tap highlight box */
    user-select: none; /* Prevents text selection on rapid taps */
    transition: background-color 0.1s, color 0.1s;
}

@media (hover: hover) {
    #hudToggleBtn:not(.active):hover {
        background-color: rgba(60, 60, 60, 1) !important;
        color: #ffc107 !important;
    }
}

/* Active State (ON - Yellow) */
#hudToggleBtn.active {
    background-color: #ffc107 !important;
    color: black !important;
    border-color: #ffc107 !important;
}

/* Visual feedback on press */
#hudToggleBtn:active {
    transform: scale(0.95);
}

/* --- FIX 2: Live HUD Layering --- */
.live-hud {
    position: fixed;
    /* Elevated to clear the Drawer (2000) and Target Panel (2500) */
    z-index: 2600 !important; 
    background: rgba(15, 15, 15, 0.9); /* Slightly darker for legibility */
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-left: 3px solid #ffc107;
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 4px 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 90px;
}

.live-hud.hidden {
    display: none;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.hud-label {
    font-family: 'GothamSS', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #888;
    letter-spacing: 0.5px;
}

.hud-value {
    font-family: 'GothamSS', sans-serif;
    font-size: 14px;
    font-weight: 900;
    color: white;
}

.hud-value.text-yellow { color: #ffc107; }
.hud-label.text-yellow { color: #ffc107; }

/* --- TACTICAL INDICATOR TOOLTIPS --- */

[data-tooltip] {
  position: relative;
}

/* Tooltip Box Styling */
[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 12px); /* Spacing to the left of buttons */
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  
  /* Tactical Aesthetics matching GothamSS font */
  background-color: rgba(29, 31, 39, 0.95);
  color: #ffc107; 
  font-family: 'GothamSS', sans-serif;
  font-weight: 900;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 193, 7, 0.4);
  white-space: nowrap;
  pointer-events: none;
  
  opacity: 0;
  transition: opacity 0.1s ease-out, transform 0.1s ease-out;
}

/* Small Indicator Arrow */
[data-tooltip]::after {
  content: '';
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid rgba(255, 193, 7, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease-out;
}

/* Desktop Hover Interaction */
@media (hover: hover) {
  [data-tooltip]:hover::before {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  [data-tooltip]:hover::after {
    opacity: 1;
  }
}

/* Ensure arrow is fully opaque on hover */
@media (hover: hover) {
  [data-tooltip]:hover::after {
    opacity: 1 !important; /* Forces full visibility */
  }
}

/* Hub specific content size */
.projects-hub-content {
  max-width: 500px !important;
  height: auto !important;
}

.projects-list {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* THE ALIGNMENT FIX: Ensure buttons in modal use same flex logic */
.projects-list .footer-btn {
  display: flex;
  align-items: center;      /* Vertically centers icon/emoji and text */
  justify-content: flex-start; /* Aligns to left side */
  text-align: left;
  margin-bottom: 0;         /* Use gap from parent container instead */
}

/* Ensure images and emojis share exact same width for text alignment */
.projects-list .footer-project-icon, 
.projects-list .icon {
  width: 24px;              /* Consistent width for all icons */
  height: 24px;
  margin-right: 15px;       /* Consistent spacing to text */
  flex-shrink: 0;
  object-fit: contain;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* GitHub specific left border color */
.github-btn {
  border-left-color: #ffffff !important;
}

/* Increase main title size for all devices */
.main-title {
  font-size: 36px !important;
}

/* Smaller title for projects modal */
#projectsModal .main-title {
  font-size: 24px !important;
}

/* ==========================================
   FIRE BUTTON GUIDE ARROWS (Above Panel)
   ========================================== */

/* Ensure the drawer allows elements to peek outside its box */
.controls-drawer {
    overflow: visible !important;
}

.fire-guide-arrow {
    display: none;
}

/* --- Mobile Fire Button (Centered & Lower) --- */
.mobile-fire-btn {
  position: absolute;
  bottom: 40px; 
  left: 50%;
  transform: translateX(-50%);
  right: auto;
  
  background-color: rgba(220, 53, 69, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-left: 4px solid #fff;
  color: white;
  
  font-family: 'GothamSS', sans-serif;
  font-weight: 900;
  font-size: 16px;
  padding: 12px 30px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  
  cursor: pointer;
  z-index: 500;
  pointer-events: auto;
  white-space: nowrap;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Smooth return to normal position */
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s;
}

/* THE FIX: Apply movement on :active AND .pressed class */
.mobile-fire-btn:active,
.mobile-fire-btn.pressed {
  /* 1. Maintain horizontal center (-50%) 
     2. Push DOWN (4px)
     3. Shrink slightly (0.95)
  */
  transform: translateX(-50%) translateY(4px) scale(0.95) !important;
  
  /* Reduce shadow to look "flat" against screen */
  box-shadow: 0 1px 5px rgba(0,0,0,0.4) !important; 
  
  /* Visual Feedback Colors */
  background-color: #ffc107 !important;
  color: black !important;
  border-color: transparent !important;
}

/* --- Ring Container (Scales via JS) --- */
.ring-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Size is set by JS */
  pointer-events: none;
  z-index: 199;
}

/* --- Shared Ring Styles --- */
.m-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-sizing: border-box;
}

/* 1. Dispersion Circle (20m Radius / 40m Width) */
.m-ring.dispersion {
  width: 100%;
  height: 100%;
  /* Dashed line to match your screenshot */
  border: 2px dashed rgba(255, 255, 255, 0.7); 
  background-color: rgba(255, 0, 0, 0.1); 
  box-shadow: inset 0 0 5px rgba(255, 0, 0, 0.1); 
}

/* 2. Deadzone Circle (10m Radius / 50% Size) - FIXED */
.m-ring.deadzone {
  width: 50%;   /* 10m / 20m = 50% */
  height: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5); 
  background-color: rgba(255, 0, 0, 0.15);    
}

/* 3. Blast Circle (5m Radius / 25% Size) */
.m-ring.blast {
  width: 25%;   /* 5m / 20m = 25% */
  height: 25%;
  background-color: rgba(255, 0, 0, 0.5); 
  border: 1px solid rgba(255, 255, 255, 0.6); 
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* --- Splash Damage Ring (High Visibility & Circular) --- */
.splash-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  
  /* Initial size (overwritten by JS) */
  width: 0;
  height: 0;
  
  /* THE FIX: Force it to be a circle */
  border-radius: 50% !important; 

  /* Visuals */
  border: 2px dashed rgba(255, 255, 255, 0.9); 
  background-color: rgba(255, 0, 0, 0.15); 
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(255, 0, 0, 0.2);
  
  pointer-events: none;
  z-index: 199;
  
  transition: width 0.1s linear, height 0.1s linear;
}

/* Inner Kill-Zone Dot (5m) */
.splash-ring::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 25%;
  height: 25%;
  background-color: rgba(255, 0, 0, 0.6); 
  border: 1px solid rgba(255, 255, 255, 0.8); 
  border-radius: 50%; /* Ensure this is also circular */
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* Utility to hide them by default */
.hidden { display: none !important; }

/* --- INLINE STYLE REPLACEMENTS --- */
.map-arrow {
  font-size: 18px;
  margin-left: 10px;
}

.watermark-bullet {
  color: #ffc107;
  margin: 0 3px;
}

/* --- Desktop Cursor Follower --- */
#desktopCursorRings {
  position: fixed; /* Follows the viewport/mouse exactly */
  top: 0;
  left: 0;
  /* Keep the translation to center the rings exactly on the cursor tip */
  transform: translate(-50%, -50%);
  /* Ensure it sits above markers but below the control panel */
  z-index: 90; 
  pointer-events: none;
}

/* --- HUD CROSSHAIR (Center +) --- */
/* === MOBILE PLACEMENT CENTER VISUAL (garrison_lining_dot_2.png) === */
#mobileCrosshair.placement-mode {
  background: url('images/ui/garrison_lining_dot_2.png') center / contain no-repeat;
}

#mobileCrosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  pointer-events: none;
  z-index: 45;
  filter: drop-shadow(0 0 10px #ffc107);
  display: none;
}

/* Hide garrison dot image during Live HUD (show only rings) */
#mobileCrosshair:not(.placement-mode) img {
  display: none !important;
}

/* === PLACEMENT MODE ARROWS (exactly like live HUD) === */
.fire-guide-arrow.placement-arrow {
  color: #ffc107;
  text-shadow: 
    0 0 10px #000000,
    0 0 6px #ffc107;
  animation: arrow-point-down 1.4s infinite ease-in-out;
  font-size: 36px;
  z-index: 2000;
  pointer-events: none;
}

/* Show arrows when panel is open AND we are in placement mode */
body.placement-active .controls-drawer:not(.closed) .fire-guide-arrow.placement-arrow {
  display: block;
}

@keyframes arrow-point-down {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(8px); opacity: 1; }
}

/* Ensure the Manual Calculator Modal doesn't have dead space */
#calcModal .modal-content {
    height: auto !important;
    min-height: unset !important;
    max-height: 90vh;
    align-self: center; /* Centers vertically if it's short */
}


/* ==========================================
   DESKTOP HOVER FIX: MORE PROJECTS
   ========================================== */
@media (hover: hover) and (min-width: 769px) {
    /* Target button AND icon inside when hovering */
    .modal-footer #btnOtherProjects:hover {
        background: rgba(255, 193, 7, 0.1) !important; /* Subtle yellow glow BG */
        border-color: #ffc107 !important;            /* Bright yellow border */
        color: #ffc107 !important;                   /* Yellow text */
        box-shadow: 0 0 15px rgba(255, 193, 7, 0.1) !important;
    }

    /* Ensure the icon specifically turns yellow too */
    .modal-footer #btnOtherProjects:hover .icon {
        stroke: #ffc107 !important;
        filter: none !important; /* Removes any grayscale if present */
    }
}

/* --- PROJECTS HUB EXTERNAL LINK ICONS --- */

.projects-list .footer-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding-left: 20px !important;
    /* Reduced right padding to let the icon get closer to the edge */
    padding-right: 15px !important; 
    width: 100% !important;
}

/* This forces the text to take up all available space, pushing the icon to the end */
.projects-list .footer-btn span {
    flex-grow: 1 !important;
    text-align: left !important;
}

.external-link-icon {
    width: 14px !important;
    height: 14px !important;
    opacity: 0.4;
    transition: all 0.2s ease;
    
    /* Ensure it doesn't shrink and stays at the very end */
    flex-shrink: 0 !important;
    margin-left: 10px !important; 
}

/* Hover highlight for the whole button */
.projects-list .footer-btn:hover {
    border-color: #ffc107 !important;
    color: #ffc107 !important;
}

.projects-list .footer-btn:hover .external-link-icon {
    opacity: 1;
    color: #ffc107;
    /* Subtle pop effect on hover */
    transform: translateX(2px); 
}

/* ==========================================
   FINAL FIX: MOBILE STICKY HOVER RESET (WHITE ICONS)
   ========================================== */
@media (hover: none) {
  /* 1. BACKGROUND: Force Grey (No Yellow) on Focus/Hover */
  .footer-btn:hover,
  .footer-btn:focus,
  .footer-btn:focus-visible,
  .projects-list .footer-btn:hover, 
  .projects-list .footer-btn:focus {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    box-shadow: none !important;
    outline: none !important;
  }

  /* 2. ICONS: Force them BRIGHT WHITE (opacity 1), not Grey */
  .footer-btn:hover .icon,
  .footer-btn:focus .icon,
  .footer-btn:focus-visible .icon,
  .projects-list .footer-btn:hover .external-link-icon,
  .projects-list .footer-btn:focus .external-link-icon {
    stroke: #ffffff !important; /* Force Bright White */
    fill: none !important;
    opacity: 1 !important;      /* CHANGED: 0.4 -> 1 (Fully Visible) */
    transform: none !important;
  }

  /* 2b. DOTS: Ensure dots inside calculator icon are also white */
  .footer-btn:hover .icon circle,
  .footer-btn:focus .icon circle {
    fill: #ffffff !important;
    stroke: none !important;
  }

  /* 3. ACTIVE: The ONLY time it should be yellow (While finger is down) */
  .footer-btn:active,
  .projects-list .footer-btn:active {
    background: rgba(255, 193, 7, 0.2) !important;
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    transition: none !important;
  }
  
  .footer-btn:active .icon,
  .projects-list .footer-btn:active .external-link-icon {
      opacity: 1 !important;
      stroke: #ffc107 !important; /* Yellow when actually pressing */
  }
  
  .footer-btn:active .icon circle {
      fill: #ffc107 !important;
  }
}

/* ==========================================================================
   FINAL UNIFIED MOBILE OPTIMIZATIONS (MAX-WIDTH: 768PX)
   ========================================================================== */
@media (max-width: 768px) {

    /* --- 1. MAIN UI & DRAWER --- */
    
    /* THE FULL-SIZE FIX: Remove borders and padding from the main wrapper */
    .shell {
        padding: 0 !important;
        margin: 0 !important;
        height: 100dvh !important;
        width: 100vw !important;
    }

    /* THE FULL-SIZE FIX: Make the map container cover the entire screen */
    .map-wrap {
        border: none !important;      /* Removes the grey border line */
        border-radius: 0 !important;  /* Square edges for full-screen look */
        height: 100dvh !important;    /* Force full viewport height */
        width: 100vw !important;      /* Force full viewport width */
        margin: 0 !important;
        padding: 0 !important;
    }

    .main-ui-overlay {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        transform: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        z-index: 3000 !important;
        pointer-events: none;
    }

    .controls-drawer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        z-index: 2000 !important;
        overflow: visible !important;
    }

    .controls-content {
        width: 100% !important;
        max-width: none !important;
        border-radius: 12px 12px 0 0 !important;
        
        /* FIX: Reduced bottom padding from 25px to 12px */
        padding: 10px 10px 12px 10px !important; 
        
        gap: 8px;
        /* FIX: Change from #181818 to solid black with 1.0 opacity */
        background-color: rgba(24, 24, 24, 1.0) !important;
        
        /* Ensure no blur effects are making it look "glassy" */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        
        border-top: 1px solid rgba(255, 255, 255, 0.3);
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: stretch;
        position: relative;
        z-index: 1300 !important;
        
        /* FIX: Force height to fit content exactly */
        height: auto !important;
        min-height: 0 !important;
    }

    /* Eraser Patch (Centered without translateX) */
    .controls-content::before {
        content: "";
        position: absolute;
        top: -2px;
        
        /* THE GPU-SAFE CENTERING FIX */
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        width: 78px; /* Fixed width matching the tab's inner seam */
        
        /* Remove transform to prevent checkerboarding */
        transform: none !important; 
        
        height: 4px;
        /* FIX: Match solid background with 1.0 opacity */
        background-color: rgba(24, 24, 24, 1.0) !important;
        z-index: 1301;
    }

    /* Drawer Tab (Centered without translateX) */
    .drawer-tab {
        position: absolute !important;
        top: -31px !important;
        
        /* THE GPU-SAFE CENTERING FIX */
        left: 0 !important;
        right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: 80px !important; /* Specific width allows margin:auto to work */
        
        /* Remove transform to avoid checkerboarding */
        transform: none !important; 
        
        height: 32px !important;
        z-index: 1000 !important;
        /* FIX: Match solid background with 1.0 opacity */
        background-color: rgba(24, 24, 24, 1.0) !important;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-bottom: none !important;
        border-radius: 10px 10px 0 0 !important;
        box-shadow: none !important;
        pointer-events: auto;
    }

    /* --- 2. DROPDOWNS & BUTTONS --- */
    .custom-dropdown {
        position: relative;
        z-index: 1400 !important;
        height: auto;
        display: flex;
        flex-direction: column;
    }
    
    .dropdown-menu { 
        z-index: 1500 !important;
        /* FIX: Change from 0.95 to 1.0 for solid opacity */
        background-color: rgba(29, 31, 39, 1.0) !important;
        
        /* Force remove blur which can cause a translucent look on some mobile browsers */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Map Button (Full Width) */
    .custom-dropdown:nth-child(1),
    .btn-map-select:nth-child(1) {
        width: 100% !important;
        flex: 0 0 100% !important;
    }

    /* Faction & Gun (50% Split) */
    .custom-dropdown:nth-child(2),
    .custom-dropdown:nth-child(3) {
        width: calc(50% - 4px) !important;
        flex: 0 0 calc(50% - 4px) !important;
    }

    /* Ensure the entire button area is a single hit-target for Firefox */
    .btn-map-select {
        font-size: 13px !important;
        padding: 10px 12px !important;
        min-height: 48px !important;
        background: rgba(29, 31, 39, 0.9) !important;
        
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-grow: 1;
        
        /* THE FIX: Ensure no internal elements block the click */
        cursor: pointer !important;
        pointer-events: auto !important;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent;
    }

    /* VITAL FOR FIREFOX: Force labels to pass clicks to the parent button */
    #currentMapName, 
    #factionLabel, 
    #gunLabel,
    .btn-map-select .item-text,
    .btn-map-select .icon {
        font-size: 14px !important;
        line-height: 1.1 !important;
        font-weight: 900 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        
        /* THE FIX: Text/Icons won't "swallow" the touch event */
        pointer-events: none !important; 
    }

    /* --- 3. TARGET DATA PANEL --- */
    .target-data-panel {
        top: 20px; /* Lower on mobile so it doesn't hit header */
        min-width: 260px;
    }
    
    .val-huge { font-size: 42px; }
    .val-mid { font-size: 14px; }
    
    .panel-row.context-row {
        padding: 8px 10px;
    }

    /* --- 4. SCALE BAR (FIXED: Spacing & Centering) --- */
    .scale-container {
        /* 1. Use Flexbox to center the child wrapper */
        display: flex !important;
        justify-content: center !important;
        align-items: flex-end !important;
        
        /* 2. Position the container itself */
        width: 100% !important;
        height: 50px !important;
        margin-bottom: 190px !important; 
        position: relative !important;
        z-index: 5 !important;
        pointer-events: none !important;
        padding: 0 !important;
    }

    .scale-wrapper {
        /* 3. Disable Absolute/Stretching logic */
        position: relative !important; 
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        margin: 0 !important;
        
        /* 4. Allow JS to control the width */
        width: auto; 
        /* The JavaScript style="width: 240px" will now apply correctly 
           and Flexbox will keep it centered. */

        /* 5. Performance & Safety */
        transform: none !important; 
        transition: none !important;
        pointer-events: none !important;
    }

    /* 6. VERTICAL SPACING FIX */
    .scale-labels { 
        position: relative; 
        width: 100%; 
        height: 16px; 
        margin-top: 4px !important; 
    }

    /* 7. CLEAN TEXT STYLE (Stroke Method) */
    .scale-lbl {
        position: absolute; 
        bottom: 0; 
        
        /* 1. GPU-SAFE CENTERING */
        transform: none !important;
        width: 40px; 
        margin-left: -20px; 
        text-align: center; 
        
        /* 2. FONT STYLING */
        font-family: "GothamSS", sans-serif; 
        font-weight: 900; 
        font-size: 12px; 
        color: #ffffff !important; 
        white-space: nowrap; 
        line-height: 1;
        letter-spacing: 1px; 

        /* 3. THE FIX: SIMPLE STROKE */
        /* We remove the complex shadow and use a real vector stroke */
        text-shadow: none !important;
        -webkit-text-stroke: 2px #000000;
        
        /* This ensures the stroke stays BEHIND the white fill */
        paint-order: stroke fill;
    }

    /* --- 5. ZOOM SLIDER (RIGHT SIDE - ADJUSTED) --- */
    .zoom-slider-container {
        position: absolute !important;
        right: 5px !important;
        left: auto !important;
        
        /* UPDATED: Increased height */
        height: 450px !important;
        max-height: 85vh !important; 
        
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none !important;
        z-index: 2200 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    .zoom-slider-track {
        width: 32px !important;
        border: 4px solid transparent;
        background-clip: padding-box;
        touch-action: none;
        pointer-events: auto !important;
    }

    .zoom-slider-handle {
        width: 30px !important;
        height: 24px !important;
        border-radius: 4px !important;
    }

    .zoom-icons span {
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Reset hover/pressed states for mobile */
    .zoom-icons span:hover {
        background-color: rgba(20, 20, 20, 0.95) !important;
        color: white !important;
    }
    .zoom-icons span.pressed {
        transform: scale(0.82) !important;
    }

    /* --- 6. ZOOM INDICATOR TEXT (CENTERED - NO TRANSFORMS) --- */
    .zoom-indicator-inline {
        position: fixed !important;
        
        /* THE GPU-SAFE CENTERING FIX */
        left: 0 !important;
        right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: 100px !important; /* Set a fixed width to allow margin:auto to work */
        
        /* Removed transform: translateX to prevent checkerboarding */
        transform: none !important; 
        
        /* Vertical position */
        bottom: 170px !important; 
        
        top: auto !important;
        z-index: 3000 !important;
        display: block !important;
        pointer-events: none !important;
    }

    #zoomIndicator {
        text-align: center !important; 
        font-size: 16px !important;
        display: block !important;
        line-height: 1 !important;
        
        /* Unified Sharp Style */
        font-family: 'GothamSS', sans-serif !important;
        font-weight: 900 !important;
        text-shadow: none !important;
        -webkit-text-stroke: 2px #000000;
        paint-order: stroke fill;
        color: #fff;
    }
    /* --- 7. LIVE HUD (TOP-RIGHT OF CROSSHAIR) --- */
    .live-hud {
        position: fixed !important;
        /* Anchor to center */
        top: 50% !important;
        left: 50% !important;
        
        /* UPDATED: Push into Top-Right Quadrant */
        /* X: 25px (Right) */
        /* Y: -105% (Up - Moves it up by its own height + 5% padding) */
        transform: translate(25px, -140%) !important;
        
        /* Reset old conflicting anchors */
        bottom: auto !important;
        right: auto !important;
        
        background: rgba(15, 15, 15, 0.9) !important;
        border-left: 3px solid #ffc107 !important;
        border-radius: 4px;
        padding: 6px 10px;
        
        z-index: 2500 !important;
        pointer-events: none;
        
        display: flex !important;
        flex-direction: column !important;
        gap: 3px;
        min-width: 80px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    }
    .live-hud .hud-row {
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }
    .live-hud .hud-label { font-size: 9px; font-weight: 700; color: #aaa; }
    .live-hud .hud-value { font-size: 12px; font-weight: 900; color: white; }
    .live-hud .hud-value.text-yellow { color: #ffc107; }
    .live-hud.hidden { display: none !important; }

    /* --- 8. TRAJECTORY SLIDER & SQUARE BUTTONS --- */
    .traj-slider-container {
        bottom: 50px !important;
        width: 96vw !important;
        padding: 10px 8px !important;
        /* Ensure it sits below target panel */
        z-index: 400 !important; 
    }

    /* THE SQUARE BUTTON FIX */
    .traj-step-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    .traj-controls-wrapper {
        gap: 8px !important;
    }

    /* --- 9. MODALS & MENUS --- */
    .modal-content {
        height: 92vh !important;
        max-height: none !important;
        margin: 0 !important;
        width: 95% !important;
    }

    /* --- THE FIX: Force Projects Modal to shrink to fit content --- */
    .modal-content.projects-hub-content {
        height: auto !important;       /* Disable the fixed 92vh height */
        min-height: auto !important;   /* Allow shrinking */
        flex: 0 1 auto !important;     /* Flexbox: Don't grow, allow shrink */
        
        /* Optional: Vertical centering if the overlay uses flex */
        margin: auto !important;       
        max-height: 85vh !important;   /* Safety cap */
    }
    /* 1. Header Container: Forced Symmetrical Padding */
    .modal-brand-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;      /* Centers title and version horizontally */
        justify-content: center !important;   /* Centers them vertically */
        text-align: center !important;
        
        /* THE ALIGNMENT FIX: 50px on both sides balances the Close Button */
        padding: 20px 50px !important; 
        gap: 6px !important;
        min-height: 70px !important;
        position: relative !important;
    }

    /* 2. Main Title: Center Locked */
    .main-title {
        font-size: 22px !important;
        letter-spacing: 1px !important;
        width: 100% !important;
        margin: 0 auto !important;
        display: block !important;
    }

    /* 3. Credits/Version: Center Locked */
    .main-subtitle-credits {
        font-size: 9px !important;
        letter-spacing: 1.5px !important;
        justify-content: center !important; /* Centers the flex content */
        margin-top: 0 !important;
        width: 100% !important;
    }

    /* 4. Close Button: Absolute Top-Right Corner */
    .close-btn {
        position: absolute !important;
        right: 5px !important;    /* Tucked into the right edge */
        top: 5px !important;      /* Tucked into the top edge */
        
        /* Reset centering from previous steps */
        transform: none !important; 
        
        /* Tactical sizing & look */
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 32px !important;
        color: rgba(255, 255, 255, 0.4) !important;
        background: none !important;
        border: none !important;
        z-index: 3100 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .map-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    /* Footer Layout */
    .modal-footer {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px 10px !important;
        flex-shrink: 0 !important;
    }
    .modal-footer .footer-btn:first-child {
        position: relative !important;
        flex: 0 0 54px !important;
        width: 54px !important;
        height: 54px !important;
        padding: 0 !important;
        font-size: 0 !important;
    }
    .modal-footer .footer-btn:first-child .icon {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 32px !important;
        height: 32px !important;
        margin: 0 !important;
        display: block !important;
    }
    /* 2. PROJECTS BUTTON (Mobile: Grid Layout) */
    .modal-footer #btnOtherProjects {
        flex: 1 !important;
        height: 54px !important;
        
        /* GRID LAYOUT: [Icon] [----- Remaining Space -----] */
        display: grid !important;
        grid-template-columns: auto 1fr !important; 
        align-items: center !important;
        
        /* Gap between Icon and Text */
        gap: 15px !important;
        
        /* Safe distance from the button edges */
        padding-left: 20px !important;
        padding-right: 20px !important;
        
        font-size: 16px !important;
        
        /* Reset Flex/Align properties */
        justify-content: unset !important;
    }

    /* ICON: Occupies Column 1 */
    .modal-footer #btnOtherProjects .icon {
        position: static !important; /* Sits naturally in the grid */
        transform: none !important;  /* Remove old centering hacks */
        
        width: 28px !important;  
        height: 28px !important; 
        
        /* Reset margins/padding */
        margin: 0 !important; 
        padding: 0 !important;
        flex-shrink: 0 !important; 
    }
    
    /* TEXT: Occupies Column 2 (The Remaining Space) */
    .modal-footer #btnOtherProjects span {
        /* Center yourself inside the remaining space */
        text-align: center !important; 
        
        width: 100% !important;
        display: block !important;
        
        /* Safety: Truncate if screen is microscopic */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        
        /* Reset padding since Grid Gap handles the spacing */
        padding: 0 !important;
        margin: 0 !important;
    }


    /* Projects Hub List Fix */
    .projects-list .footer-btn {
        flex: 0 0 auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 54px !important;
        font-size: 13px !important;
        padding: 12px 20px !important;
        justify-content: flex-start !important;
    }
    .projects-list .footer-project-icon, 
    .projects-list .icon {
        position: static !important;
        transform: none !important;
        margin-right: 15px !important;
        width: 24px !important;
        height: 24px !important;
    }

    /* --- 10. HIDES & UTILITIES --- */
    [data-tooltip]::before,
    [data-tooltip]::after,
    #desktopCursorRings,
    .mobile-crosshair.hidden, 
    .mobile-fire-btn.hidden {
        display: none !important;
    }
    
    .panel-credits { font-size: 8px; bottom: 3px; }
    
    /* --- 11. FIRE GUIDE ARROWS --- */
    .fire-guide-arrow {
        position: absolute;
        top: -55px;
        font-size: 32px;
        color: #ffc107;
        text-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 5px #ffc107;
        pointer-events: none;
        z-index: 2000;
        display: none;
    }
    .fire-guide-arrow.left { left: 10%; }
    .fire-guide-arrow.right { right: 10%; }
    
    /* Show ONLY if: HUD active + NOT dismissed + Panel OPEN */
    body.hud-active:not(.guides-dismissed) .controls-drawer:not(.closed) .fire-guide-arrow {
        display: block;
        animation: arrow-point-down 1.2s infinite;
    }
    @keyframes arrow-point-down {
        0%, 100% { transform: translateY(0); opacity: 0.5; }
        50%      { transform: translateY(8px); opacity: 1; }
    }
    
    /* Mobile Fire Button (Centered without translateX) */
    .mobile-fire-btn {
        position: absolute;
        bottom: 120px;
        
        /* THE GPU-SAFE CENTERING FIX */
        left: 0;
        right: 0;
        margin-left: auto;
        margin-right: auto;
        width: fit-content; /* Shrinks to text width */
        min-width: 160px;   /* Ensures a good hit area */
        
        /* Removed translateX to prevent checkerboarding */
        transform: none; 
        z-index: 500;
    }

    /* Vertical-only movement on press */
    .mobile-fire-btn:active, 
    .mobile-fire-btn.pressed {
        /* Remove translateX(-50%) here because margin:auto handles X-axis */
        transform: translateY(4px) scale(0.95) !important;
        
        background-color: #ffc107 !important;
        color: black !important;
        border-color: transparent !important;
        box-shadow: 0 1px 5px rgba(0,0,0,0.4) !important; 
    }

    /* REDUCE STICKY GRID LABELS (Mobile) */
    .hll-grid-label {
        font-size: 20px !important; /* Reduced from 24px */
        
        /* Adjust black outline thickness for smaller text */
        -webkit-text-stroke: 2px #000000 !important; 
    }
  }
  
 /* END OF MOBILE MEDIA QUERY */

/* ==========================================
   MATCH SETUP & SECTOR HIGHLIGHTS (FINAL)
   ========================================== */

/* Button States */
#spFilterBtn.active {
    background-color: #28a745 !important; /* Green Button for Setup */
    color: white !important;
    border-color: #28a745 !important;
}

@media (hover: hover) {
    #spFilterBtn:not(.active):hover {
        background-color: rgba(60, 60, 60, 1) !important;
        color: #28a745 !important;
    }
}

/* --- SECTOR HIGHLIGHT LAYER (Smart Auto-Step) --- */
.sector-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1; 
}

/* The Active "Target" Sector */
.sector-highlight {
    position: absolute;
    background-color: rgba(40, 167, 69, 0.3); 
    border: none;
    pointer-events: none;
    z-index: 50;
}


/* FIX 3: Safe Pulse Animation (No Box-Shadow Thrashing) */
@keyframes sector-pulse {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 0.7; }
}

/* ==========================================
   STRONGPOINT STATES (CLEANED)
   ========================================== */

/* 1. SELECTED (Active - GREEN) */
.marker.strongpoint.is-confirmed .marker-visual {
    border: none !important;
    /* Thick GREEN Ring + Glow */
    box-shadow: 
        inset 0 0 0 8px #00ff00, 
        0 0 20px rgba(0, 255, 0, 0.6) !important;
    background-color: rgba(0, 255, 0, 0.15) !important;
    opacity: 1 !important;

    /* Green Lines */
    background-image: repeating-linear-gradient(
        -45deg, 
        rgba(0, 255, 0, 0.05), 
        rgba(0, 255, 0, 0.05) 16px, 
        #00ff00 16px, 
        #00ff00 18px
    ) !important;
}

.marker.strongpoint.is-confirmed .marker-label {
    color: #00ff00 !important;
    font-weight: 900;
    text-shadow: 0 0 8px rgba(0,0,0,1);
    opacity: 1 !important;
    transform: scale(1.1);
}

/* 2. REJECTED / UNSELECTED (During Setup) */
.marker.strongpoint.is-rejected {
    opacity: 1.0 !important; 
    filter: none !important; 
    z-index: 5 !important;
    transition: opacity 0.2s;
}

.marker.strongpoint.is-rejected .marker-visual {
    /* Inset 4px RED ring (No white dots) */
    box-shadow: inset 0 0 0 4px #ff4444 !important; 
    border: none !important; 
    
    background-color: transparent !important;

    /* RED Diagonal Lines */
    background-image: repeating-linear-gradient(
        -45deg, 
        rgba(255, 68, 68, 0.15), 
        rgba(255, 68, 68, 0.15) 16px, 
        #ff4444 16px, 
        #ff4444 18px
    ) !important;
}

/* RED Label Text */
.marker.strongpoint.is-rejected .marker-label {
    opacity: 1.0 !important;
    color: #ff4444 !important;
    text-decoration: none; 
}

/* 3. LOCKED (Future Steps) - NO DOTS, JUST BLACK */
.marker.strongpoint.is-locked {
    opacity: 0.5 !important;         /* Dimmed to show it's not ready */
    pointer-events: none !important; /* Cannot click */
    filter: none !important;         /* Standard colors */
    z-index: 1 !important;          
}

.marker.strongpoint.is-locked .marker-visual {
    /* DEFAULT BLACK RING */
    box-shadow: inset 0 0 0 8px #000000 !important; 
    border: none !important; /* Removes the white dots */
    background-color: transparent !important;

    /* DEFAULT BLACK LINES */
    background-image: repeating-linear-gradient(
        -45deg, 
        rgba(255, 255, 255, 0.05), 
        rgba(255, 255, 255, 0.05) 16px, 
        #000000 16px, 
        #000000 18px
    ) !important;
}

/* Dimmed White Text */
.marker.strongpoint.is-locked .marker-label {
    opacity: 0.5 !important;
    color: #ffffff !important;
}

/* 4. OPEN / AVAILABLE (Active Sector) - FULL BLACK */
.marker.strongpoint.is-open {
    opacity: 1.0 !important;
    filter: none !important;
    z-index: 10 !important; 
    cursor: pointer;
}

.marker.strongpoint.is-open .marker-visual {
    /* DEFAULT BLACK RING */
    box-shadow: inset 0 0 0 8px #000000, 0 0 4px rgba(0,0,0,0.5) !important;
    border: none !important;
    background-color: transparent !important;

    /* DEFAULT BLACK LINES */
    background-image: repeating-linear-gradient(
        -45deg, 
        rgba(255, 255, 255, 0.1), 
        rgba(255, 255, 255, 0.1) 16px, 
        #000000 16px, 
        #000000 18px
    ) !important;
}

.marker.strongpoint.is-open .marker-label {
    opacity: 1.0 !important;
    color: #ffffff !important;
    text-shadow: none !important;
}

/* 5. INTERACTIVE HOVER (Green Preview) */
.marker.strongpoint.setup-active {
    pointer-events: auto !important;
    cursor: pointer;
}

.marker.strongpoint.setup-active:hover {
    filter: none !important;
    opacity: 1 !important;   
}

.marker.strongpoint.setup-active:hover .marker-visual {
    border: none !important;
    /* PREVIEW: Thick GREEN Ring + Glow */
    box-shadow: 
        inset 0 0 0 8px #00ff00, 
        0 0 20px rgba(0, 255, 0, 0.6) !important;
    
    /* PREVIEW: Green Lines */
    background-image: repeating-linear-gradient(
        -45deg, 
        rgba(0, 255, 0, 0.05), 
        rgba(0, 255, 0, 0.05) 16px, 
        #00ff00 16px, 
        #00ff00 18px
    ) !important;
}

.marker.strongpoint.setup-active:hover .marker-label {
    color: #00ff00 !important;
    opacity: 1 !important;
    text-shadow: 0 0 8px rgba(0,0,0,1);
}

/* ==========================================
   SETUP MODE GUIDE TEXT (TACTICAL THEME - SAFE)
   ========================================== */

.setup-guide {
    pointer-events: none;
    
    /* THEME: Dark Background (Matches Drawer/Panels) */
    background-color: rgba(20, 20, 20, 0.95) !important;
    
    /* THEME: Thin Grey Border */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    
    /* THEME: Tactical Yellow Top Accent */
    border-top: 3px solid #ffc107 !important;
    
    /* Text Styles */
    color: #ffffff !important; 
    font-family: 'GothamSS', sans-serif;
    font-weight: 900;
    font-size: 14px; 
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    
    /* Layout */
    padding: 12px 24px;
    border-radius: 2px; 
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8); 
    
    /* Position: Top Center */
    margin-bottom: 20px; 
    z-index: 2500; 
    
    /* Desktop Positioning */
    transform: none; 
    
    /* FIX: REMOVED 'will-change'. 
       This prevents Chrome Mobile from creating aggressive GPU layers 
       that cause checkerboarding/blur. */
    transition: opacity 0.2s, transform 0.2s, border-color 0.3s;
}

.setup-guide.hidden {
    display: none;
    opacity: 0;
}

/* SUCCESS STATE: Green Accent */
.setup-guide.success {
    /* Change Top Border to Green */
    border-top-color: #28a745 !important;
    
    /* Add subtle Green Glow */
    box-shadow: 0 0 30px rgba(40, 167, 69, 0.25);
    
    /* Pop effect */
    transform: scale(1.05); 
}

/* Finish Button (Matches Footer Buttons) */
.setup-finish-btn {
    background-color: rgba(40, 167, 69, 0.2); /* Semi-transparent Green */
    border: 1px solid #28a745;
    color: #ffffff;
    
    padding: 6px 16px;
    margin-left: 15px;
    border-radius: 2px;
    
    font-family: 'GothamSS', sans-serif;
    font-weight: 900;
    font-size: 12px;
    letter-spacing: 1px;
    
    cursor: pointer;
    text-transform: uppercase;
    pointer-events: auto; 
    transition: all 0.2s;
}

.setup-finish-btn:hover {
    background-color: #28a745; /* Solid Green on Hover */
    color: #000000;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

.setup-finish-btn:active {
    transform: scale(0.95);
}

/* Flex layout for the content */
.setup-guide.success {
    pointer-events: auto !important; 
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Adjustments (Keep Fixed Positioning) */
@media (max-width: 768px) {
    .setup-guide {
        font-size: 13px;
        padding: 12px 20px;
        width: auto;
        min-width: 220px;
        white-space: nowrap;
        
        position: fixed;
        top: 90px; 
        left: 50%;
        /* Force Centering on Mobile */
        transform: translateX(-50%); 
        margin: 0;
    }
    
    /* Success Pop + Center */
    .setup-guide.success {
        transform: translateX(-50%) scale(1.05);
    }

    /* 1. Row Container: Center vertically, reset horizontal spacing */
    .panel-row.context-row {
        display: flex !important;
        justify-content: center !important; /* Don't push to edges */
        align-items: center !important;     /* Vertically align centers */
        gap: 0 !important;
        padding: 8px 0 !important;          /* Balanced padding */
    }

    /* 2. The 3 Data Groups: Force 3 Equal Columns */
    .data-group {
        flex: 1 1 33% !important;        /* Each takes exactly 1/3 width */
        width: 33% !important;           /* Fallback */
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;  /* Horizontally center text */
        justify-content: center !important;
    }

    /* 3. Ensure Text is Centered */
    .lbl-tiny, .val-mid {
        text-align: center !important;
        width: 100% !important;
    }

    /* 4. Match Label Styles to Desktop */
    .lbl-tiny {
        font-size: 8px !important;
        letter-spacing: 0.5px !important;
        margin-bottom: 2px !important;
        opacity: 0.6 !important;
    }

    /* 5. Ensure Values Match Desktop Size */
    .val-mid {
        font-size: 13px !important;
        line-height: 1.2 !important;
    }

    .val-huge {
        font-size: 35px !important; /* Reduced size */
        line-height: 1 !important;
        margin-top: 0 !important;   /* Remove extra top gap */
        margin-bottom: 2px !important; /* Slight spacing before the line */
    }
}

/* CLEAN CUSTOM ARTILLERY ICONS - No square border */
.marker.custom-artillery {
    border: none !important;           /* ← REMOVED the square */
    background-color: transparent !important;
    box-shadow: none !important;
}

/* === CLEAN CUSTOM ARTILLERY ICONS (no square ever) === */
.marker.custom-artillery {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Active custom gun: clean without yellow glow */
.marker.custom-artillery.active-gun .arty-icon {
    filter: invert(1);
    transform: scale(1.1);
    transition: filter 0.2s ease, transform 0.15s ease;
}

/* Dimmed custom guns stay perfectly clean */
.marker.custom-artillery.dimmed-gun .arty-icon {
    filter: none;
    transform: scale(1);
}

/* ==========================================
   CUSTOM CONFIRM MODAL (matches dropdown style)
   ========================================== */
.confirm-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.confirm-modal {
    background: #1d1f27;
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 6px;
    max-width: 340px;
    width: 90%;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0,0,0,0.9);
}

.confirm-title {
    font-family: 'GothamSS', sans-serif;
    font-weight: 900;
    font-size: 18px;
    color: #ffc107;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.confirm-message {
    font-family: 'GothamSS', sans-serif;
    font-size: 15px;
    color: #ddd;
    line-height: 1.4;
    margin-bottom: 28px;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 28px;
    border-radius: 4px;
    font-family: 'GothamSS', sans-serif;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    min-width: 110px;
}

.confirm-btn.cancel {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: #ddd;
}

.confirm-btn.delete {
    background: #ff4444;
    border: 1px solid #ff4444;
    color: white;
}

.confirm-btn.delete:hover { background: #ff6666; }
.confirm-btn.cancel:hover { background: rgba(255,255,255,0.2); }

/* TARGET PANEL CLOSE BUTTON — safe absolute positioning */
.panel-close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;          /* slightly bigger for easy taps */
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'GothamSS', sans-serif;
    font-size: 20px;
    font-weight: 900;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    z-index: 10;
    transition: all 0.15s ease;
    user-select: none;
    
    /* THIS IS THE FIX */
    pointer-events: auto !important;
}

.panel-close-btn:hover {
    color: #ffc107;
    transform: scale(1.15);
}

.panel-close-btn:active {
    color: #ff4444;
    transform: scale(0.9);
}

/* FORCE PLACE BUTTON MOBILE-ONLY (defensive) */
@media (min-width: 769px) {
  #mobilePlaceBtn {
    display: none !important;
  }
}

/* ACTIVE GUN — use pre-inverted white icon (no CSS filter needed) */
.marker.active-gun .arty-icon {
    filter: none !important; /* important so Firefox doesn't fight us */
}

/* FIREFOX: Maximum crispness for scaled + rotated icons */
@supports (-moz-appearance: none) {
    .marker.active-gun,
    .marker.point.active-gun,
    .marker.active-gun .arty-icon,
    .marker.point.active-gun .arty-icon {
        image-rendering: crisp-edges !important;
        image-rendering: -moz-crisp-edges !important;
        backface-visibility: hidden !important;
    }
}

/* BEYOND MAX RANGE DARK OVERLAY — always on when gun selected */
#beyondRangeOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 96;
  display: none;
  
  /* Clean transparent circle (hole) centered on gun */
  mask-image: radial-gradient(
    circle at var(--gun-x) var(--gun-y),
    transparent var(--max-range-r),
    black calc(var(--max-range-r) + 1px)
  );
  -webkit-mask-image: radial-gradient(
    circle at var(--gun-x) var(--gun-y),
    transparent var(--max-range-r),
    black calc(var(--max-range-r) + 1px)
  );
}

/* MIN RANGE DARK OVERLAY — darkens inside the dead zone (no outline) */
#minRangeOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);     /* same softness as your max range */
  pointer-events: none;
  z-index: 95;                        /* slightly below max overlay */
  display: none;
  
  mask-image: radial-gradient(
    circle at var(--gun-x) var(--gun-y),
    black var(--min-range-r),
    transparent calc(var(--min-range-r) + 1px)
  );
  -webkit-mask-image: radial-gradient(
    circle at var(--gun-x) var(--gun-y),
    black var(--min-range-r),
    transparent calc(var(--min-range-r) + 1px)
  );
}

/* ENEMY ARTILLERY — same perfect centering as friendly guns */
.marker.enemy-gun {
    /* Fixed size - same as friendly guns when fully zoomed in (10x) */
    width: 13px !important;
    height: 13px !important;
   
    /* Perfect negative margin centering for fixed size */
    margin-left: -6.5px !important;
    margin-top: -6.5px !important;
   
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
   
    pointer-events: none; /* prevents accidental clicks on enemy icons */
    z-index: 90; /* sits below friendly guns */
}

.marker.enemy-gun .arty-icon {
    width: 100% !important;
    height: 100% !important;
}