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

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Remove borders and outlines from all buttons in all states */
button,
button:focus,
button:active,
button:selected,
button:hover:focus,
button:hover:active,
button:focus-visible {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Also remove focus rings and borders from all interactive elements */
a:focus,
a:active,
input:focus:not(#playerNameInput):not(#playerPasswordInput),
input:active:not(#playerNameInput):not(#playerPasswordInput),
select:focus,
select:active,
textarea:focus,
textarea:active {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

body {
    font-family: 'Exo 2', 'Arial', sans-serif;
    overflow: hidden;
    background: #000;
    color: #fff;
    cursor: none; /* Hide default cursor during gameplay */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Show cursor when menus are open */
body.menu-open {
    cursor: crosshair !important;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    transition: filter 0.2s ease, opacity 1s ease-out;
    image-rendering: auto; /* Smooth rendering with anti-aliasing */
    opacity: 0; /* Hidden initially, will be shown after title text fades in */
    visibility: hidden; /* Also hide with visibility to prevent any rendering */
}

#gameCanvas.showing {
    opacity: 1 !important; /* Override when showing */
    visibility: visible !important;
}

#gameCanvas.boosting {
    filter: brightness(1.2) saturate(1.1);
    box-shadow: inset 0 0 100px rgba(223, 232, 238, 0.2); /* Subtle white-blue glow */
}

#gameCanvas.warp {
    filter: brightness(2.2) saturate(1.6) contrast(1.3);
    box-shadow: inset 0 0 400px rgba(255, 255, 255, 0.6),
                inset 0 0 700px rgba(200, 220, 255, 0.4),
                inset 0 0 1000px rgba(150, 200, 255, 0.3);
    will-change: filter, box-shadow;
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* HUD Container */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    font-family: 'Exo 2', 'Arial', sans-serif;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    display: none !important; /* Hidden by default, will be shown when game starts */
}

#hudTop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 18px;
}

#hudTop #score {
    position: absolute;
    left: 18px;
    top: 12px;
}

#hudTop #healthBarContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#hudTop #healthBar {
    position: relative;
    margin: 0 auto;
    width: 420px;
}

#hudTop #hudInfo {
    display: flex;
    flex-direction: row;
    gap: 24px;
    justify-content: center;
}

#score, #kills, #weaponLevel, #menuTip {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.8px;
    padding: 2px 0;
    background: transparent;
    border: none;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#score {
    color: #e8f7ff;
    border-color: transparent;
    box-shadow: none;
}

#kills {
    color: #ffe8e8;
    border-color: transparent;
    box-shadow: none;
}

#weaponLevel {
    color: #e8ffe8;
    border-color: transparent;
    box-shadow: none;
}

#healthBar {
    width: 420px;
    height: 8px;
    background: rgba(120, 0, 0, 0.65);
    border: none;
    overflow: hidden;
    align-self: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    position: relative;
}

#healthBar.ultimate-ready {
    position: relative;
    box-shadow: none;
}

#healthBar.ultimate-ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(135deg,
            #ffffff 0%,
            #ffffff 4.5%,
            #ffffff 5%,
            #ffffff 5.5%,
            rgba(255, 0, 0, 0.5) 6%,
            rgba(255, 48, 0, 0.5) 6.5%,
            rgba(255, 96, 0, 0.5) 7%,
            rgba(255, 144, 0, 0.5) 7.5%,
            rgba(255, 192, 0, 0.5) 8%,
            rgba(255, 176, 32, 0.5) 8.5%,
            rgba(255, 160, 64, 0.5) 9%,
            rgba(255, 128, 64, 0.5) 9.5%,
            rgba(255, 96, 64, 0.5) 10%,
            rgba(255, 96, 96, 0.5) 10.5%,
            rgba(255, 96, 128, 0.5) 11%,
            rgba(255, 96, 160, 0.5) 11.5%,
            rgba(255, 96, 192, 0.5) 12%,
            rgba(255, 96, 224, 0.5) 12.5%,
            rgba(0, 255, 255, 0.6) 13%,
            rgba(0, 255, 128, 0.6) 13.5%,
            rgba(0, 128, 255, 0.6) 14%,
            rgba(255, 0, 255, 0.6) 14.5%,
            #ffffff 15%,
            #ffffff 19.5%,
            #ffffff 20%,
            #ffffff 20.5%,
            rgba(255, 0, 0, 0.5) 21%,
            rgba(255, 48, 0, 0.5) 21.5%,
            rgba(255, 96, 0, 0.5) 22%,
            rgba(255, 144, 0, 0.5) 22.5%,
            rgba(255, 192, 0, 0.5) 23%,
            rgba(255, 176, 32, 0.5) 23.5%,
            rgba(255, 160, 64, 0.5) 24%,
            rgba(255, 128, 64, 0.5) 24.5%,
            rgba(255, 96, 64, 0.5) 25%,
            rgba(255, 96, 96, 0.5) 25.5%,
            rgba(255, 96, 128, 0.5) 26%,
            rgba(255, 96, 160, 0.5) 26.5%,
            rgba(255, 96, 192, 0.5) 27%,
            rgba(255, 96, 224, 0.5) 27.5%,
            rgba(0, 255, 255, 0.6) 28%,
            rgba(0, 255, 128, 0.6) 28.5%,
            rgba(0, 128, 255, 0.6) 29%,
            rgba(255, 0, 255, 0.6) 29.5%,
            #ffffff 30%),
        #ffffff;
    background-size: 400% 100%, 100% 100%;
    background-blend-mode: normal;
    background-position: 0% 0%, 0% 0%;
    animation: titleGradientRoll 10s linear infinite, healthShieldUltimateFlash 1s steps(2) infinite;
    z-index: 1000;
    pointer-events: none;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#healthBar.ultimate-ready::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 0;
    pointer-events: none;
}

#healthFill {
    height: 100%;
    width: 100%;
    background: #ff0000; /* Red (default when damaged) */
    transition: width 0.08s linear;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#healthFill.ultimate-ready {
    z-index: 10 !important; /* Ensure it's visible above other elements */
    position: relative; /* Ensure z-index works */
}

@keyframes healthShieldUltimateFlash {
    0%, 49% {
        opacity: 0;
    }
    50%, 99% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

@keyframes rKeyTextColorFlash {
    0%, 49% {
        color: #ffffff; /* White when gradient is off */
    }
    50%, 99% {
        color: #000000; /* Black when gradient is on */
    }
    100% {
        color: #ffffff; /* White when gradient is off */
    }
}

@keyframes startMenuBrightFlash {
    0%, 49% {
        color: rgba(255, 255, 255, 1);
        border-color: rgba(255, 255, 255, 1);
    }
    50%, 99% {
        color: rgba(255, 255, 255, 0.75);
        border-color: rgba(255, 255, 255, 0.75);
    }
    100% {
        color: rgba(255, 255, 255, 1);
        border-color: rgba(255, 255, 255, 1);
    }
}

/* Health bar z-index is controlled by JavaScript when ultimate-ready */

#shieldBar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2; /* On top of health bar */
    pointer-events: none;
}

#shieldBar.ultimate-ready {
    position: relative;
    box-shadow: none;
}

#shieldBar.ultimate-ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(135deg,
            #ffffff 0%,
            #ffffff 4.5%,
            #ffffff 5%,
            #ffffff 5.5%,
            rgba(255, 0, 0, 0.5) 6%,
            rgba(255, 48, 0, 0.5) 6.5%,
            rgba(255, 96, 0, 0.5) 7%,
            rgba(255, 144, 0, 0.5) 7.5%,
            rgba(255, 192, 0, 0.5) 8%,
            rgba(255, 176, 32, 0.5) 8.5%,
            rgba(255, 160, 64, 0.5) 9%,
            rgba(255, 128, 64, 0.5) 9.5%,
            rgba(255, 96, 64, 0.5) 10%,
            rgba(255, 96, 96, 0.5) 10.5%,
            rgba(255, 96, 128, 0.5) 11%,
            rgba(255, 96, 160, 0.5) 11.5%,
            rgba(255, 96, 192, 0.5) 12%,
            rgba(255, 96, 224, 0.5) 12.5%,
            rgba(0, 255, 255, 0.6) 13%,
            rgba(0, 255, 128, 0.6) 13.5%,
            rgba(0, 128, 255, 0.6) 14%,
            rgba(255, 0, 255, 0.6) 14.5%,
            #ffffff 15%,
            #ffffff 19.5%,
            #ffffff 20%,
            #ffffff 20.5%,
            rgba(255, 0, 0, 0.5) 21%,
            rgba(255, 48, 0, 0.5) 21.5%,
            rgba(255, 96, 0, 0.5) 22%,
            rgba(255, 144, 0, 0.5) 22.5%,
            rgba(255, 192, 0, 0.5) 23%,
            rgba(255, 176, 32, 0.5) 23.5%,
            rgba(255, 160, 64, 0.5) 24%,
            rgba(255, 128, 64, 0.5) 24.5%,
            rgba(255, 96, 64, 0.5) 25%,
            rgba(255, 96, 96, 0.5) 25.5%,
            rgba(255, 96, 128, 0.5) 26%,
            rgba(255, 96, 160, 0.5) 26.5%,
            rgba(255, 96, 192, 0.5) 27%,
            rgba(255, 96, 224, 0.5) 27.5%,
            rgba(0, 255, 255, 0.6) 28%,
            rgba(0, 255, 128, 0.6) 28.5%,
            rgba(0, 128, 255, 0.6) 29%,
            rgba(255, 0, 255, 0.6) 29.5%,
            #ffffff 30%),
        #ffffff;
    background-size: 400% 100%, 100% 100%;
    background-blend-mode: normal;
    background-position: 0% 0%, 0% 0%;
    animation: titleGradientRoll 10s linear infinite, healthShieldUltimateFlash 1s steps(2) infinite;
    z-index: 1; /* Below shield fill (z-index: 2) but above health bar */
    pointer-events: none;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#shieldBar.ultimate-ready::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 0;
    pointer-events: none;
}

/* Shield bar z-index is controlled by JavaScript when ultimate-ready */

#shieldFill {
    height: 100%;
    width: 100%;
    background: #ffffff; /* White */
    transition: width 0.08s linear;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2; /* Above health bar (which has z-index: 1) */
}


#shieldFill.recharging {
    animation: shieldRechargeFlash 0.3s steps(1, end) infinite;
}

@keyframes shieldRechargeFlash {
    0%, 50% {
        background: #ffffff; /* White */
        box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
    }
    51%, 100% {
        background: #ffffff; /* White */
        box-shadow: none;
    }
}

#healthFill.recharging {
    animation: healthRechargeFlash 0.3s steps(1, end) infinite;
}


@keyframes healthRechargeFlash {
    0%, 50% {
        background: #ffffff; /* White */
        box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
    }
    51%, 100% {
        background: var(--recharge-base-color, #00ff00); /* Current health color */
        box-shadow: none;
    }
}

@keyframes healthUltimateFlash {
    0% {
        background: var(--health-status-color, #00ff00) !important;
        background-position: 0% 0%, 0% 0% !important;
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    }
    50% {
        background: 
            repeating-linear-gradient(135deg,
                #ffffff 0%,
                #ffffff 4.5%,
                #ffffff 5%,
                #ffffff 5.5%,
                rgba(255, 0, 0, 0.5) 6%,
                rgba(255, 48, 0, 0.5) 6.5%,
                rgba(255, 96, 0, 0.5) 7%,
                rgba(255, 144, 0, 0.5) 7.5%,
                rgba(255, 192, 0, 0.5) 8%,
                rgba(255, 176, 32, 0.5) 8.5%,
                rgba(255, 160, 64, 0.5) 9%,
                rgba(255, 128, 64, 0.5) 9.5%,
                rgba(255, 96, 64, 0.5) 10%,
                rgba(255, 96, 96, 0.5) 10.5%,
                rgba(255, 96, 128, 0.5) 11%,
                rgba(255, 96, 160, 0.5) 11.5%,
                rgba(255, 96, 192, 0.5) 12%,
                rgba(255, 96, 224, 0.5) 12.5%,
                rgba(0, 255, 255, 0.6) 13%,
                rgba(0, 255, 128, 0.6) 13.5%,
                rgba(0, 128, 255, 0.6) 14%,
                rgba(255, 0, 255, 0.6) 14.5%,
                #ffffff 15%,
                #ffffff 19.5%,
                #ffffff 20%,
                #ffffff 20.5%,
                rgba(255, 0, 0, 0.5) 21%,
                rgba(255, 48, 0, 0.5) 21.5%,
                rgba(255, 96, 0, 0.5) 22%,
                rgba(255, 144, 0, 0.5) 22.5%,
                rgba(255, 192, 0, 0.5) 23%,
                rgba(255, 176, 32, 0.5) 23.5%,
                rgba(255, 160, 64, 0.5) 24%,
                rgba(255, 128, 64, 0.5) 24.5%,
                rgba(255, 96, 64, 0.5) 25%,
                rgba(255, 96, 96, 0.5) 25.5%,
                rgba(255, 96, 128, 0.5) 26%,
                rgba(255, 96, 160, 0.5) 26.5%,
                rgba(255, 96, 192, 0.5) 27%,
                rgba(255, 96, 224, 0.5) 27.5%,
                rgba(0, 255, 255, 0.6) 28%,
                rgba(0, 255, 128, 0.6) 28.5%,
                rgba(0, 128, 255, 0.6) 29%,
                rgba(255, 0, 255, 0.6) 29.5%,
                #ffffff 30%),
            #ffffff !important;
        background-size: 400% 100%, 100% 100% !important;
        background-position: 400% 0%, 0% 0% !important;
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 0 0 30px rgba(255, 0, 0, 0.4), 0 0 45px rgba(0, 0, 255, 0.3);
    }
    100% {
        background: var(--health-status-color, #00ff00) !important;
        background-position: 0% 0%, 0% 0% !important;
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    }
}

#menuTip {
    color: #cfd7de;
    font-size: 11px;
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

#hudBottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 16px;
}

#keyIndicators {
    position: absolute;
    left: 182px; /* Right of radar (150px radar + 16px padding + 16px spacing) */
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    align-items: flex-start;
}

.keyIndicator {
    display: block; /* Always visible */
    color: #ffffff; /* White text when not pressed */
    font-size: 10px;
    font-weight: bold;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    background: transparent; /* No background when not pressed */
    border: none; /* No border */
    box-shadow: none; /* No glow */
    min-width: 50px;
    text-align: center;
    transition: all 0.1s ease;
}

.keyIndicator.active {
    color: #000000; /* Black text on white background when pressed */
    background: rgba(255, 255, 255, 1.0); /* Opaque white when pressed */
    text-shadow: none; /* No text shadow when pressed */
}

.keyIndicator.ultimate-ready {
    background: transparent; /* Transparent background, gradient shows through */
    color: #000000; /* Default black text */
    font-weight: bold; /* Bold text */
    position: relative;
    z-index: 10; /* Ensure text is above gradient */
    text-shadow: none; /* No shadow needed with color animation */
    box-shadow: none;
    animation: rKeyTextColorFlash 0.3s steps(1, end) infinite; /* Match shield recharge flash speed */
}

.keyIndicator.ultimate-ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(135deg,
            #ffffff 0%,
            #ffffff 4.5%,
            #ffffff 5%,
            #ffffff 5.5%,
            rgba(255, 0, 0, 0.5) 6%,
            rgba(255, 48, 0, 0.5) 6.5%,
            rgba(255, 96, 0, 0.5) 7%,
            rgba(255, 144, 0, 0.5) 7.5%,
            rgba(255, 192, 0, 0.5) 8%,
            rgba(255, 176, 32, 0.5) 8.5%,
            rgba(255, 160, 64, 0.5) 9%,
            rgba(255, 128, 64, 0.5) 9.5%,
            rgba(255, 96, 64, 0.5) 10%,
            rgba(255, 96, 96, 0.5) 10.5%,
            rgba(255, 96, 128, 0.5) 11%,
            rgba(255, 96, 160, 0.5) 11.5%,
            rgba(255, 96, 192, 0.5) 12%,
            rgba(255, 96, 224, 0.5) 12.5%,
            rgba(0, 255, 255, 0.6) 13%,
            rgba(0, 255, 128, 0.6) 13.5%,
            rgba(0, 128, 255, 0.6) 14%,
            rgba(255, 0, 255, 0.6) 14.5%,
            #ffffff 15%,
            #ffffff 19.5%,
            #ffffff 20%,
            #ffffff 20.5%,
            rgba(255, 0, 0, 0.5) 21%,
            rgba(255, 48, 0, 0.5) 21.5%,
            rgba(255, 96, 0, 0.5) 22%,
            rgba(255, 144, 0, 0.5) 22.5%,
            rgba(255, 192, 0, 0.5) 23%,
            rgba(255, 176, 32, 0.5) 23.5%,
            rgba(255, 160, 64, 0.5) 24%,
            rgba(255, 128, 64, 0.5) 24.5%,
            rgba(255, 96, 64, 0.5) 25%,
            rgba(255, 96, 96, 0.5) 25.5%,
            rgba(255, 96, 128, 0.5) 26%,
            rgba(255, 96, 160, 0.5) 26.5%,
            rgba(255, 96, 192, 0.5) 27%,
            rgba(255, 96, 224, 0.5) 27.5%,
            rgba(0, 255, 255, 0.6) 28%,
            rgba(0, 255, 128, 0.6) 28.5%,
            rgba(0, 128, 255, 0.6) 29%,
            rgba(255, 0, 255, 0.6) 29.5%,
            #ffffff 30%),
        #ffffff;
    background-size: 400% 100%, 100% 100%;
    background-blend-mode: normal;
    background-position: 0% 0%, 0% 0%;
    animation: titleGradientRoll 10s linear infinite, healthShieldUltimateFlash 0.3s steps(1, end) infinite;
    z-index: -1; /* Behind text */
    pointer-events: none;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.keyIndicator.ultimate-ready::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 0;
    pointer-events: none;
}

.keyIndicator.ultimate-ready.active {
    /* When both ultimate-ready and active, keep border but show black text */
    -webkit-text-fill-color: #000000;
    color: #000000;
    text-shadow: none;
    background: rgba(255, 255, 255, 1.0);
}

#chargeBars {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}


#chargeBarsWrapper {
    display: flex;
    flex-direction: row;
    gap: 18px;
    align-items: flex-end;
    justify-content: center;
}

#radarContainer {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.hudLabel {
    color: #e7e7e7;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 2px;
    text-shadow: none;
}

#radarCanvas {
    display: block;
    border: none;
    background: transparent;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#hudInfo {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.infoLine {
    color: #e6e6e6;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.8px;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    font-family: 'Exo 2', 'Arial', sans-serif;
}

.infoLine span {
    color: #ffffff;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
}

/* Boost UI */
#boostContainer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

#boostLabel {
    display: block;
    color: #dfe8ee;
    font-size: 10px;
    margin-bottom: 4px;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    transition: all 0.1s ease;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#boostLabel.active {
    color: #ffffff;
    text-shadow: none;
}

/* Boost & Ultimate Bars (Bottom) */
#boostBar {
    width: 180px;
    height: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    overflow: hidden;
    box-shadow: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#boostFill {
    height: 100%;
    width: 100%;
    background: #dfe8ee; /* White-blue */
    box-shadow: none;
    transition: width 0.05s linear;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#boostBar.active {
    box-shadow: none;
}

#boostBar.depleted {
    animation: depletedPulse 1s ease-in-out infinite;
}

@keyframes depletedPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(180, 220, 255, 0.2), inset 0 0 5px rgba(0, 0, 0, 0.8);
    }
    50% {
        box-shadow: 0 0 12px rgba(180, 220, 255, 0.4), inset 0 0 8px rgba(120, 200, 255, 0.15);
    }
}

/* Warp UI */
#warpContainer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

#warpLabel {
    display: block;
    color: #dfe8ee;
    font-size: 10px;
    margin-bottom: 4px;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    transition: all 0.1s ease;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#warpLabel.active {
    color: #ffffff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 1.0), 
                 0 0 40px rgba(200, 220, 255, 0.8);
}

#warpBar {
    width: 180px;
    height: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    overflow: hidden;
    box-shadow: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#warpFill {
    height: 100%;
    width: 100%;
    background: #ffffff; /* White */
    box-shadow: none;
    transition: width 0.05s linear;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#warpBar.active {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

#warpBar.depleted {
    animation: depletedPulse 1s ease-in-out infinite;
}

/* Ultimate Ability UI */
#ultimateContainer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

#ultimateLabel {
    display: block;
    color: #cfefff;
    font-size: 10px;
    margin-bottom: 4px;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    transition: all 0.1s ease;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#ultimateLabel.ready {
    animation: ultimateFlash 0.8s ease-in-out infinite;
    font-weight: 600;
}

#ultimateBar {
    width: 180px;
    height: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    overflow: hidden;
    box-shadow: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#ultimateFill {
    height: 100%;
    width: 0%;
    background: #ffffff; /* White */
    box-shadow: none;
    transition: width 0.1s linear;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#ultimateFill.ultimate-ready {
    animation: titleGradientRoll 10s linear infinite;
    background: 
        repeating-linear-gradient(135deg,
            #ffffff 0%,
            #ffffff 4.5%,
            #ffffff 5%,
            #ffffff 5.5%,
            rgba(255, 0, 0, 0.5) 6%,
            rgba(255, 48, 0, 0.5) 6.5%,
            rgba(255, 96, 0, 0.5) 7%,
            rgba(255, 144, 0, 0.5) 7.5%,
            rgba(255, 192, 0, 0.5) 8%,
            rgba(255, 176, 32, 0.5) 8.5%,
            rgba(255, 160, 64, 0.5) 9%,
            rgba(255, 128, 64, 0.5) 9.5%,
            rgba(255, 96, 64, 0.5) 10%,
            rgba(255, 96, 96, 0.5) 10.5%,
            rgba(255, 96, 128, 0.5) 11%,
            rgba(255, 96, 160, 0.5) 11.5%,
            rgba(255, 96, 192, 0.5) 12%,
            rgba(255, 96, 224, 0.5) 12.5%,
            rgba(0, 255, 255, 0.6) 13%,
            rgba(0, 255, 128, 0.6) 13.5%,
            rgba(0, 128, 255, 0.6) 14%,
            rgba(255, 0, 255, 0.6) 14.5%,
            #ffffff 15%,
            #ffffff 19.5%,
            #ffffff 20%,
            #ffffff 20.5%,
            rgba(255, 0, 0, 0.5) 21%,
            rgba(255, 48, 0, 0.5) 21.5%,
            rgba(255, 96, 0, 0.5) 22%,
            rgba(255, 144, 0, 0.5) 22.5%,
            rgba(255, 192, 0, 0.5) 23%,
            rgba(255, 176, 32, 0.5) 23.5%,
            rgba(255, 160, 64, 0.5) 24%,
            rgba(255, 128, 64, 0.5) 24.5%,
            rgba(255, 96, 64, 0.5) 25%,
            rgba(255, 96, 96, 0.5) 25.5%,
            rgba(255, 96, 128, 0.5) 26%,
            rgba(255, 96, 160, 0.5) 26.5%,
            rgba(255, 96, 192, 0.5) 27%,
            rgba(255, 96, 224, 0.5) 27.5%,
            rgba(0, 255, 255, 0.6) 28%,
            rgba(0, 255, 128, 0.6) 28.5%,
            rgba(0, 128, 255, 0.6) 29%,
            rgba(255, 0, 255, 0.6) 29.5%,
            #ffffff 30%),
        #ffffff;
    background-size: 400% 100%, 100% 100%;
    background-blend-mode: normal;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 0 0 30px rgba(255, 0, 0, 0.4), 0 0 45px rgba(0, 0, 255, 0.3);
}

@keyframes ultimateFillFlash {
    0% {
        background-position: 0% 0%, 0% 0%;
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 0 0 30px rgba(255, 0, 0, 0.4), 0 0 45px rgba(0, 0, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.7), 0 0 35px rgba(0, 255, 0, 0.5), 0 0 50px rgba(255, 0, 255, 0.4);
    }
    100% {
        background-position: 400% 0%, 0% 0%;
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), 0 0 30px rgba(255, 0, 0, 0.4), 0 0 45px rgba(0, 0, 255, 0.3);
    }
}

#ultimateBar.ready {
    box-shadow: none;
}

@keyframes ultimateFlash {
    0%, 100% {
        color: #ffffff;
    }
    50% {
        color: #aaccff;
    }
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    margin-left: 0;
    margin-top: 0;
    pointer-events: none;
    z-index: 100;
    background: transparent;
    border-radius: 50%;
    border: 2px solid #ff2200;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;
    display: none !important; /* Hidden by default, will be shown when game starts */
}

/* Vertical line */
#crosshair::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ff2200; /* Red by default */
    transition: background 0.1s ease;
    box-shadow: -14px 0 0 0 #ff2200, 14px 0 0 0 #ff2200;
}

/* Horizontal line */
#crosshair::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 6px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #ff2200; /* Red by default */
    transition: background 0.1s ease;
    box-shadow: 0 -14px 0 0 #ff2200, 0 14px 0 0 #ff2200;
}

/* Red when boosting (same as default) */
#crosshair.boosting::before {
    background: #ff2200; /* Red */
    box-shadow: -14px 0 0 0 #ff2200, 14px 0 0 0 #ff2200;
}

#crosshair.boosting::after {
    background: #ff2200; /* Red */
    box-shadow: 0 -14px 0 0 #ff2200, 0 14px 0 0 #ff2200;
}

#crosshair.boosting {
    border-color: #ff2200;
    box-shadow: 0 0 10px rgba(255, 34, 0, 0.4);
}

/* Green when targeting enemy */
#crosshair.targeting::before {
    background: #00ff00; /* Green */
    box-shadow: -14px 0 0 0 #00ff00, 14px 0 0 0 #00ff00;
}

#crosshair.targeting::after {
    background: #00ff00; /* Green */
    box-shadow: 0 -14px 0 0 #00ff00, 0 14px 0 0 #00ff00;
}

#crosshair.targeting {
    border-color: #00ff00;
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.5);
}

#crosshairLineCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
    display: none;
}

#crosshairLineCanvas.showing {
    display: block;
}

#gameOver {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    text-align: left;
    background: transparent;
    padding: 16px 20px;
    border: none;
    box-shadow: none;
    pointer-events: all;
    cursor: crosshair;
    min-width: 260px;
    max-width: 360px;
    z-index: 1001;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    animation: slideInFromLeft 0.3s ease-out;
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

#gameOver.hidden {
    display: none;
}

#gameOver h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #ffffff;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);
    letter-spacing: 1px;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#gameOver p {
    font-size: 14px;
    margin-bottom: 12px;
    color: #cccccc;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#leaderboard {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: left;
    background: transparent;
    padding: 16px 20px;
    border: none;
    box-shadow: none;
    pointer-events: all;
    cursor: crosshair;
    min-width: 200px;
    max-width: 300px;
    z-index: 1002;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    animation: slideInFromCenter 0.3s ease-out;
    font-family: 'Exo 2', 'Arial', sans-serif;
    color: #dfe8ee;
    font-size: 11px;
}

@keyframes slideInFromCenter {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

#leaderboard.hidden {
    display: none;
}

#leaderboard h2 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #ffffff;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);
    letter-spacing: 1px;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

#leaderboardNote {
    color: #dfe8ee;
    font-size: 11px;
    margin-bottom: 12px;
    font-family: 'Exo 2', 'Arial', sans-serif;
    line-height: 1.4;
    font-weight: 400;
    letter-spacing: 0;
}

#leaderboardTable {
    margin: 0 0 16px 0;
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 11px;
}

.leaderboardRow {
    display: grid;
    grid-template-columns: 20px 2fr 48px 46px 40px;
    gap: 6px;
    align-items: center;
    padding: 2px 0;
    color: #dfe8ee;
}

.leaderboardRow + .leaderboardRow {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.leaderboardHeader {
    font-weight: 600;
    color: rgba(223, 232, 238, 0.8);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 6px;
}

.leaderboardCell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboardCell--num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.leaderboardCell--center {
    text-align: center;
}

.leaderboardRow.leaderboardEmpty {
    grid-template-columns: 1fr;
    color: rgba(223, 232, 238, 0.8);
    padding: 6px 0;
}

#leaderboard .menuKeyButton {
    margin-top: 10px;
    opacity: 0.85;
    background: transparent;
    border: none;
    pointer-events: all;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--menu-key-gap, 10px);
    text-align: left;
    color: #dfe8ee;
    font-size: 11px;
    font-weight: 400;
}

#leaderboard .menuKeyButton .menuButtonText {
    flex: 1 1 auto;
    color: #dfe8ee;
    text-align: left;
    line-height: 24px;
    text-transform: none;
    font-style: normal;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    opacity: 1;
}

#leaderboard .menuKeyButton .menuKeyHint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--menu-key-width, 28px);
    height: 24px;
    padding: 0 6px;
    border: 1px solid rgba(223, 232, 238, 0.5);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #dfe8ee;
    background: rgba(0, 0, 0, 0.35);
    text-transform: uppercase;
    opacity: 0.85;
    position: relative;
    overflow: hidden;
    line-height: 24px;
}

#leaderboard .menuKeyButton.key-active .menuKeyHint {
    border-color: #ffffff;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}


#leaderboardList li.leaderboardOffline {
    color: rgba(223, 232, 238, 0.75);
    font-style: italic;
}

#restartBtn,
#mainMenuBtn,
#exitBtnGameOver {
    padding: 8px 0;
    font-size: 12px;
    background: transparent;
    color: #dfe8ee; /* White-blue */
    border: none !important;
    outline: none !important;
    cursor: crosshair;
    font-weight: bold;
    transition: all 0.15s;
    box-shadow: none !important;
    text-shadow: none;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-align: left;
    width: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#startBtn {
    padding: 8px 32px;
    margin: 0;
    font-size: 18px;
    font-weight: 300;
    font-style: italic;
    background: transparent;
    border: none !important;
    outline: none !important;
    cursor: crosshair;
    transition: opacity 0.3s ease;
    box-shadow: none !important;
    text-shadow: none;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    image-rendering: auto; /* Smooth rendering with anti-aliasing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-width: 200px;
    color: #ffffff;
    opacity: 0.6;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#restartBtn:hover,
#restartBtn:active,
#restartBtn:focus,
#mainMenuBtn:hover,
#mainMenuBtn:active,
#mainMenuBtn:focus,
#exitBtnGameOver:hover,
#exitBtnGameOver:active,
#exitBtnGameOver:focus {
    color: #ffffff;
    background: transparent;
    transform: translateX(4px);
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#startBtn:hover,
#startBtn:active,
#startBtn:focus {
    opacity: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#logoSplash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ff3600;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999; /* Highest z-index to be in front of everything */
    pointer-events: none;
    opacity: 1;
    transform: scaleY(0) scaleX(1.2); /* Start collapsed like CRT turning on */
    filter: brightness(0) contrast(3) saturate(5);
    position: relative;
    overflow: hidden;
    transition: filter 0.1s ease;
}

#logoSplash.turning-on {
    animation: crtTurnOn 0.25s steps(8) forwards;
    position: relative;
    overflow: hidden;
}

#logoSplash.turning-on::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 2px,
            rgba(255, 255, 255, 0.03) 2px,
            rgba(255, 255, 255, 0.03) 4px
        );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
    animation: scanLinesDown 0.25s linear forwards;
    opacity: 1;
}

#logoSplash.turning-on::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.1) 0px,
            rgba(0, 0, 0, 0.1) 1px,
            rgba(255, 255, 255, 0.05) 2px,
            rgba(0, 0, 0, 0.05) 3px,
            transparent 4px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(255, 0, 0, 0.05) 0px,
            rgba(0, 255, 0, 0.05) 1px,
            rgba(0, 0, 255, 0.05) 2px,
            transparent 3px
        );
    pointer-events: none;
    z-index: 9;
    animation: staticNoise 0.25s steps(20) forwards;
    opacity: 1;
}

#logoSplash.turned-on {
    animation: none;
    transform: scaleY(1) scaleX(1);
    filter: brightness(1) contrast(1) saturate(1);
}

/* Ensure logo animation continues through all splash states */
#logoSplash.turning-on #logoImage,
#logoSplash.turned-on #logoImage,
#logoSplash.fading-out #logoImage {
    animation: logoGrowSlow 5.95s linear forwards;
}

#logoSplash.turned-on::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.08) 0px,
            rgba(0, 0, 0, 0.08) 1px,
            transparent 1px,
            transparent 2px
        );
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
}

#logoSplash.turned-on::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 0, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(0, 0, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 2;
    opacity: 0.3;
}

#logoSplash.hidden {
    display: none;
}

#logoSplash.fading-out {
    animation: crtTurnOff 0.25s steps(8) forwards;
    position: relative;
    overflow: hidden;
    filter: grayscale(1);
    --random-offset-x: 0px;
    --random-offset-y: 0px;
    --random-rotation: 0deg;
    --random-scale-x: 1;
    --random-static-intensity: 0.5;
    --random-tear-offset: 0px;
}

#logoSplash.fading-out::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.8) 0%,
            rgba(230, 230, 230, 0.8) 8%,
            rgba(200, 200, 200, 0.8) 16%,
            rgba(170, 170, 170, 0.8) 24%,
            rgba(140, 140, 140, 0.8) 32%,
            rgba(110, 110, 110, 0.8) 40%,
            rgba(80, 80, 80, 0.8) 48%,
            rgba(50, 50, 50, 0.8) 56%,
            rgba(30, 30, 30, 0.8) 64%,
            rgba(20, 20, 20, 0.8) 72%,
            rgba(10, 10, 10, 0.8) 80%,
            rgba(5, 5, 5, 0.8) 88%,
            rgba(0, 0, 0, 0.8) 100%
        );
    pointer-events: none;
    z-index: 1;
    animation: screenTearOff 0.25s steps(10) forwards;
    opacity: 0;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

#logoSplash.fading-out::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.4) 0px,
            rgba(230, 230, 230, 0.4) 1px,
            rgba(200, 200, 200, 0.4) 2px,
            rgba(170, 170, 170, 0.4) 3px,
            rgba(140, 140, 140, 0.4) 4px,
            rgba(110, 110, 110, 0.4) 5px,
            rgba(80, 80, 80, 0.4) 6px,
            rgba(50, 50, 50, 0.4) 7px,
            rgba(30, 30, 30, 0.4) 8px,
            rgba(20, 20, 20, 0.4) 9px,
            rgba(10, 10, 10, 0.4) 10px,
            rgba(5, 5, 5, 0.4) 11px,
            rgba(0, 0, 0, 0.4) 12px,
            rgba(20, 20, 20, 0.4) 13px,
            rgba(50, 50, 50, 0.4) 14px,
            rgba(80, 80, 80, 0.4) 15px,
            rgba(110, 110, 110, 0.4) 16px,
            rgba(140, 140, 140, 0.4) 17px,
            transparent 18px,
            transparent 20px
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 1px,
            rgba(255, 255, 255, 0.2) 1px,
            rgba(255, 255, 255, 0.2) 2px,
            transparent 2px,
            transparent 3px
        );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 2;
    animation: staticNoiseIntense 0.25s steps(20) forwards, scanLinesBreak 0.25s linear forwards;
    opacity: 1;
}

@keyframes crtTurnOn {
    0% {
        opacity: 0;
        transform: scaleY(0) scaleX(1);
        filter: brightness(0) contrast(5) saturate(3);
    }
    10% {
        opacity: 0.3;
        transform: scaleY(0.2) scaleX(1.05);
        filter: brightness(0.2) contrast(4) saturate(2.5);
    }
    25% {
        opacity: 0.6;
        transform: scaleY(0.5) scaleX(1.02);
        filter: brightness(0.5) contrast(3) saturate(2);
    }
    40% {
        opacity: 0.8;
        transform: scaleY(0.75) scaleX(1.01);
        filter: brightness(0.7) contrast(2) saturate(1.5);
    }
    55% {
        opacity: 0.9;
        transform: scaleY(0.9) scaleX(1);
        filter: brightness(0.85) contrast(1.5) saturate(1.3);
    }
    70% {
        opacity: 0.95;
        transform: scaleY(0.98) scaleX(1);
        filter: brightness(0.95) contrast(1.2) saturate(1.1);
    }
    85% {
        opacity: 0.98;
        transform: scaleY(1.01) scaleX(0.99);
        filter: brightness(0.98) contrast(1.1) saturate(1.05);
    }
    100% {
        opacity: 1;
        transform: scaleY(1) scaleX(1);
        filter: brightness(1) contrast(1) saturate(1);
    }
}

@keyframes scanLinesDown {
    0% {
        background-position: 0 -100%;
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        background-position: 0 100%;
        opacity: 0.3;
    }
}

@keyframes staticNoise {
    0% {
        opacity: 1;
        background-position: 0 0;
    }
    25% {
        opacity: 0.8;
        background-position: 10px 5px;
    }
    50% {
        opacity: 0.6;
        background-position: -5px 10px;
    }
    75% {
        opacity: 0.4;
        background-position: 15px -5px;
    }
    100% {
        opacity: 0.2;
        background-position: 0 0;
    }
}

@keyframes crtTurnOff {
    0% {
        opacity: 1;
        transform: scaleY(1) scaleX(var(--random-scale-x, 1)) translateX(0) translateY(0) rotate(0deg);
        filter: brightness(1) contrast(1) saturate(1);
    }
    15% {
        opacity: 0.9;
        transform: scaleY(0.98) scaleX(calc(var(--random-scale-x, 1) * 1.02)) translateX(calc(2px + var(--random-offset-x, 0px))) translateY(var(--random-offset-y, 0px)) rotate(calc(0.5deg + var(--random-rotation, 0deg) * 0.1));
        filter: brightness(0.9) contrast(1.2) saturate(1.1);
    }
    30% {
        opacity: 0.7;
        transform: scaleY(0.95) scaleX(calc(var(--random-scale-x, 1) * 1.05)) translateX(calc(-4px + var(--random-offset-x, 0px) * 0.8)) translateY(calc(var(--random-offset-y, 0px) * 0.6)) rotate(calc(-1deg + var(--random-rotation, 0deg) * 0.2));
        filter: brightness(0.7) contrast(1.5) saturate(1.3);
    }
    45% {
        opacity: 0.5;
        transform: scaleY(0.9) scaleX(calc(var(--random-scale-x, 1) * 1.1)) translateX(calc(6px + var(--random-offset-x, 0px) * 0.6)) translateY(calc(var(--random-offset-y, 0px) * 0.4)) rotate(calc(2deg + var(--random-rotation, 0deg) * 0.3));
        filter: brightness(0.5) contrast(2) saturate(1.5);
    }
    60% {
        opacity: 0.3;
        transform: scaleY(0.85) scaleX(calc(var(--random-scale-x, 1) * 1.15)) translateX(calc(-8px + var(--random-offset-x, 0px) * 0.4)) translateY(calc(var(--random-offset-y, 0px) * 0.3)) rotate(calc(-3deg + var(--random-rotation, 0deg) * 0.4));
        filter: brightness(0.3) contrast(2.5) saturate(1.8);
    }
    75% {
        opacity: 0.15;
        transform: scaleY(0.75) scaleX(calc(var(--random-scale-x, 1) * 1.2)) translateX(calc(10px + var(--random-offset-x, 0px) * 0.2)) translateY(calc(var(--random-offset-y, 0px) * 0.2)) rotate(calc(4deg + var(--random-rotation, 0deg) * 0.5));
        filter: brightness(0.15) contrast(3) saturate(2);
    }
    90% {
        opacity: 0.05;
        transform: scaleY(0.6) scaleX(calc(var(--random-scale-x, 1) * 1.3)) translateX(calc(-12px + var(--random-offset-x, 0px) * 0.1)) translateY(calc(var(--random-offset-y, 0px) * 0.1)) rotate(calc(-5deg + var(--random-rotation, 0deg) * 0.6));
        filter: brightness(0.05) contrast(4) saturate(2.5);
    }
    100% {
        opacity: 0;
        transform: scaleY(0) scaleX(calc(var(--random-scale-x, 1) * 1.5)) translateX(0) translateY(0) rotate(0deg);
        filter: brightness(0) contrast(5) saturate(3);
    }
}

@keyframes screenTearOff {
    0% {
        opacity: 0;
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
        transform: translateX(0) scaleY(1);
    }
    20% {
        opacity: 0.6;
        clip-path: polygon(0 0, 100% 0, 100% 60%, 0 55%, 0 100%, 100% 100%);
        transform: translateX(calc(3px + var(--random-tear-offset, 0px) * 0.3)) scaleY(0.97);
    }
    40% {
        opacity: 0.8;
        clip-path: polygon(0 0, 100% 0, 100% 30%, 0 25%, 0 50%, 100% 55%, 100% 100%, 0 100%);
        transform: translateX(calc(-5px + var(--random-tear-offset, 0px) * 0.5)) scaleY(1.03);
    }
    60% {
        opacity: 0.9;
        clip-path: polygon(0 0, 100% 0, 100% 15%, 0 10%, 0 30%, 100% 35%, 100% 60%, 0 65%, 0 100%, 100% 100%);
        transform: translateX(calc(7px + var(--random-tear-offset, 0px) * 0.7)) scaleY(0.95);
    }
    80% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 5%, 0 0%, 0 15%, 100% 20%, 100% 40%, 0 45%, 0 70%, 100% 75%, 100% 100%, 0 100%);
        transform: translateX(calc(-10px + var(--random-tear-offset, 0px))) scaleY(1.05);
    }
    100% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 0%, 0 0%, 0 0%, 100% 0%, 100% 0%, 0 0%, 0 0%, 100% 0%, 100% 0%, 0 0%);
        transform: translateX(0) scaleY(0);
    }
}

@keyframes staticNoiseIntense {
    0% {
        opacity: calc(0.2 * var(--random-static-intensity, 1));
        background-position: 0 0;
    }
    10% {
        opacity: calc(0.4 * var(--random-static-intensity, 1));
        background-position: calc(5px + var(--random-offset-x, 0px) * 0.2) calc(3px + var(--random-offset-y, 0px) * 0.2);
    }
    20% {
        opacity: calc(0.6 * var(--random-static-intensity, 1));
        background-position: calc(-3px + var(--random-offset-x, 0px) * 0.3) calc(7px + var(--random-offset-y, 0px) * 0.3);
    }
    30% {
        opacity: calc(0.7 * var(--random-static-intensity, 1));
        background-position: calc(8px + var(--random-offset-x, 0px) * 0.4) calc(-2px + var(--random-offset-y, 0px) * 0.4);
    }
    40% {
        opacity: calc(0.8 * var(--random-static-intensity, 1));
        background-position: calc(-5px + var(--random-offset-x, 0px) * 0.5) calc(12px + var(--random-offset-y, 0px) * 0.5);
    }
    50% {
        opacity: calc(0.85 * var(--random-static-intensity, 1));
        background-position: calc(12px + var(--random-offset-x, 0px) * 0.6) calc(5px + var(--random-offset-y, 0px) * 0.6);
    }
    60% {
        opacity: calc(0.9 * var(--random-static-intensity, 1));
        background-position: calc(-8px + var(--random-offset-x, 0px) * 0.7) calc(-5px + var(--random-offset-y, 0px) * 0.7);
    }
    70% {
        opacity: calc(0.95 * var(--random-static-intensity, 1));
        background-position: calc(15px + var(--random-offset-x, 0px) * 0.8) calc(10px + var(--random-offset-y, 0px) * 0.8);
    }
    80% {
        opacity: var(--random-static-intensity, 1);
        background-position: calc(-10px + var(--random-offset-x, 0px) * 0.9) calc(15px + var(--random-offset-y, 0px) * 0.9);
    }
    90% {
        opacity: var(--random-static-intensity, 1);
        background-position: calc(20px + var(--random-offset-x, 0px)) calc(-8px + var(--random-offset-y, 0px));
    }
    100% {
        opacity: var(--random-static-intensity, 1);
        background-position: 0 0;
    }
}

@keyframes scanLinesBreak {
    0% {
        background-position: 0 0;
        opacity: 0.3;
    }
    25% {
        background-position: 0 -25%;
        opacity: 0.5;
    }
    50% {
        background-position: 0 -50%;
        opacity: 0.7;
        transform: translateX(2px);
    }
    75% {
        background-position: 0 -75%;
        opacity: 0.9;
        transform: translateX(-3px);
    }
    100% {
        background-position: 0 -100%;
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes screenTear {
    0% {
        opacity: 0;
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
        transform: translateX(0) scaleY(1);
    }
    10% {
        opacity: 0.7;
        clip-path: polygon(0 0, 100% 0, 100% 50%, 0 45%, 0 100%, 100% 100%);
        transform: translateX(5px) scaleY(0.98);
    }
    20% {
        opacity: 0.85;
        clip-path: polygon(0 0, 100% 0, 100% 35%, 0 30%, 0 55%, 100% 60%, 100% 100%, 0 100%);
        transform: translateX(-8px) scaleY(1.02);
    }
    30% {
        opacity: 0.95;
        clip-path: polygon(0 0, 100% 0, 100% 20%, 0 15%, 0 40%, 100% 45%, 100% 70%, 0 75%, 0 100%, 100% 100%);
        transform: translateX(12px) scaleY(0.95);
    }
    40% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 10%, 0 5%, 0 25%, 100% 30%, 100% 55%, 0 60%, 0 85%, 100% 90%, 100% 100%, 0 100%);
        transform: translateX(-15px) scaleY(1.05);
    }
    50% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 5%, 0 0%, 0 15%, 100% 20%, 100% 45%, 0 50%, 0 75%, 100% 80%, 100% 100%, 0 100%);
        transform: translateX(20px) scaleY(0.9);
    }
    60% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 2%, 0 0%, 0 10%, 100% 15%, 100% 35%, 0 40%, 0 65%, 100% 70%, 100% 100%, 0 100%);
        transform: translateX(-25px) scaleY(1.1);
    }
    70% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 1%, 0 0%, 0 5%, 100% 10%, 100% 25%, 0 30%, 0 55%, 100% 60%, 100% 100%, 0 100%);
        transform: translateX(30px) scaleY(0.85);
    }
    80% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 0%, 0 0%, 0 0%, 100% 5%, 100% 15%, 0 20%, 0 45%, 100% 50%, 100% 100%, 0 100%);
        transform: translateX(-35px) scaleY(1.15);
    }
    90% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 0%, 0 0%, 0 0%, 100% 0%, 100% 0%, 0 0%, 0 0%, 100% 0%, 100% 0%, 0 0%);
        transform: translateX(40px) scaleY(0.7);
    }
    100% {
        opacity: 1;
        clip-path: polygon(0 0, 100% 0, 100% 0%, 0 0%, 0 0%, 100% 0%, 100% 0%, 0 0%, 0 0%, 100% 0%, 100% 0%, 0 0%);
        transform: translateX(0) scaleY(0);
    }
}

@keyframes pixelInterference {
    0% {
        opacity: 0;
        transform: scale(1) translateX(0) translateY(0) rotate(0deg);
        filter: blur(0px) contrast(1) brightness(1) hue-rotate(0deg);
    }
    5% {
        opacity: 0.3;
        transform: scale(1.01) translateX(1px) translateY(-2px) rotate(0.5deg);
        filter: blur(0.3px) contrast(1.2) brightness(0.98) hue-rotate(10deg);
    }
    10% {
        opacity: 0.5;
        transform: scale(0.99) translateX(-2px) translateY(3px) rotate(-0.8deg);
        filter: blur(0.6px) contrast(1.4) brightness(0.95) hue-rotate(-15deg);
    }
    15% {
        opacity: 0.65;
        transform: scale(1.03) translateX(3px) translateY(-4px) rotate(1.2deg);
        filter: blur(1px) contrast(1.6) brightness(0.9) hue-rotate(25deg);
    }
    20% {
        opacity: 0.75;
        transform: scale(0.97) translateX(-4px) translateY(5px) rotate(-1.5deg);
        filter: blur(1.3px) contrast(1.8) brightness(0.85) hue-rotate(-30deg);
    }
    25% {
        opacity: 0.8;
        transform: scale(1.05) translateX(5px) translateY(-6px) rotate(2deg);
        filter: blur(1.6px) contrast(2) brightness(0.8) hue-rotate(40deg);
    }
    30% {
        opacity: 0.85;
        transform: scale(0.95) translateX(-6px) translateY(7px) rotate(-2.5deg);
        filter: blur(2px) contrast(2.3) brightness(0.75) hue-rotate(-50deg);
    }
    35% {
        opacity: 0.88;
        transform: scale(1.07) translateX(7px) translateY(-8px) rotate(3deg);
        filter: blur(2.3px) contrast(2.6) brightness(0.7) hue-rotate(60deg);
    }
    40% {
        opacity: 0.9;
        transform: scale(0.93) translateX(-8px) translateY(9px) rotate(-3.5deg);
        filter: blur(2.6px) contrast(2.9) brightness(0.65) hue-rotate(-70deg);
    }
    45% {
        opacity: 0.92;
        transform: scale(1.09) translateX(9px) translateY(-10px) rotate(4deg);
        filter: blur(3px) contrast(3.2) brightness(0.6) hue-rotate(80deg);
    }
    50% {
        opacity: 0.94;
        transform: scale(0.91) translateX(-10px) translateY(11px) rotate(-4.5deg);
        filter: blur(3.3px) contrast(3.5) brightness(0.55) hue-rotate(-90deg);
    }
    55% {
        opacity: 0.96;
        transform: scale(1.11) translateX(11px) translateY(-12px) rotate(5deg);
        filter: blur(3.6px) contrast(3.8) brightness(0.5) hue-rotate(100deg);
    }
    60% {
        opacity: 0.97;
        transform: scale(0.89) translateX(-12px) translateY(13px) rotate(-5.5deg);
        filter: blur(4px) contrast(4.2) brightness(0.45) hue-rotate(-110deg);
    }
    65% {
        opacity: 0.98;
        transform: scale(1.13) translateX(13px) translateY(-14px) rotate(6deg);
        filter: blur(4.3px) contrast(4.5) brightness(0.4) hue-rotate(120deg);
    }
    70% {
        opacity: 0.99;
        transform: scale(0.87) translateX(-14px) translateY(15px) rotate(-6.5deg);
        filter: blur(4.6px) contrast(4.8) brightness(0.35) hue-rotate(-130deg);
    }
    75% {
        opacity: 1;
        transform: scale(1.15) translateX(15px) translateY(-16px) rotate(7deg);
        filter: blur(5px) contrast(5) brightness(0.3) hue-rotate(140deg);
    }
    80% {
        opacity: 1;
        transform: scale(0.85) translateX(-16px) translateY(17px) rotate(-7.5deg);
        filter: blur(5.3px) contrast(5.3) brightness(0.25) hue-rotate(-150deg);
    }
    85% {
        opacity: 1;
        transform: scale(1.17) translateX(17px) translateY(-18px) rotate(8deg);
        filter: blur(5.6px) contrast(5.6) brightness(0.2) hue-rotate(160deg);
    }
    90% {
        opacity: 1;
        transform: scale(0.83) translateX(-18px) translateY(19px) rotate(-8.5deg);
        filter: blur(6px) contrast(5.8) brightness(0.15) hue-rotate(-170deg);
    }
    95% {
        opacity: 1;
        transform: scale(1.19) translateX(19px) translateY(-20px) rotate(9deg);
        filter: blur(6.3px) contrast(6) brightness(0.1) hue-rotate(180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateX(0) translateY(0) rotate(0deg);
        filter: blur(7px) contrast(6.5) brightness(0) hue-rotate(0deg);
    }
}

@keyframes scanLinesOutro {
    0% {
        background-position: 0 0;
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    20% {
        opacity: 0.5;
        background-position: 0 -20px;
    }
    30% {
        opacity: 0.7;
        background-position: 0 -40px;
    }
    40% {
        opacity: 0.85;
        background-position: 0 -60px;
    }
    50% {
        opacity: 0.95;
        background-position: 0 -80px;
    }
    60% {
        opacity: 1;
        background-position: 0 -100px;
    }
    70% {
        opacity: 1;
        background-position: 0 -120px;
    }
    80% {
        opacity: 1;
        background-position: 0 -140px;
    }
    90% {
        opacity: 1;
        background-position: 0 -160px;
    }
    100% {
        opacity: 1;
        background-position: 0 -200px;
    }
}

@keyframes scanLines {
    0% {
        opacity: 0;
        transform: translateY(-100vh);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh);
    }
}

@keyframes crtDistortion {
    0% {
        opacity: 0;
        transform: translateX(0) scaleY(1);
    }
    10% {
        opacity: 0.4;
        transform: translateX(-3px) scaleY(1.01);
    }
    20% {
        opacity: 0.6;
        transform: translateX(5px) scaleY(0.99);
    }
    30% {
        opacity: 0.75;
        transform: translateX(-6px) scaleY(1.02);
    }
    40% {
        opacity: 0.85;
        transform: translateX(8px) scaleY(0.98);
    }
    50% {
        opacity: 0.9;
        transform: translateX(-10px) scaleY(1.03);
    }
    60% {
        opacity: 0.95;
        transform: translateX(12px) scaleY(0.97);
    }
    70% {
        opacity: 0.98;
        transform: translateX(-15px) scaleY(1.04);
    }
    80% {
        opacity: 1;
        transform: translateX(18px) scaleY(0.96);
    }
    90% {
        opacity: 1;
        transform: translateX(-20px) scaleY(1.05);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scaleY(0.3);
    }
}

#logoImage {
    max-width: 28%;
    max-height: 28%;
    width: auto;
    height: auto;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    opacity: 1; /* Logo is always visible */
}

@keyframes logoGrowSlow {
    0% {
        transform: scale(0.7);
    }
    100% {
        transform: scale(1.1);
    }
}

@keyframes ultimateGradientGlitchBg {
    0% {
        background: #ff3600; /* Original red */
    }
    12.5% {
        background: #ff4000; /* Orange-red */
    }
    25% {
        background: #ff7f00; /* Orange */
    }
    37.5% {
        background: #ffbf00; /* Yellow-orange */
    }
    50% {
        background: #ffff00; /* Yellow */
    }
    62.5% {
        background: #00ff00; /* Green */
    }
    75% {
        background: #00ffff; /* Cyan */
    }
    87.5% {
        background: #0000ff; /* Blue */
    }
    100% {
        background: #8000ff; /* Purple */
    }
}

@keyframes ultimateGradientGlitchFilter {
    0% {
        filter: hue-rotate(0deg) saturate(1) brightness(1);
    }
    12.5% {
        filter: hue-rotate(20deg) saturate(1.2) brightness(1.1);
    }
    25% {
        filter: hue-rotate(40deg) saturate(1.1) brightness(1.05);
    }
    37.5% {
        filter: hue-rotate(60deg) saturate(1.3) brightness(1.15);
    }
    50% {
        filter: hue-rotate(120deg) saturate(1.2) brightness(1.1);
    }
    62.5% {
        filter: hue-rotate(180deg) saturate(1.3) brightness(1.2);
    }
    75% {
        filter: hue-rotate(240deg) saturate(1.2) brightness(1.15);
    }
    87.5% {
        filter: hue-rotate(300deg) saturate(1.3) brightness(1.2);
    }
    100% {
        filter: hue-rotate(360deg) saturate(1.3) brightness(1.2);
    }
}

#titleScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000; /* Start with black background */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99998; /* Below splash but above menu */
    pointer-events: none;
    opacity: 1; /* Start fully opaque (black screen) */
    transition: opacity 1s ease-out, background 1s ease-out;
    gap: 0;
    image-rendering: auto; /* Smooth rendering with anti-aliasing */
}

#titleScreen.hidden {
    display: none;
}

#titleScreen.showing {
    background: transparent; /* Fade background to transparent, but keep text visible */
    /* Don't fade opacity - we want the text to stay visible */
}

#gameCanvas.showing {
    opacity: 1; /* Show canvas when space background should be visible */
    transition: opacity 1s ease-out;
}

#titleText {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transform: translateY(-120px); /* Move title up more */
    transition: transform 0s; /* Keep transform separate to avoid animation conflicts */
}

#titleGenesis {
    margin-top: 8px;
}

#titleStarshot {
    font-size: 140px;
    font-weight: 300;
    font-style: italic;
    color: transparent;
    text-align: center;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0; /* Text starts invisible */
    transform: scale(0.3); /* Start smaller */
    clip-path: inset(0 100% 0 0); /* Start clipped from left */
    transition: opacity 0.7s cubic-bezier(0.99, 0.01, 0.99, 0.01), transform 0.7s cubic-bezier(0.95, 0.05, 0.795, 0.035), clip-path 0.7s cubic-bezier(0.95, 0.05, 0.795, 0.035);
    line-height: 1.0;
    background: 
        repeating-linear-gradient(135deg,
            #ffffff 0%,
            #ffffff 4.5%,
            #ffffff 5%,
            #ffffff 5.5%,
            rgba(255, 0, 0, 0.5) 6%,
            rgba(255, 48, 0, 0.5) 6.5%,
            rgba(255, 96, 0, 0.5) 7%,
            rgba(255, 144, 0, 0.5) 7.5%,
            rgba(255, 192, 0, 0.5) 8%,
            rgba(255, 176, 32, 0.5) 8.5%,
            rgba(255, 160, 64, 0.5) 9%,
            rgba(255, 128, 64, 0.5) 9.5%,
            rgba(255, 96, 64, 0.5) 10%,
            rgba(255, 96, 96, 0.5) 10.5%,
            rgba(255, 96, 128, 0.5) 11%,
            rgba(255, 96, 160, 0.5) 11.5%,
            rgba(255, 96, 192, 0.5) 12%,
            rgba(255, 96, 224, 0.5) 12.5%,
            rgba(0, 255, 255, 0.6) 13%,
            rgba(0, 255, 128, 0.6) 13.5%,
            rgba(0, 128, 255, 0.6) 14%,
            rgba(255, 0, 255, 0.6) 14.5%,
            #ffffff 15%,
            #ffffff 19.5%,
            #ffffff 20%,
            #ffffff 20.5%,
            rgba(255, 0, 0, 0.5) 21%,
            rgba(255, 48, 0, 0.5) 21.5%,
            rgba(255, 96, 0, 0.5) 22%,
            rgba(255, 144, 0, 0.5) 22.5%,
            rgba(255, 192, 0, 0.5) 23%,
            rgba(255, 176, 32, 0.5) 23.5%,
            rgba(255, 160, 64, 0.5) 24%,
            rgba(255, 128, 64, 0.5) 24.5%,
            rgba(255, 96, 64, 0.5) 25%,
            rgba(255, 96, 96, 0.5) 25.5%,
            rgba(255, 96, 128, 0.5) 26%,
            rgba(255, 96, 160, 0.5) 26.5%,
            rgba(255, 96, 192, 0.5) 27%,
            rgba(255, 96, 224, 0.5) 27.5%,
            rgba(0, 255, 255, 0.6) 28%,
            rgba(0, 255, 128, 0.6) 28.5%,
            rgba(0, 128, 255, 0.6) 29%,
            rgba(255, 0, 255, 0.6) 29.5%,
            #ffffff 30%),
        #ffffff;
    background-size: 400% 100%, 100% 100%;
    background-blend-mode: normal;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    border: none;
    cursor: crosshair;
    transition: opacity 0.7s cubic-bezier(0.99, 0.01, 0.99, 0.01), transform 0.7s cubic-bezier(0.95, 0.05, 0.795, 0.035), clip-path 0.7s cubic-bezier(0.95, 0.05, 0.795, 0.035), filter 0.15s ease;
    box-shadow: none;
    text-shadow: none;
    image-rendering: auto; /* Smooth rendering with anti-aliasing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    animation: startBtnGradientRoll 10s linear infinite;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 12px rgba(255, 0, 0, 0.3)) drop-shadow(0 0 18px rgba(0, 0, 255, 0.2));
}

#titleGenesis {
    font-size: 24px;
    font-weight: 300;
    font-style: italic;
    color: #ffffff;
    text-align: center;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 12px;
    opacity: 0; /* Fade in with menu + starfield */
    transition: opacity 1s ease-in;
    margin-top: 8px;
}

@keyframes titleGradientRoll {
    0% {
        background-position: 0% 0%, 0% 0%;
    }
    100% {
        background-position: 400% 0%, 0% 0%;
    }
}

@keyframes startBtnGradientRoll {
    0% {
        background-position: 0% 0%, 0% 0%;
    }
    100% {
        background-position: 400% 0%, 0% 0%;
    }
}

#titleStarshot.visible {
    opacity: 1;
    transform: scale(1);
    clip-path: inset(0 0 0 0); /* Fully revealed */
}

/* Keep title text visible even when title screen background fades out */
#titleScreen.showing #titleStarshot {
    opacity: 1 !important; /* Ensure text stays visible when background fades */
}

#startScreen:not(.hidden) {
    pointer-events: none; /* Don't block debug menu when visible */
}

#startScreen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(calc(-50% - 8px), calc(-50% + 140px)); /* Lower the start screen content */
    text-align: center;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    pointer-events: all;
    cursor: crosshair;
    opacity: 0; /* Start invisible for fade in */
    transition: opacity 1s ease-in, transform 0s; /* Keep transform separate to avoid animation conflicts */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#startScreenContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#startLeaderboardBtn {
    position: fixed;
    left: 8px;
    bottom: 8px;
    width: 220px;
    display: none;
    margin: 0;
    opacity: 0.75;
    padding: 0;
    background: transparent;
    border: none;
    cursor: crosshair;
    justify-content: flex-start;
    --menu-key-gap: 10px;
    z-index: 20;
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: none;
}

body.start-screen-visible #startLeaderboardBtn,
body.start-leaderboard-open #startLeaderboardBtn {
    display: inline-flex;
}

.start-leaderboard-open #startScreenContent {
    display: none;
}

.start-leaderboard-open #titleText,
.start-leaderboard-open #titleStarshot,
.start-leaderboard-open #titleGenesis {
    opacity: 0 !important;
}

#startScreen:focus,
#startScreen:focus-visible {
    outline: none;
    border: none;
    box-shadow: none;
}

#playerNameInput {
    width: 240px;
    padding: 6px 10px;
    margin: 0 0 8px;
    transform: none;
    display: block;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 4px;
    color: #ffffff;
    font-size: 12px;
    text-align: left;
    letter-spacing: 1px;
    font-family: 'Exo 2', 'Arial', sans-serif;
    outline: none;
}

#playerPasswordInput {
    width: 240px;
    padding: 6px 10px;
    margin: 0 0 6px;
    transform: none;
    display: block;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 4px;
    color: #ffffff;
    font-size: 12px;
    text-align: left;
    letter-spacing: 1px;
    font-family: 'Exo 2', 'Arial', sans-serif;
    outline: none;
}

#playerNameInput:focus,
#playerNameInput:active {
    border: 1px solid rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) !important;
}

#playerPasswordInput:focus,
#playerPasswordInput:active {
    border: 1px solid rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) !important;
}

#playerNameInput::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#playerPasswordInput::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#playerNameError {
    width: 350px;
    height: 28px;
    line-height: 28px;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: auto;
    margin-right: auto;
    font-size: 11px;
    text-align: center;
    letter-spacing: 0.5px;
    font-family: 'Exo 2', 'Arial', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#playerNameError.error {
    color: #ff6b6b;
}

#playerNameError.success {
    color: rgba(255, 255, 255, 0.85);
}

#playerNameError.info {
    color: rgba(255, 255, 255, 0.75);
}

.menuKeyButton {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    --menu-key-width: 28px;
    --menu-key-gap: 10px;
    gap: var(--menu-key-gap);
    text-align: left;
    pointer-events: none;
    cursor: default;
    color: rgba(223, 232, 238, 0.7);
    font-family: inherit;
}

.menuButtonText {
    flex: 1 1 auto;
    color: inherit;
    text-align: left;
    line-height: 24px;
}

.menuKeyHint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--menu-key-width);
    height: 24px;
    padding: 0 6px;
    border: 1px solid rgba(223, 232, 238, 0.5);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #dfe8ee;
    background: rgba(0, 0, 0, 0.35);
    text-transform: uppercase;
    opacity: 0.7;
    position: relative;
    overflow: hidden;
    line-height: 24px;
}

.menuKeyHint::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--hold-progress, 0%);
    background: rgba(255, 255, 255, 0.18);
    transition: width 0.05s linear;
    z-index: 0;
}

.menuKeyHint > span,
.menuKeyHint > strong,
.menuKeyHint {
    position: relative;
    z-index: 1;
}

#startScreen .menuKeyButton {
    justify-content: flex-start;
    width: 280px;
    margin-left: 0;
    margin-right: 0;
    --menu-key-gap: 10px;
    opacity: 0.75;
    transform: none;
    height: 24px;
    color: rgba(255, 255, 255, 0.75);
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 1px;
    font-style: normal;
    text-transform: none;
    padding: 0;
    box-sizing: border-box;
    transition: color 0.3s ease;
    background: transparent;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#startScreen .menuButtonText {
    flex: 0 0 auto;
    white-space: nowrap;
    line-height: 24px;
    text-transform: none;
    font-style: normal;
    transition: color 0.3s ease;
}
#pauseMenu .menuButtonText,
#gameOver .menuButtonText {
    text-transform: none;
    font-style: normal;
}

#startScreen .menuKeyHint {
    margin-left: 0;
    margin-right: 0;
    padding-left: 10px;
    padding-right: 10px;
    min-width: 56px;
    width: 56px;
    color: rgba(255, 255, 255, 0.75);
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.75);
    text-transform: none;
    font-style: normal;
    transition: color 0.3s ease, border-color 0.3s ease;
}

#startScreen .menuKeyButton.key-active {
    opacity: 1;
    color: #ffffff;
}

#startScreen .menuKeyButton.key-active .menuButtonText {
    color: #ffffff;
}

#startScreen .menuKeyButton.bright {
    color: #ffffff;
}

#startScreen .menuKeyButton.bright .menuKeyHint {
    color: #ffffff;
    border-color: #ffffff;
}

#startScreen .menuKeyButton.bright .menuButtonText {
    color: #ffffff;
}

#startScreen .menuKeyButton.bright-flash {
    animation: startMenuBrightFlash 0.3s steps(1, end) infinite;
}

#startScreen .menuKeyButton.bright-flash .menuKeyHint {
    animation: startMenuBrightFlash 0.3s steps(1, end) infinite;
}

#startScreen .menuKeyButton.bright-flash .menuButtonText {
    animation: startMenuBrightFlash 0.3s steps(1, end) infinite;
}

#startScreen .menuKeyButton.hidden {
    visibility: hidden;
    pointer-events: none;
}

#startActions {
    display: grid;
    grid-template-rows: 24px 24px;
    row-gap: 18px;
    height: 56px;
    align-items: center;
    justify-items: start;
    margin-top: 12px;
    margin-left: 40px;
}

#enterKeyHint,
#startBtn {
    grid-row: 1;
}

#exitBtnStart {
    grid-row: 2;
}

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

#enterKeyHint {
    justify-content: flex-start;
    width: 280px;
    margin-left: 0;
    margin-right: 0;
    --menu-key-gap: 10px;
    opacity: 0.75;
    pointer-events: none;
    cursor: default;
    padding: 0;
    box-sizing: border-box;
    background: transparent;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: none;
}

#enterKeyHint .menuKeyHint {
    margin-left: 0;
    margin-right: 0;
    padding-left: 10px;
    padding-right: 10px;
    min-width: 56px;
    width: 56px;
    color: rgba(255, 255, 255, 0.75);
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.75);
    text-transform: none;
    font-style: normal;
}

#enterKeyHint .menuButtonText {
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.75);
    font-style: normal;
}

#pauseMenu .menuKeyHint,
#gameOver .menuKeyHint {
    margin-left: 0;
    text-transform: none;
    font-style: normal;
}

#pauseMenu .menuKeyHint {
    margin-right: 10px;
}

#pauseMenu .menuKeyButton,
#gameOver .menuKeyButton {
    opacity: 0.7;
}

.menuKeyButton.key-active {
    opacity: 1;
    color: #ffffff;
}

.menuKeyButton.key-active .menuKeyHint {
    color: #ffffff;
    border-color: #ffffff;
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

#pauseMenu button.key-active {
    color: #ffffff;
    background: transparent;
    transform: translateX(4px);
    border: none !important;
    outline: none !important;
}

#restartBtn.key-active,
#mainMenuBtn.key-active,
#exitBtnGameOver.key-active {
    color: #ffffff;
    background: transparent;
    transform: translateX(4px);
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#startBtn.key-active,
#exitBtnStart.key-active {
    opacity: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.menuKeyButton.key-active .menuButtonText {
    color: #ffffff;
}

#startBtn.key-active .menuKeyHint,
#exitBtnStart.key-active .menuKeyHint {
    color: #ffffff;
    border-color: #ffffff;
    opacity: 1;
}

#startScreen.hidden {
    display: none;
}

#startScreen.visible {
    opacity: 1;
}

body.start-screen-preview #startScreen {
    opacity: 0;
    pointer-events: none;
}

body.start-screen-preview #startScreenContent {
    display: none;
}

body.start-screen-preview #startLeaderboardBtn {
    display: none;
}

body.start-screen-preview #titleText,
body.start-screen-preview #titleStarshot,
body.start-screen-preview #titleGenesis {
    opacity: 0 !important;
}

#exitBtnStart {
    padding: 8px 32px;
    margin: 0;
    font-size: 18px;
    font-weight: 300;
    font-style: italic;
    background: transparent;
    border: none !important;
    outline: none !important;
    cursor: crosshair;
    transition: opacity 0.3s ease;
    box-shadow: none !important;
    text-shadow: none;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    image-rendering: auto; /* Smooth rendering with anti-aliasing */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-width: 200px;
    color: #ffffff;
    opacity: 0.6;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#exitBtnStart:hover,
#exitBtnStart:active,
#exitBtnStart:focus {
    opacity: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#exitBtnStart:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Pause Menu */
#pauseMenu {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    text-align: left;
    background: transparent;
    padding: 16px 20px;
    border: none;
    box-shadow: none;
    pointer-events: all;
    z-index: 1001;
    cursor: crosshair;
    min-width: 220px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    animation: slideInFromLeft 0.3s ease-out;
}

#menuOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    pointer-events: none;
}

#menuOverlay.hidden {
    display: none;
}

#transitionFade {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 2000;
    pointer-events: none;
}

#transitionFade.hidden {
    display: none;
}

#launchGate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 3000;
    display: none; /* Hidden initially, will be shown after audio is ready */
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    user-select: none;
}

.launchGateLoading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease-out;
    animation: launchGateLoadingFadeIn 0.6s ease forwards;
}

.launchGateLoading.hidden {
    opacity: 0;
    pointer-events: none;
    animation: none;
}

@keyframes launchGateLoadingFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.loadingBar {
    width: min(240px, 60vw);
    height: 6px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    overflow: hidden;
    box-shadow: none;
}

.loadingBarFill {
    height: 100%;
    width: 0%;
    background: #ffffff;
    transition: width 0.2s ease;
}

.loadingBar.indeterminate .loadingBarFill {
    width: 40%;
    animation: loadingBarPulse 1.2s ease-in-out infinite;
}

@keyframes loadingBarPulse {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(220%);
    }
}

.loadingBarText {
    margin-top: 12px;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
}

.launchGateContent {
    text-align: center;
    color: #ffffff;
    font-family: 'Exo 2', 'Arial', sans-serif;
    letter-spacing: 1px;
    opacity: 0; /* Start invisible */
}

.launchGateContent.fadeIn {
    animation: launchGateFadeIn 0.5s ease-in forwards;
}

@keyframes launchGateFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.launchGateTitle {
    font-size: 26px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 32px;
}

.launchGateHint {
    font-size: 12px;
    opacity: 0.6;
    text-transform: uppercase;
}

.launchGateMouse {
    position: relative;
    width: 60px;
    height: 90px;
    margin: 0 auto 32px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 32px;
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.launchGateMouseTop {
    display: flex;
    width: 100%;
    height: 38px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.launchGateMouseLeft,
.launchGateMouseRight {
    flex: 1 1 50%;
}

.launchGateMouseLeft {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    animation: mouseClickPulse 1.4s ease-in-out infinite;
}

.launchGateMouseBody {
    flex: 1 1 auto;
    background: rgba(255, 255, 255, 0.05);
}

@keyframes mouseClickPulse {
    0%, 60%, 100% {
        background: rgba(255, 255, 255, 0.08);
    }
    70%, 80% {
        background: rgba(255, 255, 255, 0.35);
    }
}

#pauseMenu.hidden {
    display: none;
}

#pauseMenu h1 {
    font-size: 22px;
    margin-bottom: 12px;
    color: #ffffff;
    font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);
    letter-spacing: 1px;
    font-family: 'Exo 2', 'Arial', sans-serif;
}

.menuHint {
    margin-top: 8px;
    font-size: 9px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: rgba(223, 232, 238, 0.65);
    font-family: 'Exo 2', 'Arial', sans-serif;
    opacity: 0.8;
}

#pauseMenu button {
    display: block;
    width: 100%;
    padding: 8px 0;
    margin: 4px 0;
    font-size: 14px;
    background: transparent;
    color: #dfe8ee; /* White-blue */
    border: none !important;
    outline: none !important;
    cursor: crosshair;
    font-weight: bold;
    transition: all 0.15s;
    box-shadow: none !important;
    text-shadow: none;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-align: left;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#pauseMenu button:hover {
    color: #ffffff;
    background: transparent;
    transform: translateX(4px);
    border: none !important;
    outline: none !important;
}

#pauseMenu #exitBtn {
    color: inherit;
    opacity: 0.7;
}

#pauseMenu #exitBtn .menuButtonText {
    color: inherit;
}

#pauseMenu #exitBtn .menuKeyHint {
    color: inherit;
    border-color: rgba(223, 232, 238, 0.5);
}

#pauseMenu #exitBtn:hover,
#pauseMenu #exitBtn:active,
#pauseMenu #exitBtn:focus {
    color: #ffffff;
}

#pauseMenu button:active {
    transform: translateX(4px) scale(0.98);
    border: none !important;
    outline: none !important;
}

#pauseMenu button:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#pauseMenu button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#exitBtn {
    color: #dfe8ee;
    background: transparent;
    position: relative;
    z-index: 1001;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#exitBtn:hover,
#exitBtn:active,
#exitBtn:focus {
    color: #ffffff;
    background: transparent;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Right side indicators (mouse buttons and pointer radar) */
#rightSideIndicators {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    pointer-events: none;
    margin-right: 16px;
}

#mouseIndicators {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.mouseIndicator {
    display: block; /* Always visible */
    color: #ffffff; /* White text when not pressed */
    font-size: 10px;
    font-weight: bold;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    background: transparent; /* No background when not pressed */
    border: none; /* No border */
    box-shadow: none; /* No glow */
    min-width: 50px;
    text-align: center;
    transition: all 0.1s ease;
}

.mouseIndicator.active {
    color: #000000; /* Black text on white background when pressed */
    background: rgba(255, 255, 255, 1.0); /* Opaque white when pressed */
    text-shadow: none; /* No text shadow when pressed */
}

#pointerRadar {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    padding: 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#pointerRadarCanvas {
    display: block;
    border: none;
    background: transparent;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Debug Menu */
#debugMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 999999 !important; /* Highest z-index to be above everything */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    font-family: 'Exo 2', 'Arial', sans-serif;
    color: #ffffff;
    pointer-events: auto !important; /* Ensure it can receive pointer events */
    overflow-y: auto;
}

#debugMenu.hidden {
    display: none !important;
    pointer-events: none !important;
}

#debugContent {
    width: 100%;
    max-width: 1300px;
    max-height: none;
    overflow: visible;
    padding: 24px 28px;
    margin: 0 auto;
    background: #000000;
    box-shadow: none;
    border-radius: 4px;
    pointer-events: auto !important; /* Ensure content can receive clicks */
    position: relative;
    z-index: 1000000; /* Even higher than the menu itself */
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

#debugMenu.visible #debugContent {
    opacity: 1;
}

/* Minimal scrollbars on the debug menu container */
#debugMenu::-webkit-scrollbar {
    width: 8px;
}

#debugMenu::-webkit-scrollbar-track {
    background: transparent;
}

#debugMenu::-webkit-scrollbar-thumb {
    background: rgba(232, 247, 255, 0.2);
    border-radius: 6px;
}

#debugMenu::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 247, 255, 0.35);
}

#debugMenu {
    scrollbar-width: thin;
    scrollbar-color: rgba(232, 247, 255, 0.2) transparent;
}

#debugHeader {
    text-align: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(232, 247, 255, 0.15);
}

#debugHeader h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #e8f7ff;
    text-shadow: none;
    margin-bottom: 4px;
}

#debugSubtitle {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(232, 247, 255, 0.6);
}

#debugSections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.debugSection {
    padding: 16px;
    background: #000000;
    border-radius: 4px;
    box-shadow: none;
}

.debugSection h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 8px;
    color: #e8f7ff;
    border-bottom: none;
}

.debugControls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.debugControls label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: rgba(232, 247, 255, 0.9);
}

.debugControlItem {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #000000;
    border-radius: 2px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.debugControlItem:hover {
    background: rgba(0, 0, 0, 0.55);
}

.debugDescription {
    display: block;
    font-size: 0.8em;
    color: rgba(232, 247, 255, 0.55);
    margin-top: 6px;
    margin-left: 0;
    font-style: italic;
    line-height: 1.4;
}

.debugControls input[type="number"],
.debugControls input[type="range"] {
    width: 180px;
    margin-left: 10px;
    padding: 5px 8px;
    background: #000000;
    border: none;
    border-radius: 2px;
    color: #e8f7ff;
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 12px;
}

.debugControls input[type="number"]:focus,
.debugControls input[type="range"]:focus {
    outline: none;
    box-shadow: none;
}

.debugBtn {
    padding: 9px 18px;
    background: rgba(232, 247, 255, 0.08);
    border: 1px solid rgba(232, 247, 255, 0.28);
    color: #e8f7ff;
    cursor: pointer;
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.debugBtn,
.debugBtn:focus,
.debugBtn:active,
.debugBtn:focus-visible,
.debugBtn:hover:focus,
.debugBtn:hover:active,
#closeDebugMenu,
#closeDebugMenu:focus,
#closeDebugMenu:active,
#closeDebugMenu:focus-visible,
#closeDebugMenu:hover:focus,
#closeDebugMenu:hover:active,
#loadDefaultsBtn,
#loadDefaultsBtn:focus,
#loadDefaultsBtn:active,
#loadDefaultsBtn:focus-visible,
#loadDefaultsBtn:hover:focus,
#loadDefaultsBtn:hover:active {
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.debugBtn:hover {
    background: rgba(232, 247, 255, 0.18);
    border-color: rgba(232, 247, 255, 0.45);
    box-shadow: none;
}

.debugBtn.playing {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: none;
}

#closeDebugMenu {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000001;
    display: inline-block;
    margin: 0;
    padding: 8px 20px;
    background: rgba(255, 64, 64, 0.2);
    border: 1px solid rgba(255, 64, 64, 0.5);
    color: #ffffff;
    cursor: pointer;
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

#closeDebugMenu:hover {
    background: rgba(255, 64, 64, 0.35);
    border-color: rgba(255, 64, 64, 0.8);
    box-shadow: none;
}

#loadDefaultsBtn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000001;
    display: inline-block;
    margin: 0;
    padding: 8px 20px;
    background: rgba(64, 160, 255, 0.2);
    border: 1px solid rgba(64, 160, 255, 0.5);
    color: #ffffff;
    cursor: pointer;
    font-family: 'Exo 2', 'Arial', sans-serif;
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

#loadDefaultsBtn:hover {
    background: rgba(64, 160, 255, 0.35);
    border-color: rgba(64, 160, 255, 0.8);
    box-shadow: none;
}

/* Force smooth rendering across UI and canvases */
canvas,
#gameCanvas,
#hud,
#hud *,
#pauseMenu,
#pauseMenu *,
#startScreen,
#startScreen * {
    image-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
}

#startScreenPreview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    pointer-events: auto;
    cursor: crosshair;
    background: transparent;
}

#startScreenPreview.hidden {
    display: none;
}

.startScreenPreviewTitle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.startScreenPreviewStarshot {
    font-size: 140px;
    font-weight: 300;
    font-style: italic;
    color: transparent;
    text-align: center;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 1;
    transform: none;
    clip-path: inset(0 0 0 0);
    line-height: 1.0;
    background:
        repeating-linear-gradient(135deg,
            #ffffff 0%,
            #ffffff 4.5%,
            #ffffff 5%,
            #ffffff 5.5%,
            rgba(255, 0, 0, 0.5) 6%,
            rgba(255, 48, 0, 0.5) 6.5%,
            rgba(255, 96, 0, 0.5) 7%,
            rgba(255, 144, 0, 0.5) 7.5%,
            rgba(255, 192, 0, 0.5) 8%,
            rgba(255, 176, 32, 0.5) 8.5%,
            rgba(255, 160, 64, 0.5) 9%,
            rgba(255, 128, 64, 0.5) 9.5%,
            rgba(255, 96, 64, 0.5) 10%,
            rgba(255, 96, 96, 0.5) 10.5%,
            rgba(255, 96, 128, 0.5) 11%,
            rgba(255, 96, 160, 0.5) 11.5%,
            rgba(255, 96, 192, 0.5) 12%,
            rgba(255, 96, 224, 0.5) 12.5%,
            rgba(0, 255, 255, 0.6) 13%,
            rgba(0, 255, 128, 0.6) 13.5%,
            rgba(0, 128, 255, 0.6) 14%,
            rgba(255, 0, 255, 0.6) 14.5%,
            #ffffff 15%,
            #ffffff 19.5%,
            #ffffff 20%,
            #ffffff 20.5%,
            rgba(255, 0, 0, 0.5) 21%,
            rgba(255, 48, 0, 0.5) 21.5%,
            rgba(255, 96, 0, 0.5) 22%,
            rgba(255, 144, 0, 0.5) 22.5%,
            rgba(255, 192, 0, 0.5) 23%,
            rgba(255, 176, 32, 0.5) 23.5%,
            rgba(255, 160, 64, 0.5) 24%,
            rgba(255, 128, 64, 0.5) 24.5%,
            rgba(255, 96, 64, 0.5) 25%,
            rgba(255, 96, 96, 0.5) 25.5%,
            rgba(255, 96, 128, 0.5) 26%,
            rgba(255, 96, 160, 0.5) 26.5%,
            rgba(255, 96, 192, 0.5) 27%,
            rgba(255, 96, 224, 0.5) 27.5%,
            rgba(0, 255, 255, 0.6) 28%,
            rgba(0, 255, 128, 0.6) 28.5%,
            rgba(0, 128, 255, 0.6) 29%,
            rgba(255, 0, 255, 0.6) 29.5%,
            #ffffff 30%),
        #ffffff;
    background-size: 400% 100%, 100% 100%;
    background-blend-mode: normal;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    box-shadow: none;
    text-shadow: none;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    animation: startBtnGradientRoll 10s linear infinite;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5))
        drop-shadow(0 0 12px rgba(255, 0, 0, 0.3))
        drop-shadow(0 0 18px rgba(0, 0, 255, 0.2));
}

.startScreenPreviewGenesis {
    font-size: 24px;
    font-weight: 300;
    font-style: italic;
    color: #ffffff;
    text-align: center;
    font-family: 'Exo 2', 'Arial', sans-serif;
    text-transform: uppercase;
    letter-spacing: 12px;
    opacity: 1;
    margin-top: 8px;
}
