/* ANNOTATION: Version 6.0: Complete visual overhaul to a "Beavis and Butt-Head" / 9s MTV theme. */

/* --- General Setup --- */
:root {
    /* ANNOTATION: Version 6.0 - New 90s grunge color palette. */
    --main-bg: #2a2a2e;
    --text-color: #d1d1d1;
    --primary-border: #4a4a4a;
    --couch-brown: #5c3d2e;
    --metallica-blue: #4a6da7;
    --warning-red: #d92b2b;
    --nacho-cheese-yellow: #ffc700;
}

body {
    background-color: var(--main-bg);
    color: var(--text-color);
    /* ANNOTATION: Version 6.0 - Font updated to Permanent Marker. */
    font-family: 'Permanent Marker', cursive;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    /* ANNOTATION: Version 6.0 - Background updated to a noisy/static texture. */
    background-image: url('images/tv_static.png'); /* Assumes a subtle static texture image */
}

/* --- Main Layout --- */
#game-container {
    width: 95vw;
    max-width: 700px;
    height: 90vh;
    border: 4px solid var(--primary-border);
    background-color: rgba(30, 30, 30, 0.85);
    padding: 20px;
    box-shadow: 0 0 15px rgba(0,0,0,0.8), inset 0 0 10px #000;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s, border-color 0.3s;
    border-radius: 15px 15px 25px 25px / 15px; /* Crappy old TV shape */
}

header h1 {
    text-align: center;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: var(--text-color);
    font-size: 2.5em;
}

#main-content {
    display: flex;
    flex-grow: 1;
    gap: 20px;
    height: calc(100% - 60px);
    min-height: 0; 
}

#ui-container {
    flex: 1;
    border: 2px solid var(--primary-border);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0;
    background-color: #1a1a1a;
}

/* --- TV Screen Display --- */
/* ANNOTATION: Version 6.0 - Renamed and restyled for the new theme. */
#tv-screen {
    border: 2px solid var(--primary-border);
    height: 250px; 
    position: relative;
    background-color: #000;
    background-image: repeating-linear-gradient(rgba(255,255,255,0.05) 0 1px, transparent 1px 3px);
    overflow: hidden;
    transition: height 0.3s;
}

#screen-flicker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    animation: screen-flicker 15s infinite;
    opacity: 0.1;
}
@keyframes screen-flicker {
    0%, 100% { background: rgba(200, 200, 255, 0.05); }
    50% { background: transparent; }
}
#tv-image {
    width: 100%;
    height: 100%;
    /* ANNOTATION: Version 6.1 - The background-image property is now active. Ensure you have an 'images' folder with 'couch_potato.gif' inside it, or change this path to your desired image. */
    background-image: url('images/couch_potato.gif'); /* This line is now active. */
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}


/* --- Dialogue Box & Log --- */
#dialogue-box {
    border: 1px dashed var(--primary-border);
    padding: 10px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: #222;
}

.user-message { color: var(--metallica-blue); margin: 0; padding-left: 5px; font-style: italic; }
.max-message { position: relative; color: var(--nacho-cheese-yellow); } 
.max-message p { margin: 0; white-space: pre-wrap; word-wrap: break-word; }
.copy-btn { position: absolute; top: -5px; right: 0; background-color: var(--primary-border); color: var(--text-color); border: 1px solid var(--text-color); font-family: 'Permanent Marker', cursive; font-size: 14px; padding: 2px 8px; cursor: pointer; display: block; opacity: 0; transition: opacity 0.3s; }
.max-message:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background-color: var(--text-color); color: var(--main-bg); }
.copy-btn.copied { background-color: #fff; color: #000; }
#dialogue-box::-webkit-scrollbar { width: 12px; }
#dialogue-box::-webkit-scrollbar-track { background: var(--main-bg); border-left: 1px solid var(--primary-border); }
#dialogue-box::-webkit-scrollbar-thumb { background-color: var(--couch-brown); }
#dialogue-box::-webkit-scrollbar-thumb:hover { background-color: var(--warning-red); }
.cursor { animation: blink 1s step-end infinite; }

/* --- Controls --- */
#controls { border: 1px dashed var(--primary-border); padding: 10px; }
#talk-btn { width: 100%; padding: 15px; background-color: var(--metallica-blue); border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'Permanent Marker', cursive; font-size: 18px; cursor: pointer; text-transform: uppercase; transition: background-color 0.2s; margin-bottom: 10px; letter-spacing: 2px; }
#talk-btn:hover { background-color: #3a5d97; }
#text-input-container { display: flex; gap: 10px; width: 100%; }
#text-input { flex-grow: 1; background-color: transparent; border: 1px solid var(--primary-border); color: var(--text-color); font-family: 'Permanent Marker', cursive; font-size: 16px; padding: 5px 10px; }
#text-input:focus { outline: none; border-color: var(--nacho-cheese-yellow); box-shadow: 0 0 5px var(--nacho-cheese-yellow); }
#send-text-btn { padding: 5px 15px; background-color: var(--couch-brown); border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'Permanent Marker', cursive; font-size: 16px; cursor: pointer; text-transform: uppercase; transition: background-color 0.2s, color 0.2s; }
#send-text-btn:hover { background-color: #7c5d4e; }
.controls-info { font-size: 14px; text-align: center; margin-top: 10px; color: #888; }

/* --- Dormant Mode Styles --- */
#ui-container.dormant-mode #tv-screen { height: 50px; }
#ui-container.dormant-mode #tv-image { opacity: 0.1; }

/* --- Animations & Effects --- */
/* ANNOTATION: Version 6.0 - Glitch effect updated with new theme colors. */
.glitch { position: relative; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: transparent; overflow: hidden; }
.glitch::before { text-shadow: -2px 0px var(--warning-red); animation: flicker-effect 3s linear infinite alternate; }
.glitch::after { text-shadow: 2px 0px var(--metallica-blue); animation: flicker-effect 2.5s linear infinite alternate-reverse; }

@keyframes flicker-effect {
  0%, 15%, 45%, 100% { opacity: 1; clip-path: inset(0 0 0 0); }
  16% { clip-path: inset(10% 0 80% 0); }
  44% { clip-path: inset(60% 0 10% 0); }
}

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

/* ANNOTATION: Version 6.0 - New UI effect classes for FIRE and METAL. */
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-2px, 2px); }
  20%, 40%, 60%, 80% { transform: translate(2px, -2px); }
}

.fire-effect {
    box-shadow: 0 0 45px var(--warning-red), inset 0 0 45px var(--warning-red);
    border-color: var(--nacho-cheese-yellow);
    animation: screen-shake 0.5s 2;
}

.metal-effect {
    box-shadow: 0 0 45px var(--metallica-blue), inset 0 0 45px #fff;
    border-color: #c0c0c0;
    animation: screen-shake 0.2s 4;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    body { font-size: 16px; overflow: auto; height: auto; padding: 10px 0; }
    #game-container { height: auto; width: 95vw; padding: 10px; }
    #main-content { flex-direction: column; }
    #tv-screen { height: 150px; }
    #dialogue-box { min-height: 200px; max-height: 40vh; }
}