#chat { font-family: var(--f-font); color: #fff; }
.chat-btn { position: absolute; z-index: 4; width: max(calc(52px * var(--ui-k)), calc(56 * var(--u))); height: max(calc(52px * var(--ui-k)), calc(56 * var(--u))); padding: 0; border: 0; border-radius: calc(10px * var(--ui-k)); display: grid; place-items: center; cursor: pointer; pointer-events: auto; background: linear-gradient(180deg, #2f8cff, #1a55b8); box-shadow: inset 0 0 0 calc(2px * var(--ui-k)) rgba(255, 255, 255, 0.28), 0 calc(3px * var(--ui-k)) 0 rgba(8, 20, 70, 0.55), 0 calc(4px * var(--ui-k)) calc(10px * var(--ui-k)) rgba(0, 0, 0, 0.25); -webkit-tap-highlight-color: transparent; }
.chat-btn[hidden] { display: none; }
.chat-btn svg { width: 58%; height: 58%; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-btn svg .fill { fill: #fff; stroke: none; }
.chat-btn:active { transform: translateY(calc(2px * var(--ui-k))); box-shadow: inset 0 0 0 calc(2px * var(--ui-k)) rgba(255, 255, 255, 0.28), 0 1px 0 rgba(8, 20, 70, 0.55); }
.chat-btn .nb { position: absolute; top: calc(-6px * var(--ui-k)); right: calc(-6px * var(--ui-k)); }

#hud .hud-tr > .chat-btn { position: relative; width: max(calc(48px * var(--ui-k)), calc(50 * var(--u))); height: max(calc(48px * var(--ui-k)), calc(50 * var(--u))); border-radius: calc(8px * var(--ui-k)); }
.lmode > .chat-btn { right: 0; bottom: calc(100% + max(calc(10px * var(--ui-k)), calc(10 * var(--u)))); }
.pod-btns > .chat-btn { right: 0; bottom: calc(100% + max(calc(10px * var(--ui-k)), calc(10 * var(--u)))); }

.chat-panel { position: absolute; z-index: 5; right: calc(var(--sa-r) + var(--edge)); top: calc(var(--sa-t) + var(--edge) + max(calc(48px * var(--ui-k)), calc(50 * var(--u))) + max(calc(10px * var(--ui-k)), calc(10 * var(--u)))); bottom: calc(var(--sa-b) + var(--edge)); width: clamp(calc(260px * var(--ui-k)), 32vw, calc(440px * var(--ui-k))); display: flex; flex-direction: column; border-radius: calc(12px * var(--ui-k)); overflow: hidden; background: linear-gradient(160deg, rgba(8, 22, 70, 0.94), rgba(18, 60, 160, 0.9)); box-shadow: inset 0 0 0 calc(2px * var(--ui-k)) rgba(255, 255, 255, 0.18), inset calc(6px * var(--ui-k)) 0 0 var(--f-yellow), 0 calc(8px * var(--ui-k)) calc(24px * var(--ui-k)) rgba(0, 0, 0, 0.35); animation: chatIn 0.18s ease-out; }
.chat-panel[hidden] { display: none; }
body.mode-lobby .chat-panel { top: calc(var(--nav-h) + calc(4px * var(--ui-k))); }
body.mode-podium .chat-panel { top: calc(var(--sa-t) + var(--edge)); bottom: calc(var(--sa-b) + var(--edge) + 2 * max(calc(54px * var(--ui-k)), calc(56 * var(--u))) + calc(18px * var(--ui-k))); }
@keyframes chatIn { from { opacity: 0; transform: translateX(calc(16px * var(--ui-k))); } to { opacity: 1; transform: none; } }

.chat-head { flex: none; display: flex; align-items: center; gap: calc(8px * var(--ui-k)); padding: calc(6px * var(--ui-k)) calc(6px * var(--ui-k)) calc(6px * var(--ui-k)) calc(16px * var(--ui-k)); min-height: calc(48px * var(--ui-k)); background: rgba(0, 0, 0, 0.18); }
.chat-head > svg { width: max(calc(26px * var(--ui-k)), calc(28 * var(--u))); height: max(calc(26px * var(--ui-k)), calc(28 * var(--u))); flex: none; fill: none; stroke: var(--f-yellow); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-head > svg .fill { fill: var(--f-yellow); stroke: none; }
.chat-title { flex: 1; min-width: 0; font-weight: 700; font-style: italic; text-transform: uppercase; font-size: max(calc(19 * var(--u)), calc(16px * var(--ui-kf))); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 calc(2px * var(--ui-k)) 0 rgba(0, 0, 0, 0.25); }
.chat-x { flex: none; width: calc(44px * var(--ui-k)); height: calc(44px * var(--ui-k)); border: 0; border-radius: calc(8px * var(--ui-k)); padding: 0; display: grid; place-items: center; background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 0 0 1px var(--f-line); cursor: pointer; }
.chat-x svg { width: calc(20px * var(--ui-k)); height: calc(20px * var(--ui-k)); fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.chat-x:active { background: rgba(255, 255, 255, 0.2); }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: calc(8px * var(--ui-k)) calc(12px * var(--ui-k)) calc(6px * var(--ui-k)) calc(18px * var(--ui-k)); display: flex; flex-direction: column; gap: calc(4px * var(--ui-k)); scrollbar-width: thin; }
.chat-row { font-size: max(calc(15 * var(--u)), calc(14px * var(--ui-kf))); line-height: 1.3; font-weight: 500; overflow-wrap: anywhere; padding: calc(3px * var(--ui-k)) calc(8px * var(--ui-k)); border-radius: calc(6px * var(--ui-k)); background: rgba(255, 255, 255, 0.06); }
.chat-row.me { background: rgba(255, 226, 52, 0.12); }
.chat-nick { display: inline; padding: 0 calc(4px * var(--ui-k)) 0 0; margin: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--nc, #9fd4ff); cursor: pointer; text-transform: uppercase; letter-spacing: 0.02em; }
.chat-nick::after { content: ':'; color: var(--f-dim); }
.chat-row.me .chat-nick { color: var(--f-yellow); cursor: default; }
.chat-text { color: #fff; }
.chat-empty { margin: auto; padding: calc(12px * var(--ui-k)); text-align: center; color: var(--f-dim); font-weight: 600; font-size: max(calc(14 * var(--u)), calc(13px * var(--ui-kf))); }

.chat-menu { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: calc(6px * var(--ui-k)); padding: calc(8px * var(--ui-k)) calc(8px * var(--ui-k)) calc(8px * var(--ui-k)) calc(18px * var(--ui-k)); background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 1px 0 var(--f-line); }
.chat-menu[hidden] { display: none; }
.chat-menu-nick { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; text-transform: uppercase; color: var(--f-yellow); font-size: max(calc(15 * var(--u)), calc(14px * var(--ui-kf))); }
.chat-menu .f-btn { min-height: calc(44px * var(--ui-k)); padding: 0 calc(10px * var(--ui-k)); font-size: max(calc(14 * var(--u)), calc(13px * var(--ui-kf))); flex: 1 1 0; min-width: max-content; }
.chat-panel.menu-on .chat-form { display: none; }
.chat-menu .chat-x { order: -1; margin-left: auto; width: calc(40px * var(--ui-k)); height: calc(40px * var(--ui-k)); }
.chat-menu-nick { order: -2; }
.chat-menu::after { content: ''; order: -1; flex-basis: 100%; height: 0; }

.chat-form { flex: none; display: flex; gap: calc(6px * var(--ui-k)); padding: calc(8px * var(--ui-k)) calc(8px * var(--ui-k)) calc(8px * var(--ui-k)) calc(16px * var(--ui-k)); background: rgba(0, 0, 0, 0.22); }
.chat-input { flex: 1; min-width: 0; height: calc(48px * var(--ui-k)); padding: 0 calc(12px * var(--ui-k)); border: 0; border-radius: calc(8px * var(--ui-k)); background: #fff; color: var(--f-ink); font: 600 max(calc(16 * var(--u)), calc(16px * var(--ui-kf))) var(--f-font); box-shadow: inset 0 calc(2px * var(--ui-k)) 0 rgba(0, 0, 0, 0.12); outline: none; }
.chat-input::placeholder { color: #6b7896; font-weight: 500; }
.chat-input:focus { box-shadow: inset 0 0 0 calc(2px * var(--ui-k)) var(--f-yellow), inset 0 calc(2px * var(--ui-k)) 0 rgba(0, 0, 0, 0.12); }
.chat-send { flex: none; width: calc(52px * var(--ui-k)); height: calc(48px * var(--ui-k)); border: 0; border-radius: calc(8px * var(--ui-k)); padding: 0; display: grid; place-items: center; cursor: pointer; background: var(--f-yellow); box-shadow: inset 0 calc(-3px * var(--ui-k)) 0 var(--f-yellow-d); }
.chat-send svg { width: calc(24px * var(--ui-k)); height: calc(24px * var(--ui-k)); fill: none; stroke: var(--f-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat-send:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 var(--f-yellow-d); }

body.chat-open.mode-lobby #lobby .lmode { visibility: hidden; }
body.chat-open.mode-lobby #lobby .lmode > .chat-btn { visibility: hidden; }
body.chat-open #hud .pad { visibility: hidden; }

#chat-bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
body:not(.online) #chat-bubbles { display: none; }
.say-bubble { position: absolute; left: 0; top: 0; max-width: min(calc(240px * var(--ui-k)), 40vw); will-change: transform; }
.say-bubble > span { display: block; position: relative; padding: calc(6px * var(--ui-k)) calc(12px * var(--ui-k)); border-radius: calc(10px * var(--ui-k)); background: #fff; color: var(--f-ink); font: 600 max(calc(15 * var(--u)), calc(13px * var(--ui-kf))) / 1.25 var(--f-font); text-align: center; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; box-shadow: 0 calc(3px * var(--ui-k)) 0 rgba(8, 20, 70, 0.35), 0 calc(4px * var(--ui-k)) calc(12px * var(--ui-k)) rgba(0, 0, 0, 0.25); }
.say-bubble::after { content: ''; position: absolute; left: 50%; bottom: calc(-7px * var(--ui-k)); width: calc(14px * var(--ui-k)); height: calc(14px * var(--ui-k)); margin-left: calc(-7px * var(--ui-k)); background: #fff; transform: rotate(45deg); border-radius: calc(2px * var(--ui-k)); }
.say-bubble { padding-bottom: calc(7px * var(--ui-k)); }
.say-bubble::after { bottom: 1px; }
.say-bubble.in { animation: sayIn 0.2s cubic-bezier(.2, 1.4, .4, 1); }
.say-bubble.out { opacity: 0; transition: opacity 0.25s; }
@keyframes sayIn { from { opacity: 0; scale: 0.7; } to { opacity: 1; scale: 1; } }
#podium .pod-name.chat-under { visibility: hidden; }
.chat-row { cursor: pointer; }
.chat-row.sel { background: rgba(255, 255, 255, 0.2); box-shadow: inset 0 0 0 1px var(--f-yellow); }
.chat-menu-msg { flex: 1 1 100%; min-width: 0; padding: calc(2px * var(--ui-k)) 0 calc(4px * var(--ui-k)); color: var(--f-dim); font-weight: 600; font-style: italic; font-size: max(calc(14 * var(--u)), calc(13px * var(--ui-kf))); line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.chat-form.muted { display: none; }
.chat-mute { flex: none; padding: calc(12px * var(--ui-k)) calc(12px * var(--ui-k)) calc(12px * var(--ui-k)) calc(18px * var(--ui-k)); min-height: calc(48px * var(--ui-k)); display: flex; align-items: center; background: rgba(0, 0, 0, 0.28); color: #ffb4ab; font-weight: 700; font-size: max(calc(15 * var(--u)), calc(14px * var(--ui-kf))); line-height: 1.25; }
.chat-mute[hidden] { display: none; }
.chat-panel.menu-on .chat-mute { display: none; }

.sheet-over .pnl:has(.crules), .sheet-over .pnl:has(.blk-sheet) { width: min(92vw, max(calc(480px * var(--ui-k)), calc(500 * var(--u)))); max-height: calc(100% - calc(16px * var(--ui-k))); display: flex; flex-direction: column; }
.sheet-over .pnl:has(.crules) .crules, .sheet-over .pnl:has(.blk-sheet) .blk-sheet { flex: 1 1 auto; min-height: 0; overflow: auto; }
.crules-lead { margin: 0 0 calc(6px * var(--ui-k)); font-weight: 800; }
.crules-list { margin: 0; padding: 0 0 0 1.2em; display: flex; flex-direction: column; gap: calc(3px * var(--ui-k)); font-weight: 600; font-size: max(calc(15 * var(--u)), calc(13px * var(--ui-kf))); line-height: 1.3; }
.crules-list li::marker { color: var(--f-yellow-d, #e0b400); }
.crules-note { margin: calc(8px * var(--ui-k)) 0 0; opacity: 0.75; font-weight: 600; font-size: max(calc(13 * var(--u)), calc(12px * var(--ui-kf))); }
.crules-ok { font-size: max(calc(14 * var(--u)), calc(13px * var(--ui-kf))); }
.blk-note { margin: 0 0 calc(8px * var(--ui-k)); opacity: 0.8; font-weight: 600; font-size: max(calc(13 * var(--u)), calc(12px * var(--ui-kf))); }
.blk-list { display: flex; flex-direction: column; gap: calc(6px * var(--ui-k)); }
.blk-row { display: flex; align-items: center; gap: calc(8px * var(--ui-k)); padding: calc(6px * var(--ui-k)) calc(6px * var(--ui-k)) calc(6px * var(--ui-k)) calc(14px * var(--ui-k)); border-radius: calc(8px * var(--ui-k)); background: rgba(0, 0, 0, 0.06); }
.blk-row b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-row small { flex: 1; opacity: 0.6; font-weight: 600; }
.blk-row .f-btn { min-height: calc(44px * var(--ui-k)); padding: 0 calc(12px * var(--ui-k)); flex: none; }
.blk-empty { margin: calc(8px * var(--ui-k)) 0; opacity: 0.7; font-weight: 600; text-align: center; }
@media (max-height: 430px) {
  .crules-list { gap: 1px; font-size: calc(13px * var(--ui-kf)); }
  .crules-note { margin-top: calc(4px * var(--ui-k)); }
  .sheet-over .pnl:has(.crules) .pnl-head, .sheet-over .pnl:has(.blk-sheet) .pnl-head { padding-top: calc(8px * var(--ui-k)); padding-bottom: calc(6px * var(--ui-k)); }
  .sheet-over .pnl:has(.crules) .pnl-foot, .sheet-over .pnl:has(.blk-sheet) .pnl-foot { min-height: 0; padding-top: calc(8px * var(--ui-k)); padding-bottom: calc(8px * var(--ui-k)); }
}
.chat-menu { gap: calc(4px * var(--ui-k)) calc(6px * var(--ui-k)); padding-top: calc(6px * var(--ui-k)); padding-bottom: calc(8px * var(--ui-k)); }
.chat-menu .f-btn { flex: 1 1 0; min-width: 0; min-height: calc(42px * var(--ui-k)); padding: 0 calc(6px * var(--ui-k)); overflow: hidden; }
.chat-menu .f-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-menu .chat-x { width: calc(36px * var(--ui-k)); height: calc(36px * var(--ui-k)); }
.chat-menu-msg { padding: 0; }
