/* ============================================
   CRT & VHS EFFECTS
   Authentic 90s Arcade Monitor Look
   ============================================ */

/* CRT Overlay Container */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
    border-radius: 4px;
}

/* Scanlines Effect - subtle VHS lines */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.03),
        rgba(0, 0, 0, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    animation: scanlineMove 10s linear infinite;
}

/* Moving scanline bar */
.scanlines::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    animation: scanlineBar 6s linear infinite;
}

/* CRT Flicker */
.crt-flicker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    animation: crtFlicker 0.1s infinite;
    opacity: 0.02;
}

/* VHS Tracking Line - moves up the screen */
.vhs-tracking {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 20%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.1) 80%,
        transparent 100%
    );
    animation: vhsTrackingLine 8s linear infinite;
    opacity: 0.6;
}

/* Second tracking line */
.vhs-tracking::before {
    content: '';
    position: absolute;
    left: 0;
    top: 100px;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    animation: vhsTrackingLine 12s linear infinite reverse;
}

/* VHS color bleed/chromatic aberration on the whole overlay */
.crt-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 0, 0, 0.02) 0%,
        transparent 10%,
        transparent 90%,
        rgba(0, 255, 255, 0.02) 100%
    );
    pointer-events: none;
}

/* Random noise flicker */
.crt-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.02;
    animation: vhsNoise 0.2s steps(10) infinite;
    pointer-events: none;
}

@keyframes vhsTrackingLine {
    0% { top: 100%; }
    100% { top: -5%; }
}

@keyframes vhsNoise {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2%, -2%); }
    20% { transform: translate(2%, 2%); }
    30% { transform: translate(-1%, 2%); }
    40% { transform: translate(2%, -1%); }
    50% { transform: translate(-2%, 1%); }
    60% { transform: translate(1%, -2%); }
    70% { transform: translate(-1%, -1%); }
    80% { transform: translate(1%, 2%); }
    90% { transform: translate(2%, -2%); }
}

/* ============================================
   VHS UI ELEMENTS
   ============================================ */

/* VHS Timestamp - bottom right */
.vhs-timestamp {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-family: 'VCR OSD Mono', 'Courier New', monospace;
    font-size: 11px;
    color: #ffffff;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
    letter-spacing: 1px;
    opacity: 0.9;
    z-index: 150;
}

/* REC indicator - top right */
.vhs-rec {
    position: absolute;
    top: 50px;
    right: 12px;
    font-family: 'VCR OSD Mono', 'Courier New', monospace;
    font-size: 12px;
    color: #ffffff;
    text-shadow: 2px 2px 0 #000;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 150;
}

.rec-dot {
    width: 10px;
    height: 10px;
    background: #ff0000;
    border-radius: 50%;
    animation: recBlink 1s infinite;
    box-shadow: 0 0 8px #ff0000;
}

@keyframes recBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* PLAY indicator - top left */
.vhs-play {
    position: absolute;
    top: 50px;
    left: 12px;
    font-family: 'VCR OSD Mono', 'Courier New', monospace;
    font-size: 12px;
    color: #ffffff;
    text-shadow: 2px 2px 0 #000;
    z-index: 150;
    opacity: 0.9;
}

/* CRT Screen Curvature (applied to cabinet-screen) */
.cabinet-screen {
    /* Barrel distortion effect */
    transform: perspective(1000px) rotateX(1deg);
}

/* Subtle vignette effect */
.cabinet-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.15) 100%
    );
    pointer-events: none;
    z-index: 101;
    border-radius: 4px;
}

/* Screen edge glow */
.cabinet-screen::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 6px;
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.25),
        inset 0 0 80px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    z-index: 102;
}

/* Phosphor Glow Effect for bright elements */
.phosphor-glow {
    filter: blur(0.5px);
    text-shadow: 0 0 2px currentColor;
}

/* RGB Split Effect (chromatic aberration) */
.rgb-split {
    position: relative;
}

.rgb-split::before {
    content: attr(data-text);
    position: absolute;
    left: -1px;
    top: 0;
    color: #ff0000;
    opacity: 0.5;
    mix-blend-mode: screen;
}

.rgb-split::after {
    content: attr(data-text);
    position: absolute;
    left: 1px;
    top: 0;
    color: #00ffff;
    opacity: 0.5;
    mix-blend-mode: screen;
}

/* ============================================
   UPSIDE DOWN MODE CRT EFFECTS
   ============================================ */

.game-container.upside-down .scanlines {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 50, 100, 0.2),
        rgba(0, 50, 100, 0.2) 1px,
        transparent 1px,
        transparent 2px
    );
}

.game-container.upside-down .crt-flicker {
    background: rgba(139, 0, 0, 0.05);
    animation: crtFlickerUD 0.05s infinite;
}

/* Upside Down additional overlay */
.game-container.upside-down::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(0, 100, 150, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(139, 0, 0, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 5;
    animation: upsideDownPulse 2s ease-in-out infinite;
}

/* Floating Particles (Spores) */
.upside-down-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 6;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(100, 150, 200, 0.5);
    border-radius: 50%;
    animation: floatParticle 4s linear infinite;
}

/* ============================================
   SCREEN SHAKE EFFECT
   ============================================ */

.game-container.screen-shake {
    animation: screenShake 0.3s ease-in-out;
}

/* ============================================
   GLITCH EFFECT (on damage)
   ============================================ */

.game-container.glitch-effect {
    animation: glitchScreen 0.2s ease-in-out;
}

.game-container.glitch-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 0, 0, 0.1) 2px,
        rgba(255, 0, 0, 0.1) 4px
    );
    animation: glitchOverlay 0.2s ease-in-out;
    pointer-events: none;
    z-index: 50;
}

/* ============================================
   STATIC NOISE EFFECT
   ============================================ */

.static-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    z-index: 60;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-size: 100px 100px;
}

.static-noise.active {
    opacity: 0.1;
    animation: staticNoise 0.1s steps(10) infinite;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes scanlineMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 100%;
    }
}

@keyframes scanlineBar {
    0% {
        top: -10%;
    }
    100% {
        top: 110%;
    }
}

@keyframes crtFlicker {
    0% { opacity: 0.02; }
    50% { opacity: 0.04; }
    100% { opacity: 0.02; }
}

@keyframes crtFlickerUD {
    0% { opacity: 0.05; background: rgba(139, 0, 0, 0.05); }
    25% { opacity: 0.1; background: rgba(0, 50, 100, 0.05); }
    50% { opacity: 0.05; background: rgba(139, 0, 0, 0.08); }
    75% { opacity: 0.08; background: rgba(0, 50, 100, 0.05); }
    100% { opacity: 0.05; background: rgba(139, 0, 0, 0.05); }
}

@keyframes vhsTracking {
    0% {
        transform: translateX(0);
        clip-path: inset(0 0 95% 0);
    }
    10% {
        transform: translateX(-5px);
        clip-path: inset(10% 0 85% 0);
    }
    20% {
        transform: translateX(3px);
        clip-path: inset(25% 0 70% 0);
    }
    30% {
        transform: translateX(-2px);
        clip-path: inset(40% 0 55% 0);
    }
    40% {
        transform: translateX(4px);
        clip-path: inset(55% 0 40% 0);
    }
    50% {
        transform: translateX(-3px);
        clip-path: inset(70% 0 25% 0);
    }
    60% {
        transform: translateX(2px);
        clip-path: inset(85% 0 10% 0);
    }
    70%, 100% {
        transform: translateX(0);
        clip-path: inset(95% 0 0 0);
    }
}

@keyframes upsideDownPulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

@keyframes floatParticle {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
        transform: translateY(90vh) translateX(10px) scale(1);
    }
    90% {
        opacity: 0.8;
        transform: translateY(10vh) translateX(-10px) scale(1);
    }
    100% {
        transform: translateY(-10vh) translateX(0) scale(0);
        opacity: 0;
    }
}

@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5px, -3px); }
    20% { transform: translate(5px, 3px); }
    30% { transform: translate(-3px, 5px); }
    40% { transform: translate(3px, -5px); }
    50% { transform: translate(-5px, 3px); }
    60% { transform: translate(5px, -3px); }
    70% { transform: translate(-3px, -5px); }
    80% { transform: translate(3px, 5px); }
    90% { transform: translate(-5px, -3px); }
}

@keyframes glitchScreen {
    0% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
    20% {
        transform: translate(-3px, 2px);
        filter: hue-rotate(90deg);
    }
    40% {
        transform: translate(3px, -2px);
        filter: hue-rotate(180deg);
    }
    60% {
        transform: translate(-2px, -3px);
        filter: hue-rotate(270deg);
    }
    80% {
        transform: translate(2px, 3px);
        filter: hue-rotate(360deg);
    }
    100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
}

@keyframes glitchOverlay {
    0%, 100% {
        opacity: 0;
        transform: translateX(0);
    }
    25% {
        opacity: 1;
        transform: translateX(-10px);
    }
    50% {
        opacity: 0.5;
        transform: translateX(10px);
    }
    75% {
        opacity: 1;
        transform: translateX(-5px);
    }
}

@keyframes staticNoise {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -5%); }
    20% { transform: translate(5%, 5%); }
    30% { transform: translate(-10%, 5%); }
    40% { transform: translate(10%, -5%); }
    50% { transform: translate(-5%, 10%); }
    60% { transform: translate(5%, -10%); }
    70% { transform: translate(-10%, -5%); }
    80% { transform: translate(10%, 5%); }
    90% { transform: translate(-5%, -10%); }
    100% { transform: translate(5%, 10%); }
}

/* ============================================
   POWER-UP VISUAL EFFECTS
   ============================================ */

/* Eleven Mode Purple Glow */
.eleven-active .game-container {
    box-shadow:
        inset 0 0 100px rgba(255, 0, 128, 0.3),
        inset 0 0 50px rgba(128, 0, 255, 0.2);
}

/* Slow Effect (Mind Flayer) */
.game-container.slowed {
    filter: blur(1px) brightness(0.8);
}

.game-container.slowed::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 4;
}

/* ============================================
   SCREEN TRANSITIONS
   ============================================ */

.screen {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.fade-out {
    opacity: 0;
    transform: scale(0.95);
}

.screen.fade-in {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   TOUCH FEEDBACK
   ============================================ */

.control-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.1s, height 0.1s;
}

.control-btn:active::after {
    width: 100%;
    height: 100%;
}
