/* ===== RESET & BASE ===== */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --bg-deep:       #020818;
      --bg-panel:      rgba(8, 20, 50, 0.78);
      --bg-panel-dark: rgba(4, 10, 30, 0.90);
      --border:        rgba(100, 160, 255, 0.18);
      --border-glow:   rgba(100, 200, 255, 0.45);
      --accent:        #38bdf8;
      --accent2:       #818cf8;
      --text-primary:  #e2eaf8;
      --text-secondary:#94a9c9;
      --text-muted:    #4a6080;
      --green:         #34d399;
      --yellow:        #fbbf24;
      --red:           #f87171;
      --red-hot:       #ff3a1a;
      --radius:        12px;
      --radius-sm:     8px;
    }

    html, body {
      width: 100%; height: 100%;
      background: #000508;
      color: var(--text-primary);
      font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
      overflow: hidden;
      user-select: none;
    }

    /* ===== CANVAS ===== */
    #canvas-container {
      position: fixed;
      inset: 0;
      z-index: 0;
    }
    #canvas-container canvas { display: block; }

    /* ===== HEADER ===== */
    header {
      position: fixed;
      top: 0; left: 0; right: 0;
      z-index: 10;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 28px;
      background: linear-gradient(to bottom, rgba(2, 8, 24, 0.95) 0%, rgba(2, 8, 24, 0.0) 100%);
    }
    .logo {
      display: flex; align-items: center; gap: 10px;
    }
    .logo-icon {
      width: 34px; height: 34px;
      background: linear-gradient(135deg, #38bdf8, #6366f1);
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px;
      box-shadow: 0 0 18px rgba(56,189,248,0.5);
    }
    .logo-text {
      font-size: 18px; font-weight: 700; letter-spacing: 0.06em;
      background: linear-gradient(90deg, #e2eaf8, #38bdf8);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    }
    .logo-sub {
      font-size: 10px; color: var(--text-muted); letter-spacing: 0.15em; text-transform: uppercase;
    }
    .header-info {
      display: flex; align-items: center; gap: 18px;
      font-size: 12px; color: var(--text-secondary);
    }
    .header-badge {
      padding: 4px 12px;
      border: 1px solid var(--border);
      border-radius: 20px;
      background: var(--bg-panel);
      backdrop-filter: blur(10px);
      font-size: 11px;
      letter-spacing: 0.08em;
    }

    /* ===== LEFT PANEL: SCENARIO ===== */
    #panel-scenario {
      position: fixed;
      top: 116px; left: 22px;
      width: 280px;
      z-index: 10;
      background: var(--bg-panel);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 20px;
      box-shadow: 0 8px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    }
    .panel-title {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.18em;
      color: var(--text-muted);
      margin-bottom: 14px;
      display: flex; align-items: center; gap: 8px;
    }
    .panel-title::before {
      content: '';
      display: inline-block;
      width: 3px; height: 12px;
      background: var(--accent);
      border-radius: 2px;
    }

    /* Scenario Buttons */
    .scenario-btn {
      width: 100%;
      padding: 13px 16px;
      margin-bottom: 8px;
      border-radius: var(--radius-sm);
      border: 1px solid transparent;
      background: rgba(255,255,255,0.04);
      cursor: pointer;
      text-align: left;
      transition: all 0.25s ease;
      position: relative;
      overflow: hidden;
    }
    .scenario-btn::before {
      content: '';
      position: absolute; left: 0; top: 0; bottom: 0;
      width: 3px;
      border-radius: 3px 0 0 3px;
      transition: background 0.25s;
    }
    .scenario-btn:last-of-type { margin-bottom: 0; }
    .scenario-btn:hover {
      background: rgba(255,255,255,0.07);
      border-color: var(--border);
    }
    .scenario-btn.active {
      border-color: var(--border-glow);
      background: rgba(56,189,248,0.08);
    }
    .scenario-btn.ssp1.active::before  { background: var(--green); box-shadow: 0 0 8px var(--green); }
    .scenario-btn.ssp2.active::before  { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
    .scenario-btn.ssp5.active::before  { background: var(--red-hot); box-shadow: 0 0 8px var(--red-hot); }
    .scenario-btn.ssp1::before  { background: rgba(52,211,153,0.3); }
    .scenario-btn.ssp2::before  { background: rgba(251,191,36,0.3); }
    .scenario-btn.ssp5::before  { background: rgba(255,58,26,0.3); }

    .scenario-label {
      font-size: 12px; font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 3px;
    }
    .scenario-name {
      font-size: 10px; color: var(--text-secondary);
      margin-bottom: 5px;
    }
    .scenario-desc {
      font-size: 10px; color: var(--text-muted); line-height: 1.5;
    }
    .scenario-temp {
      display: inline-block;
      margin-top: 6px;
      padding: 2px 8px;
      border-radius: 10px;
      font-size: 11px; font-weight: 700;
    }
    .ssp1 .scenario-temp { background: rgba(52,211,153,0.15); color: var(--green); }
    .ssp2 .scenario-temp { background: rgba(251,191,36,0.15); color: var(--yellow); }
    .ssp5 .scenario-temp { background: rgba(255,58,26,0.15); color: var(--red-hot); }

    /* ===== RIGHT PANEL: STATS ===== */
    #panel-stats {
      position: fixed;
      top: 80px; right: 22px;
      width: 240px;
      z-index: 10;
      background: var(--bg-panel);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 20px;
      box-shadow: 0 8px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    }
    .stat-item {
      margin-bottom: 18px;
    }
    .stat-item:last-child { margin-bottom: 0; }
    .stat-label {
      font-size: 10px; color: var(--text-muted);
      text-transform: uppercase; letter-spacing: 0.12em;
      margin-bottom: 4px;
    }
    .stat-value {
      font-size: 28px; font-weight: 700;
      line-height: 1;
      background: linear-gradient(90deg, #e2eaf8, #38bdf8);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
      transition: all 0.4s ease;
    }
    .stat-value.warning { background: linear-gradient(90deg, #fbbf24, #f87171); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    .stat-value.danger  { background: linear-gradient(90deg, #f87171, #ff3a1a); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    .stat-unit {
      font-size: 13px; font-weight: 400;
      -webkit-text-fill-color: var(--text-secondary);
    }
    .stat-bar {
      height: 4px;
      background: rgba(255,255,255,0.08);
      border-radius: 2px;
      margin-top: 8px;
      overflow: hidden;
    }
    .stat-bar-fill {
      height: 100%; border-radius: 2px;
      transition: width 0.5s ease, background 0.5s ease;
    }
    .divider {
      height: 1px;
      background: var(--border);
      margin: 14px 0;
    }
    .impact-list { list-style: none; }
    .impact-list li {
      font-size: 11px; color: var(--text-secondary);
      padding: 4px 0; display: flex; align-items: flex-start; gap: 7px;
      line-height: 1.5;
      border-bottom: 1px solid rgba(255,255,255,0.04);
    }
    .impact-list li:last-child { border-bottom: none; }
    .impact-list li::before {
      content: '▸';
      color: var(--accent); flex-shrink: 0; margin-top: 1px;
    }

    /* ===== BOTTOM: TIMELINE ===== */
    #panel-timeline {
      position: fixed;
      bottom: 24px; left: 50%;
      transform: translateX(-50%);
      width: min(760px, calc(100vw - 44px));
      z-index: 10;
      background: var(--bg-panel);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 20px 28px;
      box-shadow: 0 -4px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    }
    .timeline-header {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 16px;
    }
    .timeline-year-display {
      font-size: 32px; font-weight: 800;
      letter-spacing: -0.02em;
      background: linear-gradient(90deg, #e2eaf8, #38bdf8);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    }
    .timeline-play-btn {
      width: 38px; height: 38px;
      border-radius: 50%;
      border: 1px solid var(--border-glow);
      background: rgba(56,189,248,0.12);
      color: var(--accent);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-size: 14px;
      transition: all 0.2s ease;
    }
    .timeline-play-btn:hover { background: rgba(56,189,248,0.25); box-shadow: 0 0 14px rgba(56,189,248,0.4); }
    .timeline-play-btn.playing { background: rgba(248,113,113,0.2); color: var(--red); border-color: var(--red); }

    /* Slider */
    .slider-wrap {
      position: relative;
      padding: 12px 0 4px;
    }
    .slider-track {
      position: relative;
      height: 6px;
      background: rgba(255,255,255,0.07);
      border-radius: 3px;
      cursor: pointer;
    }
    .slider-fill {
      position: absolute; left: 0; top: 0; height: 100%;
      border-radius: 3px;
      background: linear-gradient(90deg, #38bdf8, #818cf8);
      transition: width 0.05s;
      pointer-events: none;
    }
    .slider-thumb {
      position: absolute; top: 50%; transform: translate(-50%, -50%);
      width: 18px; height: 18px;
      background: #fff;
      border-radius: 50%;
      box-shadow: 0 0 0 3px rgba(56,189,248,0.5), 0 0 14px rgba(56,189,248,0.6);
      cursor: grab;
      transition: box-shadow 0.2s, width 0.2s, height 0.2s;
      z-index: 2;
    }
    .slider-thumb:active { cursor: grabbing; width: 22px; height: 22px; }
    .slider-labels {
      display: flex; justify-content: space-between;
      margin-top: 10px;
      font-size: 10px; color: var(--text-muted);
      letter-spacing: 0.08em;
    }
    .slider-ticks {
      position: absolute; left: 0; right: 0; top: -8px;
      display: flex; justify-content: space-between;
      pointer-events: none;
    }
    .slider-tick {
      width: 1px; height: 5px;
      background: rgba(255,255,255,0.12);
    }
    .speed-control {
      display: flex; align-items: center; gap: 8px;
      font-size: 11px; color: var(--text-secondary);
    }
    .speed-btn {
      padding: 3px 9px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: transparent;
      color: var(--text-secondary);
      cursor: pointer; font-size: 11px;
      transition: all 0.2s;
    }
    .speed-btn.active, .speed-btn:hover {
      border-color: var(--accent); color: var(--accent);
      background: rgba(56,189,248,0.1);
    }

    /* ===== LEGEND ===== */
    #legend {
      position: fixed;
      bottom: 120px; right: 22px;
      z-index: 10;
      background: var(--bg-panel);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 14px 16px;
      min-width: 160px;
    }
    .legend-title {
      font-size: 10px; color: var(--text-muted);
      text-transform: uppercase; letter-spacing: 0.12em;
      margin-bottom: 10px;
    }
    .legend-gradient {
      height: 12px; border-radius: 6px;
      background: linear-gradient(90deg,
        #1a3a6e 0%,
        #1e7abf 20%,
        #34d399 38%,
        #fbbf24 58%,
        #f87171 78%,
        #ff3a1a 100%
      );
      margin-bottom: 6px;
    }
    .legend-labels {
      display: flex; justify-content: space-between;
      font-size: 10px; color: var(--text-secondary);
    }

    /* ===== LOADING OVERLAY ===== */
    #loading {
      position: fixed; inset: 0;
      z-index: 100;
      background: var(--bg-deep);
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 20px;
      transition: opacity 0.8s ease;
    }
    #loading.hidden { opacity: 0; pointer-events: none; }
    .loading-globe {
      width: 80px; height: 80px;
      border-radius: 50%;
      background: linear-gradient(135deg, #0f3460, #38bdf8 50%, #1a0a2e);
      box-shadow: 0 0 40px rgba(56,189,248,0.4), inset 0 0 30px rgba(56,189,248,0.1);
      animation: spin 2s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .loading-text {
      font-size: 14px; color: var(--text-secondary); letter-spacing: 0.2em;
      text-transform: uppercase;
    }
    .loading-bar {
      width: 200px; height: 2px;
      background: rgba(255,255,255,0.1);
      border-radius: 1px; overflow: hidden;
    }
    .loading-bar-fill {
      height: 100%; width: 0;
      background: linear-gradient(90deg, #38bdf8, #818cf8);
      border-radius: 1px;
      animation: loadingBar 1.5s ease forwards;
    }
    @keyframes loadingBar { to { width: 100%; } }

    /* ===== TOOLTIP ===== */
    #tooltip {
      position: fixed;
      z-index: 20;
      background: var(--bg-panel-dark);
      border: 1px solid var(--border-glow);
      border-radius: var(--radius-sm);
      padding: 10px 14px;
      font-size: 12px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s;
      backdrop-filter: blur(16px);
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    }
    #tooltip.visible { opacity: 1; }
    .tooltip-title { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
    .tooltip-row { color: var(--text-secondary); margin-bottom: 2px; }
    .tooltip-row span { color: var(--accent); font-weight: 600; }

    /* ===== WHALE PANEL ===== */
    #panel-whale {
      position: fixed;
      top: 116px; left: 22px;
      width: 280px;
      z-index: 11;
      background: var(--bg-panel);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 18px 20px;
      box-shadow: 0 8px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
      /* Overlaps scenario panel — hidden by default */
      display: none;
    }
    #panel-whale.visible { display: block; }

    /* Mode toggle — sits above left panels */
    #mode-toggle {
      position: fixed;
      top: 68px; left: 22px;
      z-index: 12;
      display: flex;
      background: var(--bg-panel-dark);
      backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: 30px;
      padding: 3px;
      gap: 2px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    }
    .mode-btn {
      padding: 6px 14px;
      border-radius: 24px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      font-size: 11px; font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      letter-spacing: 0.05em;
      white-space: nowrap;
    }
    .mode-btn.active {
      background: rgba(56,189,248,0.18);
      color: var(--accent);
      box-shadow: 0 0 12px rgba(56,189,248,0.25);
    }

    /* Whale species filter buttons */
    .whale-species-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 7px;
      margin-bottom: 14px;
    }
    .whale-species-btn {
      padding: 9px 10px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.03);
      cursor: pointer;
      text-align: left;
      transition: all 0.2s;
      position: relative;
      overflow: hidden;
    }
    .whale-species-btn::before {
      content: '';
      position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
      border-radius: 3px 0 0 3px;
    }
    .whale-species-btn.active {
      border-color: var(--border-glow);
      background: rgba(56,189,248,0.07);
    }
    .whale-species-btn .sp-emoji { font-size: 16px; display: block; margin-bottom: 3px; }
    .whale-species-btn .sp-name  { font-size: 10px; font-weight: 600; color: var(--text-primary); display: block; }
    .whale-species-btn .sp-count { font-size: 9px; color: var(--text-muted); margin-top: 2px; }

    /* Whale stats bar */
    .whale-stats-row {
      display: flex; justify-content: space-between;
      margin-bottom: 12px;
      gap: 8px;
    }
    .whale-stat-chip {
      flex: 1; text-align: center;
      background: rgba(255,255,255,0.04);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 8px 4px;
    }
    .whale-stat-chip .wsc-val  { font-size: 18px; font-weight: 700;
      background: linear-gradient(90deg,#38bdf8,#818cf8);
      -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
    .whale-stat-chip .wsc-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }

    /* Loading spinner for whale data */
    .whale-loading {
      display: flex; align-items: center; gap: 10px;
      font-size: 11px; color: var(--text-secondary);
      padding: 8px 0;
    }
    .whale-spinner {
      width: 14px; height: 14px;
      border: 2px solid rgba(56,189,248,0.2);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      flex-shrink: 0;
    }

    /* Whale tooltip override */
    .whale-tooltip-dot {
      display: inline-block;
      width: 8px; height: 8px;
      border-radius: 50%;
      margin-right: 6px;
      vertical-align: middle;
    }

    /* Panel shift when whale mode active */
    @media (min-width: 640px) {
      body.whale-mode #panel-scenario { display: none; }
      body.whale-mode #panel-whale    { display: block; }
    }

    /* Mobile whale tab */
    .mobile-whale-species-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 7px;
      margin-bottom: 12px;
    }
    .mobile-whale-chip {
      padding: 8px 6px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.03);
      cursor: pointer;
      text-align: center;
      font-size: 10px;
      transition: all 0.2s;
    }
    .mobile-whale-chip.active { border-color: var(--border-glow); background: rgba(56,189,248,0.1); }
    .mobile-whale-chip .mwc-emoji { font-size: 18px; display: block; margin-bottom: 3px; }
    .mobile-whale-chip .mwc-name  { font-size: 9px; color: var(--text-secondary); }

    /* ===== PULSE ANIMATION for active scenario ===== */
    @keyframes pulse-glow {
      0%, 100% { box-shadow: 0 0 8px rgba(56,189,248,0.2); }
      50%       { box-shadow: 0 0 20px rgba(56,189,248,0.5); }
    }

    /* ===== MOBILE DRAWER ===== */
    /* Bottom sheet that slides up on mobile */
    #mobile-drawer {
      display: none;
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 20;
      background: var(--bg-panel-dark);
      backdrop-filter: blur(24px);
      border-top: 1px solid var(--border-glow);
      border-radius: 20px 20px 0 0;
      box-shadow: 0 -8px 40px rgba(0,0,0,0.7);
      transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
      transform: translateY(calc(100% - 56px)); /* collapsed: show only tab bar */
      max-height: 85vh;
      overflow: hidden;
    }
    #mobile-drawer.expanded {
      transform: translateY(0);
    }
    /* Drag handle */
    .drawer-handle {
      width: 36px; height: 4px;
      background: rgba(255,255,255,0.2);
      border-radius: 2px;
      margin: 10px auto 0;
      cursor: pointer;
    }
    /* Tab bar inside drawer */
    .drawer-tabs {
      display: flex;
      align-items: center;
      padding: 6px 16px 0;
      gap: 4px;
      border-bottom: 1px solid var(--border);
    }
    .drawer-tab {
      flex: 1;
      padding: 8px 4px;
      background: none;
      border: none;
      border-bottom: 2px solid transparent;
      color: var(--text-muted);
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.06em;
      cursor: pointer;
      transition: all 0.2s;
      text-align: center;
    }
    .drawer-tab.active {
      color: var(--accent);
      border-bottom-color: var(--accent);
    }
    /* Tab pages */
    .drawer-page {
      display: none;
      padding: 16px;
      overflow-y: auto;
      max-height: calc(85vh - 80px);
    }
    .drawer-page.active { display: block; }

    /* Mobile scenario buttons: horizontal compact */
    .mobile-scenario-row {
      display: flex;
      gap: 8px;
      margin-bottom: 12px;
    }
    .mobile-scenario-chip {
      flex: 1;
      padding: 10px 6px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      color: var(--text-secondary);
      cursor: pointer;
      text-align: center;
      font-size: 11px;
      font-weight: 600;
      transition: all 0.2s;
      position: relative;
    }
    .mobile-scenario-chip .chip-code { font-size: 12px; font-weight: 700; color: var(--text-primary); }
    .mobile-scenario-chip .chip-temp { font-size: 10px; margin-top: 2px; }
    .mobile-scenario-chip.active { border-color: var(--border-glow); background: rgba(56,189,248,0.10); }
    .mobile-scenario-chip.ssp1.active .chip-code { color: var(--green); }
    .mobile-scenario-chip.ssp2.active .chip-code { color: var(--yellow); }
    .mobile-scenario-chip.ssp5.active .chip-code { color: var(--red-hot); }

    /* Mobile stats grid */
    .mobile-stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-bottom: 12px;
    }
    .mobile-stat-card {
      background: rgba(255,255,255,0.04);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 12px;
    }
    .mobile-stat-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
    .mobile-stat-value { font-size: 22px; font-weight: 700;
      background: linear-gradient(90deg, #e2eaf8, #38bdf8);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    }
    .mobile-stat-value.warning { background: linear-gradient(90deg,#fbbf24,#f87171); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
    .mobile-stat-value.danger  { background: linear-gradient(90deg,#f87171,#ff3a1a); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
    .mobile-stat-unit { font-size: 11px; font-weight: 400; -webkit-text-fill-color: var(--text-secondary); }

    /* Mobile timeline inside drawer */
    .mobile-timeline-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
    }
    .mobile-year-display {
      font-size: 28px; font-weight: 800;
      background: linear-gradient(90deg, #e2eaf8, #38bdf8);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    }
    .mobile-speed-row {
      display: flex; align-items: center; gap: 6px;
      margin-bottom: 14px;
      font-size: 11px; color: var(--text-secondary);
    }

    /* Mobile header adjustments */
    @media (max-width: 639px) {
      .logo-sub    { display: none; }
      .header-info .header-badge:first-child { display: none; }
      header { padding: 10px 14px; }
      .logo-text { font-size: 15px; }
    }

    /* ===== BREAKPOINT: tablet (640-1023px) ===== */
    @media (max-width: 1023px) {
      #mode-toggle { top: 62px; left: 12px; }
      #panel-scenario {
        width: 230px;
        top: 106px;
        left: 12px;
      }
      #panel-whale {
        top: 106px;
        left: 12px;
        width: 230px;
      }
      #panel-stats {
        width: 200px;
        top: 70px;
        right: 12px;
      }
      #panel-timeline {
        bottom: 16px;
        padding: 14px 18px;
      }
      .timeline-year-display { font-size: 26px; }
      .speed-control { gap: 5px; }
      #legend {
        bottom: 130px;
        right: 12px;
        min-width: 140px;
      }
      .stat-value { font-size: 22px; }
    }

    /* ===== BREAKPOINT: mobile (< 640px) ===== */
    @media (max-width: 639px) {
      /* Hide desktop panels */
      #panel-scenario,
      #panel-stats,
      #panel-timeline,
      #panel-whale,
      #mode-toggle,
      #legend {
        display: none !important;
      }
      /* Show mobile drawer */
      #mobile-drawer { display: block; }
    }

    /* ===== BREAKPOINT: very small (< 375px) ===== */
    @media (max-width: 374px) {
      .mobile-scenario-chip .chip-code { font-size: 11px; }
      .mobile-stat-value { font-size: 18px; }
      .mobile-year-display { font-size: 22px; }
    }
