/* Original NewChat.dat pieces, drawn translucently as in the client. */
.speech-bubble{position:absolute;width:192px;transform:translateY(-100%) scale(var(--speech-scale,1));transform-origin:bottom left;font:12px/18px Tahoma,sans-serif;text-align:left;color:#fff;pointer-events:none;isolation:isolate;text-shadow:0 1px 2px #000}
.speech-style-default{width:140px;--speech-top:url('../../assets/chat-ui/default-top.png');--speech-middle:url('../../assets/chat-ui/default-middle.png');--speech-bottom:url('../../assets/chat-ui/default-bottom.png');--speech-bottom-width:146px;--speech-bottom-height:32px;--speech-bottom-left:-6px}
.speech-style-highlevel{--speech-top:url('../../assets/chat-ui/highlevel-top.png');--speech-middle:url('../../assets/chat-ui/highlevel-middle.png');--speech-bottom:url('../../assets/chat-ui/highlevel-bottom.png')}
.speech-style-npc{--speech-top:url('../../assets/chat-ui/npc-top.png');--speech-middle:url('../../assets/chat-ui/npc-middle.png');--speech-bottom:url('../../assets/chat-ui/npc-bottom.png')}
.speech-style-sit{--speech-top:url('../../assets/chat-ui/sit-top.png');--speech-middle:url('../../assets/chat-ui/sit-middle.png');--speech-bottom:url('../../assets/chat-ui/sit-bottom.png');--speech-bottom-height:33px;--speech-bottom-left:0px}
.speech-style-gm{--speech-top:url('../../assets/chat-ui/player-top.png');--speech-middle:url('../../assets/chat-ui/player-middle.png');--speech-bottom:url('../../assets/chat-ui/player-bottom.png')}
.speech-style-tutorial{width:210px;--speech-top:url('../../assets/chat-ui/tutorial-top.png');--speech-middle:url('../../assets/chat-ui/tutorial-middle.png');--speech-bottom:url('../../assets/chat-ui/tutorial-bottom.png');--speech-bottom-width:215px}
.speech-style-guildmaster{--speech-top:url('../../assets/chat-ui/guildmaster-top.png');--speech-middle:url('../../assets/chat-ui/guildmaster-middle.png');--speech-bottom:url('../../assets/chat-ui/guildmaster-bottom.png')}
.speech-frame{position:absolute;inset:0;opacity:.48;z-index:-1}
.speech-frame>div{position:absolute;left:0;width:100%;background-size:100% 100%}
.speech-frame .speech-top{top:0;height:22px;background-image:var(--speech-top)}
.speech-frame .speech-middle{top:22px;bottom:24px;background-image:var(--speech-middle);background-size:100% 24px;background-repeat:repeat-y}
/* Bottom artwork has five extra pixels on the left; align its painted edges with the upper pieces. */
.speech-frame .speech-bottom{bottom:-7px;left:var(--speech-bottom-left,-5px);width:var(--speech-bottom-width,197px);height:var(--speech-bottom-height,31px);background-image:var(--speech-bottom)}
.speech-content{padding:8px 10px 9px;min-height:43px;overflow-wrap:anywhere;white-space:pre-wrap}
.speech-name{display:block;color:#32e632;font-weight:400;margin-bottom:1px}
.speech-text{color:#f1efeb}
/* Compact composer; the desktop theme anchors it left above the live footer. */
:root body .online-panel{left:max(8px,env(safe-area-inset-left));right:auto;bottom:max(32px,env(safe-area-inset-bottom));transform:none;width:min(480px,calc(100vw - 24px));max-width:none;min-width:0;padding:0;display:grid;grid-template-columns:92px minmax(0,1fr) 32px 32px;gap:6px;box-sizing:border-box;border:0;border-radius:0;background:none;box-shadow:none;backdrop-filter:none;pointer-events:none;font:12px/1.6 Tahoma,sans-serif;text-shadow:none}
/* Reserve the HP orb height, bezel, bottom inset and a 16px gap at every desktop width. */
:root body:not(.mobile-hud) .online-panel{bottom:var(--chat-bottom,calc(var(--orb-size,100px) + 74px))}
:root body .online-panel :is(.chat-header,.chat-scope,.chat-compose-start,.chat-send,datalist){display:none}
:root body:not(.mobile-hud) .online-panel{grid-template-columns:92px minmax(0,1fr) 32px 32px 32px}
:root body:not(.mobile-hud) .online-panel .chat-header{display:contents}
:root body:not(.mobile-hud) .online-panel .chat-header>:not([data-chat-toggle]){display:none}
:root body:not(.mobile-hud) .online-panel [data-chat-toggle]{grid-column:5;grid-row:1;width:32px;height:32px;padding:0;border:1px solid #b9c8c239;border-radius:6px;background:#14211bd9;color:#d7c79e;font:20px/1 Tahoma,sans-serif;pointer-events:auto;cursor:pointer}
:root body .online-panel .chat-controls{display:contents}
:root body .online-panel .chat-send{display:grid;place-items:center;grid-row:1;width:32px;height:32px;min-height:32px;padding:0;border:1px solid #b9c8c239;border-radius:6px;background:#14211bed;color:#e8d6a7;pointer-events:auto;cursor:pointer}
:root body .online-panel .chat-send{grid-column:4}
.chat-send svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linejoin:round}
:root body .online-panel .chat-send:hover{background:#344539;border-color:#d6c28b}
:root body .online-panel .chat-controls select,:root body .online-panel>input,:root body .online-panel .chat-target{height:32px;min-height:32px;max-height:32px;box-sizing:border-box;margin:0;padding:5px 10px;border:1px solid #b9c8c239;border-radius:6px;background:#14211bd6;color:#dce4db;font:12px Tahoma,sans-serif;box-shadow:0 2px 8px #0002;backdrop-filter:blur(8px);pointer-events:auto;outline:none}
:root body .online-panel .chat-controls select{grid-column:1;grid-row:1;width:100%;max-width:none;cursor:pointer;color:#d7c79e;padding-left:9px}
.online-panel select option,.online-panel select optgroup{color:#e5e8df;background:#19261f}
:root body .online-panel>input{grid-column:2;grid-row:1;width:100%;padding-left:12px}
:root body .online-panel>input::placeholder{color:#9aab9f}
:root body .online-panel :is(select,input):focus{border-color:#cbbb8e99;background:#14211bf0;box-shadow:0 0 0 1px #cbbb8e18}
:root body .online-panel :is(select,input):hover{border-color:#cbbb8e65}
:root body .online-panel .chat-target{grid-column:1/-1;grid-row:2;width:100%}
:root body .online-panel .online-log{position:absolute;left:0;right:0;bottom:calc(100% + 8px);display:block;min-height:0;max-height:96px;overflow:auto;margin:0;padding:0 2px;border:0;border-radius:0;background:none;color:#e2e9df;font:12px/1.8 Tahoma,sans-serif;pointer-events:auto;text-shadow:0 1px 3px #000,0 0 4px #000;scrollbar-width:thin;scrollbar-color:#b9c8c230 transparent;overflow-wrap:anywhere}
:root body .online-panel:focus-within .online-log{max-height:144px;background:none}
:root body .online-panel .online-log:empty{display:none}
:root body .online-panel .online-log>div{padding:2px 6px;background:linear-gradient(90deg,#0a151866,transparent);border-radius:3px}
:root body .online-panel .chat-speaker{display:inline;min-height:0;padding:0;border:0;background:none;color:#dfd2ae;font:inherit;font-weight:bold;text-shadow:inherit;cursor:pointer}
:root body .online-panel .chat-whisper{color:#aed7bd}
:root body .online-panel .chat-party{color:#c6b5dd}
:root body .online-panel .chat-guild{color:#9dccd1}
:root body .online-panel :is(.chat-world,.chat-nation){color:#ddcb9c}
:root body .online-panel :is(.chat-war-command,.chat-war-squads,.chat-war-side,.chat-war-nation){color:#ffe180}
:root body .online-panel .chat-notice{color:#a9bfd3}
:root body .online-panel .online-invite{grid-column:1/-1;pointer-events:auto}
:root body .online-panel :is(.chat-options,.chat-more,.chat-war-menu){position:absolute;bottom:calc(100% + 8px);left:0;z-index:3;width:min(300px,100%);max-height:min(260px,40vh);overflow:auto;display:grid;gap:10px;box-sizing:border-box;padding:14px;border:1px solid #b9c8c236;border-radius:9px;background:#17241ff5;backdrop-filter:blur(12px);box-shadow:0 8px 24px #0004;color:#e0e6df;font:12px/1.6 Tahoma,sans-serif;pointer-events:auto;scrollbar-width:thin}
:root body .online-panel:has(:is(.chat-options,.chat-more,.chat-war-menu):not([hidden])) .online-log{display:none}
:is(.chat-options,.chat-war-menu) strong{font-size:10px;color:#abbdaf}
:root body .online-panel :is(.chat-more,.chat-war-menu){width:max-content;max-width:100%;gap:3px;padding:6px}
:root body .online-panel .chat-more{left:auto;right:0}
:root body .online-panel :is(.chat-more,.chat-war-menu)>button{padding:6px 9px;border:0;border-radius:4px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
:root body .online-panel :is(.chat-more,.chat-war-menu)>button:is(:hover,:focus-visible){background:#cbbb8e25}
:root body .online-panel .chat-more .community-launcher{position:relative;padding-right:36px}
:root body .online-panel .chat-more .menu-event-badge{top:50%;right:4px;transform:translateY(-50%)}
.chat-options label{display:flex;align-items:center;gap:9px;cursor:pointer}
:root body .online-panel .chat-options input[type=checkbox]{width:14px;height:14px;min-height:0;margin:0;padding:0;flex:none;accent-color:#cbbb8e}
.chat-options hr{width:100%;margin:0;border:0;border-top:1px solid #ffffff12}
:root body .online-panel .chat-options [data-chat-lock]{display:flex;justify-content:space-between;align-items:center;width:100%;padding:0;border:0;background:none;color:#e0e6df;font:12px/1.6 Tahoma,sans-serif;cursor:pointer}
.chat-options [data-chat-lock] span{padding:1px 7px;border-radius:5px;background:#ffffff0b;color:#94a69e;font-size:10px}
.chat-options [data-chat-lock][aria-pressed=true] span{color:#daceac;background:#cbbb8e25}
.chat-options small{color:#90a499;font-size:10px;line-height:1.8}
:root body .online-panel [hidden]{display:none}
.online-panel button:focus-visible{outline:2px solid #cbbb8e;outline-offset:2px}
@media(max-width:400px){:root body .online-panel{grid-template-columns:82px minmax(0,1fr) 32px 32px;gap:5px}:root body .online-panel :is(.chat-controls select,.chat-target),:root body .online-panel>input{font-size:11px}}
:root body .online-panel .online-log .chat-admin,:root body .online-panel .online-log .chat-admin .chat-speaker{color:#ffd66b;font-weight:bold}
.game-announcement{position:fixed;top:12%;left:50%;transform:translateX(-50%);width:min(640px,calc(100vw - 32px));box-sizing:border-box;z-index:9999;padding:14px 40px 16px;background:linear-gradient(#1f2c3af4,#141d27f4);color:#ffe9b0;border:2px solid #dbb65d;border-radius:6px;box-shadow:0 0 0 1px #00000080,0 8px 30px #000a;text-align:center;font:clamp(15px,2.6vw,20px)/1.6 Tahoma,sans-serif;white-space:pre-wrap;overflow-wrap:anywhere;pointer-events:none}
.game-announcement-head{font-size:12px;letter-spacing:.08em;color:#dbb65d;margin-bottom:4px}
.game-announcement-head::before,.game-announcement-head::after{content:'';display:inline-block;width:28px;height:1px;margin:0 8px;vertical-align:middle;background:#dbb65d80}
.game-announcement-title{display:block;margin-bottom:4px;color:#fff3cf;font-size:1.15em}
.game-announcement-title[hidden]{display:none}
.game-announcement-text{max-height:30dvh;overflow:auto;overscroll-behavior:contain;pointer-events:auto}
@media (orientation:landscape) and (max-height:500px){
 body.mobile-hud .game-announcement{width:min(460px,calc(100vw - 192px));padding:8px 34px 10px;font-size:13px}
}
.game-announcement-close{position:absolute;top:6px;right:8px;width:28px;height:28px;padding:0;border:0;border-radius:4px;background:none;color:#dbb65d;font-size:20px;line-height:1;cursor:pointer;pointer-events:auto}
.game-announcement-close:hover,.game-announcement-close:focus-visible{background:#dbb65d26;outline:none}
.game-announcement[hidden]{display:none}
/* Event HUD stays below desktop menu windows (25+) and mobile windows (40+). */
.event-badge{position:fixed;top:calc(8px + env(safe-area-inset-top,0px));left:50%;transform:translateX(-50%);z-index:24;display:flex;gap:8px;align-items:center;max-width:calc(100vw - 32px);box-sizing:border-box;padding:3px 12px;background:linear-gradient(#2a2310e8,#17130ae8);color:#ffe9b0;border:1px solid #dbb65d;border-radius:999px;box-shadow:0 2px 8px #0008;font:600 13px/1.5 Tahoma,sans-serif;white-space:nowrap;pointer-events:auto;cursor:default}
.event-badge[hidden]{display:none}
.event-badge-rates{display:flex;gap:8px}.event-badge-rates b{color:#ffd76a}.event-badge-time{color:#fff3cf;font-variant-numeric:tabular-nums;opacity:.9}
/* Phone HUD: the top row is full (HP/MP, menu, email notice); sit on the right under the map button, rates over time. */
body.mobile-hud .event-badge{left:auto;right:var(--mobile-right,12px);top:calc(var(--mobile-top,12px) + 104px);transform:none;flex-direction:column;align-items:flex-end;gap:0;max-width:60vw;padding:3px 10px;border-radius:10px;font-size:12px;line-height:1.4}
body.mobile-hud .event-badge-rates{flex-wrap:wrap;justify-content:flex-end;gap:0 6px}
/* Character reactions share the composer row; they never enter the chat log. */
body .emote-controls{position:static;grid-column:3;grid-row:1;pointer-events:auto;font:12px/1.6 Tahoma,sans-serif}
body .emote-controls[hidden],body .emote-controls [hidden]{display:none}
body .emote-toggle{display:grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid #cbbb8e66;border-radius:6px;background:#17241fea;color:#f3d39c;font:24px/1 sans-serif;cursor:pointer;box-shadow:0 2px 8px #0004;touch-action:manipulation}
body .emote-toggle:hover,body .emote-toggle[aria-expanded=true]{background:#3a4a35;border-color:#e4ca8b}
body .emote-picker{position:absolute;right:0;z-index:4;bottom:calc(100% + 8px);width:min(264px,calc(100vw - 32px));max-height:50dvh;overflow:auto;box-sizing:border-box;padding:12px;border:1px solid #cbbb8e66;border-radius:14px;background:#17241ff5;box-shadow:0 8px 24px #0006;backdrop-filter:blur(12px);color:#e7dcc3}
.emote-picker strong{display:block;margin-bottom:8px;font-size:13px}.emote-picker small{display:block;margin-top:8px;color:#a7b7aa;font-size:11px}
.emote-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
body .emote-grid button{display:grid;place-items:center;min-width:0;min-height:44px;padding:5px;border:1px solid transparent;border-radius:9px;background:#ffffff08;font:28px/1.2 "Segoe UI Emoji","Apple Color Emoji",sans-serif;cursor:pointer;touch-action:manipulation}
body .emote-grid button:hover{background:#cbbb8e28;border-color:#cbbb8e80}
.emote-controls button:focus-visible{outline:2px solid #e4ca8b;outline-offset:2px}
.character-emote{position:absolute;display:grid;place-items:center;width:24px;height:24px;box-sizing:border-box;filter:drop-shadow(0 1px 1px #0006);font:18px/1 "Segoe UI Emoji","Apple Color Emoji",sans-serif;pointer-events:none;transform-origin:bottom center;animation:character-emote-pop 3500ms both;z-index:2}
@keyframes character-emote-pop{0%{transform:translate(-50%,-80%) scale(calc(var(--emote-scale,1) * .4));opacity:0}8%{transform:translate(-50%,-100%) scale(calc(var(--emote-scale,1) * 1.12));opacity:var(--emote-opacity,1)}16%,75%{transform:translate(-50%,-100%) scale(var(--emote-scale,1));opacity:var(--emote-opacity,1)}88%{opacity:var(--emote-opacity,1)}100%{transform:translate(-50%,-130%) scale(var(--emote-scale,1));opacity:0}}
@media(prefers-reduced-motion:reduce){.character-emote{animation:none;transform:translate(-50%,-100%) scale(var(--emote-scale,1))}}
/* Quiet desktop chat: no outer frame; strengthen the fields only while interacting. */
:root body:not(.mobile-hud) .online-panel :is(.chat-controls select,.chat-target,.chat-send,.emote-toggle),
:root body:not(.mobile-hud) .online-panel>input{border:0;border-bottom:1px solid #e5dcc638;border-radius:4px;background:#101d1859;box-shadow:none;backdrop-filter:blur(4px);text-shadow:0 1px 3px #000}
:root body:not(.mobile-hud) .online-panel:hover :is(select,input),
:root body:not(.mobile-hud) .online-panel:focus-within :is(select,input){background:#14211bd9}
/* Share the input surface, with text ending before the two trailing controls. */
:root body:not(.mobile-hud) .online-panel>input{grid-column:2/5;padding-right:76px}
:root body:not(.mobile-hud) .online-panel .chat-send,
:root body:not(.mobile-hud) .online-panel .emote-toggle{position:relative;z-index:1;border:0;background:transparent;box-shadow:none;backdrop-filter:none}
:root body:not(.mobile-hud) .online-panel .emote-toggle{font-size:20px;color:#d7c79e}
:root body:not(.mobile-hud) .online-panel .chat-send svg{width:17px;height:17px}
:root body:not(.mobile-hud) .online-panel .chat-send:hover,
:root body:not(.mobile-hud) .online-panel .emote-toggle:is(:hover,[aria-expanded=true]){background:#cbbb8e25}
/* Five lines (1.8em line height + 4px row padding), unchanged by hover or focus. */
:root body:not(.mobile-hud) .online-panel .online-log,
:root body:not(.mobile-hud) .online-panel:focus-within .online-log{max-height:calc(9em + 20px);pointer-events:auto;overscroll-behavior:contain;touch-action:pan-y}
/* Event rates get their own row below the location, including narrow desktop screens. */
body:not(.mobile-hud) .event-badge{top:54px}
/* Keep the log below the guide rail on compact desktops, even for a whisper's second row. */
@media(min-width:701px) and (max-width:1280px){
 :root body:not(.mobile-hud) .online-panel{--chat-compose-height:32px;--chat-log-room:max(0px,calc(100dvh - var(--chat-bottom,174px) - var(--chat-compose-height) - 8px - 356px))}
 :root body:not(.mobile-hud) .online-panel:has(.chat-target:not([hidden])){--chat-compose-height:70px}
 :root body:not(.mobile-hud) .online-panel .online-log,
 :root body:not(.mobile-hud) .online-panel:focus-within .online-log{max-height:min(calc(9em + 20px),var(--chat-log-room))}
}

/* History remains scrollable while reading, including outside composer focus. */
:root body .online-panel.chat-history-open .online-log,
:root body .online-panel.chat-history-open:focus-within .online-log{max-height:min(300px,40dvh);pointer-events:auto;background:#101d18ed;border:1px solid #b9c8c239;border-radius:6px;padding:6px;overscroll-behavior:contain;touch-action:pan-y}
@media(min-width:701px) and (max-width:1280px){:root body:not(.mobile-hud) .online-panel.chat-history-open .online-log,
:root body:not(.mobile-hud) .online-panel.chat-history-open:focus-within .online-log{max-height:min(300px,40dvh,var(--chat-log-room))}}
.chat-feedback{display:none}
.online-panel .chat-time{display:inline-block;margin-right:3px;font-size:.9em;font-weight:normal;font-variant-numeric:tabular-nums;opacity:.75;white-space:nowrap}
/* Desktop reading is passive until the player types or explicitly opens history. */
:root body .online-panel .desktop-chat-toggle{display:none}
:root body:not(.mobile-hud) .online-panel .desktop-chat-toggle{display:flex;align-items:center;gap:5px;position:absolute;left:calc(100% + 6px);bottom:0;min-height:32px;padding:4px 8px;border:1px solid #b9c8c239;border-radius:6px;background:#14211bd9;color:#d7c79e;font:12px Tahoma,sans-serif;pointer-events:auto;cursor:pointer;white-space:nowrap}
:root body:not(.mobile-hud) .online-panel .desktop-chat-toggle small{padding:1px 4px;border-radius:8px;background:#b94b50;color:white}
:root body:not(.mobile-hud) .online-panel.desktop-chat-collapsed:not(.desktop-chat-active) .desktop-chat-toggle{left:0}
:root body:not(.mobile-hud) .online-panel.desktop-chat-collapsed:not(.desktop-chat-active)>:is(.online-log,.chat-header,.chat-controls,input,.chat-send,.emote-controls,.chat-options,.chat-more,.chat-war-menu){display:none}
:root body:not(.mobile-hud) .online-panel:not(.chat-history-open):not(:focus-within) .online-log,
:root body:not(.mobile-hud) .online-panel:not(.chat-history-open):not(:focus-within) .online-log *{pointer-events:none}
