html,
body {
    margin: 0;
    padding: 0;
    background-color: #000000;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 10px;
}

/* Envoltorio que toma las dimensiones exactas que adopte el canvas */
.canvas-wrapper {
    position: relative;
    height: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

canvas {
    background-color: #333;
    border: 3px solid #334466;
    border-radius: 12px;
    box-sizing: border-box;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Capa transparente justo encima del canvas */
.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Permite que los clics atraviesen al canvas en áreas vacías */
    box-sizing: border-box;
}

/* Estilo base para cada una de las 4 zonas */
.zone {
    position: absolute;
    pointer-events: auto;
    /* Habilita interacción/clics dentro de la zona */
    padding: 1px;
    background: rgb(0 0 0 / 18%);
    /* Fondo semitransparente de prueba */
    color: #fff;
    font-family: sans-serif;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Posicionamiento y fondo en la esquina superior izquierda */
.zone-top-left {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 600px;
    height: 120px;
    background-image: url(../img/bg_invecincible.webp);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border: 12px solid #0000ff00;
    padding: 10px;
}

/* ESTE ES EL CONTENEDOR QUE DEBEMOS MOVER */
#bar_invenible {
    position: absolute;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    top: 44%;
    left: 36%;
    width: 52%;
    height: 32%;
    /* border: 2px solid lime; */
    overflow: hidden;
}

/* Lista limpia dentro del hueco */
.bonus {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    /* Distribuye los 4 ítems uniformemente */
    justify-content: space-evenly;
    flex-direction: row;
}

/* Cada ranura para el ítem */
.iten_bonus {
    /* Ocupa un espacio proporcional (1/4 del total si hay 4) */
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    /* border: 1px solid rgba(255,255,255,0.3); /* Ayuda a ver las ranuras */
}

/* Ajuste de las imágenes de los ítems */
.iten_bonus img {
    display: block;
    /* La imagen se escala para caber en su ranura sin deformarse */
    max-width: 98%;
    max-height: 98%;
    object-fit: contain;
}

.zone-top-right {
    top: 15px;
    right: 15px;
}

.puntos {
    background-color: #ffffff4f;
    padding: 35px;
    align-content: center;
    min-width: 160px;
    border-radius: 5px;
    line-height: 0;
}

#puntos-value {
    font-size: 60px;
    font-weight: 100;
    color: #fdfa45;
    text-shadow: 2px 2px #0c0a0a;
    font-family: 'Jersey 10';
}

#puntos-value::before {
    background-image: url(../img/moneda_puntos.webp);
    content: "  ";
    display: inline-block;
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    /* margin-right: 13px; */
    vertical-align: middle;
    margin-bottom: 0px;
}

.zone-bottom-left {
    bottom: 15px;
    left: 15px;
}

/* El contenedor define las dimensiones fijas del icono de gasolina */
.gasolina {
    position: relative;
    width: 150px;
    height: 150px;
}

/* La garrafa se posiciona arriba con z-index alto */
.garrafa {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
    /* Por encima de la barra */
    pointer-events: none;
}

/* El fondo de la barra se ajusta al área donde está el líquido */
.bar-bg {
    position: absolute;
    top: 38%;
    left: 23%;
    width: 53%;
    height: 49%;
    z-index: 1;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

/* La barra de líquido sube y baja ajustando la propiedad height */
#health-bar {
    width: 100%;
    height: 100%;
    /* Este % lo modificarás desde JavaScript (ej. 50%) */
    background-color: #afab22;
    transition: height 0.2s ease-out;
    /* Transición suave de altura */
    border-radius: 2px;
}

.zone-bottom-right {
    bottom: 15px;
    right: 15px;

}

#oil_out {
    display: none;
    position: absolute;
    top: 30%;
    z-index: 100;
    pointer-events: none;
    flex-direction: column;
    background-color: #ffffff73;
    padding: 61px;
    color: #ff0000;
    font-family: 'JERSEY 10';
    font-size: 50px;
    background-image: url(../img/oilOut.webp);
    background-repeat: no-repeat;
    background-position-x: center;
    background-size: contain;
    border-radius: 10px;
}

img#animacion-victoria {
    position: absolute;
    top: 48%;
    width: 428px;
    z-index: 9999999999999999;
    color: #fff;
    text-align: center;
    left: 21%;
    z-index: 1;
}
#felicidades{

    position: absolute;
    top: 20%;
    width: 428px;
    z-index: 9999999999999999;
    color: #fff;
    text-align: center;
    left: 50%;
    z-index: 1;

}
.destello_rojo {
    background: #0091ff;
    background: radial-gradient(circle, rgba(0, 145, 255, 0) 0%, rgba(255, 0, 0, 0.37) 56%);
    z-index: 9999999999999999;
    color: #fff;
    text-align: center;
    animation: destello 1.2s infinite;
}

@keyframes destello {

    0%,
    100% {
        box-shadow: 0 0 0px rgba(255, 0, 0, 0);
    }

    50% {
        box-shadow: 0 0 20px 5px rgba(255, 0, 0, 0.39);
    }
}


/* Animación de vibración */
@keyframes vibrar {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-5px, 5px);
    }

    40% {
        transform: translate(-5px, -5px);
    }

    60% {
        transform: translate(5px, 5px);
    }

    80% {
        transform: translate(5px, -5px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* Clase que aplica la vibración */
.vibrando {
    animation: vibrar 0.12s infinite;
}



/* Animación de vibración */
@keyframes invencible {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-5px, 5px);
    }

    40% {
        transform: translate(-5px, -5px);
    }

    60% {
        transform: translate(5px, 5px);
    }

    80% {
        transform: translate(5px, -5px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* Clase que aplica la vibración */
.invencible {
    animation: invencible 3s infinite;
    background: #2a9b4c;
    background: radial-gradient(circle, rgba(42, 155, 76, 0) 0%, rgba(0, 255, 170, 0.36) 56%);
    z-index: 9999999999999999;

}

.vibrar_colision_destroyed {
    animation:
        vibracion_destroyed 0.01s
        /* Duración de un ciclo rápido de vibración */
        ease-in-out infinite;
    /* Vibra de forma continua dentro del tiempo total */
    animation-iteration-count: 20;
    /* 10 veces de 0.2s = exactamente 2 segundos */
}

@keyframes vibracion_destroyed {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}


/* Contenedor principal para mantener todo en su sitio */
.crt-wrapper {
    position: relative;
    display: inline-block;
    overflow: hidden;
    /* Opcional: Curvatura de los bordes para simular un monitor viejo */
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8) inset;
    aspect-ratio: 4 / 3;
}

/* La capa mágica del filtro */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* ¡Crucial para poder jugar! */
    aspect-ratio: 4 / 3;
    /* Efecto de Scanlines (líneas horizontales) */
    background: linear-gradient(to bottom,
            rgba(7, 7, 7, 0.308),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.25) 50%,
            rgba(0, 0, 0, 0.25));
    background-size: 100% 4px;
    /* Ajusta el 4px para cambiar el grosor de las líneas */

    /* Sombra interior para oscurecer los bordes (Vignette) */
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);

    /* Animación de parpadeo */
    animation: flicker 0.15s infinite;
}

/* Animación sutil de parpadeo de pantalla */
@keyframes flicker {
    0% {
        opacity: 0.94;
    }

    100% {
        opacity: 1;
    }
}

canvas {
    filter: contrast(1.1) brightness(1.09);
}