#raceChat,#menuChat{background:rgba(12,18,24,.32);border:1px solid #ffffff30;box-shadow:none;width:min(280px,calc(100vw - 32px));padding:10px;color:#fff;text-shadow:0 1px 3px #000}
#raceChat{position:fixed;right:18px;top:auto;bottom:310px;max-height:calc(100vh - 370px);overflow:auto}
#raceChat h3,#menuChat h3{font-size:14px;margin:0 24px 5px 0}
#raceChat .chat-log,#menuChat .chat-log{height:150px;max-height:150px;min-height:34px;background:transparent;padding:4px 0;font-size:12px;line-height:1.5}
#raceChat .chat-status,#menuChat .chat-help{font-size:10px;margin:4px 0;color:#eee}
#raceChat form,#menuChat form{display:flex;gap:5px;margin:5px 0 0}
#raceChat input,#menuChat input{min-width:0;padding:6px;border:1px solid #ffffff40;background:#10182055;color:#fff;font-size:12px}
#raceChat form input,#menuChat form input{flex:1;width:0}
#raceChat button,#menuChat button{padding:6px 9px;margin:0;background:#92262399;border:1px solid #ffffff35;color:#fff;font-size:11px;cursor:pointer}
#raceChat [data-chat-close]{position:absolute;right:8px;top:8px;padding:2px 7px;background:#10182066}
#raceChat [hidden],#menuChat [hidden]{display:none!important}
#publicControls{top:auto;bottom:24px;right:24px;background:#10182088;padding:7px 12px}
.racing #publicControls{top:auto;bottom:270px;right:24px}
.racing .race-place{top:18px}
#chatKeyHint{display:none;position:fixed;top:18px;left:50%;transform:translateX(-50%);z-index:71;pointer-events:none;max-width:50vw;text-align:center;font-size:13px;font-weight:600;color:#fff;text-shadow:0 1px 4px #000;background:#10182040;border-radius:5px;padding:5px 10px}
.racing #chatKeyHint{display:block}
@media(max-width:700px){.racing #publicControls{bottom:228px;right:15px}#raceChat{bottom:265px;right:12px;width:min(260px,calc(100vw - 24px));max-height:calc(100vh - 310px)}#chatKeyHint{font-size:11px;top:12px;padding:4px 6px}#raceChat .chat-log{max-height:70px}}
@media(max-height:550px){#raceChat{bottom:120px;right:12px;max-height:calc(100vh - 165px)}.racing #publicControls{right:24px;bottom:270px}#raceChat .chat-log{max-height:55px}}
#rearMirrorFrame{display:none;position:fixed;left:50%;transform:translateX(-50%);top:51px;width:min(320px,35vw);height:90px;border:3px solid #14191d;border-radius:8px;box-shadow:0 2px 8px #0008;z-index:8;pointer-events:none}
.racing #rearMirrorFrame{display:block}
.driver-label{padding:1px 4px;font-size:10px;transform:translate(-50%,-85%);background:#1118}
@media(max-width:700px){#rearMirrorFrame{top:46px;width:44vw;height:auto;aspect-ratio:32/9}#raceChat .chat-log{height:115px;max-height:115px}}
@media(max-height:550px){#raceChat .chat-log{height:85px;max-height:85px}#rearMirrorFrame{top:42px;height:55px}}

/* Movable Windows-style race chat; keep resize affordable (native browser resize). */
body.racing{--online-controls-bottom:270px}
.racing #publicControls{bottom:var(--online-controls-bottom)}
#raceChat{box-sizing:border-box;z-index:75;right:18px;bottom:calc(var(--online-controls-bottom,270px) + 90px);width:310px;height:245px;min-width:220px;min-height:155px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);padding:0;background:rgba(13,19,28,.65);border:1px solid #aeb8c55c;border-radius:9px;box-shadow:0 12px 35px #0009;backdrop-filter:blur(9px);resize:both;overflow:hidden;display:flex;flex-direction:column;text-shadow:0 1px 3px #0008}
#raceChat[hidden]{display:none!important}
#raceChat .chat-titlebar{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;gap:8px;min-height:36px;padding:0 6px 0 11px;border-bottom:1px solid #ffffff20;background:linear-gradient(180deg,#354153d9,#242d3ce0);cursor:grab;touch-action:none;user-select:none;font:700 12px/1.2 system-ui,sans-serif}
#raceChat .chat-titlebar:active{cursor:grabbing}
#raceChat .chat-titlebar:focus-visible{outline:2px solid #9ec7ff;outline-offset:-3px}
#raceChat .chat-window-actions{display:flex;gap:3px;flex-shrink:0}
#raceChat .chat-window-actions button{position:static;width:27px;height:25px;padding:0;border:0;border-radius:4px;background:transparent;color:#f0f4fd;font:700 14px/1 system-ui,sans-serif;cursor:pointer}
#raceChat .chat-window-actions button:hover{background:#ffffff28}
#raceChat .chat-window-actions [data-chat-close]:hover{background:#c52e36}
#raceChat .chat-window-content{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden;padding:7px 9px 9px}
#raceChat .chat-status{flex-shrink:0;margin:0 0 5px;color:#ced8e6;font-size:10px}
#raceChat .chat-body{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
#raceChat .chat-log{flex:1;min-height:35px;height:auto;max-height:none;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;overflow-wrap:anywhere}
#raceChat form{flex-shrink:0}
#raceChat.chat-maximized{left:8px!important;top:8px!important;right:auto!important;bottom:auto!important;width:calc(100vw - 16px)!important;height:calc(100vh - 16px)!important;max-width:none;max-height:none;resize:none}
#raceChat.chat-minimized{height:37px!important;min-height:37px;resize:none}
#raceChat.chat-minimized .chat-window-content{display:none}
#raceChat.chat-positioned{right:auto;bottom:auto}
@media(max-width:700px){body.racing{--online-controls-bottom:228px}#raceChat:not(.chat-positioned){right:12px;bottom:calc(var(--online-controls-bottom) + 90px);width:min(280px,calc(100vw - 24px));height:210px;max-height:calc(100vh - 24px)}#raceChat .chat-log{max-height:none;height:auto}}
@media(max-height:550px){body.racing{--online-controls-bottom:270px}#raceChat:not(.chat-positioned){left:10px;right:auto;top:10px;bottom:auto;height:min(200px,calc(100vh - 20px));width:min(300px,calc(100vw - 20px))}#raceChat .chat-log{max-height:none;height:auto}}
/* Mid-height displays: keep the chat titlebar onscreen, clear of Discord and Controls. */
@media(min-width:701px) and (min-height:551px) and (max-height:650px){#raceChat:not(.chat-positioned){bottom:calc(var(--online-controls-bottom,270px) + 37px);height:clamp(135px,calc(100vh - 430px),245px);min-height:135px}}
@media(max-width:700px) and (min-height:551px) and (max-height:650px){#raceChat:not(.chat-positioned){bottom:calc(var(--online-controls-bottom,228px) + 40px);height:clamp(135px,calc(100vh - 380px),195px);min-height:135px}}
