:root {
    --bg-color: #050505;
    --term-color: #00ff00; /* Vibrant Green */
    --term-dim: #008f00;
    --scan-color: rgba(0, 0, 0, 0.5);
    --glitch-color: #ff00ff;
    --font-stack: 'Courier New', Courier, monospace; /* Keeping it simple/safe */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--term-color);
    font-family: var(--font-stack);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    line-height: 1.4;
    text-shadow: 0 0 4px var(--term-dim), 0 0 8px var(--term-dim); /* Enhanced Glow */
}

/* CRT Effects */
.scanlines {
    position: fixed;
    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.3) 50%,
        rgba(0,0,0,0.3)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
    animation: scrollScanlines 10s linear infinite;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(10, 50, 10, 0) 50%, rgba(0, 0, 0, 0.9) 100%);
    pointer-events: none;
    z-index: 9;
}

/* Terminal Container */
.terminal {
    width: 95%;
    max-width: 900px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    border: 2px solid var(--term-dim);
    background: rgba(0, 20, 0, 0.3);
    position: relative;
    z-index: 1;
    box-shadow: 0 0 20px var(--term-dim), inset 0 0 20px rgba(0, 50, 0, 0.5);
    animation: flicker 0.15s infinite; /* CRT Flicker */
}

/* Typography */
header {
    border-bottom: 2px solid var(--term-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
}

h1 {
    font-size: 2rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    position: relative;
    margin-bottom: 0.5rem;
}

.status-bar {
    font-size: 0.8rem;
    display: flex;
    gap: 1.5rem;
}

.status-bar .label {
    opacity: 0.7;
}

main {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1.1rem;
    white-space: pre-wrap;
    padding-right: 1rem;
}

footer {
    margin-top: auto;
    padding-top: 2rem;
    font-size: 0.8rem;
    color: var(--term-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.sys-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--term-dim);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.legal-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-family: var(--font-stack); /* Ensure strict monospace */
    width: 100%;
    max-width: 500px;
}

.border-top, .border-bottom {
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    color: var(--term-dim);
    opacity: 0.5;
}

.legal-content {
    padding: 0.5rem 1rem;
    line-height: 1.4;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.alert {
    color: var(--term-color);
    font-weight: bold;
    animation: blinker 2s infinite;
}

.legal-content a {
    color: var(--term-color);
    text-decoration: none;
    display: inline-block;
    padding: 0 4px;
    border: 1px solid transparent;
    transition: all 0.1s;
}

.legal-content a:hover {
    background-color: var(--term-color);
    color: var(--bg-color);
    border: 1px solid var(--term-color);
    box-shadow: 0 0 5px var(--term-color);
    font-weight: bold;
    cursor: help;
}

.eof {
    align-self: flex-start;
    margin-top: 1rem;
    opacity: 0.5;
    font-size: 0.7rem;
}

/* Mobile adjustments for the ASCII borders */
@media (max-width: 600px) {
    .border-top, .border-bottom {
        font-size: 0.6rem; /* Shrink the dashes to fit better */
        letter-spacing: -1px;
    }
    .sys-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Animations */
@keyframes flicker {
    0% { opacity: 0.97; }
    50% { opacity: 1; }
    100% { opacity: 0.98; }
}

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

.blink {
    animation: blinker 1s step-end infinite;
}

.cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    background-color: var(--term-color);
    vertical-align: text-bottom;
    animation: blinker 1s step-end infinite;
}

@keyframes blinker {
    50% { opacity: 0; }
}

/* Glitch Effect */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    clip: rect(0, 0, 0, 0);
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--glitch-color);
    animation: glitch-anim-2 4s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 cyan;
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

/* Glitch keyframes retained from previous version but adjusted if needed */
@keyframes glitch-anim {
    0% { clip: rect(13px, 9999px, 88px, 0); }
    5% { clip: rect(109px, 9999px, 32px, 0); }
    10% { clip: rect(4px, 9999px, 112px, 0); }
    /* ... sparse glitching ... */
    100% { clip: rect(63px, 9999px, 91px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(65px, 9999px, 100px, 0); }
    5% { clip: rect(12px, 9999px, 7px, 0); }
    /* ... sparse glitching ... */
    100% { clip: rect(31px, 9999px, 86px, 0); }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: #000;
    border-left: 1px solid var(--term-dim);
}
::-webkit-scrollbar-thumb {
    background: var(--term-dim);
    border: 1px solid #000;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--term-color);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .terminal {
        width: 100%;
        height: 100vh; /* Full viewport height on mobile */
        border: none;
        padding: 1rem;
        border-radius: 0;
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    h1 {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }
    
    .status-bar {
        font-size: 0.7rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    main {
        font-size: 0.9rem;
    }
    
    .legal-frame {
        max-width: 100%;
    }

    .border-top, .border-bottom {
        font-size: 0.5rem;
        letter-spacing: -2px; /* Tighter dash spacing */
    }
}

/* Ensure ASCII/Logs don't break layout */
.ascii-art, .log-window, pre {
    overflow-x: auto;
    white-space: pre;
    max-width: 100%;
    scrollbar-width: thin; /* Firefox */
}

.ascii-art::-webkit-scrollbar, .log-window::-webkit-scrollbar {
    height: 4px; /* Slim scrollbar for horizontal */
}