/* ═══════════════════════════════════════════════════════════════
   RESET & CSS VARIABLES — box model reset and theme custom properties
   ═══════════════════════════════════════════════════════════════ */

* {
    box-sizing: border-box;
  }
  
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-border: #30363d;
    --primary: #58a6ff;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --shadow: 0 10px 30px rgba(0,0,0,0.4);
    --radius: 12px;
    --content-width: 82%;
    --accent: #4fd7ec;
    --input-bg: #21262d;
    --tooltip-bg: rgba(22,27,34,0.95);
  }

  body.light-mode {
    --bg: #f0f4f8;
    --panel: #ffffff;
    --panel-border: #d0d7de;
    --primary: #0077b6;
    --text: #1f2937;
    --text-muted: #6b7280;
    --shadow: 0 10px 30px rgba(0,0,0,0.08);
    --accent: #0077b6;
    --input-bg: #ffffff;
    --tooltip-bg: rgba(255,255,255,0.95);
  }
  
/* ═══════════════════════════════════════════════════════════════
   LAYOUT — page structure, body, and header
   ═══════════════════════════════════════════════════════════════ */

  body {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: clamp(14px, 1.6vw, 16px);
    text-align: center;
    margin: 0;
    background: var(--bg);
    color: var(--text);
  }

  header {
    padding: 12px 0 4px 0;
  }

  h1 {
    color: var(--accent);
    margin: 0 0 4px 0;
    font-size: clamp(20px, 3vw, 28px);
  }

  #description {
    color: var(--text-muted);
    margin: 0 0 8px 0;
    font-size: 13px;
  }

/* ═══════════════════════════════════════════════════════════════
   MAP — map container, fullscreen behavior, and Leaflet overrides
   ═══════════════════════════════════════════════════════════════ */

  /* Map container */
  #map {
    height: calc(100vh - 220px);
    min-height: 320px;
    max-height: 800px;
    width: var(--content-width);
    margin: 18px auto;
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    overflow: hidden;
    border: 1px solid var(--panel-border);
    position: relative;
  }

  #map:fullscreen {
    height: 100vh;
    width: 100vw;
    max-height: none;
    overflow: visible;
  }

  /* Fullscreen toggle button (Leaflet control, topleft) */
  .leaflet-control-fullscreen {
    margin-top: 0 !important;
  }

  .leaflet-control-fullscreen a {
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 18px;
    text-align: center;
    text-decoration: none;
    color: #666;
    display: block;
    cursor: pointer;
  }

  .leaflet-control-fullscreen a:hover {
    background: #f4f4f4;
  }

  .leaflet-control-fullscreen a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* Control bar in fullscreen mode */
  #map:fullscreen #controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1001;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    max-height: 30vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 6px 10px;
    gap: 4px;
  }

  #map:fullscreen #controls .control-row,
  #map:fullscreen #controls .control-row-2,
  #map:fullscreen #controls .search-row {
    margin: 2px 0;
    gap: 6px;
  }

  /* Push Leaflet controls below the control bar in fullscreen */
  #map:fullscreen .leaflet-top {
    top: var(--fs-controls-height, 90px);
  }

  /* Offset season overlay panels below the control bar in fullscreen */
  #map:fullscreen #seasonStormTotals {
    top: calc(var(--fs-controls-height, 90px) + 10px);
  }

  #map:fullscreen #seasonStormCards {
    top: calc(var(--fs-controls-height, 90px) + 10px);
    left: 55px;
  }

/* ═══════════════════════════════════════════════════════════════
   FOOTER — site footer attribution and links
   ═══════════════════════════════════════════════════════════════ */

  /* Footer */
  #siteFooter {
    width: var(--content-width);
    margin: 0 auto;
    padding: 18px 20px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 18px;
    margin-bottom: 18px;
  }

  #siteFooter p {
    margin: 6px 0;
    line-height: 1.5;
  }

  #siteFooter a {
    color: var(--primary);
    text-decoration: none;
  }

  #siteFooter a:hover {
    text-decoration: underline;
  }

  .footer-disclaimer {
    font-style: italic;
  }

  .footer-links {
    margin-top: 10px;
  }

/* ═══════════════════════════════════════════════════════════════
   CONTROLS — control bar, buttons, inputs, dropdowns, and rows
   ═══════════════════════════════════════════════════════════════ */

  /* Control bar */
  .control-bar {
    margin: 14px auto;
    padding: 14px;
    width: var(--content-width);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .control-bar select,
  .control-bar button,
  .control-bar input {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    height: 36px;
  }

  .control-bar select option {
    background: var(--input-bg);
    color: var(--text);
  }

  .control-bar button {
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .control-bar button:hover {
    transform: translateY(-2px);
    background: var(--panel-border);
  }

  .control-bar button.active-tracking-on {
    background: rgba(79, 215, 236, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
  }

/* ═══════════════════════════════════════════════════════════════
   INFO PANEL — storm information display and stats
   ═══════════════════════════════════════════════════════════════ */

  /* Info panel */
  .info-panel {
    position: relative;
    z-index: 0;
    width: var(--content-width);
    margin: 8px auto 18px auto;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    border-radius: 14px;
    padding: 20px;
    font-family: 'Segoe UI', sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
  }

  .info-name {
    font-size: 30px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 0.3px;
  }

  .info-meta {
    font-size: 13px;
    color: var(--text-muted);
    opacity: 0.9;
    line-height: 1.4;
  }

  .info-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
  }

  .info-stat {
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
    color: var(--text);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-width: 120px;
    text-align: center;
  }

/* ═══════════════════════════════════════════════════════════════
   LEGEND — wind scale legend panel and items
   ═══════════════════════════════════════════════════════════════ */

  /* Legend */
  #legend {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 220px;
    z-index: 1100;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 11px;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    text-align: left;
  }

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

  .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 4px;
    border: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
  }

  .legend-toggle-btn {
    display: block;
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    margin-bottom: 8px;
    transition: background 0.15s ease;
  }

  .legend-toggle-btn:hover {
    background: var(--panel-border);
  }

/* ═══════════════════════════════════════════════════════════════
   COLLAPSIBLE PANELS — shared collapse/expand toggle styles
   ═══════════════════════════════════════════════════════════════ */

  /* Collapse toggle shared styles */
  .collapse-toggle {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease;
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 32px;
    user-select: none;
    -webkit-user-select: none;
  }

  .collapse-toggle:hover {
    background: var(--panel-border);
  }

  .collapse-toggle:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .collapse-toggle-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
  }

  .collapse-toggle-indicator {
    font-size: 12px;
    font-weight: 700;
    color: #8b949e;
    white-space: nowrap;
  }

  .collapse-body.collapsed {
    display: none;
  }

/* ═══════════════════════════════════════════════════════════════
   INSTRUCTIONS PANEL — how-to-use section and keyboard shortcuts
   ═══════════════════════════════════════════════════════════════ */

  /* Instructions Panel */
  #instructionsPanel {
    width: var(--content-width);
    margin: 0 auto 8px auto;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-family: inherit;
  }

  #instructionsContent {
    padding: 12px 16px;
    font-size: 13px;
    text-align: left;
    color: var(--text);
  }

  #instructionsContent h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    margin: 12px 0 6px 0;
  }

  #instructionsContent ol {
    margin: 6px 0;
    padding-left: 20px;
  }

  #instructionsContent ol li {
    margin: 4px 0;
    line-height: 1.4;
  }

  #instructionsContent p {
    margin: 6px 0;
    line-height: 1.4;
  }

  #instructionsContent .note {
    color: var(--text-muted);
    font-size: 12px;
  }

  /* Keyboard shortcuts two-column layout */
  .shortcuts-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    margin: 6px 0;
  }

  .shortcuts-grid .shortcut-key {
    font-weight: 700;
    font-family: monospace;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    text-align: center;
  }

  .shortcuts-grid .shortcut-action {
    display: flex;
    align-items: center;
    font-size: 13px;
  }

  /* Instructions Panel toggle focus indicator */
  #instructionsToggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* Recenter Button keyboard focus indicator */
  #recenterBtn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

/* ═══════════════════════════════════════════════════════════════
   STORM POINTS & TOOLTIPS — marker shapes, tooltips, and labels
   ═══════════════════════════════════════════════════════════════ */

  /* Storm point icons */
  .storm-point { pointer-events: auto; }
  .circle { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .square { width: 10px; height: 10px; border-radius: 2px; }
  .triangle { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid red; }

  /* Tooltip and landfall label styles */
  .storm-tooltip { background-color: var(--tooltip-bg); color: var(--text); border-radius: 6px; padding: 10px; font-size: 13px; border: 1px solid var(--panel-border); }

  .timeline-hover-popup {
    position: fixed;
    z-index: 9999;
    background-color: var(--tooltip-bg);
    color: var(--text);
    border-radius: 6px;
    padding: 10px;
    font-size: 13px;
    border: 1px solid var(--panel-border);
    pointer-events: none;
    white-space: nowrap;
    display: none;
  }
  .season-name-anchor { pointer-events: none; }
  .season-name-popup { display: inline-block; font-weight: 700; }

  .season-name-tooltip {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #ffffff !important;
    font-size: 11px;
    font-weight: 700;
    padding: 0 !important;
    pointer-events: none;
    text-shadow: 0 0 3px rgba(0,0,0,0.7);
  }
  .season-name-tooltip::before,
  .season-name-tooltip::after { display: none !important; }
  .leaflet-tooltip.season-name-tooltip { color: #ffffff !important; background: transparent !important; border: none !important; box-shadow: none !important; }

  body.light-mode .season-name-tooltip,
  body.light-mode .leaflet-tooltip.season-name-tooltip {
    color: #000000 !important;
    text-shadow: 0 0 3px rgba(255,255,255,0.7);
  }

  .landfall-label {
    background-color: rgba(0,0,0,0.5);
    color: #ffffff;
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: 700;
    border: none;
    pointer-events: none;
  }

  body.light-mode .landfall-label {
    background-color: rgba(255,255,255,0.6);
    color: #111;
  }

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS — keyframe animations for cyclone markers
   ═══════════════════════════════════════════════════════════════ */

  /* Spinning cyclone marker */
  .cyclone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cyclone-wrapper {
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.4));
  }

  .cyclone-spin-ccw {
    animation: spin-ccw 5s linear infinite;
  }

  .cyclone-spin-cw {
    animation: spin-cw 5s linear infinite;
  }

  @keyframes spin-ccw {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
  }

  @keyframes spin-cw {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

/* ═══════════════════════════════════════════════════════════════
   FORECAST PULSE — sequential blink animation for forecast points
   ═══════════════════════════════════════════════════════════════ */

  .forecast-pulse .cyclone-wrapper.cyclone-spin-ccw {
    animation: spin-ccw 5s linear infinite, forecast-blink var(--pulse-total, 2.1s) step-end infinite;
    animation-delay: 0s, var(--pulse-delay, 0s);
  }

  .forecast-pulse.cw-spin .cyclone-wrapper.cyclone-spin-cw {
    animation: spin-cw 5s linear infinite, forecast-blink var(--pulse-total, 2.1s) step-end infinite;
    animation-delay: 0s, var(--pulse-delay, 0s);
  }

  @keyframes forecast-blink {
    0% { opacity: 1; filter: drop-shadow(0 0 10px rgba(255,255,255,0.9)); }
    14% { opacity: 0.3; filter: drop-shadow(0 0 6px rgba(255,255,255,0.4)); }
    100% { opacity: 0.3; filter: drop-shadow(0 0 6px rgba(255,255,255,0.4)); }
  }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — media queries for tablet and mobile layouts
   ═══════════════════════════════════════════════════════════════ */

  /* Responsive */
  @media (max-width: 900px) {
    .info-panel, #map, .control-bar, #siteFooter, #instructionsPanel { width: 95%; }
    .info-panel { flex-direction: column; gap: 12px; align-items: stretch; }
    .control-bar { flex-direction: column; }
    .control-row { flex-wrap: wrap; overflow-x: visible; }
    .control-row-2 { flex-wrap: wrap; overflow-x: visible; }
    .control-bar select, .control-bar button { width: 100%; min-height: 44px; }
    .control-bar input[type="range"] { min-height: 44px; }
  }

  @media (max-width: 768px) {
    .control-row-2 {
      flex-wrap: wrap;
      justify-content: center;
    }
    .control-row-2 select,
    .control-row-2 button,
    .control-row-2 input[type="date"] {
      flex: 0 0 auto;
      min-height: 36px;
    }
    .control-row-2 input[type="range"] {
      flex: 0 0 120px;
      min-height: 36px;
    }
  }

/* ═══════════════════════════════════════════════════════════════
   SEARCH — search input, suggestions dropdown
   ═══════════════════════════════════════════════════════════════ */

  /* Search suggestions */
  .suggestions-box {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    margin-top: 4px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 2000;
  }

  .suggestion-item {
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
  }

  .suggestion-item:hover {
    background: var(--panel-border);
  }

  #stormSearch {
    width: 100%;
    height: 44px;
    font-size: 16px;
    border-radius: 12px;
    padding: 0 16px;
    border: 1px solid var(--panel-border);
    background: var(--input-bg);
    color: var(--text);
  }

  #stormSearch:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 6px rgba(88,166,255,0.3);
  }

  .control-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    width: 100%;
    overflow-x: auto;
    justify-content: center;
  }

  .control-row select { flex: 1 1 auto; min-width: 100px; max-width: 180px; }
  .control-row button { flex: 0 0 auto; white-space: nowrap; padding: 8px 12px; }
  .control-row input[type="range"] { flex: 0 0 120px; height: 36px; }
  label[for="speed"] { flex: 0 0 auto; white-space: nowrap; margin: 0; font-size: 13px; }

  .btn-group {
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .search-row { width: 100%; display: flex; justify-content: center; }
  .search-container { position: relative; width: 100%; max-width: none; }

  .storm-tooltip-small { background-color: var(--tooltip-bg); color: var(--text); border-radius: 4px; padding: 4px 6px; font-size: 9px; border: 1px solid var(--panel-border); }
  .landfall-label-small { background-color: rgba(0,0,0,0.5); color: #ffffff; border-radius: 3px; padding: 1px 3px; font-size: 8px; font-weight: 700; border: none; pointer-events: none; }
  body.light-mode .landfall-label-small { background-color: rgba(255,255,255,0.6); color: #111; }

/* ═══════════════════════════════════════════════════════════════
   GRATICULE — grid overlay line labels
   ═══════════════════════════════════════════════════════════════ */

  /* Graticule lines */
  .graticule-label {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    font-family: monospace;
    pointer-events: none;
    white-space: nowrap;
  }
  body.light-mode .graticule-label {
    color: rgba(0,0,0,0.4);
  }

/* ═══════════════════════════════════════════════════════════════
   SEASON OVERLAYS — season mode panels, time bar, totals, timeline,
   ACE panel, storm cards, and satellite image panel
   ═══════════════════════════════════════════════════════════════ */

  /* Season / Overlay Panels */
  #stormLive { margin-top: 8px; font-size: 13px; color: var(--accent); font-weight: 900; }
  .info-left { flex: 1; min-width: 260px; }
  #seasonInfoPanels { display: none; }

  #seasonTimeBar {
    display: none; position: fixed; bottom: 20px; left: 20px; z-index: 1000;
    background: var(--panel); color: var(--text); border-radius: 10px;
    padding: 10px 16px; font-size: 13px; min-width: 220px; border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
  }
  #seasonTimeLabel { font-weight: 700; margin-bottom: 4px; font-size: 13px; color: var(--text); white-space: nowrap; text-align: center; }
  .season-time-track { background: var(--panel-border); border-radius: 4px; height: 6px; width: 100%; }
  #seasonTimeProgress { background: var(--accent); height: 6px; border-radius: 4px; width: 0%; transition: width 0.3s; }
  #seasonTimeSub { margin-top: 4px; font-size: 11px; color: var(--text-muted); }

  #seasonStormTotals {
    display: none; position: fixed; top: 80px; right: 20px; z-index: 1100;
    background: var(--panel); color: var(--text); border-radius: 10px;
    padding: 12px 16px; width: 220px; text-align: center; border: 1px solid var(--panel-border);
    pointer-events: auto; box-shadow: var(--shadow);
  }
  #seasonStormTotals .collapse-toggle,
  #seasonAcePanel .collapse-toggle,
  #legend .collapse-toggle {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px 6px;
  }

  #seasonStormTotals .collapse-toggle-title,
  #seasonAcePanel .collapse-toggle-title,
  #legend .collapse-toggle-title {
    font-size: 11px;
  }

  #seasonStormTotals .collapse-toggle-indicator,
  #seasonAcePanel .collapse-toggle-indicator,
  #legend .collapse-toggle-indicator {
    font-size: 10px;
  }

  #seasonTotalsTitle { font-size: 11px; font-weight: 700; margin-bottom: 8px; color: var(--accent); }
  #seasonTotalsGrid { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
  #seasonStrongestPanel { display: none; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--panel-border); text-align: left; font-size: 12px; line-height: 1.45; }

  #seasonTimeline {
    display: none; position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    z-index: 1000; background: var(--panel); color: var(--text); border-radius: 10px 10px 0 0;
    width: 1100px; max-width: 96vw; border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  }
  #seasonTimelineHeader { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 4px 12px; cursor: pointer; }
  .season-timeline-title { font-size: 12px; font-weight: 700; color: var(--accent); }
  #seasonTimelineToggle { font-size: 12px; color: var(--text-muted); }
  #seasonTimelineBody { padding: 0 12px 8px 12px; overflow: hidden; display: flex; justify-content: center; }
  #seasonTimelineInner { position: relative; }

  #seasonAcePanel {
    display: none; position: fixed; bottom: 20px; right: 20px; z-index: 1000;
    background: var(--panel); color: var(--text); border-radius: 10px;
    padding: 12px 16px; min-width: 220px; max-width: 300px; border: 1px solid var(--panel-border);
    text-align: center; box-shadow: var(--shadow);
    pointer-events: auto;
  }
  .season-ace-title { font-size: 11px; font-weight: 700; margin-bottom: 6px; color: var(--accent); }
  #seasonAceValue { font-size: 26px; font-weight: 900; }
  #seasonAceClass { margin-top: 6px; font-size: 12px; font-weight: 700; }
  #seasonAceNote { margin-top: 6px; font-size: 10px; color: var(--text-muted); line-height: 1.35; }
  #seasonAceThresholds { margin-top: 8px; font-size: 10px; line-height: 1.6; }



  #seasonStormCards {
    display: none; position: fixed; top: 80px; left: 20px; z-index: 1100;
    flex-direction: column; gap: 8px; max-height: 80vh; overflow-y: auto;
  }

  #stormImagePanel {
    display: none; position: fixed; bottom: 20px; right: 20px; z-index: 1000;
    background: var(--panel); color: var(--text); border-radius: 10px;
    padding: 10px; width: 240px; border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
  }
  #stormImageLabel { font-size: 10px; font-weight: 700; color: var(--accent); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
  #stormSatImage { width: 220px; height: 220px; object-fit: cover; border-radius: 6px; display: block; background: #111; }
  #stormImageCaption { font-size: 12px; font-weight: 700; color: var(--text); margin-top: 6px; text-align: center; }

  .legend-note { margin-top: 6px; font-size: 10px; color: #8b949e; }
  .legend-title { color: var(--accent); text-align: center; display: block; margin-bottom: 4px; }
  .legend-note strong { text-align: center; display: block; }

/* ═══════════════════════════════════════════════════════════════
   CONTROL ROW 2 & TIME JUMP — time inputs, speed slider, theme
   ═══════════════════════════════════════════════════════════════ */

  /* Row 2: Time jump, speed, display controls */
  .control-row-2 {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .control-row-2 select { flex: 0 0 auto; min-width: 80px; }
  .control-row-2 button { flex: 0 0 auto; white-space: nowrap; padding: 8px 12px; }
  .control-row-2 input[type="range"] { flex: 0 0 120px; height: 36px; }
  .control-row-2 #speedLabel { flex: 0 0 auto; white-space: nowrap; margin: 0; font-size: 13px; }

  #timeJumpControl #tjDate,
  #timeJumpControl #tjTime {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    height: 36px;
    flex-shrink: 1;
    min-width: 0;
    width: auto;
  }

  #timeJumpControl #rwGoBtn,
  #timeJumpControl #ffGoBtn {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    height: 36px;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
    width: auto;
  }

  #timeJumpControl #rwGoBtn:hover,
  #timeJumpControl #ffGoBtn:hover {
    transform: translateY(-2px);
    background: var(--panel-border);
  }

  #tjMessage {
    font-size: 12px;
    color: var(--accent);
    white-space: nowrap;
  }

  /* Disabled state for individual time-jump inputs only (not the entire row) */
  #timeJumpControl #tjDate:disabled,
  #timeJumpControl #tjTime:disabled,
  #timeJumpControl #rwGoBtn:disabled,
  #timeJumpControl #ffGoBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }

  /* Time Jump In-Progress State */
  #timeJumpControl.tj-in-progress {
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 6px;
    animation: tj-pulse 1.2s ease-in-out infinite;
  }

  @keyframes tj-pulse {
    0%, 100% { border-color: var(--accent); }
    50% { border-color: transparent; }
  }

  /* Mobile */
  @media (max-width: 600px) {
    .info-panel, #map, .control-bar, #siteFooter, #instructionsPanel { width: 100%; padding: 0 4px; }
    #legend { position: static; width: 100%; padding: 8px 10px; max-height: none; overflow-y: visible; }
    #map { margin: 0 auto; border-radius: 0; height: calc(100vh - 180px); }
    .control-row { flex-direction: column; }
    .control-row select, .control-row button { flex: 1 1 100%; width: 100%; max-width: none; min-height: 44px; }
    .control-row input[type="range"] { flex: 1 1 100%; width: 100%; min-height: 44px; }
    label[for="speed"] { width: 100%; text-align: left; }
    .control-row-2 { flex-wrap: wrap; }
    .control-row-2 select,
    .control-row-2 button,
    .control-row-2 input[type="date"] { min-height: 44px; }
    .control-row-2 input[type="range"] { flex: 0 0 120px; min-height: 44px; }
    .info-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .info-name { font-size: 22px; word-break: break-word; }
    .info-stat { font-size: 12px; }
    #seasonTimeBar, #seasonStormTotals, #seasonTimeline, #seasonAcePanel, #stormImagePanel, #seasonStormCards {
      position: fixed; bottom: 0; left: 0; right: 0; width: 100vw; max-width: 100vw; border-radius: 0;
    }
    #timeJumpControl #tjDate,
    #timeJumpControl #tjTime,
    #timeJumpControl #rwGoBtn,
    #timeJumpControl #ffGoBtn {
      min-height: 44px;
    }
    #timeJumpControl #tjDate {
      width: 100%;
    }
    #tjMessage {
      white-space: normal;
      text-align: center;
    }
  }

/* ═══════════════════════════════════════════════════════════════
   ACE CHART OVERLAY — backdrop, overlay panel, header, body, legend
   ═══════════════════════════════════════════════════════════════ */

  /* Backdrop: semi-transparent background behind the chart overlay */
  .ace-chart-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease-out;
  }

  .ace-chart-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .ace-chart-backdrop.collapsing {
    transition: opacity 300ms ease-in;
  }

  /* Chart overlay container */
  .ace-chart-overlay {
    position: fixed;
    z-index: 2001;
    background: var(--panel);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: top 300ms ease-out,
                left 300ms ease-out,
                width 300ms ease-out,
                height 300ms ease-out,
                border-radius 300ms ease-out,
                opacity 300ms ease-out;
  }

  .ace-chart-overlay.visible {
    opacity: 1;
    pointer-events: auto;
    overflow: visible;
  }

  .ace-chart-overlay.collapsing {
    transition: top 300ms ease-in,
                left 300ms ease-in,
                width 300ms ease-in,
                height 300ms ease-in,
                border-radius 300ms ease-in,
                opacity 300ms ease-in;
  }

  .ace-chart-overlay.animating {
    pointer-events: none;
  }

  /* Header: title and close button row */
  .ace-chart-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    flex-shrink: 0;
  }

  .ace-chart-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    margin: 0;
  }

  /* Close button */
  .ace-chart-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
  }

  .ace-chart-close:hover {
    background: var(--panel-border);
    color: var(--text);
  }

  .ace-chart-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* Body: holds the canvas, fills remaining space */
  .ace-chart-body {
    position: relative;
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 0 16px;
    min-height: 0;
  }

  .ace-chart-body canvas {
    width: 100%;
    height: 100%;
    display: block;
  }

  /* Legend: row of legend items at the bottom */
  .ace-chart-legend {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 10px 16px 14px;
    flex-shrink: 0;
    font-size: 12px;
  }

  .ace-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .ace-chart-legend-actual {
    color: var(--accent);
  }

  .ace-chart-legend-climo {
    color: var(--text-muted);
  }

/* ═══════════════════════════════════════════════════════════════
   ACE CHART OVERLAY — Responsive Breakpoints
   ═══════════════════════════════════════════════════════════════ */

/* Default (> 900px): overlay dimensions set by JS inline styles in toggleAceChartOverlay */

/* Tablet (≤ 900px) */
@media (max-width: 900px) {
  .ace-chart-overlay.visible {
    left: 2.5vw !important;
    width: 95vw !important;
    top: 20vh !important;
    height: 60vh !important;
  }
}

/* Mobile (≤ 600px) */
@media (max-width: 600px) {
  .ace-chart-overlay.visible {
    left: 0 !important;
    width: 100vw !important;
    top: auto !important;
    bottom: 0 !important;
    height: 60vh !important;
    border-radius: 0 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ACE CHART — button and tooltip styles
   ═══════════════════════════════════════════════════════════════ */

/* Chart button on ACE panel */
.ace-chart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ace-chart-btn:hover {
  background: var(--input-bg);
  border-color: var(--primary);
}

.ace-chart-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Tooltip overlay */
.ace-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--tooltip-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  z-index: 10;
  white-space: nowrap;
}

.ace-chart-tooltip-date {
  font-weight: 600;
  margin-bottom: 2px;
}

.ace-chart-tooltip-ace {
  color: var(--accent);
}

.ace-chart-tooltip-climo {
  color: var(--text-muted);
}

.ace-chart-tooltip-category {
  font-weight: 600;
  font-size: 11px;
  margin-top: 2px;
}

/* Intensity panel tooltip */
.intensity-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--tooltip-bg, rgba(20, 30, 40, 0.95));
  border: 1px solid var(--panel-border, #334455);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text, #e0e8f0);
  z-index: 10000;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   INTENSITY DETAIL PANEL — backdrop, overlay, header, body,
   plot containers, bottom panel, active highlight, responsive,
   tooltip, and focus indicators
   ═══════════════════════════════════════════════════════════════ */

  /* Backdrop: semi-transparent background behind the intensity overlay */
  .intensity-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 300ms ease-out;
  }

  .intensity-backdrop.visible {
    display: block;
    opacity: 1;
  }

  .intensity-backdrop.collapsing {
    transition: opacity 300ms ease-in;
  }

  /* Overlay container (season mode) */
  .intensity-overlay {
    position: fixed;
    z-index: 2001;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: top 300ms ease-out,
                left 300ms ease-out,
                width 300ms ease-out,
                height 300ms ease-out,
                border-radius 300ms ease-out,
                opacity 300ms ease-out;
  }

  .intensity-overlay.visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
  }

  .intensity-overlay.collapsing {
    transition: top 300ms ease-in,
                left 300ms ease-in,
                width 300ms ease-in,
                height 300ms ease-in,
                border-radius 300ms ease-in,
                opacity 300ms ease-in;
  }

  .intensity-overlay.animating {
    pointer-events: none;
  }

  /* Header: title and close button row */
  .intensity-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
  }

  .intensity-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
  }

  /* Close button */
  .intensity-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
  }

  .intensity-close:hover {
    background: var(--panel-border);
    color: var(--text);
  }

  /* Body: holds two plot containers side by side */
  .intensity-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    gap: 8px;
    padding: 12px;
    overflow: auto;
    min-height: 0;
  }

  /* Plot container */
  .intensity-plot-container {
    flex: 1;
    min-width: 200px;
    min-height: 150px;
    position: relative;
  }

  .intensity-plot-container canvas {
    width: 100%;
    height: 100%;
    display: block;
  }

  /* Bottom panel (individual mode) */
  .intensity-bottom-panel {
    position: fixed;
    bottom: 20px;
    left: 320px;
    right: 290px;
    height: 275px;
    z-index: 1000;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    color: var(--text);
  }

  .intensity-bottom-panel.collapsed {
    height: 32px;
    overflow: hidden;
  }

  .intensity-bottom-panel.visible {
    display: flex;
  }

  /* Bottom panel header */
  .intensity-bottom-header {
    padding: 8px 12px 4px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
  }

  .intensity-bottom-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
  }

  .intensity-bottom-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
  }

  .intensity-bottom-toggle:hover {
    background: var(--panel-border);
    color: var(--text);
  }

  /* Bottom panel body */
  .intensity-bottom-body {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 0 12px 8px 12px;
    flex: 1;
    min-height: 150px;
  }

  /* Active timeline bar highlight */
  .intensity-active {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-radius: 2px;
  }

  /* Responsive: stack plots vertically at ≤600px */
  @media (max-width: 600px) {
    .intensity-body {
      flex-direction: column;
    }

    .intensity-bottom-body {
      flex-direction: column;
    }

    .intensity-overlay.visible {
      left: 0 !important;
      width: 100vw !important;
      top: auto !important;
      bottom: 0 !important;
      height: 65vh !important;
      border-radius: 0 !important;
    }

    .intensity-bottom-panel {
      left: 10px;
      right: 10px;
      width: auto;
      max-width: 100vw;
      border-radius: 0;
      height: 200px;
    }
  }

  /* Tablet breakpoint */
  @media (max-width: 900px) {
    .intensity-overlay.visible {
      left: 2.5vw !important;
      width: 95vw !important;
      top: 15vh !important;
      height: 65vh !important;
    }
  }

  /* Focus indicators — 3:1 contrast ratio */
  .intensity-overlay button:focus-visible,
  .season-bar:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  .intensity-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }
