:root {
  --ink: #e9eef2;
  --muted: #9fb3c2;
  --panel: rgba(6, 18, 30, 0.93);
  --panel-edge: rgba(180, 210, 230, 0.16);
  --brass: #e0c27a;
  --friend: #8cd1ff;
  --enemy: #ff6b54;
  --good: #73e68c;
  --sea: #071a2c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sea); color: var(--ink);
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; outline: none; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; }
.screen.on { display: block; }
.screen.center.on { display: flex; align-items: center; justify-content: center; padding: 16px; }
/* The live map shows through behind menus, darkened toward the edges. */
.screen.center { background: radial-gradient(ellipse at center, rgba(7,26,44,0.15), rgba(3,10,18,0.6)); }
.card, .panel, button, input { pointer-events: auto; }
.card { background: var(--panel); border: 1px solid var(--panel-edge); padding: 24px 28px;
  width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  /* No backdrop-filter or soft drop shadow: everything here floats over a
     canvas that repaints every frame, so either one makes the browser redo
     a large blur every frame (very slow without a GPU compositor). A nearly
     opaque fill and a crisp edge read the same. */
  outline: 1px solid rgba(0,0,0,0.35); }
.card.small { width: min(380px, 100%); text-align: center; }
h1, h2 { margin: 0 0 8px; font-weight: 650; letter-spacing: 0.02em; }
h1 { font-size: 30px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin-top: 18px; }
/* Jost: a free Futura-style geometric sans. Futura was everywhere in 1940s
   military, poster and chart lettering; set in spaced capitals it reads as a
   period chart title (SIL OFL, self-hosted in web/fonts). */
@font-face { font-family: "Jost"; src: url("fonts/jost.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
.brand { font-family: "Jost", "Futura", "Century Gothic", sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: 0.24em;
  color: var(--brass); font-size: 34px; line-height: 1; margin-bottom: 10px; }
.callsign { margin: 0 0 18px; }
.callsign strong { color: var(--ink); }
.ship-card.random strong { color: var(--brass); }
.muted { color: var(--muted); }
.fine { font-size: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.loading-status { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 22px; }
.spinner { display: inline-block; flex-shrink: 0; width: 32px; height: 32px; border: 3px solid var(--panel-edge); border-top-color: var(--brass); border-radius: 50%; will-change: transform; animation: spinner-turn 0.85s linear infinite; }
@keyframes spinner-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.field { display: block; margin-top: 14px; color: var(--muted); font-size: 13px; }
input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: rgba(255,255,255,0.06); border: 1px solid var(--panel-edge); }
input:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
button { font: inherit; color: var(--ink); background: rgba(255,255,255,0.07); border: 1px solid var(--panel-edge);
  padding: 8px 14px; cursor: pointer; }
button:hover { background: rgba(255,255,255,0.13); }
button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
button.sel { border-color: var(--brass); background: rgba(224,194,122,0.14); }
button.primary { background: var(--brass); color: #1b1407; border: none; font-weight: 650; }
button.primary:hover { filter: brightness(1.08); }
button.big { width: 100%; padding: 13px; margin-top: 20px; font-size: 17px; }
button.ghost { background: rgba(6,18,30,0.6); }
.ship-card { text-align: left; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.ship-card strong { font-size: 16px; }
.ship-card .cost { color: var(--brass); font-variant-numeric: tabular-nums; font-size: 13px; }
.ship-card .role { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ship-card .kind { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.ship-card .arm { font-size: 12px; }
.clock { font-size: 40px; font-variant-numeric: tabular-nums; margin: 8px 0; }
.clock.small { font-size: 15px; margin: 2px 0 0; color: var(--muted); }
.queue-estimate { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 18px; font-size: 12px; }
.queue-estimate strong { color: var(--brass); font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* HUD */
.hud .panel { position: absolute; background: var(--panel); border: 1px solid var(--panel-edge); }
#topbar { top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 8px 14px;
  width: min(640px, calc(100% - 32px)); pointer-events: none; }
.tickets { flex: 1; display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-weight: 650; }
.tickets .bar { flex: 1; height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; }
.tickets .bar i { display: block; height: 100%; width: 100%; transition: width 0.3s; }
.tickets.mine { color: var(--friend); } .tickets.mine .bar i { background: var(--friend); }
.tickets.enemy { color: var(--enemy); } .tickets.enemy .bar i { background: var(--enemy); margin-left: auto; }
.mid { text-align: center; }
.pips { display: flex; gap: 5px; justify-content: center; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); position: relative; overflow: hidden; }
.pip i { position: absolute; left: 0; right: 0; bottom: 0; }
.pip.friend { border-color: var(--friend); } .pip.enemy { border-color: var(--enemy); }
.banner { position: absolute; top: 104px; left: 50%; transform: translateX(-50%); background: rgba(150,30,20,0.85); padding: 6px 14px;
  font-weight: 650; letter-spacing: 0.05em; }
.hidden { display: none !important; }
#feed { position: absolute; top: 12px; right: 12px; width: 300px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
#feed div { background: var(--panel); padding: 4px 10px; border-radius: 6px; font-size: 13px; animation: fade 8s forwards; }
#feed .f { color: var(--friend); } #feed .e { color: var(--enemy); } #feed .me { color: var(--brass); font-weight: 650; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#leave { position: absolute; top: 12px; left: 12px; }
#netstat { position: absolute; top: 10px; left: 12px; }
#ship { left: 12px; bottom: 12px; width: 300px; padding: 12px 14px; pointer-events: none; }
/* Hit points: dark numbers with a light halo read on the bright fill and on
   the dark empty track alike. */
.hpbar { position: relative; height: 15px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.hpbar i { position: absolute; inset: 0 auto 0 0; background: var(--good); transition: width 0.2s; }
.hpbar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 15px; font-weight: 700; color: #0b1620;
  font-variant-numeric: tabular-nums; text-shadow: 0 0 2px rgba(255,255,255,0.95), 0 0 2px rgba(255,255,255,0.95), 0 0 3px rgba(255,255,255,0.7); }
.gauges { align-items: flex-start; }
.label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 3px; }
.telegraph, .rudder { display: flex; gap: 2px; }
.telegraph b, .rudder b { width: 12px; height: 16px; background: rgba(255,255,255,0.1); }
.telegraph b.on, .rudder b.on { background: var(--brass); }
.telegraph b.rev.on { background: var(--enemy); }
.num { font-variant-numeric: tabular-nums; font-weight: 650; }
.weapons { display: flex; gap: 8px; margin-top: 10px; }
.weapon { flex: 1; font-size: 11px; color: var(--muted); }
.weapon .bars { display: flex; gap: 3px; margin-top: 3px; }
.weapon .bar { flex: 1; height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.weapon .bar i { display: block; height: 100%; background: var(--ink); transition: width 0.2s linear; }
.weapon .bar.ready i { background: var(--good); }
.weapon.guns { flex: 1.6; }
#help { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); text-align: center; width: min(560px, 60%); }
.center-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.center-overlay .card { background: rgba(6,18,30,0.72); }
table { width: 100%; border-collapse: collapse; margin-top: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px 6px; }
td { padding: 5px 6px; border-top: 1px solid var(--panel-edge); }
td.f { color: var(--friend); } td.e { color: var(--enemy); } td.me { color: var(--brass); font-weight: 650; }
#toast { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: var(--panel); padding: 8px 16px;
  border: 1px solid var(--panel-edge); }
@media (max-width: 720px) {
  #ship { width: calc(100% - 24px); }
  #help { display: none; }
  #feed { width: 60%; top: 64px; }
}
.banner.warn { top: 112px; background: rgba(200,120,20,0.92); font-size: 17px; padding: 9px 18px; animation: fogpulse 1s ease-in-out infinite; }
.banner.warn b { font-variant-numeric: tabular-nums; }
@keyframes fogpulse { 50% { background: rgba(170,40,20,0.92); } }

/* Scoreboard (hold Tab) and the end-of-battle board */
.board { width: min(1060px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow: auto; padding: 18px 20px; }
.board-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; text-align: left; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; border-bottom: 1px solid var(--panel-edge); margin-bottom: 4px; }
.board-team.friendly .board-head strong { color: var(--friend); }
.board-team.hostile .board-head strong { color: var(--enemy); }
.board-head span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.board-teams table { width: 100%; border-collapse: collapse; font-size: 13px; }
.board-teams th { color: var(--muted); font-weight: 500; font-size: 11px; text-align: right; padding: 2px 6px; }
.board-teams th:nth-child(2) { text-align: left; }
.board-teams td { padding: 2px 6px; }
.board-teams td.num { text-align: right; font-variant-numeric: tabular-nums; }
.board-teams td.cap { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-teams tr.me td.cap { color: var(--brass); font-weight: 650; }
.board-teams tr.me { background: rgba(224,194,122,0.08); }
.board-teams tr.down { opacity: 0.45; }
.hullcell { width: 112px; padding: 1px 6px 1px 2px !important; }
.hullcell svg { display: block; width: 104px; height: 16px; }
.hullcell .hull { stroke: rgba(0,0,0,0.6); stroke-width: 1.2; }
.friendly .hullcell .hull { fill: var(--friend); }
.hostile .hullcell .hull { fill: var(--enemy); }
.hullcell .house { fill: rgba(240,244,248,0.6); }
.hullcell .funnel { fill: #141a21; }
.hullcell .turret { fill: #27313b; }
#s-ended .card { width: min(1060px, calc(100vw - 32px)); }
#s-ended .board-teams { max-height: calc(100vh - 260px); overflow: auto; margin: 10px 0 18px; }

/* Ability slots (keys 1-4), bottom centre */
.abilities { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.ability { pointer-events: auto; cursor: default; position: relative; width: 52px; height: 52px; background: var(--panel); border: 1px solid var(--panel-edge);
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ability .sweep { position: absolute; inset: 0; }
.ability .key { position: absolute; top: 3px; left: 5px; font-size: 10px; color: var(--muted); font-weight: 600; }
.ability .lbl { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; z-index: 1; }
.ability .n { position: absolute; bottom: 3px; right: 5px; font-size: 11px; font-style: normal; color: var(--brass); font-variant-numeric: tabular-nums; z-index: 1; }
.ability .cd { position: absolute; bottom: 3px; left: 5px; font-size: 10px; color: var(--ink); z-index: 1; font-variant-numeric: tabular-nums; }
.ability.active { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.ability.cooling .lbl { opacity: 0.55; }
.ability.spent { opacity: 0.4; }
.ability.empty { opacity: 0.35; }

/* In-game menu (Esc) */
.menu h2 { margin-bottom: 14px; }
.menu .stack { display: flex; flex-direction: column; gap: 8px; }
.menu .stack button { width: 100%; }
.menu .row.center { justify-content: center; gap: 10px; }
button.danger { background: var(--enemy); color: #1c0805; border: none; font-weight: 650; }
.controls { width: 100%; border-collapse: collapse; margin: 4px 0 14px; text-align: left; font-size: 13px; }
.controls td { padding: 4px 4px; border-bottom: 1px solid var(--panel-edge); }
.controls td:last-child { text-align: right; white-space: nowrap; }
kbd { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px; border: 1px solid var(--panel-edge); border-bottom-width: 2px; 
  font-family: inherit; font-weight: 600; font-size: 11px; line-height: 1.5; text-align: center; background: rgba(255,255,255,0.05); }
#m-keys { width: min(440px, calc(100vw - 48px)); }
.card.small.menu:has(#m-keys:not(.hidden)) { width: min(480px, 100%); }

.ability-tip { position: fixed; z-index: 20; width: 250px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--panel-edge);
  outline: 1px solid rgba(0,0,0,0.35); font-size: 12px; pointer-events: none; }
.ability-tip .tip-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ability-tip .tip-head strong { font-size: 13px; color: var(--brass); }
.ability-tip p { margin: 0 0 8px; color: var(--ink); line-height: 1.4; }
.ability-tip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; color: var(--muted); }
.ability-tip dd { margin: 0; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Waiting to respawn: a quiet strip under the score widget, out of the way
   of spectating. */
.respawn { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); display: flex; align-items: baseline; gap: 10px;
  padding: 5px 12px; background: var(--panel); border: 1px solid var(--panel-edge); font-size: 13px; white-space: nowrap; pointer-events: auto; }
.respawn #dead-title { color: var(--enemy); font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; font-size: 11px; }
.respawn #dead-text { color: var(--ink); font-variant-numeric: tabular-nums; }
button.link { background: none; border: none; padding: 0; color: var(--muted); font-size: 12px; text-decoration: underline; cursor: pointer; }
button.link:hover { color: var(--ink); }

/* Chat feed (reactions), bottom right, like the kill feed */
#chat { position: absolute; right: 12px; bottom: 12px; width: 320px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; pointer-events: none; }
#chat div { background: var(--panel); padding: 4px 10px; border-radius: 6px; font-size: 13px; animation: fade 10s forwards; }
#chat .f { color: var(--friend); } #chat .e { color: var(--enemy); } #chat .me { color: var(--brass); font-weight: 650; }
#chat .tag { font-size: 10px; letter-spacing: 0.08em; color: var(--friend); font-weight: 700; }
#chat .emoji { font-size: 16px; line-height: 1; }

/* Reaction wheel (hold right mouse) */
.wheel { position: fixed; width: 320px; height: 320px; z-index: 30; pointer-events: none; }
.wheel svg { overflow: visible; }
.wheel .cat, .wheel .item { fill: rgba(6, 18, 30, 0.9); stroke: var(--panel-edge); stroke-width: 1; }
.wheel .cat.on { fill: rgba(224, 194, 122, 0.3); stroke: var(--brass); }
.wheel .item.on { fill: rgba(224, 194, 122, 0.42); stroke: var(--brass); }
.wheel .hub { fill: rgba(6, 18, 30, 0.9); stroke: var(--panel-edge); }
.wheel text { fill: var(--ink); text-anchor: middle; dominant-baseline: middle; }
.wheel .cat-label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.wheel .item-label { font-size: 10.5px; }
.wheel .emoji { font-size: 24px; }
.wheel .hub-label { font-size: 10px; fill: var(--muted); letter-spacing: 0.08em; }
.wheel.cooling .item, .wheel.cooling .cat { opacity: 0.45; }

/* Main menu. The existing map canvas remains visible behind a small stack
   and one popout. Solid fills and crisp borders avoid compositing a blur
   or a shadow over the map as it repaints. */
#s-menu.on { justify-content: flex-start; padding: 140px var(--lobby-gutter) 40px; }
.lobby { --lobby-gutter: 5vw; font-family: "Jost", "Futura", sans-serif; }
.lobby-header { position: absolute; top: 40px; left: var(--lobby-gutter); right: var(--lobby-gutter); display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.lobby-header .brand { font-size: 30px; line-height: 1.12; margin: 0; }
.lobby-header .callsign { margin: 5px 0 0; font-size: 12px; }
.lobby-layout { position: relative; display: flex; gap: 20px; align-items: flex-start; height: min(660px, calc(100dvh - 200px)); min-height: 380px; }
.lobby-stack { width: 290px; flex-shrink: 0; }
.lobby-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 94px; padding: 20px 23px; margin-bottom: 10px; text-align: left; background: var(--panel); }
.lobby-button > span:first-child { min-width: 0; }
.lobby-button small { display: block; margin-bottom: 4px; font-size: 9px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.lobby-button strong { display: block; font-size: 25px; font-weight: 450; overflow-wrap: anywhere; line-height: 1.2; }
.lobby-arrow { margin-left: auto; color: var(--muted); font-size: 28px; line-height: 1; }
.lobby-button[aria-expanded="true"] { border-color: var(--brass); background: #172e3c; }
.lobby-button[aria-expanded="true"] .lobby-arrow { color: var(--brass); }
.lobby-controls, .lobby-donate { min-height: 67px; font-size: 19px; }
.lobby-donate { pointer-events: auto; color: var(--ink); border: 1px solid var(--panel-edge); text-decoration: none; }
.lobby-donate:hover { background: rgba(255,255,255,0.13); }
.lobby-donate:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.lobby-ship-preview { display: flex; flex-shrink: 0; width: 70px; margin-left: auto; }
.lobby-ship-preview:empty { display: none; }
.lobby-ship-preview svg { width: 100%; height: 20px; }
.lobby-ship-preview:not(:empty) + .lobby-arrow { margin-left: 0; }
.lobby-play { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 28px; padding: 15px 23px; font-size: 20px; }
.lobby-popout { pointer-events: auto; display: flex; flex-direction: column; width: 380px; height: 100%; border: 1px solid var(--panel-edge); background: #091b2a; }
.lobby-popout-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; scrollbar-width: auto; scrollbar-color: #3c5365 transparent; }
.lobby-popout-scroll::-webkit-scrollbar { width: 12px; }
.lobby-popout-scroll::-webkit-scrollbar-thumb { background: #3c5365; }
.lobby-popout-scroll::-webkit-scrollbar-track { background: transparent; }
.lobby-popout-scroll:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }
.lobby .ship-card, .lobby .battle-card { position: relative; width: 100%; padding: 16px; margin-bottom: 9px; background: #102534; border: 1px solid var(--panel-edge); text-align: left; }
.lobby .ship-card:hover, .lobby .battle-card:hover { background: #193443; }
.lobby .ship-card.sel, .lobby .battle-card.sel { border-color: var(--brass); background: #1b3340; }
.lobby .sel::after { content: '✓'; position: absolute; top: 17px; right: 13px; color: var(--brass); font-size: 11px; }
.lobby .choice-name { display: block; padding-right: 20px; font-size: 21px; font-weight: 450; line-height: 1.25; overflow-wrap: anywhere; }
.lobby .role { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.lobby .ship-card .role { font-size: 11px; }
.lobby .ship-card .cost { font-size: 12px; }
.lobby .ship-card .arm { font-size: 11px; }
.lobby .random .choice-name { color: var(--brass); }
.lobby-ship-group h3 { position: sticky; top: -12px; z-index: 1; display: flex; justify-content: space-between; padding: 14px 4px 9px; margin: 0; font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); font-weight: 450; background: #091b2a; }
.ship-card-preview { display: flex; align-items: center; justify-content: center; height: 46px; margin: 5px 0; }
.ship-card-preview svg { width: 100%; height: 46px; }
.lobby .hull { fill: #89a8bd; stroke: #203a4b; stroke-width: 0.7; }
.lobby .house { fill: #c7d4db; }
.lobby .funnel { fill: #172c3a; }
.lobby .turret { fill: #314b60; stroke: #9ab0bf; stroke-width: 0.5; }
.lobby .sel .hull, .lobby-ship-preview .hull { fill: var(--brass); }
.lobby .controls { margin: 0; font-size: 12px; }
.lobby .controls td { padding: 12px 3px; }
.lobby .controls td:first-child { width: 48%; }
.lobby .controls td:last-child { white-space: normal; }
.lobby .controls kbd { margin-top: 3px; }
@media (max-width: 800px) {
  .lobby { --lobby-gutter: 24px; }
  .lobby-stack { width: 250px; }
  .lobby-layout { gap: 16px; }
  .lobby-popout { width: min(360px, calc(100vw - 314px)); }
  .lobby-button { padding: 18px; }
  .lobby-button strong { font-size: 23px; }
  .lobby-ship-preview { width: 50px; }
}
@media (max-width: 640px) {
  .lobby { --lobby-gutter: 22px; }
  #s-menu.on { padding: 135px 22px 22px; align-items: flex-start; overflow-y: auto; pointer-events: auto; }
  .lobby-header { top: 27px; left: 22px; right: 22px; }
  .lobby-header .brand { font-size: 25px; }
  .lobby-header .callsign { max-width: 120px; text-align: right; font-size: 11px; }
  .lobby-layout { width: 100%; height: auto; min-height: 0; flex-direction: column; }
  .lobby-stack { width: min(290px, 100%); }
  .lobby-popout { width: 100%; height: min(520px, 60dvh); flex-shrink: 0; }
}
@media (max-width: 640px) and (max-height: 600px) {
  .lobby-layout { height: auto; }
}
@media (max-height: 600px) {
  #s-menu.on { padding-top: 90px; padding-bottom: 12px; align-items: flex-start; }
  .lobby-header { top: 16px; }
  .lobby-header .brand { font-size: 22px; }
  .lobby-layout { height: calc(100dvh - 102px); min-height: 0; }
  .lobby-stack { max-height: 100%; overflow-y: auto; pointer-events: auto; }
  .lobby-button { min-height: 64px; padding: 10px 18px; margin-bottom: 8px; }
  .lobby-controls, .lobby-donate { min-height: 48px; }
  .lobby-play { margin-top: 16px; padding: 11px 18px; }
}
.lobby .battle-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding-top: 12px; margin-top: 13px; border-top: 1px solid var(--panel-edge); }
.lobby .battle-facts:empty { display: none; }
.battle-fact-label { display: block; font-size: 9px; color: var(--muted); letter-spacing: 0.07em; text-transform: uppercase; }
.battle-fact-value { display: block; font-size: 17px; margin-top: 3px; line-height: 1.25; }
.battle-fact-detail { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Each language keeps its native name; translation-source badges use the UI language. */
.lobby-stack { max-height: 100%; overflow-y: auto; pointer-events: auto; scrollbar-width: thin; }
.lobby-language { min-height: 76px; }
.lobby-language strong { font-size: 21px; }
.lobby .language-card { position: relative; display: block; width: 100%; padding: 16px; margin-bottom: 9px; border: 1px solid var(--panel-edge); background: #102534; text-align: left; }
.lobby .language-card:hover { background: #193443; }
.lobby .language-card.sel { border-color: var(--brass); background: #1b3340; }
.translation-source { display: block; margin-top: 9px; font-size: 11px; line-height: 1.5; color: var(--muted); }
html:lang(ja) .lobby, html:lang(zh) .lobby { font-family: system-ui, sans-serif; }
@media (max-width: 640px) { .lobby-stack { max-height: none; overflow-y: visible; } }
@media (max-height: 600px) { .lobby-language { min-height: 64px; } }
@font-face { font-family: "IH Japanese"; src: url("fonts/ih-japanese.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IH Chinese"; src: url("fonts/ih-chinese.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
html:lang(ja) body, html:lang(ja) .lobby, [lang|="ja"] { font-family: "IH Japanese", system-ui, sans-serif; }
html:lang(zh) body, html:lang(zh) .lobby, [lang|="zh"] { font-family: "IH Chinese", system-ui, sans-serif; }
