/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #050510;
    color: #e0e0e0;
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
    height: 100dvh;
    /* Use dynamic viewport height for mobile */
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    user-select: none;
    -webkit-user-select: none;
    /* Mobile Safari */
}

/* On mobile, canvas fills screen better */
#game-container {
    position: relative;
    /* responsive mapping */
    width: 100vw;
    height: 100dvh;
    max-width: calc(100dvh * (16 / 9));
    /* limit width if screen is super wide */
    max-height: calc(100vw * (9 / 16));
    /* limit height if screen is super tall */

    border: 2px solid #00f0ff;
    background: #0a0a0e;
    overflow: hidden;
    /* Prevent default touch actions like double-tap zoom ONLY in game area */
    touch-action: none;
}

@media (max-width: 820px) {
    #game-container {
        border: none;
        /* Removed max overrides to strictly maintain local 16:9 rendering */
    }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* ensure proper scaling algorithm without blur depending on browser support */
    image-rendering: pixelated;
    object-fit: fill;
    /* GPU acceleration hints: force layer promotion */
    will-change: transform;
    transform: translateZ(0);
}

/* UI Elements */
.game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    z-index: 10;
    pointer-events: none;
    font-size: 18px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}

@media (max-width: 600px) {
    .game-ui {
        padding: 5px 10px;
        font-size: 12px;
    }
}

.label {
    color: #ff0099;
    margin-right: 10px;
    text-shadow: 0 0 5px #ff0099;
}

#score,
#hi-score,
.value {
    color: #00f0ff;
    text-shadow: 0 0 5px #00f0ff;
}

/* Overlays (Start/End Screens) */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: none;
    z-index: 20;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    padding: 40px 0;
    backdrop-filter: blur(5px);
}

.overlay.active {
    display: block;
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 64px;
    font-weight: 900;
    letter-spacing: 5px;
    margin-bottom: 10px;
    color: #f9d71c;
    text-shadow: 3px 3px 0px #ff0099, -3px -3px 0px #00f0ff;
    position: relative;
}

@media (max-width: 600px) {
    h1 {
        font-size: 32px;
        letter-spacing: 2px;
        text-shadow: 2px 2px 0 #cc00cc;
    }

    .subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .blink {
        font-size: 14px;
    }
}

.subtitle {
    font-size: 24px;
    color: #00f0ff;
    margin-bottom: 40px;
    letter-spacing: 2px;
}

.blink {
    animation: blink 1s infinite;
    font-size: 18px;
    color: #fff;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* CRT Scanlines Effect */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.1) 50%,
            rgba(0, 0, 0, 0.1));
    background-size: 100% 4px;
    z-index: 99;
    pointer-events: none;
    opacity: 0.6;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.9);
    z-index: 98;
    pointer-events: none;
}

/* Glitch Animation for Title */
.glitch {
    animation: glitch 3s infinite;
}

@keyframes glitch {
    0% {
        transform: translate(0);
        text-shadow: 3px 3px 0px #ff0099, -3px -3px 0px #00f0ff;
    }

    2% {
        transform: translate(-2px, 2px);
        text-shadow: -3px 3px 0px #ff0099, 3px -3px 0px #00f0ff;
    }

    4% {
        transform: translate(2px, -2px);
        text-shadow: 3px -3px 0px #ff0099, -3px 3px 0px #00f0ff;
    }

    6% {
        transform: translate(0);
        text-shadow: 3px 3px 0px #ff0099, -3px -3px 0px #00f0ff;
    }

    100% {
        transform: translate(0);
        text-shadow: 3px 3px 0px #ff0099, -3px -3px 0px #00f0ff;
    }
}

/* Ensure canvas looks pixelated if scaling */
canvas {
    image-rendering: pixelated;
}

/* Mobile Controls Styling */
#mobile-controls {
    display: none;
    /* Hidden by default on desktop */
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 0;
    /* Container itself shouldn't block view, buttons will float */
    z-index: 100;
    padding: 0 20px;
    pointer-events: none;
    /* Let touches pass through the container to the game */
}

/* Show on touch devices or small screens (including landscape phones) */
@media (hover: none) and (pointer: coarse),
(max-width: 1024px),
(max-height: 600px) {
    #mobile-controls {
        display: flex;
        justify-content: flex-end;
        /* Right align the JUMP button */
        align-items: flex-end;
        height: 100px;
        /* Give space for buttons */
        bottom: 10px;
    }
}

.cyber-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #00f0ff;
    color: #00f0ff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    padding: 10px 15px;
    border-radius: 5px;
    box-shadow: 0 0 10px #00f0ff;
    text-shadow: 0 0 5px #00f0ff;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    /* Prevent scroll/zoom on button drag */
    pointer-events: auto;
    /* Re-enable pointer events for the buttons */
}

.cyber-btn:active {
    background: #00f0ff;
    color: #000;
}

.cyber-btn.big {
    font-size: 24px;
    padding: 20px 40px;
    border-color: #ff0099;
    color: #ff0099;
    box-shadow: 0 0 15px #ff0099;
}

.cyber-btn.big:active {
    background: #ff0099;
    color: #000;
}