/* ========== CSS Variables & Reset ========== */
:root {
    /* Color Palette */
    --bg-dark: #0a0e27;
    --bg-darker: #050810;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-cyan: #00f5ff;
    --accent-pink: #ff006e;
    --accent-orange: #ff6b35;
    --accent-purple: #8338ec;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --glow-cyan: rgba(0, 245, 255, 0.6);
    --glow-pink: rgba(255, 0, 110, 0.5);

    /* Typography */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Orbitron', sans-serif;
    /* Changed to Orbitron for UI matching */

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Effects */
    --blur-sm: 10px;
    --blur-md: 20px;
    --blur-lg: 40px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    background: var(--bg-darker);
    color: var(--text-primary);
    cursor: default;
}

/* ========== Canvas ========== */
#myCanvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

/* ========== Glassmorphism Components ========== */
.glass-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ========== Launch Button (Circular) ========== */
#launchButtonContainer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 280px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Outer Ring */
.launch-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.0) 100%);
    backdrop-filter: blur(4px);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* Progress/Status Ring (Optional decoration) */
.launch-ring::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.3);
    border-right-color: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

#launchButton {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff9a6e 0%, #ff5e62 50%, #ff006e 100%);
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow:
        0 10px 30px rgba(255, 0, 110, 0.4),
        inset 0 5px 15px rgba(255, 255, 255, 0.4),
        inset 0 -5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Inner glow/reflection */
#launchButton::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 20%;
    width: 60%;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 50%;
    opacity: 0.6;
    filter: blur(5px);
}

#launchButton:hover {
    transform: scale(1.05);
    box-shadow:
        0 15px 40px rgba(255, 0, 110, 0.6),
        inset 0 5px 20px rgba(255, 255, 255, 0.5);
}

#launchButton:active {
    transform: scale(0.95);
}

/* ========== Rocket Selector ========== */
#rocketSelector {
    position: fixed;
    top: 40px;
    left: 40px;
    width: 280px;
    padding: 20px;
    z-index: 1000;
}

#rocketSelector label {
    display: block;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.select-wrapper {
    position: relative;
}

#rocketType {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    appearance: none;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
}

#rocketType:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Custom arrow */
.select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

/* ========== Status Badge (Pill) ========== */
#statusBadge {
    position: fixed;
    top: 40px;
    right: 40px;
    padding: 12px 24px;
    border-radius: 30px;
    background: rgba(0, 245, 255, 0.1);
    border: 1px solid rgba(0, 245, 255, 0.3);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    min-width: 160px;
    /* Fixed min-width to prevent jitter */
    justify-content: flex-start;
    /* Align content to start */
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #00f5ff;
    box-shadow: 0 0 10px #00f5ff;
    animation: pulse-dot 2s infinite;
    flex-shrink: 0;
    /* Prevent dot from shrinking */
}

#statusText {
    color: #00f5ff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
    white-space: nowrap;
    /* Prevent wrapping */
    min-width: 100px;
    /* Reserve space for text */
}

@keyframes pulse-dot {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stable Cursor */
.cursor {
    display: inline-block;
    opacity: 1;
    animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ========== Instrument Panel ========== */
#instrumentPanel {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    padding: 25px 40px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(10, 20, 40, 0.8) 0%, rgba(5, 10, 20, 0.9) 100%);
    border: 1px solid rgba(0, 245, 255, 0.2);
    box-shadow:
        0 0 30px rgba(0, 245, 255, 0.05),
        inset 0 0 20px rgba(0, 245, 255, 0.05);
}

.telemetry-item {
    text-align: center;
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Vertical Dividers */
.telemetry-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 10%;
    height: 80%;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(0, 245, 255, 0.3), transparent);
}

.telemetry-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.telemetry-value {
    font-size: 1.8rem;
    color: #00f5ff;
    font-weight: 500;
    text-shadow: 0 0 15px rgba(0, 245, 255, 0.4);
    font-family: 'Orbitron', sans-serif;
    font-variant-numeric: tabular-nums;
    /* Fix number jitter */
    min-width: 120px;
    /* Reserve space */
    text-align: center;
}

/* ========== Music Toggle (Bottom Right Pill) ========== */
#musicButton {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    /* Pill/Circle */
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1000;
}

#musicButton:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

/* ========== Countdown Display ========== */
#countdownDisplay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 50px rgba(0, 245, 255, 0.8);
    z-index: 2000;
    display: none;
    pointer-events: none;
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

/* Responsive */
@media (max-width: 768px) {
    #instrumentPanel {
        width: 90%;
        bottom: 20px;
        padding: 15px;
    }

    .telemetry-value {
        font-size: 1.2rem;
    }

    #launchButtonContainer {
        width: 200px;
        height: 200px;
    }

    #launchButton {
        width: 160px;
        height: 160px;
        font-size: 1.5rem;
    }

    #rocketSelector {
        top: 20px;
        left: 20px;
        width: auto;
    }

    #statusBadge {
        top: 20px;
        right: 20px;
        padding: 8px 16px;
    }
}