:root {
    --neon-blue: #00f2ff;
    --neon-pink: #ff00ff;
    --dark-bg: #0a0a0c;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--dark-bg);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Fullscreen Background Menu */
#main-menu {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.5)),
        url('img/bg.png') no-repeat center center;
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Pushes logo up and button down */
    align-items: center;
    padding: 100px 0;
    transition: opacity 0.8s ease, visibility 0.8s;
}

.logo-area {
    text-align: center;
    pointer-events: none;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    background-color: #0a0a0c;
    background-image:
        linear-gradient(rgba(0, 242, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 242, 255, 0.05) 1px, transparent 1px);
    background-size: 100px 100px;
}

#ui-layer {
    position: absolute;
    inset: 0;
    z-index: 50;
    pointer-events: none;
}

.ui-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* HUD Styling */
.stats {
    position: absolute;
    top: 30px;
    left: 30px;
    font-weight: 900;
    font-size: 1.5rem;
    color: white;
    text-shadow: 2px 2px 0px black;
}

.speedometer {
    position: absolute;
    bottom: 40px;
    right: 40px;
    font-size: 3rem;
    font-weight: 900;
    color: white;
    border-bottom: 5px solid var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue);
}

/* Menu Text & Button */
h1 {
    font-size: 5rem;
    letter-spacing: 15px;
    margin: 0;
    color: white;
    text-shadow: 0 0 20px var(--neon-pink);
}

h1 span {
    color: var(--neon-blue);
}

p {
    color: white;
    letter-spacing: 5px;
    font-weight: 300;
}

.menu-btn {
    padding: 20px 60px;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid var(--neon-blue);
    color: var(--neon-blue);
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
    pointer-events: auto;
    text-transform: uppercase;
}

.menu-btn:hover {
    background: var(--neon-blue);
    color: black;
    box-shadow: 0 0 40px var(--neon-blue);
    transform: scale(1.1);
}

/* Countdown Visuals */
#countdown-overlay {
    background: rgba(0, 0, 0, 0.7);
    z-index: 60;
}

.lights-box {
    display: flex;
    gap: 25px;
    background: #1a1a1a;
    padding: 25px 50px;
    border-radius: 100px;
    border: 5px solid #333;
}

.light {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #000;
    border: 4px solid #222;
}

.light.active-red {
    background: #ff4757;
    box-shadow: 0 0 40px #ff4757, inset 0 0 15px white;
}

.light.active-green {
    background: #2ed573;
    box-shadow: 0 0 50px #2ed573, inset 0 0 15px white;
}

#countdown-text {
    font-size: 10rem;
    margin-top: 20px;
    text-shadow: 0 0 30px var(--neon-blue);
}


.exit-btn:hover {
    background: #ff4757;
    color: white;
    box-shadow: 0 0 15px #ff4757;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Allows clicking THROUGH the transparent layer to the canvas */
    z-index: 10;
}

/* Ensure the button itself RE-ENABLES pointer events */
.exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    pointer-events: auto;
    z-index: 1000;
    background: #ff4757;
    color: white;
    padding: 10px 25px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

/* HUD Stats Panel */
.hud-stats {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hud-stat {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--neon-blue);
    color: white;
    font-size: 1.1rem;
    font-weight: 900;
    padding: 6px 16px;
    letter-spacing: 2px;
    border-radius: 4px;
    text-shadow: 0 0 8px var(--neon-blue);
    min-width: 110px;
}

.hud-stat span {
    color: var(--neon-blue);
}

/* Result Overlays (Level Complete / Game Over) */
.result-overlay {
    background: rgba(0, 0, 0, 0.82);
    z-index: 80;
    pointer-events: auto;
}

.result-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 60px 80px;
    border-radius: 16px;
    border: 3px solid;
    animation: result-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes result-pop {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.win-box  { border-color: var(--neon-blue); box-shadow: 0 0 60px rgba(0,242,255,0.3); background: rgba(0,20,30,0.9); }
.lose-box { border-color: #ff4757;          box-shadow: 0 0 60px rgba(255,71,87,0.3);  background: rgba(30,0,10,0.9); }

.result-flag { font-size: 5rem; line-height: 1; }

.result-title {
    font-size: 3rem;
    margin: 0;
    letter-spacing: 6px;
    text-transform: uppercase;
}

.win-title  { color: var(--neon-blue); text-shadow: 0 0 20px var(--neon-blue); }
.lose-title { color: #ff4757;          text-shadow: 0 0 20px #ff4757; }

.result-sub {
    color: rgba(255,255,255,0.75);
    font-size: 1.1rem;
    letter-spacing: 2px;
    margin: 0;
}

.result-btn {
    margin-top: 10px;
    font-size: 1.2rem;
    padding: 16px 50px;
}

.retry-btn-style {
    border-color: #ff4757;
    color: #ff4757;
    box-shadow: 0 0 20px rgba(255,71,87,0.4);
}

.retry-btn-style:hover {
    background: #ff4757;
    color: white;
    box-shadow: 0 0 40px #ff4757;
}