* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', sans-serif;
    color: white;
    user-select: none;
    -webkit-user-select: none;
}

canvas {
    display: block;
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #001530 0%, #000000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 30px;
}

.splash-content {
    text-align: center;
    width: 250px;
}

.loading-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 20px;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: #00ffff;
    box-shadow: 0 0 10px #00ffff;
    transition: width 0.3s ease-out;
}

#loading-status {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(0, 255, 255, 0.5);
    margin-top: 10px;
}

.glitch-text {
    font-size: 40px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 5px;
    text-shadow: 0 0 10px #0ff;
    animation: glitch 2s infinite;
}

@keyframes glitch {
    0% {
        transform: skew(0deg);
    }

    20% {
        transform: skew(-1deg);
        text-shadow: 2px 0 red, -2px 0 blue;
    }

    21% {
        transform: skew(0deg);
        text-shadow: 0 0 10px #0ff;
    }

    50% {
        transform: skew(1deg);
    }

    51% {
        transform: skew(0deg);
    }
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#damage-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 30, 30, 0.7) 100%);
    opacity: 0;
    transition: opacity 0.1s;
    pointer-events: none;
}

#crosshair {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 255, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    top: 50%;
    left: 50%;
    transition: transform 0.05s;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

#fps-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-family: monospace;
    font-size: 12px;
    color: #00ff88;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 1000;
}

#crosshair.shoot-anim {
    transform: translate(-50%, -50%) scale(1.8);
    border-color: rgba(0, 255, 255, 0.2) !important;
    background: rgba(0, 255, 255, 0.8) !important;
}

#score-display {
    position: absolute;
    top: 5vh;
    left: 5vw;
    color: #fff;
    font-size: clamp(20px, 4vw, 32px);
    font-weight: bold;
    text-shadow: 0 0 10px #0ff;
    z-index: 10;
}


#multiplier-display {
    position: absolute;
    top: 10vh;
    left: 5vw;
    color: #ffd700;
    font-size: clamp(16px, 3vw, 24px);
    font-weight: bold;
    text-shadow: 0 0 8px #ffd700;
    z-index: 10;
}


/* Settings Container */
#settings-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
    pointer-events: auto;
}

/* Portrait Mode Adjustments */
@media (orientation: portrait) {
    #cosmetic-ui {
        width: 90vw;
        margin-top: 5vh;
    }

    .skin-grid {
        flex-wrap: wrap;
    }

    .skin-btn {
        width: calc(50% - 10px);
    }

    #powerup-container {
        bottom: 12vh;
    }



    #settings-container {
        flex-direction: column;
        top: 20px;
        left: 20px;
    }
}

.settings-btn {
    width: 45px;
    height: 45px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.settings-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    transform: scale(1.05);
}

.settings-btn:active {
    transform: scale(0.95);
}

.settings-btn.disabled-btn {
    opacity: 0.5;
    filter: grayscale(100%);
    text-decoration: line-through;
    color: #ff3366;
    border-color: rgba(255, 51, 102, 0.3);
}

/* HUD Base */
#hud {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.top-hud {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 60px;
}

#ammo-display {
    position: absolute;
    top: 20px;
    /* Docked at the top center */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 24, 40, 0.9) 0%, rgba(0, 8, 16, 0.95) 100%);
    border: 1px solid rgba(0, 255, 255, 0.45);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.15), inset 0 0 10px rgba(0, 255, 255, 0.05);
    border-radius: 20px;
    padding: 4px 24px;
    pointer-events: none;
    z-index: 50;
    transition: transform 0.1s;
}

#ammo-count {
    font-size: 26px;
    font-weight: bold;
    color: #00ffff;
    text-shadow: 0 0 12px rgba(0, 255, 255, 0.95), 0 0 4px rgba(255, 255, 255, 0.8);
    text-align: center;
    letter-spacing: 2px;
}

#ammo-count.danger {
    color: #ff3366;
    text-shadow: 0 0 12px rgba(255, 51, 102, 0.95), 0 0 4px rgba(255, 255, 255, 0.8);
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.3;
    }
}

#score-container {
    font-size: 20px;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#stage-indicator {
    font-size: 14px;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 5px;
    font-weight: bold;
}

/* Combo UI */
#combo-ui {
    position: absolute;
    top: 72px;
    /* Moved down to avoid overlapping the ammo display */
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    transition: opacity 0.3s;
}

.combo-text {
    font-size: 13px;
    color: #ffffff;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.7);
    letter-spacing: 3px;
    text-transform: uppercase;
}

#multi-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 5px;
}

.combo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: all 0.2s;
}

.combo-dot.active {
    background: #00ffff;
    border-color: #00ffff;
    box-shadow: 0 0 12px #00ffff, 0 0 4px #00ffff;
}

#cosmetic-ui {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 10px;
    pointer-events: auto;
}

.skin-grid {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 15px 0;
}

.skin-btn {
    width: 85px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.skin-btn img {
    width: clamp(32px, 8vw, 48px);
    height: clamp(32px, 8vw, 48px);
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
    image-rendering: crisp-edges;
}

.skin-btn span {
    font-size: clamp(8px, 1.5vw, 10px);
    font-weight: bold;
    text-transform: uppercase;
    color: #0ff;
    white-space: nowrap;
}

.skin-btn small {
    font-size: 8px;
    color: #fff;
    opacity: 0.6;
}

.skin-btn:hover {
    background: rgba(0, 255, 255, 0.1);
    border-color: rgba(0, 255, 255, 0.3);
}

.skin-btn.selected {
    border-color: #0ff;
    background: rgba(0, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.skin-btn.locked {
    opacity: 0.3;
    filter: grayscale(1);
    cursor: not-allowed;
}

.skin-btn.locked:hover {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.05);
}

#skin-desc {
    font-size: clamp(10px, 2vw, 12px);
    opacity: 0.8;
    margin-top: 10px;
    color: #fff;
}

/* Powerup Buttons */
#powerup-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    pointer-events: auto;
}

.powerup-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: visible;
    transition: all 0.2s;
}

.powerup-btn:not(.disabled) {
    border-color: currentColor;
    box-shadow: 0 0 15px currentColor;
}

.powerup-btn.disabled {
    opacity: 0.3;
    cursor: default;
}

.powerup-btn:not(.disabled):active {
    transform: scale(0.9);
}

.count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    font-size: 12px;
    padding: 1px 5px;
    z-index: 3;
    color: white;
}

.timer-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: currentColor;
    opacity: 0.3;
    transition: height 0.1s linear;
}

/* Flying pickup animation */
.flying-pickup {
    position: fixed;
    font-size: 24px;
    pointer-events: none;
    z-index: 1000;
    transition: transform 0.6s ease-in, opacity 0.6s ease-in;
}

/* Screens */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #00050a;
    /* Solid color fallback */
    background: radial-gradient(circle at center, #001530 0%, #000000 100%);
    pointer-events: auto;
    color: #fff;
    z-index: 20;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    /* Allow scrolling on short screens */
    padding: 20px;
    box-sizing: border-box;
}

.screen-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-height: 100vh;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

#start-screen h1,
#game-over-screen h1 {
    font-size: clamp(30px, 8vw, 80px);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: clamp(10px, 2vh, 20px);
    margin-top: 20px;
}

#start-screen h1 {
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff;
}

#game-over-screen h1 {
    color: #ff0055;
    text-shadow: 0 0 10px #ff0055;
}

.screen p {
    font-size: clamp(12px, 3vw, 1.1rem);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 450px;
    line-height: 1.5;
    margin-bottom: clamp(10px, 2vh, 30px);
}

.screen button {
    background: transparent;
    border: 2px solid #00ffff;
    color: #00ffff;
    padding: 14px 40px;
    font-size: 1.1rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 4px;
}

.screen button:hover {
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    transform: scale(1.05);
}

.screen button:active {
    transform: scale(0.95);
}

/* New Record Animation */
@keyframes pulseRecord {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.record-anim {
    animation: pulseRecord 1.5s ease-in-out infinite;
    will-change: transform, opacity;
}

/* Combo Pulse */
@keyframes comboPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
        text-shadow: 0 0 5px #fff;
    }

    100% {
        transform: scale(1);
    }
}

.combo-pulse-anim {
    animation: comboPulse 0.3s ease-out;
    will-change: transform;
}