/* ========================================
   Kosmos-Expansions-Simulator — Styles
   Premium dark cosmic theme
   ======================================== */



/* ---- CSS Variables ---- */
:root {
    --bg-deep: #050510;
    --bg-panel: rgba(10, 10, 30, 0.75);
    --bg-panel-solid: #0a0a1e;
    --glass-border: rgba(100, 140, 255, 0.15);
    --glass-glow: rgba(80, 120, 255, 0.08);
    --accent-cyan: #00e5ff;
    --accent-magenta: #e040fb;
    --accent-blue: #448aff;
    --accent-gold: #ffff55;
    --accent-red: #ff5252;
    --text-primary: #e8eaf6;
    --text-secondary: rgba(200, 210, 240, 0.7);
    --text-dim: rgba(160, 170, 200, 0.5);
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    font-family: var(--font-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ---- Canvas ---- */
#universe-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ---- Loader ---- */
#loader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-ring {
    width: 80px;
    height: 80px;
    border: 3px solid rgba(100, 140, 255, 0.1);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    margin-top: 24px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* ---- Title ---- */
#app-title {
    position: fixed;
    top: 24px;
    left: 32px;
    z-index: 10;
    pointer-events: none;
}

#app-title h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#app-title p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ---- Stats HUD (Charts) ---- */
#stats-hud {
    position: fixed;
    top: 190px;
    left: 24px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#stats-hud.visible {
    opacity: 1;
    transform: translateY(0);
}

.chart-container {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 0 28px rgba(20, 60, 180, 0.15);
}

.chart-container canvas {
    display: block;
}

/* ---- Gauge Diagram ---- */
#gauge-container {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#gauge-container.visible {
    opacity: 1;
    transform: translateY(0);
}

#gauge-canvas {
    display: block;
}

#timeline {
    position: fixed;
    top: 80px;
    left: 32px;
    right: 340px;
    z-index: 10;
}

#timeline-track {
    position: relative;
    height: 4px;
    background: rgba(100, 140, 255, 0.12);
    border-radius: 2px;
    cursor: default;
    margin-top: 40px;
    /* space for above-labels */
    pointer-events: none;
}

#timeline-track:hover {
    background: rgba(100, 140, 255, 0.12);
}

#timeline-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    width: 0%;
    transition: width 0.05s linear;
    pointer-events: none;
}

#timeline-fill-ship {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, #ffff55, var(--accent-magenta));
    width: 0%;
    transition: width 0.05s linear, left 0.05s linear;
    pointer-events: none;
    opacity: 0;
}

#timeline-fill-ship.active {
    opacity: 1;
}

#timeline-cursor {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    margin-top: -7px;
    background: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6), 0 0 4px rgba(0, 229, 255, 0.9);
    pointer-events: none;
    transition: left 0.05s linear, background 0.5s ease, box-shadow 0.5s ease;
    z-index: 2;
}

/* Phase 2: ship launched — switch to golden rocket */
#timeline-cursor.ship-active {
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
    background: radial-gradient(circle, rgba(255, 215, 64, 0.9) 30%, rgba(255, 215, 64, 0) 70%);
    box-shadow: none;
}

#timeline-cursor.ship-active::after {
    content: '🚀';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    filter: drop-shadow(0 0 4px rgba(255, 215, 64, 0.6));
}

/* Timeline fill switches to gold-magenta after ship launch — now using separate element */

/* Markers container sits on top of the track */
#timeline-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
}

/* Each marker is a vertical column centered on its left% position */
.tl-marker {
    position: absolute;
    top: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
    pointer-events: auto;
    cursor: pointer;
}

/* Dot sits on the track line */
.tl-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: var(--transition);
    flex-shrink: 0;
    position: absolute;
    top: -3px;
    /* center on the track */
}

/* Connector line from dot to label */
.tl-line {
    width: 1px;
    background: rgba(200, 210, 240, 0.25);
    flex-shrink: 0;
    position: absolute;
}

/* Label text */
.tl-label {
    font-size: 0.58rem;
    font-weight: 500;
    color: var(--text-dim);
    white-space: nowrap;
    transition: color 0.3s ease;
    letter-spacing: 0.02em;
    position: absolute;
}

/* --- BELOW markers (tier 1, 2) : label below the track --- */
.tl-marker[data-tier="1"] .tl-line {
    top: 4px;
    height: 8px;
}

.tl-marker[data-tier="1"] .tl-label {
    top: 14px;
}

.tl-marker[data-tier="2"] .tl-line {
    top: 4px;
    height: 22px;
}

.tl-marker[data-tier="2"] .tl-label {
    top: 28px;
}

/* --- ABOVE markers (tier -1, -2) : label above the track --- */
.tl-marker[data-tier="-1"] .tl-line {
    bottom: 4px;
    height: 10px;
}

.tl-marker[data-tier="-1"] .tl-label {
    bottom: 16px;
}

.tl-marker[data-tier="-2"] .tl-line {
    bottom: 4px;
    height: 24px;
}

.tl-marker[data-tier="-2"] .tl-label {
    bottom: 30px;
}

.tl-marker:hover .tl-dot {
    transform: scale(1.6);
    box-shadow: 0 0 8px rgba(200, 210, 240, 0.5);
}

.tl-marker:hover .tl-label {
    color: var(--text-primary);
}

/* Today marker special style */
.tl-marker.today .tl-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.tl-marker.today .tl-label {
    color: var(--accent-cyan);
    font-weight: 700;
    font-size: 0.65rem;
}

.tl-marker.today:hover .tl-dot {
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.8);
}

.stat-item,
.stat-card {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    min-width: 240px;
    transition: var(--transition);
}

.stat-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.stat-item:nth-child(2) .stat-value,
.stat-card:nth-child(2) .stat-value {
    color: var(--accent-magenta);
}

.stat-item:nth-child(3) .stat-value,
.stat-card:nth-child(3) .stat-value {
    color: var(--accent-gold);
}

.stat-item:nth-child(4) .stat-value,
.stat-card:nth-child(4) .stat-value {
    color: var(--accent-blue);
}

.stat-item:nth-child(5) .stat-value,
.stat-card:nth-child(5) .stat-value {
    color: var(--text-secondary);
}

/* ---- Control Panel ---- */
#control-panel {
    position: fixed;
    top: 50%;
    right: 28px;
    transform: translateY(-50%);
    z-index: 10;
    width: 310px;
    background: linear-gradient(145deg, rgba(12, 14, 38, 0.88), rgba(8, 10, 28, 0.92));
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(100, 140, 255, 0.2);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(0, 229, 255, 0.04),
        inset 0 1px 0 rgba(100, 140, 255, 0.12),
        inset 0 -1px 0 rgba(224, 64, 251, 0.06);
}

.panel-title {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: rgba(160, 175, 220, 0.6);
    margin-bottom: 20px;
    text-align: center;
}

/* ---- Slider Groups ---- */
.slider-group {
    margin-bottom: 24px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.slider-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.slider-display {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-cyan);
    min-width: 70px;
    text-align: right;
}

.slider-group:nth-child(3) .slider-display {
    color: var(--accent-magenta);
}

/* Custom range slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.25), rgba(224, 64, 251, 0.2));
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 0 8px rgba(0, 229, 255, 0.08);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.5), 0 0 4px rgba(0, 229, 255, 0.8);
    cursor: grab;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
    cursor: grab;
}

/* ---- Buttons ---- */
.btn-row,
.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.btn {
    padding: 12px 8px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: rgba(20, 20, 50, 0.6);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(0, 229, 255, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.15);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: translateY(0);
}

.btn.active {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.2), inset 0 0 20px rgba(0, 229, 255, 0.05);
}

.btn-launch {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(255, 82, 82, 0.15), rgba(224, 64, 251, 0.15));
    border-color: rgba(255, 82, 82, 0.3);
    color: var(--accent-red);
}

.btn-launch:hover {
    border-color: var(--accent-red);
    box-shadow: 0 4px 20px rgba(255, 82, 82, 0.2);
}

.btn-launch.launched {
    border-color: var(--accent-red);
    box-shadow: 0 0 20px rgba(255, 82, 82, 0.3), inset 0 0 20px rgba(255, 82, 82, 0.05);
    animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse-red {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 82, 82, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 82, 82, 0.5);
    }
}

.btn-reset {
    grid-column: 1 / -1;
    opacity: 0.5;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    padding: 8px;
}

.btn-reset:hover {
    opacity: 0.9;
}

/* Phase label */
.phase-label {
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent-cyan);
    margin-bottom: 18px;
    padding: 8px 12px;
    background: rgba(0, 229, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 8px;
    transition: color 0.5s ease, border-color 0.5s ease, background 0.5s ease;
}

/* Ready pulse for launch button when Phase 2 starts */
.btn-launch.ready-pulse {
    opacity: 1 !important;
    pointer-events: auto !important;
    animation: ready-glow 1.5s ease-in-out infinite;
    border-color: var(--accent-magenta);
    color: var(--accent-magenta);
}

/* Ready pulse for start button after intro quiz */
.btn-action.ready-pulse {
    animation: start-glow 1.5s ease-in-out infinite;
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

@keyframes ready-glow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(224, 64, 251, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(224, 64, 251, 0.6), 0 0 60px rgba(224, 64, 251, 0.2);
    }
}

@keyframes start-glow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(0, 229, 255, 0.6), 0 0 60px rgba(0, 229, 255, 0.2);
    }
}

/* ---- Divider ---- */
.panel-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.3), rgba(224, 64, 251, 0.3), transparent);
    margin: 22px 0;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

/* ---- Zoom Buttons ---- */
.zoom-buttons {
    display: flex;
    gap: 6px;
}

.btn-zoom {
    opacity: 0;
    transition: opacity 0.8s ease, background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    flex: 1;
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(20, 20, 50, 0.6);
    font-size: 0.7rem;
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-transform: none;
    text-align: center;
    letter-spacing: 0.02em;
    overflow: visible;
    width: auto;
    height: auto;
}

.btn-zoom:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
}

.btn-zoom.active {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3), inset 0 0 10px rgba(0, 229, 255, 0.05);
}

.btn-zoom::after {
    display: none;
}

/* MW timeline marker */
.tl-marker.milkyway .tl-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-magenta);
    box-shadow: 0 0 6px rgba(224, 64, 251, 0.5);
}

.tl-marker.milkyway .tl-label {
    color: var(--accent-magenta);
    font-weight: 600;
    font-size: 0.6rem;
}



/* ---- Galaxy Count ---- */
#galaxy-count {
    position: fixed;
    bottom: 20px;
    left: 32px;
    z-index: 10;
    font-size: 0.7rem;
    color: var(--text-dim);
    pointer-events: none;
}

/* ---- Warning Overlay ---- */
#warning-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#warning-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.warning-card {
    position: relative;
    background: linear-gradient(145deg, rgba(12, 16, 40, 0.97), rgba(8, 10, 28, 0.98));
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(100, 140, 255, 0.15);
    border-radius: 20px;
    padding: 44px 40px;
    max-width: 520px;
    width: 92%;
    text-align: center;
    box-shadow:
        0 0 60px rgba(0, 229, 255, 0.08),
        0 20px 80px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#warning-overlay.visible .warning-card {
    transform: scale(1);
}

.warning-card h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00e5ff, #e040fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.warning-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.warning-guess {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-gold);
    text-align: center;
    margin-bottom: 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(255, 215, 64, 0.08), rgba(224, 64, 251, 0.05));
    border: 1px solid rgba(255, 215, 64, 0.2);
    border-radius: 12px;
    line-height: 1.5;
}

.warning-explanation {
    font-size: 0.82rem;
    color: rgba(180, 190, 220, 0.65);
    line-height: 1.7;
    margin-bottom: 24px;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

.warning-results-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-cyan);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.warning-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 28px;
}

.warning-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(100, 140, 255, 0.08);
    border-left: 3px solid rgba(0, 229, 255, 0.3);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.warning-stat:nth-child(3) {
    border-left-color: var(--accent-gold);
    background: rgba(255, 215, 64, 0.03);
}

.ws-label {
    font-size: 0.78rem;
    color: rgba(180, 190, 220, 0.5);
    letter-spacing: 0.02em;
    text-align: left;
}

.ws-value {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    margin-left: 12px;
}

.ws-value.ws-highlight {
    font-size: 1.2rem;
    color: var(--accent-gold);
    text-shadow: 0 0 16px rgba(255, 215, 64, 0.4);
}

.warning-dismiss {
    padding: 14px 48px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.12), rgba(224, 64, 251, 0.12));
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: 14px;
    color: var(--accent-cyan);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.warning-dismiss:hover {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(224, 64, 251, 0.2));
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.2), 0 0 60px rgba(224, 64, 251, 0.1);
    transform: translateY(-2px);
}

/* ============================================
   RESPONSIVE — Tablet & Phone (≤768px)
   ============================================ */
@media (max-width: 768px) {
    #app-title {
        left: 12px;
        top: 12px;
    }

    #app-title h1 {
        font-size: 1.1rem;
    }

    #timeline {
        top: 58px;
        left: 10px;
        right: 10px;
    }

    #timeline-track {
        margin-top: 24px;
    }

    .tl-label {
        font-size: 0.5rem;
        letter-spacing: 0;
    }

    .tl-marker.today .tl-label {
        font-size: 0.55rem;
    }

    #stats-hud {
        left: 6px;
        top: 108px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        max-width: calc(100vw - 12px);
    }

    .chart-container {
        flex: 1 1 0;
        min-width: 0;
        max-width: calc(50vw - 9px);
        overflow: hidden;
    }

    .chart-container canvas {
        display: block;
        width: 100% !important;
        height: auto !important;
    }

    #gauge-container {
        right: 8px;
        bottom: auto;
        top: 108px;
    }

    #gauge-canvas {
        width: 130px !important;
        height: auto !important;
    }

    #control-panel {
        width: 100%;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        transform: none;
        border-radius: 16px 16px 0 0;
        padding: 16px 16px 24px;
        max-height: 46vh;
        overflow-y: auto;
        scrollbar-width: none;
    }

    #control-panel::-webkit-scrollbar {
        display: none;
    }

    .panel-title {
        margin-bottom: 10px;
    }

    .phase-label {
        margin-bottom: 10px;
        padding: 6px 10px;
        font-size: 0.72rem;
    }

    .slider-group {
        margin-bottom: 14px;
    }

    .slider-label {
        font-size: 0.7rem;
    }

    .slider-display {
        font-size: 0.85rem;
    }

    .btn {
        padding: 13px 6px;
        font-size: 0.75rem;
        min-height: 44px;
    }

    .btn-launch {
        font-size: 0.78rem;
    }

    input[type="range"] {
        height: 8px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 26px;
        height: 26px;
    }

    .zoom-buttons {
        gap: 4px;
    }

    .btn-zoom {
        padding: 8px 2px;
        font-size: 0.62rem;
        min-height: 44px;
    }

    #distance-label {
        display: none;
    }
}

/* ============================================
   RESPONSIVE — Small phones (≤480px)
   ============================================ */
@media (max-width: 480px) {
    #app-title h1 {
        font-size: 0.9rem;
    }

    #timeline {
        top: 50px;
    }

    #control-panel {
        padding: 12px 12px 20px;
        max-height: 50vh;
    }

    #stats-hud {
        flex-direction: column;
        max-width: calc(100vw - 12px);
    }

    .chart-container {
        max-width: calc(100vw - 12px);
    }

    #gauge-container {
        display: none;
    }

    .btn {
        font-size: 0.68rem;
        padding: 10px 4px;
    }

    .slider-label {
        font-size: 0.62rem;
    }

    .tl-label {
        font-size: 0.42rem;
    }
}


/* ============================================
   RESPONSIVE OVERRIDE — Tablet & Phone (<=768px)
   Overrides legacy breakpoint above
   ============================================ */
@media (max-width: 768px) {
    #app-title {
        left: 12px;
        top: 12px;
    }

    #app-title h1 {
        font-size: 1.1rem;
    }

    #timeline {
        top: 58px;
        left: 10px;
        right: 10px;
    }

    #timeline-track {
        margin-top: 24px;
    }

    .tl-label {
        font-size: 0.5rem;
        letter-spacing: 0;
    }

    .tl-marker.today .tl-label {
        font-size: 0.55rem;
    }

    #stats-hud {
        left: 4px !important;
        top: 108px !important;
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 6px;
        max-width: calc(100vw - 8px);
    }

    .chart-container {
        flex: 1 1 0;
        min-width: 0;
        max-width: calc(50vw - 7px) !important;
        overflow: hidden;
    }

    .chart-container canvas {
        display: block;
        width: 100% !important;
        height: auto !important;
    }

    #gauge-container {
        right: 6px !important;
        bottom: auto !important;
        top: 108px !important;
    }

    #gauge-canvas {
        width: 120px !important;
        height: auto !important;
    }

    #control-panel {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        transform: none !important;
        border-radius: 16px 16px 0 0;
        padding: 14px 14px 22px !important;
        max-height: 46vh;
        overflow-y: auto;
        scrollbar-width: none;
    }

    #control-panel::-webkit-scrollbar {
        display: none;
    }

    .panel-title {
        margin-bottom: 8px;
    }

    .phase-label {
        margin-bottom: 8px;
        padding: 6px 10px;
        font-size: 0.72rem;
    }

    .slider-group {
        margin-bottom: 12px;
    }

    .slider-label {
        font-size: 0.7rem;
    }

    .slider-display {
        font-size: 0.85rem;
    }

    .btn {
        padding: 12px 6px;
        font-size: 0.74rem;
        min-height: 44px;
    }

    .btn-launch {
        font-size: 0.77rem;
    }

    .button-row,
    .btn-row {
        gap: 8px;
    }

    input[type="range"] {
        height: 8px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 26px;
        height: 26px;
        border: none;
    }

    .zoom-buttons {
        gap: 4px;
    }

    .btn-zoom {
        padding: 8px 2px;
        font-size: 0.62rem;
        min-height: 44px;
    }

    #distance-label {
        display: none;
    }
}

@media (max-width: 480px) {
    #app-title h1 {
        font-size: 0.88rem;
    }

    #timeline {
        top: 50px;
    }

    #control-panel {
        padding: 10px 10px 20px !important;
        max-height: 50vh;
    }

    #stats-hud {
        flex-direction: column !important;
    }

    .chart-container {
        max-width: calc(100vw - 8px) !important;
    }

    #gauge-container {
        display: none !important;
    }

    .btn {
        font-size: 0.67rem;
        padding: 10px 4px;
    }

    .slider-label {
        font-size: 0.62rem;
    }

    .tl-label {
        font-size: 0.4rem;
    }
}


/* ============================================
   MOBILE TAB BAR
   ============================================ */
#mobile-tabs {
    display: none;
    /* desktop: hidden */
}

@media (max-width: 768px) {

    /* Tab bar — always visible at bottom */
    #mobile-tabs {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: linear-gradient(145deg, rgba(10, 12, 32, 0.97), rgba(6, 8, 22, 0.98));
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(100, 140, 255, 0.2);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        gap: 2px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    }

    .mtab {
        flex: 1;
        background: transparent;
        border: 1px solid transparent;
        border-radius: 10px;
        color: rgba(180, 190, 220, 0.55);
        font-family: var(--font-display);
        font-size: 0.58rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        padding: 8px 2px 6px;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        line-height: 1.2;
        min-height: 50px;
        justify-content: center;
        text-transform: uppercase;
    }

    .mtab.active {
        color: var(--accent-cyan);
        background: rgba(0, 229, 255, 0.07);
        border-color: rgba(0, 229, 255, 0.2);
        box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
    }

    .mtab:active {
        transform: scale(0.95);
    }

    /* Hidden panel state on mobile */
    /* Strong hiding classes for mobile logic */
    .mobile-panel-hidden {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .hidden-tab {
        display: none !important;
    }

    /* Override responsive layout: each panel is a floating card */
    #control-panel,
    #gauge-container,
    #chart-cmb-panel,
    #chart-asym-panel {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 62px !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        max-height: calc(100vh - 62px - 70px);
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        z-index: 100;
        scrollbar-width: none;
        max-width: 100% !important;
    }

    #control-panel::-webkit-scrollbar,
    #gauge-container::-webkit-scrollbar {
        display: none;
    }

    /* Chart panels: fit canvas to screen */
    #chart-cmb-panel,
    #chart-asym-panel {
        background: var(--bg-panel);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
    }

    #chart-cmb-panel canvas,
    #chart-asym-panel canvas {
        width: 100% !important;
        height: auto !important;
    }

    /* Gauge panel */
    #gauge-container {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-panel);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        padding: 20px;
    }

    #gauge-canvas {
        width: 260px !important;
        height: auto !important;
    }

    /* Stats HUD wrapper: no longer positions children — tabs handle it */
    #stats-hud {
        position: static !important;
        opacity: 1 !important;
        transform: none !important;
        display: contents;
        /* chart panels position themselves */
    }

    #stats-hud.visible {
        opacity: 1 !important;
    }
}

/* ---- Intro Quiz Overlay ---- */
#intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 16, 0.92);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    opacity: 1;
    transition: opacity 0.6s ease;
}

#intro-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.intro-card {
    max-width: 560px;
    padding: 48px 40px;
    background: rgba(15, 20, 45, 0.85);
    border: 1px solid rgba(100, 140, 255, 0.15);
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(20, 60, 180, 0.2), 0 0 120px rgba(0, 229, 255, 0.05);
    text-align: center;
    animation: introFloat 0.8s ease-out;
}

@keyframes introFloat {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.intro-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.intro-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    background: linear-gradient(90deg, #5c8aff, #00e5ff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
    font-weight: 700;
}

.intro-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.intro-question {
    color: #e6b800;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.intro-choices {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 30px;
}

.intro-btn {
    background: rgba(20, 25, 45, 0.8);
    border: 1px solid rgba(100, 140, 255, 0.15);
    border-radius: 8px;
    padding: 10px 18px;
    color: #b4bedc;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.intro-btn:hover {
    background: rgba(40, 50, 80, 0.8);
    color: #fff;
    border-color: rgba(100, 140, 255, 0.3);
}

.intro-btn.selected {
    background: rgba(0, 229, 255, 0.1);
    border-color: #00e5ff;
    color: #00e5ff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.intro-confirm {
    width: 100%;
    background: linear-gradient(135deg, #182035, #222a45);
    border: 1px solid rgba(100, 140, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    color: #8da0d0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.intro-confirm.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.intro-confirm:hover {
    background: linear-gradient(135deg, #1e2842, #2a3458);
    color: #fff;
    border-color: rgba(100, 140, 255, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}