* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #010408;
    --glass: rgba(4, 10, 20, 0.72);
    --glass-border: rgba(120, 200, 255, 0.14);
    --text: #c0c8d0;
    --text-strong: #e8f4ff;
    --text-dim: rgba(160, 176, 192, 0.6);
    --neon: #00d4ff;
    --neon-soft: rgba(0, 212, 255, 0.35);
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(ellipse at 50% 40%, #04101e 0%, #020812 45%, var(--bg) 100%);
    color: var(--text);
    overflow: hidden;
}

button { font-family: inherit; }

#map-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#bg, #fx { pointer-events: none; }
#map { cursor: grab; opacity: 0; transition: opacity 1.4s ease; }
body.ready #map { opacity: 1; }

.vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ---------- Shared glass panel look ---------- */
.legend, .timeline, .help-modal, .tooltip, .zoom-controls {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ---------- UI entrance ---------- */
.hud-header, .legend, .timeline, .zoom-controls, .help-icon, .legend-fab {
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(.2, .8, .2, 1);
}
.hud-header { transform: translate(-50%, -14px); }
.legend { transform: translateX(-20px); }
.timeline { transform: translate(-50%, 20px); }
.zoom-controls { transform: translate(20px, -50%); }

body.ready .hud-header { opacity: 1; transform: translate(-50%, 0); transition-delay: 0.2s; }
body.ready .legend { opacity: 1; transform: none; transition-delay: 0.35s; }
body.ready .timeline { opacity: 1; transform: translate(-50%, 0); transition-delay: 0.5s; }
body.ready .zoom-controls { opacity: 1; transform: translate(0, -50%); transition-delay: 0.6s; }
body.ready .help-icon, body.ready .legend-fab { opacity: 1; transition-delay: 0.6s; }

/* ---------- Loader ---------- */
.loader {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: radial-gradient(ellipse at center, #031020 0%, var(--bg) 70%);
    transition: opacity 0.9s ease, visibility 0.9s;
}
.loader.hidden { opacity: 0; visibility: hidden; }

.loader-orbs { position: relative; width: 90px; height: 90px; }
.loader-orbs span {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 18px var(--c), 0 0 40px var(--c);
    animation: orbit 2.4s cubic-bezier(.5, 0, .5, 1) infinite;
    animation-delay: var(--d);
    transform-origin: 50% 50%;
}
@keyframes orbit {
    0%   { transform: rotate(0deg) translateX(34px) scale(1); opacity: 1; }
    50%  { transform: rotate(180deg) translateX(18px) scale(0.6); opacity: 0.5; }
    100% { transform: rotate(360deg) translateX(34px) scale(1); opacity: 1; }
}

.loader-title {
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--text-strong);
    text-shadow: 0 0 20px var(--neon-soft);
}
.loader-bar {
    width: 220px;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.loader-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #00ffff, #4488ff, #cc44ff);
    box-shadow: 0 0 12px var(--neon);
    transition: width 0.2s ease;
}
.loader-text { font-size: 0.8rem; color: var(--text-dim); }
.loader.error .loader-text { color: #ff6688; }

/* ---------- Header ---------- */
.hud-header {
    position: absolute;
    top: 18px;
    left: 50%;
    text-align: center;
    pointer-events: none;
    z-index: 5;
}
.hud-header h1 {
    font-size: 1.55rem;
    font-weight: 300;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-strong);
    text-shadow: 0 0 12px rgba(0, 212, 255, 0.6), 0 0 32px rgba(0, 212, 255, 0.25);
    animation: breathe 5s ease-in-out infinite;
}
.hud-header p {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 12px;
    border-radius: 20px;
    background: rgba(2, 8, 16, 0.6);
    backdrop-filter: blur(6px);
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}
.counter {
    color: #00ff88;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}
@keyframes breathe {
    0%, 100% { text-shadow: 0 0 12px rgba(0, 212, 255, 0.6), 0 0 32px rgba(0, 212, 255, 0.2); }
    50%      { text-shadow: 0 0 18px rgba(0, 212, 255, 0.9), 0 0 48px rgba(0, 212, 255, 0.4); }
}

/* ---------- Icon buttons ---------- */
.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(220, 240, 255, 0.75);
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    color: #fff;
    border-color: var(--neon);
    background: rgba(0, 212, 255, 0.12);
    box-shadow: 0 0 14px var(--neon-soft);
    transform: scale(1.07);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible, .legend-main:focus-visible, .play-btn:focus-visible {
    outline: 2px solid var(--neon);
    outline-offset: 2px;
}

.help-icon {
    position: absolute;
    top: 18px;
    left: 16px;
    z-index: 10;
    border-radius: 50%;
}

/* ---------- Help modal ---------- */
.help-modal {
    position: absolute;
    top: 60px;
    left: 16px;
    border-radius: 12px;
    padding: 16px 20px;
    z-index: 30;
    max-width: 300px;
    font-size: 0.8rem;
    line-height: 1.6;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top left;
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}
.help-modal.active { opacity: 1; visibility: visible; transform: none; }
.help-modal .count {
    color: #00ff88;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}
.help-modal .desc { color: rgba(192, 200, 208, 0.75); margin-bottom: 12px; }
.help-modal strong { color: var(--text-strong); font-weight: 500; }
.shortcuts { list-style: none; margin-bottom: 12px; color: var(--text-dim); font-size: 0.72rem; }
.shortcuts li { margin: 3px 0; }
kbd {
    font-family: inherit;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-strong);
}
.help-modal a { color: rgba(68, 136, 255, 0.8); text-decoration: none; font-size: 0.72rem; }
.help-modal a:hover { color: #4488ff; }

/* ---------- Zoom controls ---------- */
.zoom-controls {
    position: absolute;
    right: 16px;
    top: 50%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 14px;
}
.zoom-controls .icon-btn { border: none; background: transparent; }
.zoom-level {
    width: 3px;
    height: 70px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}
.zoom-level-fill {
    width: 100%;
    height: 0;
    background: linear-gradient(0deg, #4488ff, #00ffff);
    box-shadow: 0 0 8px var(--neon);
}

/* ---------- Legend ---------- */
.legend-fab { display: none; }

.legend {
    position: absolute;
    bottom: 20px;
    left: 16px;
    width: 290px;
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
    z-index: 10;
    border-radius: 14px;
    padding: 14px 10px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
}
.legend-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-strong);
    letter-spacing: 0.03em;
}
.legend-toggle-all {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: rgba(192, 200, 208, 0.75);
    font-size: 0.66rem;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.legend-toggle-all:hover { color: #fff; border-color: var(--neon); box-shadow: 0 0 10px var(--neon-soft); }

.legend-hint { font-size: 0.66rem; color: var(--text-dim); padding: 3px 6px 10px; }

.legend-item {
    border-radius: 9px;
    transition: background 0.25s, box-shadow 0.25s;
    opacity: 0;
}
body.ready .legend-item { animation: slideIn 0.5s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: none; }
}
.legend-item.hovered {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 2px 0 0 var(--c);
}

.legend-main {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 6px 8px;
    background: none;
    border: none;
    color: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 9px;
}

.legend-dot {
    position: relative;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--c);
    box-shadow: 0 0 8px var(--c), 0 0 2px #fff inset;
    transition: all 0.25s;
}
/* Soft pulsing halo around each color dot */
.legend-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid var(--c);
    opacity: 0;
    animation: dotPulse 2.8s ease-out infinite;
}
.legend-item:nth-child(2) .legend-dot::after { animation-delay: .4s; }
.legend-item:nth-child(3) .legend-dot::after { animation-delay: .8s; }
.legend-item:nth-child(4) .legend-dot::after { animation-delay: 1.2s; }
.legend-item:nth-child(5) .legend-dot::after { animation-delay: 1.6s; }
.legend-item:nth-child(6) .legend-dot::after { animation-delay: 2s; }
.legend-item:nth-child(7) .legend-dot::after { animation-delay: 2.4s; }
@keyframes dotPulse {
    0%   { transform: scale(0.6); opacity: 0.8; }
    100% { transform: scale(1.8); opacity: 0; }
}
.legend-item.hovered .legend-dot { transform: scale(1.25); box-shadow: 0 0 14px var(--c), 0 0 28px var(--c); }

.legend-names { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.legend-name { font-size: 0.82rem; color: var(--text-strong); }
.legend-latin { font-size: 0.64rem; font-style: italic; color: var(--c); opacity: 0.75; }
.legend-bar {
    margin-top: 4px;
    height: 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.legend-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--c);
    box-shadow: 0 0 6px var(--c);
    transition: width 0.6s cubic-bezier(.2, .8, .2, 1);
}
.legend-count {
    font-size: 0.72rem;
    color: rgba(190, 205, 220, 0.75);
    font-variant-numeric: tabular-nums;
}

.legend-desc {
    max-height: 0;
    font-size: 0.71rem;
    line-height: 1.45;
    color: rgba(192, 200, 208, 0.8);
    padding: 0 10px 0 31px;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
}
.legend-item.hovered .legend-desc { max-height: 120px; padding-bottom: 9px; }
.legend-desc a { display: block; margin-top: 3px; color: var(--c); text-decoration: none; opacity: 0.85; }
.legend-desc a:hover { opacity: 1; text-shadow: 0 0 8px var(--c); }

.legend-item.off .legend-dot { background: transparent; box-shadow: none; border: 1.5px solid var(--c); opacity: 0.5; }
.legend-item.off .legend-dot::after { display: none; }
.legend-item.off .legend-name,
.legend-item.off .legend-latin,
.legend-item.off .legend-count { opacity: 0.35; text-decoration: line-through; }
.legend-item.off .legend-bar { opacity: 0.3; }

/* ---------- Timeline ---------- */
.timeline {
    position: absolute;
    bottom: 20px;
    left: 50%;
    width: min(520px, calc(100vw - 640px));
    min-width: 360px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px 12px 12px;
    border-radius: 16px;
}

.play-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--neon);
    background: radial-gradient(circle, rgba(0, 212, 255, 0.25), rgba(0, 212, 255, 0.05));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px var(--neon-soft);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: playGlow 2.6s ease-in-out infinite;
}
.play-btn:hover { transform: scale(1.08); box-shadow: 0 0 26px var(--neon); }
.play-btn:active { transform: scale(0.95); }
.play-btn svg { width: 18px; height: 18px; fill: currentColor; }
.play-btn .icon-pause { display: none; }
.play-btn.playing .icon-play { display: none; }
.play-btn.playing .icon-pause { display: block; }
.play-btn.playing { animation: none; box-shadow: 0 0 24px var(--neon); }
@keyframes playGlow {
    0%, 100% { box-shadow: 0 0 10px var(--neon-soft); }
    50%      { box-shadow: 0 0 24px var(--neon), 0 0 4px var(--neon) inset; }
}

.timeline-body { flex: 1; min-width: 0; }
.timeline-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}
.timeline-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; }
.timeline-year {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s, text-shadow 0.3s;
}
.timeline-year.live { color: #00ffff; text-shadow: 0 0 10px rgba(0, 255, 255, 0.6); }

.timeline-track { position: relative; height: 34px; }
.histogram {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    height: 24px;
    display: flex;
    align-items: flex-end;
    gap: 1px;
    pointer-events: none;
}
.histogram span {
    flex: 1;
    border-radius: 2px 2px 0 0;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.3s, box-shadow 0.3s;
}
.histogram span.lit {
    background: linear-gradient(0deg, rgba(0, 212, 255, 0.35), rgba(0, 255, 255, 0.8));
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.4);
}

#yearSlider {
    --p: 100%;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 14px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
#yearSlider::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, #00ffff var(--p), rgba(255, 255, 255, 0.1) var(--p));
}
#yearSlider::-moz-range-track {
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, #00ffff var(--p), rgba(255, 255, 255, 0.1) var(--p));
}
#yearSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5.5px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.35), 0 0 14px #00ffff;
    transition: transform 0.15s;
}
#yearSlider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.35), 0 0 14px #00ffff;
}
#yearSlider:hover::-webkit-slider-thumb { transform: scale(1.25); }
#yearSlider:focus-visible { outline: none; }
#yearSlider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.6), 0 0 18px #00ffff; }

/* ---------- Tooltip ---------- */
.tooltip {
    --c: #00ffff;
    position: fixed;
    left: 0;
    top: 0;
    color: var(--text);
    padding: 10px 14px 11px;
    border-radius: 10px;
    border-left: 2px solid var(--c);
    pointer-events: none;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.15s, transform 0.15s;
    font-size: 0.78rem;
    line-height: 1.45;
    z-index: 1000;
    max-width: 260px;
    min-width: 170px;
}
.tooltip.visible { opacity: 1; transform: none; }
.tooltip-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c);
}
.tooltip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.tooltip-title {
    font-weight: 500;
    margin: 3px 0 2px;
    font-size: 0.9rem;
    color: var(--text-strong);
}
.tooltip-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1px 12px;
    font-size: 0.72rem;
}
.tooltip-grid span { color: var(--text-dim); }
.tooltip-grid b { font-weight: 500; color: var(--text); text-align: right; }

.tooltip-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}
.tooltip-grid sup { font-size: 0.6em; }
.tooltip-spark { display: block; width: 100%; height: 34px; margin-top: 8px; overflow: visible; }
.tooltip-spark path { fill: none; stroke: var(--c); stroke-width: 1.5; vector-effect: non-scaling-stroke; opacity: 0.85; }
.tooltip-spark circle { fill: #fff; stroke: var(--c); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* ---------- Header lines ---------- */
.hud-lines { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-lines p { margin-top: 6px; }
.hud-lines .hud-vitals { margin-top: 0; font-size: 0.7rem; }
.hud-vitals b { font-weight: 600; font-variant-numeric: tabular-nums; }
.hud-vitals .births { color: #00ffff; text-shadow: 0 0 8px rgba(0, 255, 255, 0.5); }
.hud-vitals .deaths { color: #cc88ff; text-shadow: 0 0 8px rgba(204, 68, 255, 0.5); }
.help-update { font-size: 0.68rem; color: var(--text-dim); margin-bottom: 8px; }

/* ---------- Indicator picker ---------- */
.legend-status { font-size: 0.66rem; color: var(--neon); }
.legend-status.error { color: #ff6688; }
.ind-picker { padding: 4px 6px 8px; }
.ind-theme {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin: 8px 0 5px;
}
.ind-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ind-chip {
    font-size: 0.7rem;
    padding: 4px 9px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(210, 225, 240, 0.8);
    cursor: pointer;
    transition: all 0.2s;
}
.ind-chip:hover { color: #fff; border-color: var(--neon); box-shadow: 0 0 10px var(--neon-soft); }
.ind-chip.active {
    color: #001018;
    background: var(--neon);
    border-color: var(--neon);
    box-shadow: 0 0 14px var(--neon-soft);
    font-weight: 500;
}
.ind-chip:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }

.ind-card {
    margin: 4px 6px 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.15);
}
.ind-name { font-size: 0.9rem; font-weight: 500; color: var(--text-strong); }
.ind-desc { font-size: 0.7rem; line-height: 1.45; color: rgba(192, 200, 208, 0.8); margin-top: 3px; }
.ind-world { font-size: 0.72rem; color: var(--text-dim); margin-top: 6px; }
.ind-world:empty { display: none; }
.ind-world b { color: var(--neon); font-weight: 600; }

.legend-top { padding: 8px 8px 2px; }
.legend-top-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.legend-top ol { list-style: none; counter-reset: top; }
.legend-top li {
    counter-increment: top;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
    padding: 2px 0;
}
.legend-top li::before {
    content: counter(top);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 0.6rem;
    color: #001018;
    background: var(--c);
    box-shadow: 0 0 8px var(--c);
}
.legend-top li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-strong); }
.legend-top li b { font-weight: 500; font-variant-numeric: tabular-nums; color: rgba(190, 205, 220, 0.85); }

/* ---------- Medium screens: timeline on the right of the legend ---------- */
@media (max-width: 1100px) and (min-width: 769px) {
    .timeline {
        left: auto;
        right: 16px;
        width: calc(100vw - 340px);
        min-width: 0;
        transform: translateY(20px);
    }
    body.ready .timeline { transform: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .hud-header { top: 14px; width: calc(100vw - 110px); }
    .hud-header h1 { font-size: 1rem; letter-spacing: 0.08em; }
    .hud-header p { font-size: 0.7rem; }

    .icon-btn { width: 38px; height: 38px; }
    .help-icon { top: 12px; left: 12px; }
    .help-modal { top: 58px; left: 12px; max-width: calc(100vw - 24px); font-size: 0.76rem; }

    .zoom-controls { right: 10px; top: 42%; }
    .zoom-level { height: 46px; }

    .timeline {
        left: 10px;
        right: 10px;
        bottom: 12px;
        width: auto;
        min-width: 0;
        transform: translateY(20px);
        padding: 10px 14px 10px 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
    body.ready .timeline { transform: none; }

    .legend-fab {
        display: block;
        position: absolute;
        left: 10px;
        bottom: calc(96px + env(safe-area-inset-bottom, 0px));
        z-index: 11;
        padding: 8px 14px;
        border-radius: 20px;
        border: 1px solid var(--glass-border);
        background: var(--glass);
        backdrop-filter: blur(14px);
        color: var(--text-strong);
        font-size: 0.78rem;
        cursor: pointer;
        box-shadow: 0 0 14px var(--neon-soft);
    }

    .legend {
        left: 10px;
        right: 10px;
        bottom: calc(140px + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-height: 45dvh;
        pointer-events: none;
    }
    body.ready .legend { opacity: 0; transform: translateY(12px); }
    body.ready .legend.open { opacity: 1; transform: none; pointer-events: auto; }
    .legend-desc { display: none; }

    .tooltip {
        left: 50% !important;
        top: 70px !important;
        transform: translateX(-50%);
        max-width: 80vw;
    }
    .tooltip.visible { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
