@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body {
    margin: 0;
    padding: 0;
    background-color: #111;
    /* Dark background */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    font-family: 'Press Start 2P', cursive;
    /* Retro font */
    color: white;
}

#title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: black;
    z-index: 10;
    transition: opacity 1s ease-out;
    animation: fadeIn 3s ease-in;
}

.title-text {
    font-size: 60px;
    color: #0ff;
    text-shadow:
        0 0 5px #0ff,
        0 0 10px #0ff,
        0 0 20px #00f,
        0 0 40px #00f,
        0 0 80px #00f;
    margin-bottom: 50px;
    text-align: center;
    animation: pulsate 2s infinite alternate;
    position: relative;
    z-index: 20;
    /* Keep above burst */
}

.title-text.flash {
    animation: titleFlash 0.5s ease-out forwards;
}

@keyframes titleFlash {
    0% {
        color: white;
        text-shadow: 0 0 50px white;
        transform: scale(1.1);
    }

    100% {
        color: #0ff;
        text-shadow:
            0 0 5px #0ff,
            0 0 10px #0ff,
            0 0 20px #00f,
            0 0 40px #00f,
            0 0 80px #00f;
        transform: scale(1);
    }
}

.start-prompt {
    font-size: 20px;
    color: white;
    animation: blink 1s infinite step-end;
}

@keyframes pulsate {
    0% {
        text-shadow:
            0 0 4px #0ff,
            0 0 10px #0ff,
            0 0 20px #00f;
    }

    100% {
        text-shadow:
            0 0 10px #0ff,
            0 0 20px #0ff,
            0 0 40px #00f,
            0 0 80px #00f;
    }
}

/* Multi-layer Rainbow Burst */
.burst-clone {
    position: absolute;
    font-family: 'Press Start 2P', cursive;
    font-size: 60px;
    font-weight: bold;
    color: transparent;
    z-index: 100;
    pointer-events: none;
    white-space: nowrap;
    transform-origin: center center;
}

@keyframes expandBurst {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        transform: scale(var(--target-scale));
        opacity: 0;
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

#game-container {
    position: relative;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

canvas {
    background-color: black;
    display: block;
    image-rendering: pixelated;
    /* Essential for pixel art */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas if needed */
}

#score {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 20px;
    font-weight: bold;
}

#health-bar-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 20px;
    border: 2px solid white;
    background-color: #333;
}

#health-bar {
    width: 100%;
    height: 100%;
    background-color: #0f0;
    /* Green health */
    transition: width 0.2s, background-color 0.2s;
}

#diamond-container {
    position: absolute;
    top: 60px;
    /* Below score */
    left: 20px;
    display: flex;
    gap: 10px;
}

.diamond-icon {
    width: 32px;
    height: 32px;
    background-image: url('assets/diamond.png');
    background-size: cover;
    image-rendering: pixelated;
    animation: pulse 2s infinite;
}

#boss-health-container {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 300px;
    /* Cinematic height */
    border: 2px solid white;
    background-color: #333;
}

#boss-health-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    /* Starts empty */
    background-color: red;
    transition: height 0.5s linear;
    /* Smooth fill */
    box-shadow: 0 0 10px red;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border: 2px solid red;
}

#rainbow-gauge-container {
    position: absolute;
    bottom: 50px;
    /* Above health bar (20px + 20px height + 10px gap) */
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 10px;
    border: 2px solid white;
    background-color: #333;
}

#rainbow-gauge-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, red, orange, yellow, green, blue, indigo, violet);
    background-size: 200% 100%;
    animation: rainbowScroll 2s linear infinite;
    transition: width 0.1s linear;
}

@keyframes rainbowScroll {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

.hidden {
    display: none !important;
}

#start-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #0f0;
    font-size: 30px;
    text-shadow: 0 0 20px #0f0;
    animation: rainbowFlash 0.5s infinite linear;
}

@keyframes rainbowFlash {
    0% {
        color: red;
        text-shadow: 0 0 10px red;
    }

    14% {
        color: orange;
        text-shadow: 0 0 10px orange;
    }

    28% {
        color: yellow;
        text-shadow: 0 0 10px yellow;
    }

    42% {
        color: green;
        text-shadow: 0 0 10px green;
    }

    57% {
        color: blue;
        text-shadow: 0 0 10px blue;
    }

    71% {
        color: indigo;
        text-shadow: 0 0 10px indigo;
    }

    85% {
        color: violet;
        text-shadow: 0 0 10px violet;
    }

    100% {
        color: red;
        text-shadow: 0 0 10px red;
    }
}



#danger-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: red;
    font-size: 30px;
    /* Smaller to fit */
    font-weight: bold;
    text-shadow: 0 0 20px red;
    animation: dangerBlink 0.2s infinite;
    z-index: 100;
}

@keyframes dangerBlink {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #game-container {
        touch-action: none;
        /* Prevent browser scrolling/zooming */
    }

    .title-text {
        font-size: 30px;
        /* Smaller title */
        margin-bottom: 20px;
    }

    .start-prompt {
        font-size: 14px;
        /* Smaller prompt */
    }

    #gameCanvas {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    /* Larger Touch Targets */
    .menu-btn {
        padding: 20px 40px;
        font-size: 16px;
    }

    /* Adjust UI Overlay for Mobile */
    #ui-layer {
        width: 100%;
        height: 100%;
    }

    /* Ensure menus are centered */
    #main-menu-screen,
    #name-input-screen,
    #instructions-screen,
    #leaderboard-screen {
        padding: 10px;
    }
}