:root {
    --bg-color: #121212;
    --header-bg: #1f1f1f;
    --input-bg: #2c2c2c;
    --text-color: #e0e0e0;
    --accent-color: #00e676;
    --my-msg-bg: #005c4b;
    --other-msg-bg: #333333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background-color: var(--header-bg);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    border: 1px solid #333;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    background-color: var(--input-bg);
    border: 1px solid #444;
    color: white;
    border-radius: 6px;
    font-size: 1rem;
    text-align: center;
}

.modal-content button {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 6px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
}

.error-text {
    color: #ff5252;
    margin-top: 10px;
    min-height: 20px;
    font-size: 0.9rem;
}

.chat-header {
    padding: 15px;
    background-color: var(--header-bg);
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

#current-username {
    color: var(--accent-color);
    font-weight: bold;
}

#chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0; 
    overflow-anchor: none;
}

#messages-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-row {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.msg-row.me { align-self: flex-end; align-items: flex-end; }
.msg-row.other { align-self: flex-start; align-items: flex-start; }

.msg-name {
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 4px;
    margin-left: 2px;
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 10px;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.msg-row.me .msg-bubble {
    background-color: var(--my-msg-bg);
    border-bottom-right-radius: 0;
}

.msg-row.other .msg-bubble {
    background-color: var(--other-msg-bg);
    border-bottom-left-radius: 0;
}

#chat-form {
    height: 70px;
    background-color: var(--header-bg);
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

#message-input {
    flex: 1;
    height: 45px;
    border-radius: 25px;
    border: none;
    padding: 0 15px;
    background-color: var(--input-bg);
    color: white;
    font-size: 1rem;
}

#message-input:focus { outline: none; background-color: #383838; }

#chat-form button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background-color: var(--accent-color);
    color: #000;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loading-indicator {
    text-align: center;
    font-size: 0.8rem;
    color: #666;
    padding: 10px;
}