html, body { height: 100%; }
body {
    margin: 0;
    display: flex;
    flex-direction: column;
    background: #000;
    color: #00ff00;
    font-family: "Courier New", monospace;
    background-image: repeating-linear-gradient(
            to bottom,
            rgba(0,255,0,0.05) 0 2px,
            transparent 2px 4px
    );
}

#screen {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    line-height: 1.35;
    transition: transform 0.03s;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 0, 0.3) transparent;
}

#input-line {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid rgba(0,255,0,0.2);
}
.prompt::after { content: ">"; margin-right: .5rem; }
#cmd {
    flex: 1;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

#screen a {
    color: inherit;
    text-decoration: none;
}

#screen a:hover,
#screen a:focus {
    font-weight: bold;
    text-decoration: none;
    filter: brightness(1.3);
    outline: none;
}

#screen::-webkit-scrollbar {
    width: 8px;
}

#screen::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

#screen::-webkit-scrollbar-thumb {
    background-color: rgba(0, 255, 0, 0.3);
    border-radius: 4px;
}

#screen::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 255, 0, 0.5);
}

#screen {
    max-height: calc(100vh - 100px);
}

#screen {
    position: relative;
}

#screen::before,
#screen::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    mix-blend-mode: screen;
}

#screen::before {
    background: repeating-linear-gradient(
            to bottom,
            rgba(255, 0, 0, 0.08) 0 2px,
            rgba(0, 255, 255, 0.08) 2px 4px
    );
    clip-path: inset(0 0 0 0);
}

#screen::after {
    background: repeating-linear-gradient(
            90deg,
            rgba(0,0,0,0) 0 3px,
            rgba(255,255,255,0.04) 3px 4px
    );
    filter: hue-rotate(20deg) saturate(1.5);
    transform: translate(0,0);
}

body.glitch-active #screen {
    animation: crt-glitch-jitter 120ms steps(2,end) infinite;
}

body.glitch-active #screen::before {
    opacity: .35;
    animation: crt-scanshift 60ms steps(2,end) infinite;
}

body.glitch-active #screen::after {
    opacity: .22;
    animation: crt-rgbsplit 80ms steps(2,end) infinite;
}

@keyframes crt-glitch-jitter {
    0%   { transform: translate(0,0) skew(0deg); }
    20%  { transform: translate(-2px,1px) skewX(1deg); }
    40%  { transform: translate(2px,-1px) skewY(-1deg); }
    60%  { transform: translate(-1px,2px); }
    80%  { transform: translate(1px,-2px) skew(-0.5deg); }
    100% { transform: translate(0,0); }
}

@keyframes crt-scanshift {
    0%   { clip-path: inset(0 0 60% 0); }
    50%  { clip-path: inset(40% 0 0 0); }
    100% { clip-path: inset(0 0 0 0); }
}

@keyframes crt-rgbsplit {
    0%   { transform: translate(0,0); }
    33%  { transform: translate(-2px,0); }
    66%  { transform: translate(2px,0); }
    100% { transform: translate(0,0); }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    #screen {
        padding: 0.5rem;
        font-size: 14px;
        line-height: 1.4;
    }
    
    #input-line {
        padding: 0.5rem;
        position: sticky;
        bottom: 0;
        background: #000;
        border-top: 2px solid rgba(0,255,0,0.3);
    }
    
    #cmd {
        font-size: 16px;
        -webkit-appearance: none;
    }
    
    #screen a {
        padding: 2px 0;
        display: inline-block;
        min-height: 20px;
    }
    
    #screen::-webkit-scrollbar {
        width: 12px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 12px;
    }
    
    #screen {
        padding: 0.25rem;
        font-size: 12px;
    }
    
    .prompt::after {
        margin-right: 0.25rem;
    }
}

