body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    /* Fondo blanco para que coincida con la nueva imagen */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    font-family: sans-serif;
}

.monitor-wrapper {
    position: relative;
    /* Para que los porcentajes coincidan siempre con la foto del monitor,
       el contenedor debe ser SIEMPRE un cuadrado perfecto (aspect-ratio 1:1)
       independientemente de si la pantalla es panorámica o vertical. */
    width: 100vmin;
    height: 100vmin;
    /* dvmin es más preciso en móviles modernos para evitar barras de navegación */
    width: 100dvmin;
    height: 100dvmin;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Fondo negro que se quedará visible cuando la pantalla "se apague" y encoja */
.monitor-wrapper::before {
    content: "";
    position: absolute;
    /* Mismos valores que el .screen-container para que tape el agujero del monitor */
    top: 13%;
    left: 14%;
    width: 73%;
    height: 57%;
    background-color: #050505;
    z-index: 0;
}

/* El monitor transparente se pone POR ENCIMA del iframe */
.monitor-wrapper::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('monitor.png') center/contain no-repeat;
    pointer-events: none;
    /* Permite clics al iframe */
    z-index: 10;
}

.screen-container {
    position: absolute;
    /* Estos porcentajes pueden necesitar ajuste para cuadrar exactamente con la pantalla de la foto */
    top: 13%;
    left: 14%;
    width: 73%;
    height: 57%;
    background-color: #111;
    /* Quitamos el border-radius rígido porque ahora el marco transparente del PNG
       es el que da la forma redondeada y abombada a las esquinas y bordes. */
    border-radius: 0;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 1);
    z-index: 1;
    /* Transformación para dar algo de profundidad */
    transform: perspective(700px);
}

iframe {
    /* Efecto "Zoom out" para que quepa más contenido.
       Un factor de 0.8 = 80%. Para compensar, el tamaño real debe ser 100 / 0.8 = 125%.
       Si quieres más zoom (ej. 0.75), pon width/height a 133.3% y scale(0.75). */
    width: 125%;
    height: 125%;
    transform: scale(0.8);
    transform-origin: top left;
    border: none;
    border-radius: inherit;
}

/* Efectos CRT: Scanlines */
.scanlines {
    position: absolute;
    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.2) 50%,
            rgba(0, 0, 0, 0.2));
    background-size: 100% 2px;
    pointer-events: none;
    /* Permite hacer clic en el iframe */
    z-index: 2;
    border-radius: inherit;
}


/* Efectos CRT: Brillo interior (Vignette) y tintado */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    z-index: 3;
    border-radius: inherit;
}

/* Parpadeo sutil */
.screen-container::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    z-index: 4;
    pointer-events: none;
    animation: flicker 0.20s infinite;
}

@keyframes flicker {
    0% {
        opacity: 0.05;
    }

    50% {
        opacity: 0.01;
    }

    100% {
        opacity: 0.06;
    }
}

/* Botón oculto para salir del modo retro */
.power-button {
    position: absolute;
    /* Ajusta estos porcentajes para colocar el enlace exactamente sobre el botón de POWER de la imagen */
    bottom: 16.5%;
    left: 47.5%;
    width: 4%;
    height: 3%;
    z-index: 20;
    /* Tiene que estar por encima de todo */
    cursor: pointer;
    border-radius: 5px;
}

/* Animación de apagado CRT */
@keyframes crt-off {
    0% {
        transform: perspective(700px) scale(1, 1);
        filter: brightness(1);
    }

    60% {
        transform: perspective(700px) scale(1, 0.005);
        filter: brightness(10);
    }

    100% {
        transform: perspective(700px) scale(0, 0.005);
        filter: brightness(10);
        opacity: 0;
    }
}

.screen-container.off {
    animation: crt-off 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* Animación de encendido CRT (Inversa) */
@keyframes crt-on {
    0% {
        transform: perspective(700px) scale(0, 0.005);
        filter: brightness(10);
        opacity: 0;
    }

    40% {
        transform: perspective(700px) scale(1, 0.005);
        filter: brightness(10);
        opacity: 1;
    }

    100% {
        transform: perspective(700px) scale(1, 1);
        filter: brightness(1);
        opacity: 1;
    }
}

.screen-container.on {
    animation: crt-on 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
/* Estado apagado por defecto para que no haya flashazos antes de encender */
.screen-container.off-state {
    opacity: 0;
    transform: perspective(700px) scale(0, 0.005);
}
