:root {
    --bg-color: #050510;
    --lane-color: rgba(255, 255, 255, 0.03);
    --lane-border: rgba(255, 255, 255, 0.1);
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-green: #00ff9d;
    --neon-yellow: #ffea00;
    --text-color: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

#game-window-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#video-background {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.3);
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

#visualizer-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Above video(0), below game(auto/flex item but game cont has z-index? no, but canvas inside has 1) */
    /* Wait, game-container is flex item. z-index defaults to auto.
       Video is 0 (absolute). Visualizer 1 (absolute).
       Game container should be higher.
    */
    pointer-events: none;
    mix-blend-mode: overlay;
    /* Adapt colors */
}

body {
    background-color: var(--bg-color);
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 600px;
    height: 100vh;
    /* Gradient: Black (top) -> Silver (bottom) */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(192, 192, 192, 0.5) 100%);
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.1);
    border-left: 1px solid var(--lane-border);
    border-right: 1px solid var(--lane-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* UI Elements */
#score-board {
    position: absolute;
    top: 20px;
    left: 20px;
    text-align: left;
}

.score-label {
    font-size: 14px;
    opacity: 0.7;
    letter-spacing: 2px;
}

#score-value {
    font-size: 32px;
    font-weight: 900;
    text-shadow: 0 0 10px var(--neon-blue);
}

#combo-board {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    /* Hidden by default, shown when combo > 0 */
    transition: opacity 0.2s, transform 0.1s;
}

#combo-board.active {
    opacity: 1;
}

#combo-value {
    font-size: 64px;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 20px rgba(255, 234, 0, 0.5);
    line-height: 1;
}

.combo-label {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 4px;

    color: #fff;
}

#judgment-display {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 48px;
    font-weight: 900;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

.judge-perfect-plus {
    color: var(--neon-blue);
    text-shadow: 0 0 20px var(--neon-blue);
    animation: popFade 0.5s ease-out forwards;
}

.judge-perfect {
    color: var(--neon-green);
    text-shadow: 0 0 20px var(--neon-green);
    animation: popFade 0.5s ease-out forwards;
}

.judge-great {
    color: var(--neon-yellow);
    text-shadow: 0 0 20px var(--neon-yellow);
    animation: popFade 0.5s ease-out forwards;
}

.judge-miss {
    color: #ff3333;
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes popFade {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -40%) scale(0.9);
    }
}


/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: auto;
    transition: opacity 0.5s;
}

.shake {
    animation: shake 0.2s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.logo {
    font-size: 64px;
    font-weight: 900;
    margin-bottom: 20px;
    background: linear-gradient(45deg, var(--neon-blue), var(--neon-pink));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 243, 255, 0.3);
}

input[type="file"] {
    margin: 20px 0;
    padding: 10px;
    border: 1px solid var(--lane-border);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.glow-btn {
    padding: 15px 40px;
    font-size: 24px;
    font-weight: 700;
    color: white;
    background: transparent;
    border: 2px solid var(--neon-pink);
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.2);
    transition: all 0.3s;
}

.glow-btn:hover {
    background: var(--neon-pink);
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.6);
    transform: scale(1.05);
}

.glow-btn.hidden {
    display: none;
}

#countdown-number {
    font-size: 150px;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 50px white;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Controls Hint (Visual only) */
#controls-hint {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
    pointer-events: none;
}

.key-hint {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
}

/* Song Selection */
#song-selection {
    display: flex;
    gap: 20px;
    margin: 30px 0;
}

.song-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--lane-border);
    border-radius: 10px;
    padding: 20px;
    width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.song-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.song-card .song-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 5px;
    color: white;
    text-align: center;
}

.song-card .song-artist {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 15px;
    text-align: center;
}

.song-card .difficulty-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #000;
    text-transform: uppercase;
}

/* Difficulty Specific Styles */
.difficulty-normal {
    border-color: var(--neon-green);
}

.difficulty-normal:hover {
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.3);
}

.difficulty-normal .difficulty-badge {
    background: var(--neon-green);
    box-shadow: 0 0 10px var(--neon-green);
}

.difficulty-hard {
    border-color: var(--neon-yellow);
}

.difficulty-hard:hover {
    box-shadow: 0 0 20px rgba(255, 234, 0, 0.3);
}

.difficulty-hard .difficulty-badge {
    background: var(--neon-yellow);
    box-shadow: 0 0 10px var(--neon-yellow);
}

.difficulty-extreme {
    border-color: var(--neon-pink);
}

.difficulty-extreme:hover {
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

/* Results Screen */
.results-title {
    font-size: 48px;
    font-weight: 900;
    color: white;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.results-score-label {
    font-size: 16px;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 10px;
}

#results-score {
    font-size: 80px;
    font-weight: 900;
    color: var(--neon-blue);
    text-shadow: 0 0 40px var(--neon-blue);
    margin-bottom: 30px;
}

#results-medal {
    font-size: 36px;
    font-weight: 900;
    padding: 10px 40px;
    border-radius: 50px;
    background: white;
    color: black;
    margin-bottom: 40px;
    box-shadow: 0 0 30px white;
    animation: pulse 1s infinite alternate;
}

.medal-none {
    display: none;
}

.medal-gold {
    background: #FFD700;
    box-shadow: 0 0 30px #FFD700;
}

.medal-platinum {
    background: #E5E4E2;
    box-shadow: 0 0 30px #E5E4E2;
}

.medal-diamond {
    background: #B9F2FF;
    box-shadow: 0 0 30px #B9F2FF;
}

.medal-diamond-perfect {
    background: linear-gradient(45deg, #B9F2FF, #FFD700);
    box-shadow: 0 0 40px #B9F2FF;
}