/* Chat rooms. Grid replaces the old absolute positioning, so the message list
   scrolls on its own while the composer stays pinned beneath it. */

#RoomTabs .content-div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 184px;
    grid-template-rows: minmax(0, 1fr) auto;
    height: 560px;
    min-height: 0;
}

.chat-messages {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    margin: 0;
    padding: 20px 24px;
    list-style: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Keeps a short conversation at the bottom, next to the composer. Unlike
   justify-content: flex-end, this still lets a long one scroll to the top. */
.chat-messages > :first-child { margin-top: auto; }

.chat-messages li.message {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
        "name time"
        "body body";
    column-gap: 8px;
    row-gap: 2px;
    align-items: baseline;
    margin: 0;
    padding: 0;
    border: none;
    font-size: 15px;
}

.message-left { grid-area: name; }
.message-right { grid-area: time; }
.message-body {
    grid-area: body;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.chat-name { font-size: 14px; font-weight: 600; }
.message-you { margin-left: 6px; font-size: 13px; color: var(--tcg-muted); }
.message-time { font-size: 13px; color: var(--tcg-muted); }

.send-message {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--tcg-rule);
}

.message-box {
    flex-grow: 1;
    min-width: 0;
    display: flex;
}

.new-message {
    flex-grow: 1;
    width: auto;
    height: 44px;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1px solid var(--tcg-field);
    border-radius: var(--tcg-radius-sm);
    background: var(--tcg-surface);
    color: var(--tcg-ink);
    font: inherit;
    font-size: 15px;
    resize: none;
    overflow: hidden;
}
.new-message:hover { border-color: var(--tcg-field-hover); }
.new-message:focus {
    outline: none;
    border-color: var(--tcg-ink);
    box-shadow: var(--tcg-focus-ring);
}

.send-button {
    height: 44px;
    padding: 0 20px;
    border: none;
    border-radius: var(--tcg-radius-sm);
    background: var(--tcg-ink);
    color: #FFFFFF;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.send-button:hover { background: var(--tcg-ink-hover); }

.room-players {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-height: 0;
    box-sizing: border-box;
    padding: 20px;
    border-left: 1px solid var(--tcg-rule);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.room-players-title {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--tcg-muted);
}

.playerList {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.playerList li {
    font-size: 15px;
    overflow-wrap: anywhere;
}

.player-you { color: var(--tcg-muted); }

@media (max-width: 640px) {
    #RoomTabs .content-div {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto auto;
        height: 620px;
    }
    .room-players {
        grid-column: 1;
        grid-row: 3;
        max-height: 140px;
        border-left: none;
        border-top: 1px solid var(--tcg-rule);
    }
}
