/* Version 6.0: Complete visual overhaul to a 1980s "ALF" TV show theme. */

/* --- General Setup --- */
:root {
    /* ANNOTATION: Version 6.0 - New 1980s color palette. */
    --main-bg: #4a2b0f;
    --text-color: #ffb86c;
    --primary-border: #8c5a30;
    --accent-orange: #f9882c;
    --screen-bg: #221a14;
    --crt-green: #9dffb0;
}

body {
    background-color: var(--main-bg);
    color: var(--text-color);
    /* ANNOTATION: Version 6.0 - Font updated to VT323. */
    font-family: 'VT323', monospace;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('images/80s_carpet.png'); /* Assumes a subtle 80s texture image */
}

/* ANNOTATION: Version 6.0 - Added a CRT scanline effect to the body. */
body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(20, 10, 0, 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));
    z-index: 2;
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;
}

/* --- Main Layout --- */
#game-container {
    width: 95vw;
    max-width: 700px;
    height: 90vh;
    border: 4px solid var(--primary-border);
    background-color: #3d220c;
    padding: 20px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    transition: transform 0.1s;
}

header h1 {
    text-align: center;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--accent-orange);
    text-shadow: 2px 2px 0px #000;
}

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

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

/* --- ALF Display --- */
/* ANNOTATION: Version 6.0 - Renamed and restyled for the new theme. */
#alf-display {
    border: 1px solid var(--primary-border);
    height: 250px; 
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: var(--screen-bg);
    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 alternate;
    opacity: 0.15;
}
@keyframes screen-flicker {
    0% { background: rgba(255, 200, 150, 0.05); }
    50% { background: transparent; }
    100% { background: rgba(200, 255, 200, 0.05); }
}
/* ANNOTATION: Version 6.0 - Placeholder container for an image of ALF. */
#alf-image {
    width: 120px;
    height: 120px;
    /* background-image: url('images/alf_pixel.png'); */ /* Example placeholder */
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    border: 2px solid var(--primary-border);
    padding: 5px;
    background-color: #111;
}

/* --- 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;
}

.user-message { color: var(--crt-green); margin: 0; padding-left: 5px; }
.max-message { position: relative; } /* Re-using class name to avoid JS/HTML changes */
.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: 'VT323', monospace; font-size: 16px; padding: 2px 8px; cursor: pointer; display: none; opacity: 0; transition: opacity 0.3s; }
.max-message:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background-color: var(--text-color); color: var(--screen-bg); }
.copy-btn.copied { background-color: #fff; color: #000; }
#dialogue-box::-webkit-scrollbar { width: 12px; }
#dialogue-box::-webkit-scrollbar-track { background: var(--screen-bg); border-left: 1px solid var(--primary-border); }
#dialogue-box::-webkit-scrollbar-thumb { background-color: var(--primary-border); }
#dialogue-box::-webkit-scrollbar-thumb:hover { background-color: var(--accent-orange); }
.cursor { animation: blink 1s step-end infinite; }

/* --- Player HUD & Controls --- */
#controls { border: 1px dashed var(--primary-border); padding: 10px; }
#talk-btn { width: 100%; padding: 15px; background-color: var(--accent-orange); border: 2px solid var(--primary-border); color: #000; font-family: 'VT323', monospace; font-size: 20px; cursor: pointer; text-transform: uppercase; transition: background-color 0.2s; margin-bottom: 10px; letter-spacing: 2px; text-shadow: 1px 1px 0px var(--text-color); }
#talk-btn:hover { background-color: #ffaa5e; }
#text-input-container { display: flex; gap: 10px; width: 100%; }
#memo-input { flex-grow: 1; background-color: transparent; border: 1px solid var(--primary-border); color: var(--text-color); font-family: 'VT323', monospace; font-size: 18px; padding: 5px 10px; }
#memo-input:focus { outline: none; border-color: var(--accent-orange); box-shadow: 0 0 5px var(--accent-orange); }
#send-text-btn { padding: 5px 15px; background-color: transparent; border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'VT323', monospace; font-size: 18px; cursor: pointer; text-transform: uppercase; transition: background-color 0.2s, color 0.2s; }
#send-text-btn:hover { background-color: var(--primary-border); }
.controls-info { font-size: 14px; text-align: center; margin-top: 10px; color: #a0a0a0; }

/* --- Dormant Mode Styles --- */
#ui-container.dormant-mode #dialogue-box { flex-grow: 0.1; }

/* --- Animations & Effects --- */
/* ANNOTATION: Version 6.0 - Glitch effect updated to be a CRT text flicker. */
.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(--accent-orange); animation: flicker-effect 3s linear infinite alternate; }
.glitch::after { text-shadow: 2px 0px var(--crt-green); animation: flicker-effect 2.5s linear infinite alternate-reverse; opacity: 0.7; }

@keyframes flicker-effect {
  0%, 15%, 45%, 100% { opacity: 1; }
  16%, 44% { opacity: 0.8; }
}

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

/* ANNOTATION: Version 6.0 - New UI effect classes for ALF theme. */
.tv-static-effect {
    animation: tv-static-anim 0.5s linear;
}
@keyframes tv-static-anim {
    0% { filter: grayscale(1) contrast(3); opacity: 0.5; }
    25% { transform: translate(2px, -3px); }
    50% { filter: grayscale(0) contrast(1); opacity: 1; }
    75% { transform: translate(-2px, 3px); }
    100% { transform: translate(0, 0); }
}

.kitchen-mess-effect {
    animation: kitchen-mess-anim 0.4s linear;
}
@keyframes kitchen-mess-anim {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* --- 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; }
    #alf-display { height: 150px; }
    #dialogue-box { min-height: 200px; max-height: 40vh; }
}