/* Version 6.0: Complete visual and thematic overhaul to "H.P. Lovecraft" / Cosmic Horror. */

/* --- General Setup --- */
:root {
    /* ANNOTATION: Version 6.0 - New Lovecraftian color palette. */
    --main-bg: #1a1a2e; /* Deep space blue/purple */
    --text-color: #a9a9b3; /* Faded parchment/grey */
    --primary-border: #4a4e69; /* Dark, cold stone */
    --accent-purple: #7e57c2; /* The color of the void's whisper */
    --accent-green: #5a8e69; /* Sickly, eldritch green */
    --portal-bg: #0f0f1a; /* The deepest void */
}

body {
    background-color: var(--main-bg);
    color: var(--text-color);
    /* ANNOTATION: Version 6.0 - Font updated to a more scholarly, archaic style. */
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    background-image: radial-gradient(circle, #2a2a4e 0%, var(--main-bg) 70%);
}

/* --- Main Layout --- */
#game-container {
    width: 95vw;
    max-width: 700px;
    height: 90vh;
    border: 1px solid var(--primary-border);
    background-color: rgba(26, 26, 46, 0.7);
    backdrop-filter: blur(3px);
    padding: 20px;
    box-shadow: 0 0 25px rgba(0,0,0,0.7), inset 0 0 15px var(--portal-bg);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.5s, border-color 0.5s;
}

header h1 {
    text-align: center;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--text-color);
    /* ANNOTATION: Version 6.0 - New font for the header for a runic feel. */
    font-family: 'Uncial Antiqua', cursive;
    font-weight: normal;
}

#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;
}

/* --- Portal Display --- */
/* ANNOTATION: Version 6.0 - Renamed and restyled for the new theme. */
#portal-display {
    border: 1px solid var(--primary-border);
    height: 250px; 
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-color: var(--portal-bg);
    background-image: url('images/stars.png'); /* Assumes a subtle star texture */
    overflow: hidden;
    transition: height 0.3s;
    animation: pulse 15s infinite alternate;
}

@keyframes pulse {
    0% { box-shadow: inset 0 0 10px rgba(126, 87, 194, 0.1); }
    100% { box-shadow: inset 0 0 25px rgba(126, 87, 194, 0.3); }
}

/* ANNOTATION: Version 6.0 - This is now a placeholder for a cosmic symbol/glyph. */
#portal-image {
    width: 100px;
    height: 100px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    border: 1px dashed var(--primary-border);
    opacity: 0.2;
}


/* --- 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: #888; margin: 0; padding-left: 5px; font-style: italic; }
.max-message { position: relative; } /* Re-using class name to avoid JS changes */
.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: 'Cormorant Garamond', serif; font-size: 14px; 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(--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-purple); }
.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: transparent; border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'Uncial Antiqua', cursive; font-size: 18px; cursor: pointer; text-transform: uppercase; transition: background-color 0.2s, color 0.2s; margin-bottom: 10px; letter-spacing: 2px; }
#talk-btn:hover { background-color: var(--accent-purple); border-color: var(--accent-purple); color: #fff; }
#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: 'Cormorant Garamond', serif; font-size: 17px; padding: 5px 10px; }
#memo-input:focus { outline: none; border-color: var(--accent-purple); box-shadow: 0 0 5px var(--accent-purple); }
#send-text-btn { padding: 5px 15px; background-color: transparent; border: 2px solid var(--primary-border); color: var(--text-color); font-family: 'Uncial Antiqua', cursive; 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: #888; }

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

/* --- Animations & Effects --- */
/* ANNOTATION: Version 6.0 - Glitch effect updated to fit cosmic horror theme. */
.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: -1px 0px var(--accent-purple); animation: flicker-effect 4s linear infinite alternate; }
.glitch::after { text-shadow: 1px 0px var(--accent-green); animation: flicker-effect 3.5s linear infinite alternate-reverse; }

@keyframes flicker-effect {
  0%, 15%, 45%, 100% { opacity: 1; text-shadow: -1px 0 var(--accent-purple); }
  16%, 44% { opacity: 0.5; text-shadow: 1px 0 var(--accent-green); }
}

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

/* ANNOTATION: Version 6.0 - New UI effect classes for Lovecraftian theme. */
.void-whisper-effect {
    box-shadow: 0 0 35px var(--accent-purple), inset 0 0 35px var(--accent-purple);
    border-color: var(--accent-purple);
}

.eldritch-madness-effect {
    box-shadow: 0 0 35px var(--accent-green), inset 0 0 35px var(--accent-green);
    border-color: var(--accent-green);
}

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