.lobby-balance-shortcuts {
    display: flex;
    align-items: center;
    gap: clamp(4px, .5vw, 9px);
}

.lobby-balance-shortcuts .hud-control {
    min-height: 44px;
    padding: 5px 12px 7px;
}

.lobby-balance-shortcuts .hud-emblem { width: 24px; height: 24px; }

.lobby-chat {
    position: fixed;
    z-index: 101;
    left: clamp(14px, 2.3vw, 38px);
    bottom: clamp(12px, 2.7vh, 28px);
    width: min(356px, calc(100vw - 28px));
    box-sizing: border-box;
    border: 3px solid var(--hud-ink);
    border-radius: 10px 17px 10px 15px;
    box-shadow: 0 4px #743919, 0 9px 20px #321a0d59;
    color: var(--hud-ink);
    font: 700 14px/1.35 var(--ui-display);
}

.lobby-chat:not([open]) { width: max-content; }

.lobby-chat-tab {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    padding: 3px 11px 6px;
    list-style: none;
    background: var(--hud-panel-blue);
    border-radius: 7px 13px 7px 11px;
    box-shadow: var(--hud-panel-rim);
    color: var(--ui-paper);
    font: 900 15px/1.1 var(--hud-lettering);
    text-shadow: 0 2px var(--hud-ink);
    -webkit-text-stroke: 1px var(--hud-ink);
    paint-order: stroke fill;
    cursor: pointer;
}

.lobby-chat-tab::-webkit-details-marker { display: none; }
.lobby-chat-tab:focus-visible { outline: 2px solid #fff1bb; outline-offset: -5px; }
.lobby-chat[open] .lobby-chat-tab { border-bottom: 3px solid var(--hud-ink); border-radius: 7px 13px 0 0; }

.lobby-chat-icon {
    display: grid;
    place-items: center;
    position: relative;
    width: 22px;
    height: 15px;
    flex: none;
    border: 2px solid var(--hud-ink);
    border-radius: 5px 7px 5px 3px;
    background: #ffca58;
    box-shadow: inset 0 2px #ffedaf;
}

.lobby-chat-icon::before {
    content: '';
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--hud-ink);
    box-shadow: -5px 0 var(--hud-ink), 5px 0 var(--hud-ink);
}

.lobby-chat-icon::after {
    content: '';
    position: absolute;
    left: 3px;
    bottom: -4px;
    width: 5px;
    height: 5px;
    rotate: 45deg;
    border-right: 2px solid var(--hud-ink);
    border-bottom: 2px solid var(--hud-ink);
    background: #ffca58;
}

.lobby-chat-chevron {
    width: 7px;
    height: 7px;
    margin-inline: auto 3px;
    rotate: -135deg;
    border-right: 2px solid var(--hud-ink);
    border-bottom: 2px solid var(--hud-ink);
}

.lobby-chat[open] .lobby-chat-chevron { rotate: 45deg; }

.lobby-chat-body {
    padding: 9px;
    border-radius: 0 0 7px 11px;
    background: linear-gradient(145deg, #ffe7b396, #e9a56dba);
}

.lobby-chat-history {
    height: clamp(92px, 20dvh, 180px);
    box-sizing: border-box;
    overflow: auto;
    overscroll-behavior: contain;
    overflow-anchor: none;
    padding: 6px 8px;
    border: 1px solid #ab7149;
    border-radius: 6px 10px 6px 8px;
    background: #fff3d36b;
    box-shadow: inset 0 2px 3px #6f3b171e;
}

.lobby-chat-empty { margin: 0; padding: 5px 1px; color: #744e33; }
.lobby-chat-older {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ab7149;
    border-radius: 6px;
    background: #fff3d6;
    color: #744e33;
    font: 800 12px var(--ui-display);
    cursor: pointer;
}
.lobby-chat-older:focus-visible { outline: 2px solid #116687; }
.lobby-chat-history ol { margin: 0; padding: 0; list-style: none; }
.lobby-chat-history li { padding: 5px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.lobby-chat-history li + li { border-top: 1px solid #d69b6338; }
.lobby-chat-history time { margin-right: 6px; color: #744e33; font-size: 11px; }
.lobby-chat-history strong { color: #135b75; }

.lobby-chat-form {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 5px;
    align-items: center;
    margin-top: 7px;
}

.lobby-chat-form input {
    min-width: 0;
    height: 40px;
    box-sizing: border-box;
    padding: 0 8px;
    color: var(--hud-ink);
    border: 2px solid #a06b44;
    border-radius: 6px 8px 6px 8px;
    background: #fff7e4;
    font: 700 16px var(--ui-display);
}

.lobby-chat-form input:focus-visible { outline: 2px solid #116687; outline-offset: 1px; }

.lobby-chat-form .hud-control {
    --hud-plate: var(--hud-orange);
    min-height: 40px;
    padding: 4px 12px 6px;
    font-size: 12px;
}

#lobbyChatEmojiButton {
    --hud-plate: var(--hud-square);
    width: 36px;
    padding: 4px;
}

.lobby-chat-smile {
    position: relative;
    width: 20px;
    height: 20px;
    border: 2px solid var(--hud-ink);
    border-radius: 50%;
    background: #ffcb5c;
    box-shadow: inset 0 2px #fff1b5;
}

.lobby-chat-smile::before,
.lobby-chat-smile::after {
    position: absolute;
    left: 50%;
    content: '';
}

.lobby-chat-smile::before {
    top: 4px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    box-shadow: -4px 0 var(--hud-ink), 4px 0 var(--hud-ink);
    translate: -50%;
}

.lobby-chat-smile::after {
    top: 8px;
    width: 10px;
    height: 5px;
    border-radius: 0 0 9px 9px;
    background: var(--hud-ink);
    translate: -50%;
}

.lobby-chat-emojis {
    position: absolute;
    z-index: 1;
    bottom: calc(100% + 6px);
    left: 0;
    display: grid;
    grid-template-columns: repeat(3, 48px);
    gap: 3px;
    padding: 5px;
    border: 2px solid var(--hud-ink);
    border-radius: 7px 11px 7px 10px;
    background: var(--hud-panel-sand);
    box-shadow: 0 3px #743919, 0 6px 12px #321a0d59;
}

.lobby-chat-emojis[hidden] { display: none; }

.lobby-chat-sticker-option {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
}

.lobby-chat-sticker-option:is(:hover, :focus-visible) {
    border-color: #a57243;
    background: #fff3ce;
    outline: none;
}

.lobby-chat-sticker {
    display: inline-block;
    width: 48px;
    height: 48px;
    vertical-align: middle;
    background: url('/assets/lobby-image/hud/chat-emojis.webp') var(--emoji-x) var(--emoji-y) / 300% 300% no-repeat;
}

.lobby-chat-history .lobby-chat-sticker { width: 43px; height: 43px; }

.lobby-chat-status { margin: 5px 2px 0; color: #744e33; font-size: 12px; }

@media (max-width: 620px) {
    .lobby-balance-shortcuts { gap: 3px; }
    .lobby-balance-shortcuts .hud-control {
        --hud-plate: var(--hud-square);
        min-height: 40px;
        width: 39px;
        padding: 4px;
    }
    .lobby-balance-shortcuts .hud-control span { display: none; }
    .lobby-chat-tab { font-size: 13px; }
}

@media (max-width: 374px) {
    .hud-lobby .game-logo { top: 64px; }
}

@media (max-height: 470px) {
    .lobby-chat-history { height: clamp(63px, 21dvh, 100px); }
}
