.chat-drawer {
    position: fixed;
    top: 50%;
    right: max(0px, calc((100vw - var(--game-shell-width)) / 2));
    z-index: 12;
    width: min(360px, calc(100vw - 46px));
    height: min(620px, 78dvh);
    border: 1px solid #d3aa595c;
    border-radius: 16px;
    background:
        radial-gradient(circle at 100% 0, #6f4b2426, transparent 34%),
        linear-gradient(160deg, #111923fa, #090e15fc);
    box-shadow: -18px 12px 48px #000b;
    transform: translate(100%, -50%);
    transition: transform 220ms cubic-bezier(.22, .75, .24, 1);
    backdrop-filter: blur(15px);
}

.chat-drawer.is-open {
    transform: translate(0, -50%);
}

.chat-drawer-body {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    height: 100%;
    overflow: hidden;
}

.chat-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px 12px;
    border-bottom: 1px solid #ffffff10;
}

.chat-drawer-header small {
    display: block;
    margin-bottom: 3px;
    color: #d9a84f;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .13em;
}

.chat-drawer-header h2 {
    margin: 0;
    color: #f1e6d2;
    font: 700 21px/1.1 Georgia, serif;
}

.chat-realtime-note {
    max-width: 245px;
    margin: 5px 0 0;
    color: #75808d;
    font-size: 9px;
    line-height: 1.35;
}

.chat-drawer-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #ffffff14;
    border-radius: 9px;
    color: #aeb6c1;
    background: #0c121acc;
    font-size: 19px;
    cursor: pointer;
}

.chat-channel-list {
    display: flex;
    gap: 7px;
    padding: 10px 12px;
    border-bottom: 1px solid #ffffff0d;
}

.chat-channel-button {
    padding: 7px 11px;
    border: 1px solid #c8953b70;
    border-radius: 999px;
    color: #f0d49c;
    background: #3928168c;
    font-size: 11px;
    font-weight: 750;
}

.chat-channel-button.is-active {
    border-color: #e4b763b8;
    color: #fff0cb;
    background: #67451ea8;
    box-shadow: inset 0 0 12px #e8b95817;
}

.chat-channel-button:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.chat-message-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 0;
    margin: 0;
    padding: 13px 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #b78a48 #0b1119;
}

.chat-message {
    padding: 9px 10px;
    border: 1px solid #ffffff0d;
    border-radius: 10px;
    background: #121a24c9;
}

.chat-message-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.chat-message-meta strong {
    overflow: hidden;
    color: #e8c887;
    font: 700 12px Georgia, serif;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-message-meta time {
    flex: 0 0 auto;
    color: #687483;
    font-size: 9px;
}

.chat-message p {
    margin: 0;
    color: #d6dbe2;
    font-size: 12px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.chat-connection-state {
    margin: auto;
    padding: 18px;
    color: #8995a3;
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.chat-connection-state.is-error {
    color: #d59a8e;
}

.chat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    padding: 10px 11px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #ffffff10;
    background: #0c121af2;
}

.chat-compose input {
    min-width: 0;
    height: 40px;
    padding: 0 11px;
    border: 1px solid #ffffff17;
    border-radius: 9px;
    outline: none;
    color: #eef0f3;
    background: #151e29;
    font: inherit;
    font-size: 12px;
}

.chat-compose input:focus {
    border-color: #d1a15085;
    box-shadow: 0 0 0 2px #d1a15018;
}

.chat-compose button {
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d4a65382;
    border-radius: 9px;
    color: #f3d99f;
    background: #3b2916;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

@media (max-width: 520px) {
    .chat-drawer {
        height: min(600px, 76dvh);
    }

}
