@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&display=swap');

:root {
    --ink: #040406;
    --night: #06070d;
    --blood: #ff2740;
    --toxic: #9be301;
    --muted: #c9c9c9;
    --hud-bg: rgba(7, 10, 16, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: 'Oswald', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 20% 20%, #220b18 0%, #08090f 50%, #010103 100%);
    overflow: hidden;
    position: relative;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    color: #f5f5f5;
    letter-spacing: 0.03em;
}

#ui {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: hidden;
}

#backdropFX {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

#backdropFX .grid,
#backdropFX .vignette,
#backdropFX .embers {
    position: absolute;
    inset: 0;
}

#backdropFX .grid {
    background-image: linear-gradient(rgba(255, 38, 91, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(132, 237, 74, 0.07) 1px, transparent 1px);
    background-size: 120px 120px;
    transform: perspective(400px) rotateX(65deg);
    transform-origin: top;
    filter: blur(1px);
    opacity: 0.55;
    animation: gridPan 30s linear infinite;
}

#backdropFX .vignette {
    background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
    mix-blend-mode: soft-light;
}

#backdropFX .embers {
    background: radial-gradient(circle at 10% 20%, rgba(255, 35, 59, 0.35), transparent 50%),
        radial-gradient(circle at 80% 10%, rgba(155, 227, 1, 0.3), transparent 45%),
        radial-gradient(circle at 60% 80%, rgba(255, 96, 55, 0.25), transparent 55%);
    animation: emberDrift 24s ease-in-out infinite;
    opacity: 0.5;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 2rem;
    z-index: 10;
    pointer-events: none;
    flex-wrap: wrap;
}

.stat-chip {
    background: var(--hud-bg);
    padding: 0.75rem 1.2rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--toxic);
    text-shadow: 0 0 15px rgba(155, 227, 1, 0.45);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    backdrop-filter: blur(8px);
}

#lives.accent {
    color: var(--blood);
    text-shadow: 0 0 15px rgba(255, 39, 64, 0.55);
}

.stat-chip.subtle {
    color: #c7d2df;
    text-shadow: none;
    border-color: rgba(199, 210, 223, 0.25);
}

.stat-chip.lowfx {
    color: #ffb347;
    border-color: rgba(255, 179, 71, 0.5);
}

#dangerTag {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.95rem;
    color: #ff8b8b;
    border-color: rgba(255, 39, 64, 0.45);
    animation: pulse 1.4s ease-in-out infinite;
}

#arena {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 32px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.75), 0 0 45px rgba(255, 37, 75, 0.2);
}

#arenaGlow {
    position: absolute;
    inset: 0;
    border-radius: 32px;
    box-shadow: inset 0 0 75px rgba(255, 39, 64, 0.35), inset 0 0 90px rgba(155, 227, 1, 0.12);
    pointer-events: none;
    mix-blend-mode: screen;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
    background: radial-gradient(circle at center, rgba(8, 9, 12, 0.65) 0%, rgba(2, 2, 4, 0.95) 65%);
}

#audioControls {
    position: absolute;
    bottom: 1.25rem;
    right: 1.5rem;
    z-index: 20;
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    background: rgba(7, 10, 16, 0.65);
    backdrop-filter: blur(10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.05);
    pointer-events: auto;
}

#audioControls.hidden {
    opacity: 0;
    pointer-events: none;
}

#audioControls .slider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #d9d9d9;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#audioControls input[type="range"] {
    width: 120px;
    accent-color: var(--blood);
}

/* Overlays */
#overlay,
#pauseOverlay,
#gameOverOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(3, 5, 9, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    transition: opacity 0.3s ease;
    text-align: center;
    padding: 0 1.5rem;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.visible {
    opacity: 1;
    pointer-events: all;
}

#title {
    font-size: clamp(2.5rem, 5vw, 3.8rem);
    font-weight: 700;
    color: var(--blood);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 25px rgba(255, 39, 64, 0.7), 0 0 50px rgba(155, 227, 1, 0.35);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

#subtitle {
    font-size: 1.1rem;
    color: var(--muted);
    margin-bottom: 2rem;
    padding: 0 1rem;
}

#gameOverTitle {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    color: var(--blood);
    margin-bottom: 1rem;
    text-shadow: 0 0 25px rgba(255, 39, 64, 0.7);
}

#finalScore {
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 2rem;
}

button {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    background: radial-gradient(circle at 30% 20%, #ff5d3b, #930017 80%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.85rem 2.75rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.55), 0 0 25px rgba(255, 39, 64, 0.5);
    outline: none;
    touch-action: manipulation;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

button:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.65), 0 0 35px rgba(255, 39, 64, 0.6);
}

button:active {
    transform: translateY(0) scale(0.99);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55), 0 0 18px rgba(255, 39, 64, 0.5);
}

.small {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 1rem;
    text-align: center;
    padding: 0 1rem;
}

@keyframes gridPan {
    0% {
        transform: perspective(400px) rotateX(65deg) translateY(0);
    }

    100% {
        transform: perspective(400px) rotateX(65deg) translateY(200px);
    }
}

@keyframes emberDrift {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px) scale(1.04);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.65;
        filter: drop-shadow(0 0 10px rgba(255, 39, 64, 0.8));
    }

    50% {
        opacity: 1;
        filter: drop-shadow(0 0 18px rgba(255, 39, 64, 1));
    }
}

/* Mobile optimization */
@media (max-width: 768px) {
    #ui {
        padding: 1rem;
    }

    #hud {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        align-items: stretch;
        gap: 0.55rem 0.75rem;
        padding: 1rem;
        max-width: 480px;
        width: 100%;
    }

    .stat-chip {
        font-size: 1rem;
        width: 100%;
    }

    #subtitle {
        font-size: 1rem;
    }

    button {
        font-size: 1rem;
        padding: 0.75rem 2rem;
    }
}

@media (max-width: 480px) {
    #title {
        letter-spacing: 0.08em;
    }

    #subtitle {
        font-size: 0.95rem;
    }

    .stat-chip {
        font-size: 0.95rem;
    }
}