/* agarfunny — interface. Every color here comes from themes.css (the theme chosen, set as data-palette on <html>).
   Roles: the primary is you and the one action that matters, a switch that is on; the secondary frames and ranks; the
   tertiary marks the focus and accents. Surfaces are flat with a hairline. Over the arena (HUD, chat) the panels have
   no veil at all, only a hairline, so that nothing of the game is hidden; a shadow around the letters keeps them
   readable, light letters on a dark arena and dark ones on a light one. */

:root {
  --over-arena: transparent;
  --over-arena-line: rgba(255, 255, 255, .13);
  --over-arena-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 0 3px rgba(0, 0, 0, .95), 0 0 7px rgba(0, 0, 0, .7);
  --display: Unbounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
canvas { display: block; }
#arena { position: fixed; inset: 0; width: 100vw; height: 100dvh; touch-action: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
kbd {
  display: inline-block; min-width: 1.9em; padding: .12em .5em; text-align: center;
  font: 700 .78rem/1.5 var(--body); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px;
}

/* ---------- Lobby: everything on one screen. Two cards side by side, one at a time on a narrow screen. ---------- */

.lobby {
  position: fixed; inset: 0; z-index: 5; margin: 0;
  display: flex; overflow-y: auto; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}
.lobby-bg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lobby-shell { position: relative; width: min(1000px, 100%); margin: auto; }
.lobby .lobby-switch { display: none; margin-bottom: 10px; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr); gap: 18px; align-items: stretch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.play-card { padding: 24px 28px 20px; }
.settings-card { padding: 22px 24px 20px; }

.brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 20px; container-type: inline-size; }
/* The logo, in the theme's colors: the symbol and the wordmark side by side. */
.logo { display: flex; align-items: center; gap: 7px; margin: 0; direction: ltr; flex: none; }
/* The wordmark about as tall as the cell of the symbol, so that the two read as one. */
/* Both shrink with the card, so that the header stays one line on every screen. */
.logo-symbol { width: min(62px, 14cqw); aspect-ratio: 62 / 52; background: var(--brand-symbol) center / contain no-repeat; }
.logo-word { width: min(182px, 41cqw); aspect-ratio: 182 / 40; margin-top: 5px; background: var(--brand-wordmark) center / contain no-repeat; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tagline { margin: 10px 0 16px; color: var(--muted); max-width: 48ch; }

.field { margin-bottom: 15px; }
.field-label, .settings-card h3, .top h3 {
  display: block; margin: 0 0 8px;
  font: 700 .72rem/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}

.segmented {
  display: flex; padding: 4px; gap: 4px; background: var(--input); border: 1px solid var(--line); border-radius: 14px;
}
.segmented button {
  flex: 1; padding: 11px 10px; border: 1px solid transparent; border-radius: 10px; background: none;
  color: var(--muted); font-weight: 700; white-space: nowrap; transition: color .15s, background .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.segmented button[aria-checked="true"]::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%;
  background: var(--tertiary); vertical-align: .08em;
}

.status { display: flex; align-items: center; gap: 4px 10px; min-width: 0; margin: 0; font-size: .82rem; color: var(--muted); }
.status strong { color: var(--text); font-weight: 700; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.status[data-ready="true"] i { background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent); }

/* The skin and the nickname, each under its own name. */
.identity { display: grid; grid-template-columns: 62px minmax(0, 1fr); column-gap: 14px; align-items: center; }
.skin-label { text-align: center; }
.skin-slot { position: relative; }
.bubble {
  position: relative; display: block; width: 62px; height: 62px; padding: 0; border-radius: 50%;
  border: 2px dashed var(--line-strong); background: var(--input); overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.bubble:hover { border-color: var(--secondary); transform: scale(1.04); }
.bubble canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bubble::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; opacity: .55;
  background:
    linear-gradient(var(--muted), var(--muted)) center / 100% 2px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center / 2px 100% no-repeat;
}
.bubble[data-skin]::after { display: none; }
.bubble[data-skin] { border-style: solid; border-color: var(--primary); }
.bubble-clear {
  position: absolute; left: 42px; top: -6px; width: 24px; height: 24px; padding: 0; z-index: 1;
  border-radius: 50%; border: 2px solid var(--surface);
  background: var(--danger); color: var(--on-danger); font-size: 0;
}
.bubble-clear:hover { filter: brightness(1.12); }
.identity input {
  width: 100%; height: 62px; padding: 0 18px; border-radius: 16px;
  background: var(--input); border: 1px solid var(--line); font-size: 1.15rem; font-weight: 700;
}
.identity input::placeholder { color: var(--faint); }
.identity input:focus { outline: none; border-color: var(--secondary); }

.cta { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.cta:has(#watch[hidden]) { grid-template-columns: 1fr; }
.btn {
  height: 52px; border-radius: 14px; border: 1px solid var(--line-strong); background: none;
  font-weight: 800; font-size: 1.02rem; transition: transform .12s, background .15s, border-color .15s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.ghost:hover:not(:disabled) { border-color: var(--secondary); }

.segmented.mini { padding: 3px; gap: 3px; border-radius: 11px; }
.segmented.mini button { padding: 5px 11px; font-size: .8rem; border-radius: 8px; }
.segmented.mini button[aria-checked="true"]::before { display: none; }

/* The best scores of the server picked above, right in the menu. */
.top { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.top-head, .settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-head h3 { margin: 0; }
/* Ten places, in two columns read downward. */
.top-list {
  margin: 8px 0 0; padding: 0; list-style: none; counter-reset: top; min-height: 130px;
  display: grid; grid-auto-flow: column; grid-template: repeat(5, 26px) / repeat(2, minmax(0, 1fr)); column-gap: 16px;
}
.top-list li {
  counter-increment: top; display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 700; font-size: .86rem;
}
.top-list li::before { content: counter(top); width: 1.2em; color: var(--secondary); font-weight: 800; }
.top-list span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-list b { color: var(--primary); font-variant-numeric: tabular-nums; }
.top-list li.empty { grid-column: 1 / -1; color: var(--muted); font-weight: 500; }
.top-list li.empty::before { content: none; }
.btn.small { height: 38px; padding: 0 16px; margin-top: 10px; font-size: .86rem; border-radius: 10px; }
.top-more { display: flex; align-items: center; justify-content: center; color: var(--text); text-decoration: none; border-color: var(--secondary); }

.settings-head { margin-bottom: 14px; }
.segmented.tabs { flex: 1; }
.segmented.tabs button { padding: 8px 10px; font-size: .86rem; }

/* A server and its rules: in the list of the servers, and the one picked in the play card. */
.rooms { display: flex; flex-direction: column; gap: 8px; }
.room, .server-card {
  display: block; width: 100%; padding: 10px 13px; text-align: left;
  background: var(--input); border: 1px solid var(--line); border-radius: 13px;
}
.room:hover, .server-card:hover { border-color: var(--line-strong); }
.room[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent); }
.room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.room-head strong, .server-card strong { font-weight: 800; }
.room-head span { flex: none; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.server-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* A server of the list: what to press, and under the one picked, for a private room, what can be done with it. */
.room-item { background: var(--input); border: 1px solid var(--line); border-radius: 13px; }
.room-item:hover { border-color: var(--line-strong); }
.room-item[data-picked] { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent); }
.room-item .room { background: none; border: 0; box-shadow: none; }
/* What is written on a line is rewritten while it may be pressed: the press is always the line's own. */
.room > * { pointer-events: none; }
.server-field { display: none; }
.server-card small { display: block; font: 700 .66rem/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.server-card strong { display: block; overflow-wrap: anywhere; }
/* What the page has to say about the last press: under the buttons it is about. */
.message { margin: 10px 2px 0; min-height: 1.4em; color: var(--muted); font-size: .86rem; }
.message[data-kind="error"] { padding: 7px 11px; border-radius: 10px; border: 1px solid var(--danger); color: var(--danger-text); background: color-mix(in srgb, var(--danger) 12%, transparent); font-weight: 700; }
.status[data-ready="true"] { display: none; }
.brand-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
/* The one heading with something beside it: its margins are the line's, whatever the other headings here get. */
#panel-servers .list-head h3 { margin: 0; }
.online { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; line-height: 1; font-weight: 700; color: var(--muted); white-space: nowrap; }
.online::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
#language {
  height: 28px; max-width: 108px; padding: 0 4px; border-radius: 8px; background: var(--input); border: 1px solid var(--line);
  color: var(--muted); font: 700 .76rem var(--body);
}
.server-card > span { min-width: 0; }
.server-card em { flex: none; font-style: normal; font-weight: 800; font-size: .82rem; color: var(--secondary); }
.tags { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 7px; }
.tags span {
  padding: 1px 6px; border-radius: 7px; border: 1px solid; text-align: center; font-size: .72rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums;
}
.tags span[data-kind="cells"] { color: var(--tag-cells); border-color: color-mix(in srgb, var(--tag-cells-tint) 40%, transparent); background: color-mix(in srgb, var(--tag-cells-tint) 8%, transparent); }
.tags span[data-kind="virus"] { color: var(--tag-virus); border-color: color-mix(in srgb, var(--tag-virus-tint) 40%, transparent); background: color-mix(in srgb, var(--tag-virus-tint) 8%, transparent); }
.tags span[data-kind="timer"] { color: var(--tag-timer); border-color: color-mix(in srgb, var(--tag-timer-tint) 40%, transparent); background: color-mix(in srgb, var(--tag-timer-tint) 8%, transparent); }
.tags span[data-kind="tabbing"] { color: var(--tag-tabbing); border-color: color-mix(in srgb, var(--tag-tabbing-tint) 40%, transparent); background: color-mix(in srgb, var(--tag-tabbing-tint) 9%, transparent); }
.tags span[data-kind="watch"] { color: var(--tag-watch); border-color: color-mix(in srgb, var(--tag-watch-tint) 40%, transparent); background: color-mix(in srgb, var(--tag-watch-tint) 8%, transparent); }
.tags span[data-kind="other"] { color: var(--text-softer); border-color: var(--line-strong); }
#private h3 { margin-top: 14px; }
#panel-servers.called { animation: called .9s ease-out; border-radius: 14px; }
@keyframes called { 0%, 35% { box-shadow: 0 0 0 3px var(--secondary); } 100% { box-shadow: 0 0 0 3px transparent; } }
.join-line { display: flex; gap: 8px; }
.join-line input {
  flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--input);
  border: 1px solid var(--line); font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.join-line .btn { flex: none; height: 38px; padding: 0 14px; font-size: .84rem; border-radius: 10px; }
.room-note { margin: 6px 2px; min-height: 1.2em; color: var(--muted); font-size: .8rem; }
#room-note:empty { min-height: 0; margin: 4px 0; }
.more-rooms { margin: 2px; color: var(--muted); font-size: .8rem; }
.room-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 7px 9px; border-top: 1px solid var(--line); }
.room-tools .btn { height: 30px; padding: 0 10px; font-size: .78rem; border-radius: 8px; }

/* The making of a room: every rule on one screen. */
.dialog.create { width: min(640px, 100%); }
.create .fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.create label { display: flex; flex-direction: column; gap: 4px; font: 700 .68rem/1 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.create label.wide { grid-column: span 2; }
.create select, .create input {
  width: 100%; min-width: 0; height: 38px; padding: 0 10px; border-radius: 10px; background: var(--input);
  border: 1px solid var(--line-strong); color: var(--text); font: 700 .9rem var(--body); letter-spacing: 0; text-transform: none;
}
.create footer { display: flex; justify-content: flex-end; gap: 10px; }
.create footer .btn { height: 42px; padding: 0 18px; font-size: .9rem; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.tile {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 10px 0 13px;
  background: var(--input); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; font-size: .9rem; text-align: left;
}
.tile:hover { border-color: var(--line-strong); }
.tile i { position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px; border: 1px solid var(--line-strong); }
.tile i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .16s, background .15s;
}
.tile[aria-checked="true"] i { background: var(--primary); border-color: var(--primary); }
.tile[aria-checked="true"] i::after { transform: translateX(16px); background: var(--on-primary); }
.swatches { display: grid; grid-template-columns: repeat(7, max-content); gap: 9px; }
.swatch {
  position: relative; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid var(--line-strong); cursor: pointer;
}
.swatch[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.swatch.custom { background: conic-gradient(#ff5c6c, #ffb347, #ccff00, #00d1df, #8a4fff, #ff5c6c); }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.controls-note { margin: 0 0 8px; color: var(--muted); font-size: .84rem; }
.control-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 100px 128px; gap: 8px; align-items: center;
  padding: 6px 0; border-top: 1px solid var(--line); font-weight: 700; font-size: .88rem;
}
.control-row button, .control-row select {
  height: 34px; min-width: 0; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--input); font-weight: 700;
}
.control-row button.listening { border-color: var(--primary); color: var(--primary); }
.control-row button.empty { color: var(--muted); }
.fixed-keys { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; line-height: 2; }
.fixed-keys b { margin-right: 10px; color: var(--text); }
.fixed-keys + .fixed-keys { margin-top: 4px; padding-top: 0; border-top: 0; }
.fixed-keys span { margin-right: 14px; white-space: nowrap; }
.fixed-keys kbd { margin-right: 6px; }
.debug-help { margin: 12px 0 0; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); font-size: .82rem; }

/* ---------- Best scores: a window over the menu ---------- */

.top-more { width: 100%; }
.dialog.scores { width: min(820px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.scores-picks { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.scores-note { margin: 8px 2px; color: var(--muted); }
.scores-note:empty { margin: 4px 0; }
.scores-scroll { overflow: auto; min-height: 0; }
.scores-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scores-table th {
  position: sticky; top: 0; background: var(--surface); padding: 8px; text-align: left;
  font: 700 .66rem/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.scores-table td { padding: 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.scores-table .n { text-align: right; }
.scores-table .rank { color: var(--secondary); font-weight: 800; }
.scores-table .who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.scores-table .mass { color: var(--primary); font-weight: 800; }
.scores-table td.when { color: var(--muted); font-size: .86rem; }
@media (max-width: 560px) {
  .scores-table .eaten, .scores-table .when { display: none; }
  .scores-table .who { max-width: 140px; }
}

/* ---------- The footer, the statistics and the pages ---------- */

.round-button { width: 34px; height: 34px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: none; }
.round-button:hover { border-color: var(--secondary); }
.round-button svg { width: 18px; height: 18px; fill: var(--secondary); }
.foot {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 4px; width: fit-content; max-width: 100%;
  margin: 22px auto 0; padding: 5px 7px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px;
}
.foot button { padding: 3px 11px; border: 1px solid transparent; border-radius: 13px; background: none; color: var(--text-soft); font: 700 .78rem/1.5 var(--body); }
.foot button:hover { background: var(--surface-2); color: var(--text); }
.foot button.accent { color: var(--secondary); border-color: var(--secondary); }
.dialog.profile, .dialog.pages { width: min(660px, 100%); max-height: calc(100dvh - 32px); }
.dialog-body { overflow: auto; min-height: 0; }
.dialog-body a { color: var(--secondary); font-weight: 800; }
.dialog-body a.join-discord { display: inline-flex; align-items: center; height: 44px; padding: 0 20px; color: var(--on-primary); text-decoration: none; }
.discord-banner { display: block; max-width: 100%; border-radius: 8px; }
.dialog-body h3 { margin: 14px 0 5px; font: 800 .72rem/1.3 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--secondary); }
#pages-tabs { flex-wrap: wrap; align-self: flex-start; }
#pages-body p { margin: 0 0 8px; line-height: 1.5; font-size: .92rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.stat-tiles div { padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; }
.stat-tiles dt { font: 700 .62rem/1.3 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); overflow-wrap: anywhere; }
.stat-tiles dd { margin: 3px 0 0; font: 800 1.15rem/1.2 var(--body); color: var(--primary); font-variant-numeric: tabular-nums; }
#profile-modes p { margin: 3px 0; font-size: .9rem; }
#profile-modes b { color: var(--secondary); }
#profile-erase { margin-top: 12px; }
@media (max-width: 640px) { .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-height: 760px) { .foot { margin-top: 9px; padding: 2px 5px; } .foot button { padding: 0 9px; font-size: .73rem; } }

/* ---------- Themes ---------- */

/* Where the anti-bot widget shows itself when it wants a click, over everything; empty and out of the way otherwise. */
.bot-check { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40; direction: ltr; }

.theme-picks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
/* Each in its own colors: its ground, its three accents, its name. */
.theme-pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 7px 4px 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 11px; color: var(--text);
}
.theme-pick b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font: 800 .72rem/1.2 var(--body); white-space: nowrap; }
.theme-dots { display: flex; gap: 3px; }
.theme-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--primary); }
.theme-dots i:nth-child(2) { background: var(--secondary); }
.theme-dots i:nth-child(3) { background: var(--tertiary); }
.theme-pick:hover { border-color: var(--secondary); }
.theme-pick[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
@media (max-height: 760px) { .theme-picks { margin-bottom: 8px; } .theme-pick { padding: 4px 3px; gap: 2px; } }

/* ---------- Skin chooser ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--shade) 72%, transparent);
}
.dialog { width: min(560px, 100%); max-height: min(640px, 100%); display: flex; flex-direction: column; padding: 22px 22px 18px; }
.dialog header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog h2 { margin: 0; font: 800 1.1rem/1 var(--display); letter-spacing: -.02em; }
.icon-btn { position: relative; flex: none; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: none; font-size: 0; }
.icon-btn::before, .icon-btn::after, .bubble-clear::before, .bubble-clear::after {
  content: ""; position: absolute; left: calc(50% - 7px); top: calc(50% - 1px); width: 14px; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(45deg);
}
.icon-btn::after, .bubble-clear::after { transform: rotate(-45deg); }
.bubble-clear::before, .bubble-clear::after { left: calc(50% - 5px); width: 10px; }
.icon-btn:hover { border-color: var(--secondary); }
/* The window keeps its height whatever the category holds; the tools stay put, the skins scroll. */
.skins-window { width: min(720px, 100%); height: min(640px, calc(100dvh - 32px)); max-height: none; }
.skin-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.skin-tools .segmented { flex: none; max-width: 100%; overflow-x: auto; }
.skin-tools .segmented button { flex: none; }
#skin-search { flex: 1; min-width: 150px; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--input); border: 1px solid var(--line); font-weight: 700; }
.skin-grid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); grid-auto-rows: max-content;
  align-content: start; gap: 8px; overflow-y: auto; padding: 4px;
}
.skin-empty { grid-column: 1 / -1; margin: 8px 4px; color: var(--muted); font-size: .9rem; }
/* Off screen, a skin is not laid out: there are more than a thousand. */
.skin-card { position: relative; display: grid; min-width: 0; content-visibility: auto; contain-intrinsic-size: auto 100px; }
.skin-tile {
  display: grid; justify-items: center; align-content: start; gap: 7px; min-width: 0; padding: 10px 4px 8px; border-radius: 14px;
  background: none; border: 1px solid transparent; color: var(--muted); font-size: .76rem; font-weight: 700;
}
.skin-tile img, .skin-tile .none { width: 58px; height: 58px; border-radius: 50%; }
.skin-tile img { object-fit: cover; background: var(--surface-2); }
.skin-tile span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.skin-tile .none { border: 2px dashed var(--line-strong); background: linear-gradient(135deg, transparent 47%, var(--line-strong) 47% 53%, transparent 53%); }
.skin-tile:hover { background: var(--surface-2); color: var(--text); }
.skin-tile[aria-pressed="true"] { border-color: var(--primary); color: var(--text); background: var(--surface-2); }
/* The star: on the skin under the pointer or the keyboard, and always on a favorite. */
.skin-star {
  position: absolute; top: 4px; inset-inline-end: 4px; width: 27px; height: 27px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%;
  background: var(--surface); color: var(--muted); font-size: .95rem; line-height: 1; opacity: 0;
}
.skin-card:hover .skin-star, .skin-card:focus-within .skin-star, .skin-star[aria-pressed="true"] { opacity: 1; }
.skin-star:hover { color: var(--text); }
.skin-star[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); }
@media (hover: none) { .skin-star { opacity: 1; } }

/* ---------- In game ---------- */

.hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.over {
  background: var(--over-arena); border: 1px solid var(--over-arena-line); border-radius: 14px;
  text-shadow: var(--over-arena-shadow);
}
.score { position: absolute; top: 12px; left: 12px; min-width: 172px; padding: 12px 16px 12px; }
.score .label, .radar-line { font: 700 .66rem/1 var(--body); letter-spacing: .13em; text-transform: uppercase; color: var(--text-soft); }
.score strong { display: block; margin: 5px 0 9px; font: 800 1.85rem/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--primary); }
.score dl { display: flex; gap: 16px; margin: 0; }
.score dt { font: 700 .6rem/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--text-softer); }
.score dd { margin: 4px 0 0; font: 700 .95rem/1 var(--body); font-variant-numeric: tabular-nums; }
.board {
  position: absolute; top: 12px; right: 12px; width: min(248px, 42vw); padding: 12px 10px 10px; text-align: center;
}
.board h2 {
  margin: 0 4px 7px; padding: 2px 0 11px; border-bottom: 2px solid var(--secondary);
  font: 800 1rem/1 var(--display); letter-spacing: -.01em;
}
.board ol { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.board li {
  counter-increment: rank; display: flex; justify-content: center; gap: 7px; padding: 4px 8px; border-radius: 8px;
  font-weight: 700; font-size: .98rem; white-space: nowrap;
}
.board li::before { content: counter(rank) "."; flex: none; color: var(--secondary); font-weight: 800; font-variant-numeric: tabular-nums; }
.board li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.board li.mine { background: color-mix(in srgb, var(--primary) 82%, transparent); color: var(--on-primary); font-weight: 800; text-shadow: none; }
.board li.mine::before { color: var(--on-primary); }
.hud-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; white-space: nowrap; }
.late, .round { margin: 0; padding: 7px 14px; font-weight: 800; font-size: .86rem; font-variant-numeric: tabular-nums; }
.round { font-size: 1rem; }
.round[data-urgent] { color: var(--danger); border-color: var(--danger); }
/* The winner of the last round: a name in gold under the title, said once and apart from the rows, with the same crown
   on its row. No box: a hairline parts it from the standings. */
.champion { margin: 0 4px 7px; padding: 0 0 8px; border-bottom: 1px solid color-mix(in srgb, currentColor 16%, transparent); }
.champion p { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 7px; margin: 0; min-width: 0; }
.champion .champion-who { flex-wrap: nowrap; }
.champion strong { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--gold); font-size: 1.12rem; font-weight: 800; line-height: 1.35; }
.champion-about { font-size: .7rem; font-weight: 600; line-height: 1.4; opacity: .72; font-variant-numeric: tabular-nums; }
.champion-mass::before { content: "·"; margin-right: 7px; }
.crown, .board li.champion-row span::before {
  flex: none; width: 17px; height: 13px; background: var(--gold);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 18'%3E%3Cpath d='M2 17V3l5.5 5L12 1l4.5 7L22 3v14z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.champion.arrives { animation: champion-in .35s ease-out; }
@keyframes champion-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .champion.arrives { animation: none; } }
.board li.champion-row span { color: var(--gold); }
.board li.champion-row.mine span { color: inherit; }
.board li.champion-row span::before { content: ""; display: inline-block; width: .95em; height: .72em; margin-right: .38em; }
.board li.champion-row.mine span::before { background: currentColor; }
body[data-theme="light"] .champion, body[data-theme="light"] .board li.champion-row { --gold: var(--gold-on-light); }
@media (max-width: 880px) {
  .champion strong { font-size: .9rem; }
  .champion-about { font-size: .6rem; }
  .champion-mass { display: none; }
  .champion .crown { width: 13px; height: 10px; }
}
.radar { position: absolute; right: 12px; bottom: 12px; padding: 8px; }
.radar-line { display: flex; justify-content: space-between; gap: 12px; margin: 2px 2px 7px; font-variant-numeric: tabular-nums; }
.radar-line b { color: var(--text); font-weight: 700; }
.radar-line b[data-fps="low"] { color: var(--warning); }
.radar-line b[data-fps="bad"], .radar-line b[data-ping="bad"] { color: var(--danger); }
.radar-line b[data-ping="low"] { color: var(--warning); }
#minimap { width: 176px; height: 176px; border-radius: 8px; }

/* Chat: every line carries its own dark backing, so it reads on a dark or a light arena. */
.chat { position: absolute; left: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.chat-log { display: flex; flex-direction: column; align-items: flex-start; max-height: 232px; overflow: hidden; justify-content: flex-end; }
.chat.open { z-index: 2; }
/* Open, the log scrolls back: it starts at the top (a log that ends at the bottom cannot be scrolled up) and a short one
   is pushed down by its first line. */
.chat.open .chat-log { justify-content: flex-start; overflow-y: auto; pointer-events: auto; }
.chat.open .chat-log > :first-child { margin-top: auto; }
.msg {
  max-width: 100%; margin-top: 4px; padding: 5px 10px 6px; border-radius: 10px;
  background: var(--over-arena); border: 1px solid var(--over-arena-line); text-shadow: var(--over-arena-shadow);
  font-size: .9rem; line-height: 1.3; overflow-wrap: anywhere; flex: none;
}
.msg b { margin-right: .5em; font-weight: 800; }
.msg.server { color: var(--text-soft); }
.msg.server b { font-weight: 700; letter-spacing: .02em; }
.chat-form { display: none; margin-top: 8px; pointer-events: auto; }
.chat.open .chat-form { display: block; }
.chat-box { position: relative; overflow: hidden; border-radius: 12px; color: var(--chat-text); background: color-mix(in srgb, var(--bg) 72%, transparent); border: 1px solid var(--secondary); }
.chat-box input { display: block; width: 100%; height: 42px; padding: 0 14px; background: none; border: 0; outline: none; font-size: .95rem; }
.chat-box input::placeholder { color: var(--placeholder); }
.chat-wait { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--primary); transform-origin: left; transform: scaleX(0); }
.chat-box.refused { animation: refuse .3s; border-color: var(--danger); }
@keyframes refuse { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.chat[data-hidden="true"] .chat-log, .chat[data-hidden="true"] .chat-form { display: none; }
.chat-hint kbd { margin: 0 2px; padding: 0 .4em; font-size: .7rem; }
.chat-hint { display: inline-flex; gap: 8px; align-items: center; margin-top: 6px; padding: 4px 9px; border-radius: 9px; font-size: .76rem; color: var(--text-soft); background: var(--over-arena); border: 1px solid var(--over-arena-line); text-shadow: var(--over-arena-shadow); }
.chat-hint kbd { color: inherit; background: none; border-color: var(--over-arena-line); }
.chat.open .chat-hint { display: none; }

.dock { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 10px; pointer-events: auto; }
.dock button {
  min-width: 78px; padding: 10px 14px; border-radius: 14px; font-weight: 800; font-size: .88rem;
  background: var(--over-arena); border: 1px solid var(--over-arena-line); color: var(--text);
  text-shadow: var(--over-arena-shadow);
}
.dock button:active { transform: scale(.96); }
.dock #return { background: color-mix(in srgb, var(--primary) 82%, transparent); color: var(--on-primary); border-color: var(--primary); text-shadow: none; }

/* A light arena: dark letters with a light shadow, and darker versions of the two colors. */
body[data-theme="light"] .hud {
  color: var(--on-light-text); --text: var(--on-light-text); --over-arena-line: rgba(0, 0, 0, .2);
  --over-arena-shadow: 0 1px 2px rgba(255, 255, 255, 1), 0 0 3px rgba(255, 255, 255, .95), 0 0 7px rgba(255, 255, 255, .8);
}
body[data-theme="light"] .hud :is(.score .label, .score dt, .radar-line, .msg.server, .chat-hint) { color: var(--on-light-soft); }
body[data-theme="light"] .score strong { color: var(--primary-on-light); }
body[data-theme="light"] .board li::before { color: var(--secondary-on-light); }
body[data-theme="light"] .board li.mine, body[data-theme="light"] .board li.mine::before { color: var(--on-primary); }
body[data-theme="light"] .chat-box { --text: var(--chat-text); color: var(--chat-text); text-shadow: none; }

/* The spectator's controls, and a leaderboard that can be clicked while watching. */
.dock { align-items: stretch; }
.watch-bar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; max-width: min(560px, calc(100vw - 24px)); padding: 8px 10px; }
.watch-bar span { min-width: 150px; max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center; font-weight: 800; }
.dock .watch-bar button { min-width: 36px; padding: 6px 10px; border-radius: 9px; font-size: .8rem; }
.dock .watch-bar button:disabled { opacity: .45; }
.watch-bar small { flex-basis: 100%; text-align: center; font-size: .7rem; opacity: .8; }
.hud[data-watching] .board { pointer-events: auto; }
.hud[data-watching] .board li { cursor: pointer; }
.hud[data-watching] .board li:hover { background: color-mix(in srgb, var(--secondary) 28%, transparent); }
@media (max-width: 880px) {
  .dock { bottom: 124px; width: max-content; }
  .watch-bar small { display: none; }
}
/* No room beside the spectator's controls on a phone: the menu button goes under them. */
@media (max-width: 520px) {
  .dock.spectating { flex-direction: column; }
}

/* ---------- Death screen: who did it, how the life went, and the way back in. ---------- */

.death {
  position: fixed; inset: 0; z-index: 4; display: flex; overflow-y: auto; padding: 16px;
  background: color-mix(in srgb, var(--shade) 58%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: death-in .35s ease-out;
}
@keyframes death-in { from { opacity: 0; } }
.death-card { width: min(480px, 100%); margin: auto; padding: 22px 22px 18px; box-shadow: 0 22px 60px rgba(0, 0, 0, .5); }
.death-head { display: flex; align-items: center; gap: 15px; padding-bottom: 15px; border-bottom: 2px solid var(--secondary); }
.death-head canvas { width: 56px; height: 56px; flex: none; }
.death-head div { min-width: 0; }
.death-head h2 { margin: 0; font: 800 1.4rem/1.15 var(--display); letter-spacing: -.025em; }
.death-head p { margin: 5px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.death-head p b { color: var(--text); font-weight: 800; }
.death-label { font: 700 .66rem/1 var(--body); letter-spacing: .13em; text-transform: uppercase; color: var(--text-dim); }
.death-score { padding: 16px 0 2px; text-align: center; }
.death-score strong {
  display: block; margin: 7px 0 6px; font: 800 2.9rem/1 var(--display); letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; color: var(--primary);
}
.death-best { display: inline-block; color: var(--muted); font-size: .86rem; }
.death-best:empty { display: none; }
.death-best.record { padding: 2px 11px; border-radius: 99px; background: var(--primary); color: var(--on-primary); font-weight: 800; }
.death-graph { margin: 12px 0 0; }
.death-graph figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.death-graph figcaption span + span { color: var(--text); font-size: .8rem; font-variant-numeric: tabular-nums; }
.death-graph canvas { width: 100%; height: 96px; touch-action: none; cursor: crosshair; }
.death-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 14px 0 16px; overflow: hidden;
  background: var(--line); border: 1px solid var(--line); border-radius: 14px;
}
.death-stats div { padding: 10px 6px 11px; background: var(--surface-2); text-align: center; }
.death-stats dt { font: 700 .6rem/1.2 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--placeholder); }
.death-stats dd { margin: 5px 0 0; font: 800 1.15rem/1 var(--body); font-variant-numeric: tabular-nums; }
.death-actions { display: grid; grid-template-columns: 1.7fr 1fr 1fr; gap: 10px; }
.death-actions .btn { height: 50px; font-size: .95rem; white-space: nowrap; }
.death-actions kbd { margin-left: 8px; font-size: .68rem; }
.death-actions .primary kbd { color: var(--on-primary); background: color-mix(in srgb, var(--bg) 10%, transparent); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }

/* Panels the player took off. */
body[data-no-score] #score-card, body[data-no-board] .board, body[data-no-map] #minimap, body[data-no-net] .radar-line,
body[data-no-map][data-no-net] #radar { display: none !important; }
body[data-no-map] .radar { padding: 7px 10px; }
body[data-no-map] .radar-line { margin: 0; }
body[data-no-net] .radar-line { margin: 0; }

/* The menu on a short screen: tighter, three scores. */
@media (max-height: 760px) {
  .lobby { padding: 5px 12px; }
  .play-card { padding: 16px 22px 14px; }
  .settings-card { padding: 16px 18px 14px; }
  .logo-symbol { width: min(58px, 14cqw); }
  .logo-word { width: min(168px, 41cqw); margin-top: 4px; }
  .list-head { margin-bottom: 3px; }
  .list-head h3, .list-head .online { line-height: 1; }
  .brand { margin-bottom: 12px; }
  .tagline { margin: 6px 0 10px; font-size: .88rem; }
  .field { margin-bottom: 10px; }
  .field-label, .settings-card h3, .top h3 { margin-bottom: 6px; }
  .segmented button { padding: 8px 9px; }
  .segmented.mini button { padding: 4px 10px; }
  .room-tools { padding: 4px 8px; }
  .room-tools .btn { height: 27px; }
  .message { margin-top: 6px; font-size: .8rem; }
  .fixed-keys { line-height: 1.7; }
  .identity { grid-template-columns: 52px minmax(0, 1fr); }
  .bubble { width: 52px; height: 52px; }
  .bubble-clear { left: 34px; }
  .identity input { height: 52px; }
  .btn { height: 46px; }
  .btn.small { height: 32px; margin-top: 7px; }
  .top { margin-top: 10px; padding-top: 10px; }
  .top-list { grid-template-rows: repeat(5, 18px); min-height: 90px; margin-top: 4px; }
  .top-list li { font-size: .78rem; }
  .settings-head { margin-bottom: 10px; }
  .rooms { gap: 6px; }
  .room, .server-card { padding: 7px 11px; }
  .room-note { margin: 3px 2px; }
  #private h3 { margin-top: 8px; }
  .create .fields { gap: 7px 10px; }
  .create select, .create input { height: 32px; }
  .rooms { gap: 4px; }
  .room, .server-card { padding: 4px 9px; }
  .room-head { line-height: 1.2; }
  .tags { gap: 2px 3px; margin-top: 2px; }
  .tags span { font-size: .67rem; line-height: 1.18; }
  .settings-card { padding-top: 10px; padding-bottom: 10px; }
  .settings-head { margin-bottom: 7px; }
  .segmented.tabs button { padding: 6px 10px; }
  .room-tools { padding: 3px 8px; }
  .room-tools .btn { height: 26px; }
  #panel-servers h3 { margin-top: 6px; margin-bottom: 4px; }
  .join-line input, .join-line .btn { height: 34px; }
  .tiles { gap: 6px; margin-bottom: 11px; }
  .tile { min-height: 38px; }
  .swatch { width: 28px; height: 28px; }
  .control-row { padding: 4px 0; }
  .control-row button, .control-row select { height: 30px; }
  .controls-note { margin-bottom: 5px; }
  .fixed-keys { margin-top: 7px; padding-top: 7px; line-height: 1.9; }
  .debug-help { margin-top: 7px; }
}
@media (max-height: 620px) {
  .rooms { gap: 4px; }
  .room, .server-card { padding: 3px 9px; }
  .room .tags { gap: 2px 3px; margin-top: 1px; }
  .room .tags span { padding: 0 4px; font-size: .62rem; line-height: 1.15; }
  .room-head { line-height: 1.15; font-size: .88rem; }
  .room-tools { padding: 2px 7px; }
  .room-tools .btn { height: 24px; }
  #panel-servers h3 { margin-top: 4px; margin-bottom: 3px; }
  .join-line input, .join-line .btn { height: 30px; }
  .settings-card { padding-top: 9px; padding-bottom: 9px; }
  .settings-head { margin-bottom: 6px; }
  .message:not([data-kind="error"]), .top-list { display: none; }
  .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .top-head .segmented { display: none; }
  .top .btn.small { margin: 0; }
}
@media (max-width: 880px) {
  .lobby-shell { width: min(520px, 100%); }
  .lobby .lobby-switch { display: flex; }
  .lobby-grid { grid-template-columns: minmax(0, 1fr); }
  .lobby-shell[data-view="play"] .settings-card, .lobby-shell[data-view="settings"] .play-card { display: none; }
  .server-field { display: block; }
}
/* On a small screen the tips give way: only what answers a press stays. */
@media (max-width: 880px) and (max-height: 800px) {
  .message[data-kind="tip"] { display: none; }
}
@media (max-width: 560px) {
  .play-card { padding: 16px 16px 14px; }
  .settings-card { padding: 16px 14px; }
  .logo { gap: 5px; }
  .brand { gap: 8px; }
  .online { font-size: .7rem; }
  #language { height: 24px; font-size: .7rem; }
  .lobby .segmented:not(.mini) button { padding: 9px 5px; font-size: .84rem; }
  .tile { font-size: .82rem; padding: 0 8px 0 10px; gap: 6px; }
  .create .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .join-line .btn { padding: 0 10px; font-size: .8rem; }
  .tags { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 3px; margin-top: 2px; }
  .tags span { padding: 0 4px; font-size: .63rem; line-height: 1.12; }
  .room { padding: 3px 8px; }
  .rooms { gap: 4px; }
  .room-head { line-height: 1.15; font-size: .88rem; }
  .settings-card { padding: 10px 12px; }
  .control-row { grid-template-columns: minmax(0, 1fr) 76px 104px; gap: 6px; font-size: .8rem; }
  .radar { bottom: 12px; padding: 6px; }
  .radar-line { display: none; }
  #minimap { width: 96px; height: 96px; }
  .hud-top { top: auto; bottom: 120px; }
  .board { width: 150px; padding: 9px 6px 7px; }
  .board h2 { font-size: .74rem; }
  .chat { width: calc(100vw - 24px - 112px); bottom: 12px; }
  .chat.open { width: calc(100vw - 24px); }
  .board li { gap: 5px; padding: 3px 4px; font-size: .8rem; }
  .death { padding: 10px; }
  .death-card { padding: 18px 14px 14px; }
  .death-actions { grid-template-columns: 1fr 1fr; }
  .death-actions .primary { grid-column: 1 / -1; }
  .death-actions kbd { display: none; }
  .chat-log { max-height: 130px; }
}
/* A touch screen has no Enter nor C to be told about. */
@media (pointer: coarse) { .chat-hint { display: none; } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
