* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    overflow: hidden;
    background-color: #020008;
    font-family: 'Outfit', sans-serif;
    color: white;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #2e0b3b 0%, #000000 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 1.5s ease-out;
}

.content {
    text-align: center;
    z-index: 60;
    width: 90%;
}

h1 {
    font-family: 'Great Vibes', cursive;
    font-size: 4rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #d8b4fe, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(168, 85, 247, 0.6);
    animation: float 3s ease-in-out infinite;
    line-height: 1.2;
}

p {
    font-size: 1.2rem;
    color: #e9d5ff;
    margin-bottom: 40px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

button {
    padding: 15px 40px;
    font-size: 1.3rem;
    background: rgba(138, 43, 226, 0.2);
    color: #fff;
    border: 2px solid #d8b4fe;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Great Vibes', cursive;
    transition: all 0.4s ease;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
    backdrop-filter: blur(5px);
}

button:hover {
    background: #d8b4fe;
    color: #050011;
    box-shadow: 0 0 50px rgba(168, 85, 247, 1);
    transform: scale(1.1);
}

#game-btn,
#upload-btn {
    position: absolute;
    z-index: 20;
    padding: 10px 30px;
    font-size: 1.5rem;
    opacity: 0;
    transition: opacity 1s ease;
}

/* PC Default */
#game-btn {
    bottom: 30px;
    right: 30px;
}

#upload-btn {
    bottom: 30px;
    left: 30px;
}

#file-input {
    display: none;
}

/* MINI GAME UI */
#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 0, 10, 0.95);
    /* Increased opacity for clarity */
    z-index: 30;
    display: none;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
}

#motivational-bar {
    width: 90%;
    text-align: center;
    font-family: 'Great Vibes', cursive;
    font-size: 2rem;
    color: #d8b4fe;
    min-height: 3rem;
    margin-top: 20px;
    /* Safer margin */
    margin-bottom: 5px;
    text-shadow: 0 0 10px #ba55d3;
    animation: fadeInPhrase 0.5s ease-out;
}

@keyframes fadeInPhrase {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#score-display {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: 1.5rem;
    color: #ffffff;
    opacity: 0.8;
    margin-bottom: 10px;
}

#lanes-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 70%;
    /* Reduced height slightly to avoid UI cramping */
    display: flex;
    justify-content: space-between;
    border-bottom: 3px solid #d8b4fe;
}

.lane {
    position: relative;
    width: 25%;
    height: 100%;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.key-receptor {
    position: absolute;
    bottom: 15px;
    left: 5%;
    width: 90%;
    height: 15%;
    max-height: 80px;
    border: 2px solid #d8b4fe;
    border-radius: 10px;
    background: rgba(138, 43, 226, 0.1);
    transition: transform 0.1s;
}

.key-receptor.active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 20px #fff;
    border-color: #fff;
}

.hit-glow {
    animation: glowFlash 0.3s ease-out;
}

@keyframes glowFlash {
    0% {
        background: white;
        box-shadow: 0 0 50px white;
    }

    100% {
        background: rgba(138, 43, 226, 0.1);
        box-shadow: none;
    }
}

.note {
    position: absolute;
    width: 80%;
    height: 8%;
    left: 10%;
    top: -10%;
    background: linear-gradient(to bottom, #ff69b4, #9400d3);
    border-radius: 8px;
    box-shadow: 0 0 10px #ff69b4;
    pointer-events: none;
}

.hit-sparkle {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background: radial-gradient(circle, #fff 10%, transparent 70%);
    opacity: 0;
    animation: sparkleAnim 0.4s ease-out forwards;
}

@keyframes sparkleAnim {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

#close-game {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.5);
    /* CLEARER BACKGROUND */
    border: 2px solid #d8b4fe;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    /* Force on top */
}

/* Runner Score UI */
#runner-score {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: 'Great Vibes', cursive;
    font-size: 2rem;
    color: #ffd700;
    display: none;
    text-shadow: 0 0 10px orange;
    z-index: 40;
}

#runner-msg {
    position: absolute;
    top: 50%;
    width: 100%;
    text-align: center;
    font-family: 'Outfit';
    font-size: 1.5rem;
    color: white;
    display: none;
    z-index: 40;
}

/* MOBILE OPTIMIZATIONS */
@media (max-width: 768px) {

    /* Stack buttons at bottom center */
    #upload-btn {
        left: 50%;
        transform: translateX(-50%);
        bottom: 85px;
        width: 80%;
        font-size: 1.2rem;
    }

    #game-btn {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        bottom: 25px;
        width: 80%;
        font-size: 1.5rem;
        background: #d8b4fe;
        color: #050011;
    }

    h1 {
        font-size: 3rem;
    }

    /* FIX MOBILE PHRASE OVERLAP */
    #motivational-bar {
        font-size: 1.5rem;
        margin-top: 50px;
        /* Push below close button */
        padding: 0 10px;
    }

    #close-game {
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.8);
        /* Even darker on mobile */
    }
}

@media (min-width: 768px) {
    h1 {
        font-size: 6rem;
    }

    #motivational-bar {
        font-size: 3rem;
    }

    #score-display {
        font-size: 2rem;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
        filter: brightness(1);
    }

    50% {
        transform: translateY(-15px);
        filter: brightness(1.2);
    }
}