/* Version 6.3: Improved mobile responsiveness and voice input functionality. */

/* --- General Setup --- */
:root {
    /* ANNOTATION: Version 6.0 - New gothic color palette. */
    --main-bg: #1a1a1a;
    --text-color: #d7d2c8;
    --primary-border: #4a4137;
    --accent-red: #7a0000;
    --accent-purple: #3a2e4a;
    --text-shadow: rgba(0, 0, 0, 0.7);
}

body {
    background-color: var(--main-bg);
    color: var(--text-color);
    /* ANNOTATION: Version 6.0 - Font updated to IM Fell English. */
    font-family: 'IM Fell English', serif;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    /* ANNOTATION: Version 6.0 - Background updated to a stone texture. Assumes image exists. */
    background-image: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('images/stone_texture.png');
}

/* --- Main Layout --- */
#game-container {
    width: 95vw;
    max-width: 700px;
    height: 90vh;
    border: 2px solid var(--primary-border);
    background-color: rgba(26, 26, 26, 0.85);
    padding: 20px;
    box-shadow: 0 0 35px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    transition: box-shadow 1s, border-color 1s;
}

header h1 {
    text-align: center;
    margin: 0 0 15px 0;
    letter-spacing: 4px;
    color: var(--text-color);
    text-shadow: 0 0 5px var(--accent-red), 0 0 10px var(--text-shadow);
}

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

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

/* --- Agent Display --- */
#agent-display {
    border: 1px solid var(--primary-border);
    height: 250px; 
    position: relative;
    /* ANNOTATION: Version 6.0 - Background changed to a damask pattern. Assumes image exists. */
    background: repeating-linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('images/damask.png');
    overflow: hidden;
    transition: height 0.5s ease-in-out;
}

#screen-flicker-overlay { /* Re-using for candlelight flicker */
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: transparent;
    animation: candlelight-flicker 8s infinite;
    opacity: 0.1;
}
@keyframes candlelight-flicker {
    0%, 100% { opacity: 0.1; } 20% { opacity: 0.05; } 40% { opacity: 0.15; } 60% { opacity: 0.08; } 80% { opacity: 0.2; }
}

/* ANNOTATION: Version 6.2 - This section is updated to display the portrait. */
#agent-image { 
    width: 150px; 
    height: 150px;
    /* This line summons the image. Ensure the path is correct. */
    background-image: url('images/poe_portrait.png'); 
    background-repeat: no-repeat; 
    background-size: cover; /* This ensures the image fills the circle perfectly */
    background-position: center;
    /* The border is now a solid line, like a locket frame */
    border: 3px solid var(--primary-border);
    /* This incantation makes the portrait circular */
    border-radius: 50%; 
    padding: 0;
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(0,0,0,0.8); /* A subtle shadow for depth */
}


/* --- Dialogue Box & Log --- */
#dialogue-box {
    border: 1px dashed var(--primary-border);
    padding: 15px; flex-grow: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 25px;
    background: rgba(0,0,0,0.2);
}
.user-message { color: #a0a0a0; margin: 0; padding-left: 5px; font-style: italic; }
.max-message { position: relative; } 
.max-message p { margin: 0; white-space: pre-wrap; word-wrap: break-word; line-height: 1.6; }
.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: 'IM Fell English', serif; font-size: 14px; padding: 3px 8px; cursor: pointer; display: block; opacity: 0; transition: opacity 0.4s; }
.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(--primary-border); }
#dialogue-box::-webkit-scrollbar-thumb:hover { background-color: var(--accent-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(--accent-red); border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'IM Fell English', serif; font-size: 20px; cursor: pointer; text-transform: uppercase; transition: background-color 0.2s; margin-bottom: 10px; letter-spacing: 2px; }
#talk-btn:hover { background-color: #a01f1f; }
#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: 'IM Fell English', serif; font-size: 18px; padding: 8px 12px; }
#memo-input:focus { outline: none; border-color: var(--accent-red); box-shadow: 0 0 5px var(--accent-red); }
#send-text-btn { padding: 5px 15px; background-color: transparent; border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'IM Fell English', serif; font-size: 16px; 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; }
#ui-container.dormant-mode #agent-display { height: 95%; }

/* --- Animations & Effects --- */
@keyframes blink { 50% { opacity: 0; } }

.raven-effect {
    box-shadow: 0 0 60px #000, inset 0 0 60px #000;
    border-color: #000;
}

.heartbeat-effect {
    animation: heartbeat-pulse 1s infinite;
}
@keyframes heartbeat-pulse {
    0%, 100% {
        box-shadow: 0 0 35px rgba(0,0,0,0.8);
        border-color: var(--primary-border);
    }
    50% {
        box-shadow: 0 0 45px var(--accent-red), inset 0 0 25px var(--accent-red);
        border-color: var(--accent-red);
    }
}

/* --- ANNOTATION: Version 6.3 - Responsive Design rules updated for better mobile experience --- */
@media (max-width: 768px) {
    body { 
        font-size: 16px; /* Reduced base font size for mobile */
        overflow: auto; 
        height: auto; 
        padding: 0; 
    }
    #game-container { 
        height: auto; 
        min-height: 95dvh; /* Use dynamic viewport height for better mobile sizing */
        width: 100%; 
        max-width: 100%;
        border: none; /* Remove border for a cleaner mobile look */
        padding: 10px; 
        margin: 0;
        box-shadow: none; /* Remove shadow on mobile */
    }
    header h1 {
        font-size: 1.5em; /* Adjust header size for smaller screens */
        margin-bottom: 10px;
    }
    #main-content { 
        flex-direction: column; 
        gap: 10px; /* Reduced gap for a tighter layout */
    }
    #agent-display { 
        height: 150px; 
    }
    #agent-image { 
        width: 100px; 
        height: 100px; 
    }
    #dialogue-box { 
        min-height: 200px; 
        max-height: 50vh; /* Allow slightly more space for dialogue */
        gap: 15px; /* Reduced gap between messages */
    }
    #controls {
        padding: 5px; /* Reduced padding */
    }
    #talk-btn {
        font-size: 18px; /* Adjusted font size for readability */
        padding: 12px; /* Adjusted padding */
    }
    #memo-input {
        font-size: 16px; /* Adjusted font size */
    }
}