:root {
    --color-black: #0f0f13;
    --color-dark-lilac: #3E4385;
    --color-sage: #A3B18A;
    --color-paper-white: #F0F2E8;
    --font-headings: 'DM Serif Display', serif;
    --font-body: 'DM Sans', sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-black);
    font-family: var(--font-body);
    color: var(--color-paper-white);
}

#game-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#exit-game-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    color: var(--color-sage);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--color-sage);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

#exit-game-btn:hover {
    background: var(--color-sage);
    color: var(--color-black);
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; 
}

/* Elevator Doors Animation */
#elevator-doors {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5; /* Above game, below UI */
    pointer-events: none;
    display: flex;
}

.door {
    width: 50%;
    height: 100%;
    background-color: #000;
    transition: transform 1.5s ease-in-out;
    transform: scaleX(0); /* Initially open (hidden) */
}

.door.left {
    transform-origin: left;
}

.door.right {
    transform-origin: right;
}

/* Closed state - activated via JS */
#elevator-doors.closing .door {
    transform: scaleX(1);
}


#top-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    pointer-events: auto;
    z-index: 100;
}

#sound-btn {
    font-size: 1.5rem;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--color-sage);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#settings-btn {
    display: none; /* Hidden as functionality removed */
}

#elevator-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    background: rgba(15, 15, 19, 0.8);
    padding: 1.5rem;
    border: 1px solid var(--color-sage);
    border-radius: 8px;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(5px);
    opacity: 0; /* Hidden initially */
    transition: opacity 1s ease;
    pointer-events: none; /* Prevent clicks while hidden */
}

#elevator-controls.visible {
    opacity: 1;
    pointer-events: auto;
}

.floor-display {
    font-family: var(--font-headings);
    font-size: 1.5rem;
    color: var(--color-sage);
    letter-spacing: 1px;
}

.controls {
    display: flex;
    gap: 1rem;
}

button {
    background: transparent;
    border: 1px solid var(--color-sage);
    color: var(--color-sage);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: bold;
    transition: all 0.3s ease;
    border-radius: 4px;
}

button:hover:not(:disabled) {
    background: var(--color-sage);
    color: var(--color-black);
}

button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 19, 0.95);
    padding: 3rem;
    text-align: center;
    border: 1px solid var(--color-sage);
    border-radius: 4px;
    pointer-events: auto;
    max-width: 500px;
    width: 90%;
}

#instructions h1 {
    font-family: var(--font-headings);
    font-size: 3rem;
    color: var(--color-sage);
    margin-bottom: 1rem;
}

#instructions p {
    margin-bottom: 2rem;
    font-size: 1.2rem;
    line-height: 1.6;
}

/* Modals */
#story-modal, #settings-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

.modal-content, .settings-content {
    background: var(--color-black);
    border: 1px solid var(--color-dark-lilac);
    padding: 2rem;
    max-width: 600px;
    width: 95%;
    height: 80vh; /* Taller for chat */
    position: relative;
    box-shadow: 0 0 30px rgba(62, 67, 133, 0.3);
    display: flex;
    flex-direction: column;
}

.settings-content {
    height: auto;
    max-width: 400px;
}

#close-modal, #close-settings {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    border: none;
    padding: 0;
    line-height: 1;
    z-index: 10;
}

/* Conversation UI */
.resident-profile {
    text-align: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(163, 177, 138, 0.3);
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.avatar-container {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    background: #2a2a2a;
    border: 2px solid var(--color-sage);
    margin-bottom: 0.5rem;
}

#resident-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#story-title {
    font-family: var(--font-headings);
    font-size: 1.8rem;
    color: var(--color-sage);
    margin: 0;
}

#resident-name {
    font-size: 1rem;
    color: #9ca3af;
    margin: 0.25rem 0 0 0;
}

#chat-container {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    padding: 0.8rem;
    border-radius: 8px;
    max-width: 80%;
    line-height: 1.5;
    font-size: 1rem;
}

.message.ai {
    background: rgba(62, 67, 133, 0.3);
    align-self: flex-start;
    border-top-left-radius: 0;
}

.message.user {
    background: rgba(163, 177, 138, 0.2);
    align-self: flex-end;
    border-top-right-radius: 0;
    text-align: right;
}

.message.system {
    background: transparent;
    color: #666;
    font-style: italic;
    align-self: center;
    font-size: 0.9rem;
    text-align: center;
}

.conversation-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.text-input-wrapper {
    flex-grow: 1;
    display: flex;
    gap: 0.5rem;
}

#text-input {
    flex-grow: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid #444;
    color: white;
    padding: 0.8rem;
    border-radius: 4px;
    font-family: var(--font-body);
}

#text-input:focus {
    outline: none;
    border-color: var(--color-sage);
}

/* Settings */
.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-sage);
    font-weight: bold;
}

.setting-desc {
    font-size: 0.9rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

#api-key-input {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
}

#save-settings {
    align-self: flex-end;
}
