html, body { 
    margin:0; 
    padding:0; 
    width:100%; 
    height:100%; 
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;
}
#map { 
    width:100%; 
    height:100%; 
}

/* Modal styling */
.modal { 
    position: fixed; 
    inset:0; 
    background: rgba(0,0,0,0.75); 
    backdrop-filter: blur(4px); 
    display:flex; 
    align-items:center; 
    justify-content:center; 
    z-index:9999; 
    padding:16px; 
    animation:fadeIn 0.2s ease-out;
}
@keyframes fadeIn { 
    from{opacity:0;} 
    to{opacity:1;} 
}
@keyframes slideUp { 
    from{opacity:0; transform: translateY(20px);} 
    to{opacity:1; transform:translateY(0);} 
}
.modal-content { 
    background: linear-gradient(135deg,#1a1a2e 0%,#16213e 100%); 
    color:#e8e8e8; 
    padding:0; 
    border-radius:16px; 
    max-width:700px; 
    width:100%; 
    max-height:90vh; 
    overflow:hidden; 
    position:relative; 
    box-shadow:0 20px 60px rgba(0,0,0,0.5); 
    animation:slideUp 0.3s ease-out;
}
.modal-header { 
    background:linear-gradient(135deg,#0f3460 0%,#16213e 100%); 
    padding:20px 24px; 
    border-bottom:2px solid rgba(255,255,255,0.1); 
    display:flex; 
    justify-content:space-between; 
    align-items:center;
}
#modal-title, #stats-modal-title { 
    margin:0; 
    font-size:1.5rem; 
    font-weight:600; 
    color:#fff; 
    flex:1;
}
#modal-close, #settings-close, #stats-close { 
    cursor:pointer; 
    font-size:32px; 
    color:#e8e8e8; 
    background:rgba(255,255,255,0.1); 
    border-radius:50%; 
    width:40px; 
    height:40px; 
    display:flex; 
    align-items:center; 
    justify-content:center; 
    transition:all 0.2s ease; 
    border:none; 
    line-height:1; 
    flex-shrink:0; 
    margin-left:16px;
}
#modal-close:hover, #settings-close:hover, #stats-close:hover { 
    background:rgba(255,255,255,0.2); 
    transform:rotate(90deg); 
}
#modal-body, #settings-body, #stats-body { 
    padding:24px; 
    overflow-y:auto; 
    max-height:calc(90vh - 100px);
}
#modal-body h3, #stats-body h3 { 
    margin-top:0; 
    margin-bottom:12px; 
    font-size:1.3rem; 
    font-weight:600; 
    padding-bottom:8px; 
    border-bottom:2px solid #000; 
}
#modal-body p, #stats-body p { 
    margin:12px 0; 
    line-height:1.6;
}
#modal-body strong, #stats-body strong { 
    color:#FFFFFF; 
    font-weight:600;
}
#modal-body small { 
    color:#b0b0b0; 
    font-size:0.85rem; 
    display:block; 
    margin:8px 0;
}
#modal-body em { 
    color:#9e9e9e; 
    font-style:italic;
}
.alert-section { 
    background:rgba(255,255,255,0.05); 
    padding:20px; 
    border-radius:12px; 
    margin-bottom:20px; 
    border-left:4px solid #000;
}
.alert-section:last-child { 
    margin-bottom:0;
}

/* Last updated timestamp under the menu */
#last-updated {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: rgba(31,41,55,0.85);
    color: #cbd5e1;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    pointer-events: none;
    white-space: nowrap;
    display: none;
}

@media (max-width:640px) {
  .modal { padding:8px; align-items:flex-end; }
  .modal-content { max-height:85vh; border-bottom-left-radius:0; border-bottom-right-radius:0;}
  .modal-header { padding:16px 20px; }
  #modal-title, #stats-modal-title { font-size:1.25rem; }
  #modal-close, #settings-close, #stats-close { width:36px; height:36px; font-size:28px; }
  #modal-body, #settings-body, #stats-body { padding:20px; max-height:calc(85vh - 80px);}
  #modal-body h3, #stats-body h3 { font-size:1.15rem;}
  .alert-section { padding:16px; }
  #last-updated { top: 80px; font-size: 11px; padding: 3px 10px; }
}
::-webkit-scrollbar { width:8px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05);}
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius:4px;}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3);}

/* Menu & Legend styles */
.menu-container{
    position:absolute;top:12px;left:50%;transform:translateX(-50%);z-index:1000;
    background:rgba(31,41,55,.95);padding:8px 12px;border-radius:12px;
    box-shadow:0 4px 20px rgba(0,0,0,.5);border:1px solid rgba(255,255,255,.15);
    display:flex;align-items:center;gap:8px;
    max-width:95vw;overflow-x:auto;white-space:nowrap;scrollbar-width:none;
    overflow:visible !important;
}
.menu-container::-webkit-scrollbar{display:none}

.logo-section{display:flex;align-items:center;padding-right:12px;border-right:1px solid rgba(255,255,255,.2);margin-right:8px;flex-shrink:0;}
.logo-text{font-size:16px;font-weight:700;color:#fff;letter-spacing:-.4px;}

.menu-item{
    display:inline-flex;align-items:center;
    flex-shrink:0;margin-right:8px;
}
.menu-item:last-child{margin-right:0;}

.dropbtn{
    background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.2);
    color:#E5E7EB;padding:8px 14px;border-radius:8px;cursor:pointer;
    font-size:13px;font-weight:600;display:flex;align-items:center;gap:6px;
    transition:all .3s;white-space:nowrap;min-height:38px;
}
.dropbtn:hover{background:rgba(255,255,255,.18);border-color:rgba(255,255,255,.35);transform:translateY(-1px)}
.dropbtn.active{color:#fff;font-weight:700;background:rgba(59,130,246,.3);border-color:#60A5FA}
.dropbtn i{font-size:12px;transition:transform .2s}
.dropdown.active .dropbtn i{transform:rotate(180deg)}

.dropdown{position:relative;display:inline-block;}
.dropdown-content{
    display:none;position:absolute;top:100%;left:0;
    width:max-content;min-width:200px;max-width:320px;
    background:rgba(31,41,55,.98);border:1px solid rgba(255,255,255,.15);
    border-radius:8px;overflow:visible;box-shadow:0 6px 20px rgba(0,0,0,.5);
    z-index:3000;
    margin-top:4px;
    pointer-events:auto;max-height:400px;overflow-y:auto;
}
.dropdown.active .dropdown-content{display:block;}
.dropdown-content button{
    width:100%;text-align:left;padding:12px 16px;background:none;border:none;
    color:#E5E7EB;font-size:13px;cursor:pointer;transition:background .2s;
    white-space:nowrap;display:block;
    border-bottom:1px solid rgba(255,255,255,.08);
}
.dropdown-content button:last-child{border-bottom:none;}
.dropdown-content button:hover{background:rgba(255,255,255,.1)}
.dropdown-content button.active{color:#fff;background:rgba(59,130,246,.4);font-weight:600}

.hamburger{cursor:pointer;font-size:20px;color:#fff;padding:8px;z-index:1001;display:none;}
.hamburger i{font-size:20px;}

.mobile-menu{
    display:none;position:absolute;top:58px;left:50%;transform:translateX(-50%);
    background:rgba(31,41,55,.98);border-radius:10px;padding:8px 0;
    box-shadow:0 6px 20px rgba(0,0,0,.5);z-index:1000;
    width:calc(100vw - 40px);max-width:400px;max-height:70vh;overflow-y:auto;
    border:1px solid rgba(255,255,255,.15);
}
.mobile-menu button{
    width:100%;text-align:left;padding:10px 16px;background:none;border:none;
    color:#E5E7EB;font-size:13px;cursor:pointer;transition:background .2s;
    white-space:nowrap;
}
.mobile-menu button:hover{background:rgba(255,255,255,.1)}
.mobile-menu button.active{color:#fff;background:rgba(59,130,246,.4);font-weight:600}

.legend-container{
    position:absolute;bottom:0;left:0;right:0;z-index:1000;
    background:rgba(31,41,55,.95);box-shadow:0 -2px 20px rgba(0,0,0,.5);
    border-top:1px solid rgba(255,255,255,.15);
    padding:10px 16px;width:100%;box-sizing:border-box;
}
.legend-title{
    text-align:center;color:#fff;font-weight:600;margin-bottom:6px;font-size:12px;
}
.legend-gradient{
    height:14px;background:linear-gradient(to right,
        #FAFAFA 0%, #88FF88 5.88%, #22FF22 11.76%, #00DD00 17.65%, 
        #00AA00 23.53%, #007700 29.41%, #003366 35.29%, #0055AA 41.18%, 
        #2288EE 47.06%, #55BBFF 52.94%, #00FFFF 58.82%, #AA77DD 64.71%, 
        #7733AA 70.59%, #770000 76.47%, #BB0000 82.35%, #FF3300 88.24%, 
        #FF7700 94.12%, #AA8800 97.06%, #FFFF00 99.41%, #FFDDDD 100%
    );
    border-radius:4px;border:1px solid rgba(255,255,255,.2);margin:0 4px;
}
.legend-values{
    display:flex;justify-content:space-between;margin-top:4px;color:#E5E7EB;
    font-size:10px;line-height:1;
}
.legend-values span{flex:1;text-align:center;}

.legend-items{
    display:flex;flex-wrap:wrap;gap:12px 16px;
    justify-content:center;align-items:center;
    row-gap:8px;
}
.legend-item{
    display:flex;align-items:center;gap:8px;flex-shrink:0;
}
.legend-color{
    width:24px;height:16px;border-radius:3px;
    border:1px solid rgba(255,255,255,.3);flex-shrink:0;
}
.legend-label{
    font-size:11px;color:#E5E7EB;white-space:nowrap;
}

/* Settings modal styles */
#settings-modal .modal-content {
  max-width: 420px;
}
#settings-modal .modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 70vh;
}
.style-radio-group {
  margin-bottom: 24px;
}
.style-radio-group label {
  display: block;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.style-radio-group label:hover {
  background: rgba(255,255,255,0.08);
}
.style-radio-group input[type="radio"]:checked + span {
  font-weight: 600;
  color: #60A5FA;
}

/* Mobile responsiveness for menu */
@media (max-width: 1180px) and (orientation: landscape),
       (max-width: 1024px) {
    .hamburger { display: block !important; }
    #wmsMenuContainer { display: none !important; }
}

@media (min-width: 1181px) and (orientation: landscape) {
    .hamburger { display: none !important; }
    .mobile-menu { display: none !important; }
}

/* Legend toggle button & panel */
.legend-toggle-btn {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 1100;
    background: rgba(31,41,55,0.95);
    color: #e5e7eb;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}

.legend-toggle-btn:hover {
    background: rgba(55,65,81,0.98);
    transform: scale(1.08);
}

.legend-toggle-btn.active {
    background: rgba(59,130,246,0.4);
    border-color: #60a5fa;
}

#legendPanel {
    position: absolute;
    bottom: 78px;
    left: 16px;
    z-index: 1050;
    background: rgba(31,41,55,0.96);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 220px;
    max-width: 340px;
    max-height: 66vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.55);
    display: none;
    color: #e5e7eb;
    font-size: 13px;
}

#legendPanel.show {
    display: block;
}

.legend-panel-title {
    font-weight: 600;
    color: #fff;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    font-size: 1.05rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.legend-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.25);
    flex-shrink: 0;
}

.legend-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Optional: Make geolocate button more visible / styled */
.maplibregl-ctrl-geolocate {
    background-color: rgba(31,41,55,0.95) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
    width: 40px !important;
    height: 40px !important;
}

.maplibregl-ctrl-geolocate:hover {
    background-color: rgba(55,65,81,0.98) !important;
}

.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon {
    filter: brightness(1.2);
}

/* ── Top Radar Control Bar ── (new clean values - no centering, no rounding) */
#radar-control-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 56px !important;
    background: rgba(10, 10, 12, 1.0) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 0 !important;
    padding: 0 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    z-index: 1000 !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.6) !important;
    max-width: none !important;
    justify-content: space-between !important;
}

@media (max-width: 768px) {
    #radar-control-bar {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        padding: 0 12px !important;
        gap: 8px !important;
        height: 56px !important;
        align-items: center !important;
        box-sizing: border-box !important;
    }
}

/* Radar Transparency Slider Bar - hidden to avoid conflict */
#radar-opacity-bar {
    display: none !important;
}

/* Status bar - hidden to avoid conflict */
#radar-status-bar {
    display: none !important;
}

/* Radar Timeline Scrubber - hidden to avoid conflict */
#radar-timeline {
    display: none !important;
}

/* Colorbar strip - new clean values for stacking below gray bar */
#radar-colorbar-strip {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: auto !important;
    display: none !important;
    pointer-events: none !important;
    z-index: 11 !important;
    background: #000000 !important;
    border-top: 1px solid rgba(255,255,255,0.10) !important;
}
#radar-colorbar-strip.visible { 
    display: block !important; 
}

#radar-colorbar {
    position: relative !important;
    top: 0 !important; 
    left: 0 !important;
    width: 100% !important;
    height: 24px !important;
    display: block !important;
}

#radar-colorbar-labels {
    position: absolute !important;
    top: 0 !important; 
    left: 6px !important; 
    right: 6px !important;
    height: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 9px !important;
    color: #ffffff !important;
    font-family: 'JetBrains Mono', monospace !important;
    text-shadow: 0 0 3px rgba(0,0,0,1), 0 0 6px rgba(0,0,0,1) !important;
    pointer-events: none !important;
}

#radar-colorbar-title {
    position: absolute !important;
    top: 2px !important;
    left: 6px !important;
    font-size: 8px !important;
    color: rgba(255,255,255,0.55) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.1em !important;
    font-family: 'JetBrains Mono', monospace !important;
    pointer-events: none !important;
    line-height: 1 !important;
    display: none !important;
}

/* Legend toggle button & panel - safe positioning above gray bar */
.legend-toggle-btn {
    position: fixed !important;
    bottom: 120px !important;
    left: 16px !important;
    z-index: 1003 !important;
    background: rgba(15, 23, 42, 0.95) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    cursor: pointer !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4) !important;
}

#legendPanel {
    position: fixed !important;
    bottom: 104px !important;
    left: 16px !important;
    z-index: 1004 !important;
    background: rgba(31,41,55,0.96) !important;
    border: 1px solid rgba(255,255,255,0.18) !important;
    border-radius: 8px !important;
    padding: 14px 16px !important;
    min-width: 220px !important;
    max-width: 340px !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.55) !important;
    display: none !important;
    color: #e5e7eb !important;
    font-size: 13px !important;
}

#legendPanel.show {
    display: block !important;
}

/* FULL-WIDTH DRAWING TOOLBAR - safe positioning */
#drawing-toolbar {
    position: fixed !important;
    bottom: 120px !important;
    right: 16px !important;
    left: auto !important;
    height: auto !important;
    background: rgba(15,23,42,0.98) !important;
    border-top: none !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    z-index: 1003 !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.7) !important;
    padding: 6px 10px !important;
    border-radius: 0 !important;
}

#drawing-toolbar button {
    background: transparent !important;
    color: #efefef !important;
    border: none !important;
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    font-size: 1.2rem !important;
    cursor: pointer !important;
    border-radius: 0 !important;
}

#drawing-toolbar button:hover { 
    background: rgba(255,255,255,0.1) !important; 
}

#drawing-toolbar button.active { 
    background: #60a5fa !important; 
    color: #000 !important; 
    border-color: #bae6fd !important; 
}

#forecast-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);   /* Slightly darker overlay */
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

#forecast-modal.show { 
    display: flex; 
}

/* Make the modal content full screen */
#forecast-modal-content {
    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 0;                    /* Remove rounded corners for full screen feel */
    width: 100vw;                        /* Full viewport width */
    height: 90vh;                       /* Full viewport height */
    max-width: none;                     /* Remove max-width restriction */
    max-height: none;                    /* Remove max-height restriction */
    box-shadow: none;                    /* Optional: remove shadow on full screen */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;                           /* Ensure no margin */
}

/* Optional: Keep a subtle border or slight margin if you prefer */
#forecast-modal-content {
    /* If you want a tiny bit of breathing room instead of perfect edge-to-edge: */
    /* width: 98vw; */
    /* height: 98vh; */
    /* border-radius: 8px; */
}

/* Header - make it look good on full screen */
#forecast-modal-header {
    background: rgba(15,23,42,1);
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

/* Close button - slightly larger and easier to tap on full screen */
#forecast-modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 28px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
}
#forecast-modal-close:hover { color: #f87171; }

#forecast-iframe {
    flex: 1;
    border: none;
    background: #fff;
}

/* DRAWING CANVAS */
#drawing-canvas {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    pointer-events: none;
    z-index: 55;
    display: none;
}
#drawing-canvas.active { 
    pointer-events: auto; 
    display: block; 
}

/* Radar Sites Toggle Button */
#radar-sites-btn {
    background: rgba(96,165,250,0.15);
    color: #ffffff;
    border: 1px solid rgba(96,165,250,0.4);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#radar-sites-btn:hover { 
    background: rgba(96,165,250,0.3); 
}

#radar-sites-btn.active { 
    background: #60a5fa; 
    color: #000; 
    border-color: #bae6fd; 
}

/* Mobile Opacity Control - hidden to avoid conflict */
#mobile-opacity-control {
    display: none !important;
}

/* Keep Screen Awake */
#wake-lock-btn {
  display: none !important;
}

@media (max-width: 1200px) {
  #wake-lock-btn {
    display: inline-flex !important;
  }
}

/* GPS marker */
@keyframes gps-pulse {
    0% { box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.5); }
    70% { box-shadow: 0 0 0 14px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.5); }
}
.gps-live-marker {
    width: 18px;
    height: 18px;
    background: #00ff88;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.5);
    animation: gps-pulse 2s infinite ease-in-out;
    pointer-events: none;
}