.battle-chat-button{position:relative;display:inline-grid;place-items:center;vertical-align:middle;width:32px;min-width:32px;min-height:32px;padding:5px!important;margin-left:7px;border:1px solid #bca477;border-radius:9px;background:#10263a;color:#f5dc9b;box-shadow:none;cursor:pointer}.battle-chat-button[hidden]{display:none!important}.battle-chat-button svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.battle-chat-button .chat-unread{position:absolute;right:-6px;top:-7px;display:grid;place-items:center;min-width:17px;height:17px;padding:0 3px;border-radius:10px;background:#f5c45a;color:#182130;font:800 10px/1 system-ui,sans-serif}.chat-unread[hidden]{display:none!important}.battle-chat-button.has-unread{border-color:#ffe09b;box-shadow:0 0 11px #f2c25199;animation:chatNotice 2s ease-in-out infinite alternate}@keyframes chatNotice{to{box-shadow:0 0 17px #f2c251cc}}
.battle-chat-dialog{width:min(480px,calc(100vw - 24px));max-height:calc(100dvh - 30px);box-sizing:border-box;padding:18px;border:2px solid #cda95e;border-radius:15px;background:linear-gradient(145deg,#172f48,#071724);color:#f7e5bd;box-shadow:0 20px 80px #000b}.battle-chat-dialog::backdrop{background:#020b14bb;backdrop-filter:blur(5px)}.battle-chat-dialog>header,.chat-message>header,.chat-send-row{display:flex;align-items:center;justify-content:space-between;gap:10px}.battle-chat-dialog h2{margin:0;font:700 24px Georgia,serif}.chat-close{border:0;background:none;color:inherit;font-size:24px;min-height:36px;min-width:36px;padding:0}.chat-channels{display:flex;gap:8px;margin:13px 0}.chat-channels button{flex:1;min-height:38px}.chat-channels [aria-pressed="true"]{border-color:#edc879;color:#ffe4a6;background:#2b4557}.chat-messages{height:clamp(140px,35dvh,330px);overflow:auto;overscroll-behavior:contain;padding:9px;background:#06121ec9;border-radius:10px;border:1px solid #7e9ab644}.chat-message{max-width:92%;margin:0 0 10px;padding:8px 10px;background:#183247;border-radius:10px}.chat-message.is-own{margin-left:auto;background:#2a413f}.chat-message strong{font:700 12px system-ui,sans-serif;color:#f4d99b}.chat-message time{font:10px system-ui,sans-serif;color:#9fb8cc}.chat-message p{white-space:pre-wrap;overflow-wrap:anywhere;font:14px/1.45 system-ui,sans-serif;margin:5px 0 0;color:#eef3f7}.chat-empty{font:13px/1.5 system-ui,sans-serif;color:#a8bdce}.battle-chat-dialog label{display:block;margin:12px 0 5px;font:12px system-ui,sans-serif}.battle-chat-dialog textarea{width:100%;box-sizing:border-box;resize:vertical;max-height:110px;min-height:54px;padding:9px;border:1px solid #8e9b9f;border-radius:8px;background:#071725;color:#fff;font:14px system-ui,sans-serif}.chat-send-row{margin-top:8px}.chat-send-row>button{min-height:40px}.chat-status{font:12px/1.35 system-ui,sans-serif;color:#ffc3a7;overflow-wrap:anywhere}@media(prefers-reduced-motion:reduce){.battle-chat-button.has-unread{animation:none}}@media(max-width:460px){.battle-chat-dialog{padding:13px}.battle-chat-button{width:28px;min-width:28px;min-height:28px;padding:4px!important;margin-left:4px}}

/* Badges must remain visible outside the button's decorative frame. */
.battle-chat-button{box-sizing:border-box;overflow:visible!important;line-height:1;isolation:isolate}
.battle-chat-button .chat-unread{box-sizing:border-box;min-width:21px;height:21px;padding:0 4px;right:-8px;top:-8px;border:2px solid #102537;z-index:5;font:800 11px/17px system-ui,sans-serif;letter-spacing:normal;white-space:nowrap;pointer-events:none}

/* A wider, stable touch target for the room chat. */
#lobby #lobbyChatButton{width:56px;min-width:56px;max-width:56px;height:44px;min-height:44px;flex:0 0 56px;padding:8px!important;border-radius:10px}
#lobby #lobbyChatButton svg{width:24px;height:24px}
/* Keep the page still; only the message history scrolls inside the dialog. */
.battle-chat-dialog[open]{display:flex;flex-direction:column;overflow:hidden}
.battle-chat-dialog>header,.battle-chat-dialog>.chat-channels,.battle-chat-dialog>form{flex-shrink:0}
.battle-chat-dialog .chat-messages{flex:0 1 auto;min-height:60px;overflow-anchor:none;scroll-behavior:auto}

/* Open messages near the top, including safe space around phone cutouts. */
.battle-chat-dialog{margin:max(10px,env(safe-area-inset-top)) auto auto;max-height:calc(100dvh - max(10px,env(safe-area-inset-top)) - max(10px,env(safe-area-inset-bottom)))}

.battle-chat-dialog .chat-compose-row{display:flex;align-items:stretch;gap:8px;min-width:0}.battle-chat-dialog .chat-compose-row textarea{flex:1 1 0;width:0;min-width:0;margin:0}.battle-chat-dialog .chat-compose-row>button{flex:0 0 auto;align-self:stretch;min-height:54px;margin:0;padding:9px 13px;white-space:nowrap}.battle-chat-dialog form>.chat-status{display:block;margin-top:6px}.battle-chat-dialog form>.chat-status:empty{display:none}@media(max-width:460px){.battle-chat-dialog .chat-compose-row{gap:6px}.battle-chat-dialog .chat-compose-row>button{padding-inline:10px;font-size:13px}}

@media (max-width:600px) {
  .battle-chat-dialog[open] {
    top:var(--chat-visible-top,0px);
    width:calc(100vw - 16px);
    height:min(680px,calc(var(--chat-visible-height,100dvh) - 16px));
    max-height:calc(var(--chat-visible-height,100dvh) - 16px);
    margin:8px auto auto;padding:13px;
  }
  .battle-chat-dialog .chat-messages {flex:1 1 0;min-height:0;height:auto}
  .battle-chat-dialog .chat-compose-row textarea {font-size:16px;resize:none}
}
