body {
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #050505;
    font-family: 'VT323', monospace;
    overflow: hidden;
    color: #e0e0e0;
}

/* Main Layout Container: The "Cabinet" */
#game-layout {
    display: grid;
    grid-template-areas:
        "header header header"
        "left   main   right"
        "footer footer footer";
    grid-template-columns: 200px 800px 200px;
    grid-template-rows: 60px 600px 40px;
    background-color: #1a1a1a;
    border: 4px solid #444;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    position: relative;
}

/* Areas */
header {
    grid-area: header;
    background: #222;
    border-bottom: 2px solid #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    box-shadow: inset 0 -5px 10px rgba(0,0,0,0.5);
}

#sidebar-left {
    grid-area: left;
    background: #181818;
    border-right: 2px solid #333;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#game-wrapper {
    grid-area: main;
    position: relative;
    width: 800px;
    height: 600px;
    background: #000;
}

#sidebar-right {
    grid-area: right;
    background: #181818;
    border-left: 2px solid #333;
    padding: 1rem;
    overflow: hidden;
    position: relative;
}

footer {
    grid-area: footer;
    background: #222;
    border-top: 2px solid #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    font-size: 0.9rem;
    color: #888;
}

/* Canvas */
canvas {
    background-color: #222;
    display: block;
    /* Remove border as wrapper handles it */
}

/* Warning Box */
.warning-box {
            border: 2px solid #ff0000;
            background-color: rgba(50, 0, 0, 0.3);
            color: #ffcccc;
            padding: 20px;
            margin: 30px 0;
            box-shadow: 0 0 15px rgba(255, 0, 0, 0.2);
        }
.warning-title {
	color: #ff0000;
	font-weight: bold;
	font-size: 1.5rem;
	margin-bottom: 10px;
	display: block;
	text-transform: uppercase;
}

/* Overlay System (Modified for new layout) */
#overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.overlay-content {
    background: #000;
    border: 2px solid #00ff00;
    padding: 20px;
    max-width: 500px; /* Default small size */
    width: 90%;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
    text-align: center;
    position: relative; /* For X button positioning if needed */
}

.hidden {
    display: none !important;
}

/* Retro CRT Panel Styling */
.crt-panel {
    background-color: #111;
    border: 2px solid #00ff00;
    padding: 2rem;
    width: 500px;
    color: #00ff00;
    box-shadow:
        0 0 10px #00ff00,
        inset 0 0 20px rgba(0, 255, 0, 0.2);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* CRT Scanline Effect */
.crt-panel::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    z-index: 2;
}

.crt-panel h2 {
    font-size: 2.5rem;
    margin-top: 0;
    text-shadow: 0 0 5px #00ff00;
    letter-spacing: 2px;
}

.crt-line {
    height: 2px;
    background-color: #00ff00;
    box-shadow: 0 0 5px #00ff00;
    margin: 1rem 0;
}

.crt-panel p {
    font-size: 1.2rem;
    line-height: 1.5;
    text-shadow: 0 0 2px #00ff00;
}

.link-list {
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

.link-list li {
    margin: 1rem 0;
}

.link-list a {
    color: #00ff00;
    text-decoration: none;
    font-size: 1.5rem;
    border: 1px solid #00ff00;
    padding: 5px 15px;
    transition: all 0.2s;
    display: inline-block;
    width: 80%;
    background: rgba(0, 255, 0, 0.1);
}

.link-list a:hover {
    background-color: #00ff00;
    color: #000;
    box-shadow: 0 0 10px #00ff00;
    cursor: pointer;
}

/* Retro Buttons */
.retro-btn {
    background: #000;
    color: #00ff00;
    border: 2px solid #00ff00;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    padding: 5px 15px;
    cursor: pointer;
    text-shadow: 0 0 5px #00ff00;
    box-shadow: 0 0 5px #00ff00;
    transition: all 0.2s;
    text-transform: uppercase;
}

.retro-btn:hover {
    background: #00ff00;
    color: #000;
}

.retro-btn.danger {
    color: #ff0000;
    border-color: #ff0000;
    text-shadow: 0 0 5px #ff0000;
    box-shadow: 0 0 5px #ff0000;
}

.retro-btn.danger:hover {
    background: #ff0000;
    color: #000;
}

/* Header Specifics */
.header-title {
    font-size: 1.8rem;
    color: #00ffea;
    text-shadow: 0 0 10px #00ffea;
    letter-spacing: 2px;
}

.header-controls {
    display: flex;
    gap: 10px;
}

/* Footer Specifics */
.footer-link {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}
.footer-link:hover {
    color: #fff;
    text-shadow: 0 0 5px #fff;
}

/* Sidebar Specifics */
.sidebar-btn {
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
}

/* Surreal Stream Styles */
/* Constrained Text Window */
.surreal-text {
    /* Fixed Dimensions */
    height: 500px; /* Explicit height limit */
    width: 95%;   /* almost Fill sidebar width */
    
    /* Layout Flow */
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Anchors content to the bottom */
    align-items: center;
    
    /* Containment */
    overflow: hidden; /* Clips text that slides off the top */
    position: absolute; /* Pins it within the relative sidebar parent */
    bottom: 5px;       /* Spacing from bottom */
    left: 0;
	
	border: thick double #33ee00;
	box-shadow: 0px 1px 3px 7px #336611 inset;
	border-radius: 10px;
}

.surreal-word {
    font-size: 1.5rem;
    color: #00ff00;
    text-shadow: 0 0 5px #00ff00;
    opacity: 0;
    transition: opacity 0.5s;
    text-align: center;
    margin: 5px 0;
    /* Random Rotation handled in JS or CSS variable if complex, but simple transform here is fine */
}

.surreal-word.fade-in {
    opacity: 1;
}

.surreal-word.fade-out {
    opacity: 0;
    transition: opacity 1s;
}

/* Zone 8: Glitch Tear Entry */
.surreal-word {
    font-size: 1.4rem;
    color: #00ff00;
    opacity: 0; /* Hidden until animation starts */
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    transform-origin: left center;
}

.surreal-word.slide-in {
    /* Increased duration to 0.95s as requested */
    animation: severe-tear 0.95s steps(4, end) forwards;
}

@keyframes severe-tear {
    0% {
        opacity: 1;
        /* 2x Width (20), 1.5x Height */
        transform: scaleX(40) scaleY(2.5) translateX(-5%) skewX(70deg);
        clip-path: inset(20% 0 50% 0); /* Slice the middle */
        text-shadow: 15px 25px red, -15px -25px blue;
        filter: blur(4px) contrast(200%);
        background: rgba(0, 255, 0, 0.2);
    }
    15% {
        /* Flip and Compress */
        transform: scaleX(-2) scaleY(1.2) skewX(-40deg);
        clip-path: inset(0 0 0 0); /* Full view */
        text-shadow: -5px 0 red, 5px 0 blue;
        color: #fff;
    }
    30% {
        /* Vertical Slice */
        transform: scaleX(10) scaleY(0.5) translateX(10%);
        clip-path: inset(40% 0 40% 0);
        text-shadow: 0 10px red, 0 -10px blue;
        filter: blur(2px);
    }
    50% {
        /* Jitter */
        transform: scaleX(1.5) scaleY(1.1) skewX(20deg);
        clip-path: none;
        text-shadow: -2px 0 red, 2px 0 blue;
    }
    80% {
        /* Stabilizing */
        transform: scale(1.05);
        text-shadow: 0 0 5px #00ff00;
        color: #00ff00;
        background: transparent;
    }
    100% {
        opacity: 1;
        transform: scale(1);
        text-shadow: 0 0 5px #00ff00;
        clip-path: none;
    }
}