#room-chat {
  position:fixed; inset:0 auto auto 0; z-index:18; margin:0; padding:0; border:0;
  max-width:none; max-height:none; box-sizing:border-box; overflow:visible; background:transparent;
  color:#eaf0f8; text-align:left; pointer-events:none; transform-origin:0 0;
  font:13px/1.4 system-ui,"Microsoft YaHei",sans-serif;
}
#room-chat::backdrop { background:transparent; pointer-events:none; }
.arena-rotated #room-chat { transform:rotate(90deg); }
.arena-rotated #room-chat.chat-local { position:absolute;transform:none; }
#room-chat [hidden] { display:none !important; }
#room-chat .chat-dock {
  --chat-edge:max(8px,env(safe-area-inset-bottom));
  position:absolute; left:calc(max(8px,env(safe-area-inset-left)) + var(--chat-shift,0px)); bottom:calc(var(--chat-edge) + var(--chat-lift,0px));
  display:flex; flex-direction:column; align-items:flex-start; gap:4px; max-width:90%; pointer-events:none;
}
.board-portrait .portrait-match #room-chat .chat-dock { --chat-edge:calc(50px + env(safe-area-inset-bottom)); }
#room-chat button,#room-chat input { box-sizing:border-box; margin:0; font:inherit; min-height:0; min-width:0; }
#room-chat button { cursor:pointer; color:#e9e7df; }
#room-chat button:focus-visible,#room-chat input:focus-visible { outline:2px solid #f1ce86; outline-offset:1px; }
#room-chat button:disabled { opacity:.58;cursor:default; }
#room-chat .chat-toggle {
  pointer-events:auto; display:flex; align-items:center; gap:8px; width:160px; max-width:100%; height:30px;
  padding:0 10px; border:1px solid #8e7852; border-radius:15px; background:#182638f2;
  box-shadow:0 2px 8px #0005; text-align:left;
}
.chat-toggle span { flex:1; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.chat-toggle i { position:relative; border:1.4px solid currentColor; border-radius:5px; color:#e9cb8e; font:700 12px/11px system-ui; text-align:center; width:19px; height:13px; }
.chat-toggle i::after { content:''; position:absolute; left:3px; bottom:-3px; border-top:3px solid currentColor; border-right:3px solid transparent; }
.chat-toggle b { min-width:17px; border-radius:10px; padding:0 3px; background:#bb564b; color:white; text-align:center; font-size:11px; }
#room-chat .chat-panel {
  box-sizing:border-box; pointer-events:auto; width:320px; max-width:100%; height:min(280px,calc(var(--chat-visible,100dvh) - var(--chat-edge) - 44px));
  display:flex;flex-direction:column; gap:5px; padding:9px; overflow:auto; overscroll-behavior:contain;
  background:#142131fa; border:1px solid #776949; border-radius:10px; box-shadow:0 6px 25px #05091177;
}
#room-chat .chat-panel header { display:flex; align-items:center; justify-content:space-between; padding:0 1px 4px; border-bottom:1px solid #354255; }
#room-chat .chat-panel header strong { color:#edd39e; font-size:14px; letter-spacing:.06em; }
#room-chat .chat-panel header {gap:4px;}
#room-chat .chat-panel header strong {margin-right:auto;white-space:nowrap;}
#room-chat .voice-control {display:grid;place-items:center;flex:none;width:28px;height:26px;padding:3px;color:#a4adb9;background:transparent;border:0;border-radius:5px;}
#room-chat .voice-control:hover {background:#2a394b;}
#room-chat .voice-control[aria-pressed=true],#room-chat .voice-mini {color:#6ae29d;}
#room-chat .voice-control svg,#room-chat .voice-mini svg {display:block;width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
#room-chat .voice-control[aria-pressed=true] .voice-slash,#room-chat .voice-mini .voice-slash {display:none;}
#room-chat .voice-mic[aria-busy=true] {outline:1px dotted currentColor;}
#room-chat .voice-mini {position:absolute;left:calc(100% + 4px);display:grid;place-items:center;width:24px;height:24px;background:#142b24;border:1px solid #487b5e;border-radius:50%;}
#room-chat .chat-toggle {position:relative;}
#room-chat .chat-panel:not([hidden]) ~ .chat-toggle .voice-mini {display:none;}
#room-chat[data-speaking~=blue] .chat-line.blue [data-player]::after,
#room-chat[data-speaking~=red] .chat-line.red [data-player]::after {content:'';display:inline-block;width:10px;height:10px;margin-left:3px;background:linear-gradient(#6ae29d 0 0) left center/2px 45%,linear-gradient(#6ae29d 0 0) center/2px 100%,linear-gradient(#6ae29d 0 0) right center/2px 65%;background-repeat:no-repeat;}
#room-chat .chat-settings { padding:1px 6px; color:#bac5d2; background:transparent; font-size:11px; border:1px solid #4f6074; border-radius:5px; }
#room-chat .chat-settings[aria-expanded=true] {color:#f3d296;border-color:#96835d;}
.chat-filters { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 8px; }
.chat-filters label { display:flex; align-items:center; gap:4px; margin:0; font-size:12px; }
#room-chat .chat-filters input { flex:none; height:16px; width:16px; accent-color:#dec18c; }
.chat-log { flex:1 1 70px; min-height:30px; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; }
.chat-log > small {color:#9cabbf;}
.chat-line { display:flex; align-items:baseline; gap:7px; padding:2px 0; overflow-wrap:anywhere; }
#room-chat .chat-line [data-player] {flex:none;max-width:47%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:700;color:#9dcafa;background:transparent;border:0;padding:0;pointer-events:auto;}
#room-chat .chat-line.red [data-player] {color:#ffafa7;}
#room-chat .chat-line.watch [data-player] {color:#d3d9df;}
.chat-line.own span {color:#e4d4af;}
.chat-quick {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;}
#room-chat .chat-quick button { min-height:26px; border:1px solid #455469; border-radius:4px; padding:3px 4px; color:#e2e7ee; background:#243449; text-wrap:balance; font-size:12px;line-height:1.25; }
#room-chat .chat-quick button:hover:enabled { border-color:#bb9d68;background:#314158; }
#room-chat form {display:flex;gap:5px;margin:0;}
#room-chat form input {flex:1;width:0;max-width:100%;height:32px;padding:4px 7px;border:1px solid #4b596c;border-radius:4px;background:#0f1a29;color:#edf1f6;}
#room-chat.chat-keyboard .chat-dock {--chat-edge:4px;}
#room-chat.chat-keyboard .chat-panel {overflow:hidden;}
#room-chat.chat-keyboard .chat-quick {min-height:0;overflow-y:auto;flex-shrink:1;}
#room-chat.chat-keyboard .chat-panel form {flex:none;}
#room-chat form button {width:49px;height:32px;padding:0 6px;white-space:nowrap;border:0;border-radius:4px;background:#dec18c;color:#251f18;font-weight:700;}
.chat-error {color:#ffc2af;}
#room-chat .voice-info {color:#a9becb;}
.chat-bubble {position:absolute;bottom:calc(100% + 4px);left:0;width:max-content;max-width:min(255px,84vw);background:#152234e8;border:1px solid #5d6e81;border-radius:8px;padding:4px 8px;pointer-events:none;}
.chat-bubble .chat-line span {display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
@media(pointer:coarse) {
  #room-chat form input {font-size:16px;}
}
.arena-wide #room-chat .chat-toggle {width:142px;height:28px;}

