/* Base sizing so the CRT overlay always covers the viewport */
html,body{height:100%;   overflow-x: hidden;    }

/* Hide numerical spinners (mobile Safari) */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button{display:none}

/* ----------------- ENHANCED CRT EFFECT ----------------- */

/* CRT Screen Container - curved edges and phosphor effect */
.crt-screen {
    position: relative;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #001100 0%, #000800 50%, #000400 100%);
    border-radius: 20px;
    overflow: hidden; /* Changed from auto to hidden */
    transform: perspective(1000px) rotateX(1deg);
    box-shadow:
    inset 0 0 100px rgba(0,255,0,0.1),
    inset 0 0 200px rgba(0,255,0,0.05),
    0 0 50px rgba(0,255,0,0.3);
}

/* Screen curvature effect */
.crt-content {
    position: absolute;
    inset: 15px;
    border-radius: 15px;
    overflow: hidden; /* Changed from auto to hidden */
    transform: perspective(800px) rotateY(0deg);
    background:
    radial-gradient(circle at 50% 50%, rgba(0,255,0,0.03) 0%, transparent 50%),
    linear-gradient(180deg, transparent 0%, rgba(0,255,0,0.02) 50%, transparent 100%);
}

/* Enhanced phosphor glow with color bleeding */
.glow {
    text-shadow: 
    0 0 2px #00ff00,
    0 0 4px #00ff00,
    0 0 8px #00ff00,
    0 0 12px #00aa00,
    0 0 16px #008800;
    filter: blur(0.3px);
}

/* Scanlines with varying intensity */
.crt-content::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    rgba(0,255,0,0.03) 1px,
    rgba(0,255,0,0.08) 2px,
    transparent 3px,
    transparent 4px
    );
    animation: scanlines 0.1s linear infinite;
    z-index: 10;
}

/* Style for the command input field */
#cmd {
    min-width: 1ch; /* Ensures input is at least 1 character wide when empty */
    /* width: auto; /* width will be set by JS, auto can be a fallback if JS fails */
}

/* Moving scanlines */
@keyframes scanlines {
    0% { transform: translateY(0px); }
    100% { transform: translateY(4px); }
}

/* Flicker overlay with phosphor persistence */
.crt-content::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: 
    radial-gradient(ellipse at 30% 20%, rgba(0,255,0,0.1) 0%, transparent 40%),
    radial-gradient(ellipse at 70% 80%, rgba(0,255,0,0.08) 0%, transparent 30%),
    linear-gradient(90deg, transparent 0%, rgba(0,255,0,0.02) 50%, transparent 100%);
    mix-blend-mode: screen;
    opacity: 0.6;
    /* animation: crtFlicker 0.25s ease-in-out infinite alternate; */
    z-index: 20;
}

@keyframes crtFlicker {
    0% { 
    opacity: 0.4;
    transform: scale(1.001) translate(0.1px, 0.05px);
    }
    25% { 
    opacity: 0.65;
    transform: scale(1.0005) translate(-0.05px, 0.1px);
    }
    50% { 
    opacity: 0.5;
    transform: scale(1.002) translate(0.08px, -0.05px);
    }
    75% { 
    opacity: 0.7;
    transform: scale(0.9998) translate(-0.1px, 0.08px);
    }
    100% { 
    opacity: 0.45;
    transform: scale(1.001) translate(0.05px, -0.1px);
    }
}

/* Terminal content with enhanced effects */
.terminal-content {
    position: relative;
    height: 100%;
    z-index: 5;
    background: transparent;
    animation: phosphorGlow 2s ease-in-out infinite alternate;
}

@keyframes phosphorGlow {
    0% { filter: brightness(1) contrast(1.05); }
    100% { filter: brightness(1.02) contrast(1.1); }
}

/* Enhanced text rendering with color fringing */
.crt-text {
    position: relative;
    color: #00ff00;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.crt-text::before {
    content: attr(data-text);
    position: absolute;
    left: -0.5px;
    top: 0;
    color: #ff0040;
    opacity: 0.3;
    z-index: -1;
    filter: blur(0.5px);
}

.crt-text::after {
    content: attr(data-text);
    position: absolute;
    left: 0.5px;
    top: 0;
    color: #0080ff;
    opacity: 0.3;
    z-index: -1;
    filter: blur(0.5px);
}

/* Beam effect for active line */
.active-line {
    position: relative;
    background: linear-gradient(90deg, 
    rgba(0,255,0,0.05) 0%, 
    rgba(0,255,0,0.1) 50%, 
    rgba(0,255,0,0.05) 100%);
    animation: beamSweep 3s ease-in-out infinite;
}

@keyframes beamSweep {
    0%, 100% { background-position: -100% 0; }
    50% { background-position: 100% 0; }
}

/* Cursor with enhanced glow */
.crt-cursor {
    animation: cursorBlink 1s step-end infinite, cursorGlow 2s ease-in-out infinite alternate;
    background: #00ff00;
    width: 2px;
    height: 1em;
    display: inline-block;
    margin-left: 2px;
    box-shadow: 
    0 0 4px #00ff00,
    0 0 8px #00ff00,
    0 0 12px #00aa00;
}

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

@keyframes cursorGlow {
    0% { box-shadow: 0 0 2px #00ff00, 0 0 2px #00ff00, 0 0 2px #00aa00; }
    100% { box-shadow: 0 0 2px #00ff00, 0 0 2px #00ff00, 0 0 2px #00aa00; }
}

/* Power button effect */
.power-indicator {
    position: absolute;
    top: 10px;
    right: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #00ff00;
    box-shadow: 
    0 0 6px #00ff00,
    inset 0 0 3px rgba(255,255,255,0.3);
    animation: powerPulse 3s ease-in-out infinite;
    z-index: 30;
}

@keyframes powerPulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Static noise overlay */
.static-noise {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.02;
    background-image: 
    radial-gradient(circle at 20% 30%, white 1px, transparent 2px),
    radial-gradient(circle at 80% 60%, white 1px, transparent 2px),
    radial-gradient(circle at 40% 80%, white 1px, transparent 2px);
    background-size: 50px 50px, 30px 30px, 40px 40px;
    animation: staticMove 0.1s linear infinite;
    z-index: 15;
}

@keyframes staticMove {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-1px, 1px); }
    50% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, -1px); }
    100% { transform: translate(1px, 1px); }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .crt-screen {
    border-radius: 10px;
    transform: perspective(800px) rotateX(0.5deg);
    }
    
    .crt-content {
    inset: 8px;
    border-radius: 8px;
    }
    
    .glow {
    text-shadow: 
        0 0 2px #00ff00,
        0 0 2px #00ff00,
        0 0 2px #00aa00;
    }
}