/* Overlay screens: loading, main menu, co-op, loadout, shop, settings, how to
   play, pause, results. Load order: base, hud, menu, touch.

   One system for every screen outside play: dark glass panels over the live
   scene, display type for titles and numbers, one accent-filled primary action
   per screen, a quiet list for everything else. Built from the tokens in
   base.css; nothing here invents a colour. */

/* ===================================================================== layer */

#overlay {
  display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  padding: 12px 0; overflow-x: hidden; overflow-y: auto; z-index: 20;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  /* The scene orbits behind the menu, so the overlay only shades it: darkest
     behind the left-hand column where the text is, nearly clear on the right. */
  background:
    linear-gradient(90deg, rgba(7, 9, 12, .9) 0%, rgba(7, 9, 12, .62) 34%, rgba(7, 9, 12, .18) 72%, rgba(7, 9, 12, .3) 100%),
    linear-gradient(0deg, rgba(7, 9, 12, .7) 0%, transparent 30%);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .22) transparent;
  transition: background-color var(--t-med) var(--ease-out);
}
/* Nothing from the partly assembled world should show through while real
   assets are loading. In particular, this prevents procedural stand-ins
   from flashing behind the progress panel before their models arrive. */
#overlay.asset-loading { background: rgb(8, 10, 14); backdrop-filter: none; }
/* Mid-run screens sit over a frozen frame of the fight: dim and soften it so
   the panel reads, without hiding where the player is. */
#overlay:has(> #panel-pause:not(.hidden)),
#overlay:has(> #panel-dead:not(.hidden)) {
  background: radial-gradient(ellipse at center, rgba(7, 9, 12, .55), rgba(7, 9, 12, .86));
  backdrop-filter: blur(6px) saturate(115%);
  -webkit-backdrop-filter: blur(6px) saturate(115%);
}
#overlay:has(> #panel-dead:not(.hidden)) {
  background: radial-gradient(ellipse at center, rgba(40, 6, 8, .55), rgba(7, 9, 12, .9));
}

/* A panel is never taller than the window: it scrolls instead of clipping. */
.panel {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow-x: hidden; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
/* Every screen arrives with a short rise-and-fade. Display:none to block
   restarts the animation, so no script has to orchestrate it. */
.panel:not(.hidden) { animation: screen-in var(--t-med) var(--ease-out) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes nudge {
  0%, 100% { transform: none; }
  25% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
}
body.reduced-motion #overlay *,
body.reduced-motion #overlay *::before,
body.reduced-motion #overlay *::after {
  animation: none !important; transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  #overlay *, #overlay *::before, #overlay *::after { animation: none !important; }
}

/* ================================================================== controls */

:where(#overlay) :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Zero-specificity resets, so any class below wins over them. */
:where(#overlay) button { font: inherit; color: inherit; }
:where(#overlay) a { color: var(--info); text-underline-offset: 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 48px; padding: 0 28px;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  letter-spacing: .12em; text-transform: uppercase; line-height: 1;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(255, 107, 44, .22);
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--accent-hi); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(255, 107, 44, .32); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn:disabled, .btn[disabled] {
  cursor: not-allowed; opacity: .4; transform: none; box-shadow: none;
}
.btn.ghost, .btn.secondary {
  color: var(--text); background: rgba(255, 255, 255, .04);
  border-color: var(--line-strong); box-shadow: none;
}
.btn.ghost:hover, .btn.secondary:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .34); }
.btn.secondary { background: var(--bg-3); }
.btn.danger { color: #fff; background: var(--danger); box-shadow: 0 6px 18px rgba(255, 77, 77, .22); }
.btn.danger:hover { background: #ff6a6a; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; letter-spacing: .1em; }
body.touch .btn.small { min-height: 44px; }

/* The one primary action of the front screen. */
.btn-hero {
  width: 100%; min-height: 76px; padding: 12px 22px;
  flex-direction: column; align-items: flex-start; gap: 6px;
  position: relative; text-align: left;
  border-radius: var(--r-md);
  background: linear-gradient(100deg, var(--accent) 0%, #ff7d3a 60%, var(--accent-hi) 100%);
}
.btn-hero::after {
  content: ''; position: absolute; right: 22px; top: 50%;
  width: 0; height: 0; margin-top: -9px;
  border-left: 14px solid var(--accent-ink); border-top: 9px solid transparent; border-bottom: 9px solid transparent;
  transition: transform var(--t-fast) var(--ease-out);
}
.btn-hero:hover::after { transform: translateX(4px); }
.btn-hero-main { font-size: 34px; font-weight: 800; letter-spacing: .06em; }
.btn-hero-sub {
  font-family: var(--font-ui); font-weight: 600; font-size: 11px;
  letter-spacing: .14em; opacity: .72; white-space: normal; padding-right: 28px;
}

/* Secondary navigation: a list, not a wall of buttons. */
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  width: 100%; min-height: 42px; padding: 0 14px;
  font-family: var(--font-display); font-weight: 700; font-size: 21px;
  letter-spacing: .08em; text-align: left; color: var(--text-dim);
  background: transparent; border: 0; border-left: 2px solid transparent;
  border-radius: 0 var(--r-sm) var(--r-sm) 0; cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast), padding var(--t-fast) var(--ease-out);
}
.nav-item small {
  font-family: var(--font-ui); font-weight: 600; font-size: 10.5px;
  letter-spacing: .14em; color: var(--text-faint); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.nav-item:hover, .nav-item:focus-visible {
  color: var(--text); padding-left: 18px;
  background: linear-gradient(90deg, var(--accent-soft), transparent 85%);
  border-left-color: var(--accent);
}
#overlay .nav-item:focus-visible { outline-offset: 0; }
.nav-item:hover small, .nav-item:focus-visible small { color: var(--text-dim); }
.nav-item[hidden] { display: none; }
.nav-item.danger:hover, .nav-item.danger:focus-visible {
  color: var(--danger); border-left-color: var(--danger);
  background: linear-gradient(90deg, rgba(255, 77, 77, .14), transparent 85%);
}
body.touch .nav-item { min-height: 48px; }

/* Inputs */
.fld-label {
  display: block; margin: 0 0 6px;
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  letter-spacing: .2em; color: var(--text-faint);
}
.fld-label small { font-size: 11px; letter-spacing: .14em; opacity: .7; margin-left: 6px; }
.fld, .field {
  display: block; width: 100%; min-height: 48px; padding: 0 14px;
  font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: .08em;
  color: var(--text); background: rgba(0, 0, 0, .38);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  user-select: text; -webkit-user-select: text;
}
.fld { text-transform: uppercase; }
.field { font-family: var(--font-ui); font-weight: 500; font-size: 15px; letter-spacing: .02em; }
.fld::placeholder, .field::placeholder { color: var(--text-faint); opacity: .7; }
.fld:focus, .field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fld.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 77, 77, .14); }
.fld.code {
  font-family: var(--font-mono); font-weight: 700; font-size: 28px;
  letter-spacing: .42em; text-align: center; padding-left: calc(14px + .42em);
}

/* Switch: a checkbox drawn as a toggle, still a native checkbox underneath. */
.toggle {
  display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer;
  position: relative; padding: 4px 0;
}
.toggle input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.toggle-track {
  flex: 0 0 44px; width: 44px; height: 26px; border-radius: 13px; position: relative; margin-top: 1px;
  background: rgba(255, 255, 255, .14); border: 1px solid var(--line-strong);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text);
  transition: transform var(--t-fast) var(--ease-out);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: var(--accent-ink); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.toggle-text { display: flex; flex-direction: column; gap: 3px; }
.toggle-text b {
  font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: .08em; color: var(--text);
}
.toggle-text small { font-size: 12px; line-height: 1.45; color: var(--text-dim); }

/* Cards and copy */
.card {
  background: rgba(255, 255, 255, .035); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s-4);
}
.card h3 {
  font-family: var(--font-display); font-weight: 800; font-size: 20px;
  letter-spacing: .1em; margin-bottom: 6px;
}
.card-copy, .screen-copy { font-size: 13px; line-height: 1.55; color: var(--text-dim); }
.screen-copy { margin: -4px 0 var(--s-4); max-width: 60ch; }
.gold { color: var(--gold); }
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 7px;
  font-family: var(--font-mono); font-weight: 700; font-size: 11px; color: var(--text);
  background: var(--bg-3); border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px;
}
body:not(.touch) .touch-only { display: none !important; }
body.touch .keys-desktop { display: none; }

/* ===================================================================== brand */

.brand { display: flex; flex-direction: column; gap: 6px; }
.brand-center { align-items: center; text-align: center; }
.brand-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 800; font-size: 15px;
  letter-spacing: .3em; color: var(--accent);
}
.brand-mark { width: 18px; height: 18px; fill: var(--accent); filter: drop-shadow(0 0 8px rgba(255, 107, 44, .6)); }
.brand-name {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(54px, 7.2vw, 112px); line-height: .84; letter-spacing: .005em;
  color: var(--text); text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5), 0 18px 40px rgba(0, 0, 0, .55);
}
.brand-name em {
  display: block; font-style: normal; color: var(--accent);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .45), 0 0 34px rgba(255, 107, 44, .35);
}
.brand-tag {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  letter-spacing: .42em; color: var(--text-faint);
}

/* =================================================================== loading */

#panel-load {
  width: min(560px, 100%); max-width: none; overflow: visible;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-7);
  text-align: center;
}
#panel-load .brand-name { font-size: clamp(56px, 10vw, 120px); }
.load-box { width: min(440px, 100%); }
.load-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3);
  margin-bottom: 10px;
}
#loading {
  font-family: var(--font-mono); font-weight: 700; font-size: 12px;
  letter-spacing: .18em; color: var(--text-dim); text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#loadpct { font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: var(--accent); }
#loadbar {
  width: 100%; height: 6px; border-radius: 3px; overflow: hidden;
  background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
}
#loadfill {
  height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, #c4461a, var(--accent) 60%, var(--accent-hi));
  box-shadow: 0 0 14px rgba(255, 107, 44, .6);
  transition: width .25s var(--ease-out);
}
.load-tip {
  display: flex; gap: var(--s-3); align-items: flex-start; text-align: left;
  margin-top: var(--s-6); min-height: 44px;
  font-size: 14px; line-height: 1.5; color: var(--text-dim);
  transition: opacity .35s;
}
.load-tip.fade { opacity: 0; }
.load-tip-label {
  flex: 0 0 auto; padding: 3px 7px; margin-top: 1px; border-radius: 4px;
  font-family: var(--font-display); font-weight: 800; font-size: 12px; letter-spacing: .18em;
  color: var(--accent-ink); background: var(--gold);
}
.load-tip:has(#load-tip-text:empty) { visibility: hidden; }
/* A load failure the player can actually read, instead of a progress bar that
   stops moving and never explains itself. */
#loading.fatal {
  color: var(--danger); font-size: 15px; letter-spacing: .16em; white-space: normal;
  text-shadow: var(--shadow);
}
#panel-load:has(#loading.fatal) .load-tip, #panel-load:has(#loading.fatal) #loadpct { display: none; }
.fatal-detail {
  width: min(520px, 100%); margin: 14px auto 0;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.6;
  color: var(--text-dim); text-align: left;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 10px 12px; white-space: pre-wrap; word-break: break-word;
}

/* ================================================================ main menu */

#panel-menu {
  width: 100%; max-width: none; min-height: calc(100vh - 24px); min-height: calc(100dvh - 24px);
  overflow: visible; max-height: none;
  display: flex; align-items: center;
  padding: 56px clamp(8px, 4.5vw, 96px) 16px;
}
.menu-main {
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: var(--s-5);
}
.menu-actions { display: flex; flex-direction: column; gap: 2px; }
.menu-actions .btn-hero { margin-bottom: var(--s-3); }

.menu-corner {
  position: fixed; z-index: 3;
  top: max(14px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: var(--s-3);
  padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  font-size: 12px; letter-spacing: .06em;
}
.menu-corner .who { color: var(--text-dim); font-weight: 600; }
.menu-corner .who b { color: var(--text); font-weight: 700; }
#credits, .credit-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .08em;
  color: var(--gold); padding: 4px 12px 4px 8px; border-radius: 999px;
  background: rgba(255, 207, 77, .1); border: 1px solid rgba(255, 207, 77, .28);
}
#credits b, .credit-pill b { color: var(--gold); font-weight: 800; font-size: 17px; }
.cr-gem {
  width: 10px; height: 10px; transform: rotate(45deg); border-radius: 2px;
  background: linear-gradient(135deg, #fff2b8, var(--gold) 55%, #c9961d);
  box-shadow: 0 0 8px rgba(255, 207, 77, .6);
}
.menu-corner .btn.small { min-height: 32px; border-radius: 999px; }
.menu-corner .btn[hidden] { display: none; }

/* Consent: calm by default, explanatory when someone tries to play without it. */
.consent {
  padding: 10px 12px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .035); border: 1px solid var(--line);
  transition: border-color var(--t-med), background var(--t-med);
}
.legal-consent {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: 12.5px; line-height: 1.5; color: var(--text-dim);
}
.legal-consent input {
  flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px;
  accent-color: var(--accent); cursor: pointer;
}
body.touch .legal-consent input { width: 22px; height: 22px; }
.legal-consent a, .auth-policy a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
#legal-note {
  font-size: 12px; line-height: 1.45; color: var(--text-dim);
  margin-left: 28px;
}
#legal-note:empty { display: none; }
.consent.attention {
  border-color: rgba(255, 176, 32, .65); background: rgba(255, 176, 32, .08);
  animation: nudge .32s var(--ease-out);
}
.consent.attention #legal-note { color: var(--warn); margin-top: 6px; }
.consent.accepted { border-color: transparent; background: transparent; padding-top: 0; padding-bottom: 0; }
.consent.accepted .legal-consent { color: var(--text-faint); font-size: 11.5px; }
.consent.accepted #legal-note { color: var(--ok); margin-top: 4px; }

.menu-toast {
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 13px; line-height: 1.45; color: var(--text);
  background: rgba(255, 77, 77, .12); border: 1px solid rgba(255, 77, 77, .4);
  border-left: 3px solid var(--danger);
}
.menu-toast[hidden] { display: none; }

/* Live concurrency and the durable all-time run total share one quiet line. */
.livecount {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px;
  font-family: var(--font-mono); font-weight: 500; font-size: 11px;
  letter-spacing: .1em; color: var(--text-faint);
}
.livecount[hidden] { display: none; }
.live-now:empty, .playcount:empty { display: none; }
.live-now::before {
  content: ''; display: inline-block; vertical-align: middle;
  width: 7px; height: 7px; margin: -2px 8px 0 0; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
  animation: live-pulse 2.4s ease-in-out infinite;
}
@keyframes live-pulse { 50% { opacity: .45; } }
.live-now:not(:empty) + .playcount::before { content: '·'; margin-right: 14px; opacity: .7; }

/* Compact release card: visible beside the menu immediately, but non-modal
   so every play and account control remains usable until it is dismissed. */
#overlay.patch-open { gap: clamp(18px, 3vw, 42px); }
#panel-patchnotes {
  position: fixed; z-index: 2;
  right: clamp(16px, 4vw, 72px); top: 50%; transform: translateY(-50%);
  width: 330px; max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 120px); overflow-y: auto;
  animation-name: card-in;
}
@keyframes card-in {
  from { opacity: 0; transform: translate(14px, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}
.patch-sheet {
  position: relative; overflow: hidden; text-align: left;
  border-radius: var(--r-lg); border: 1px solid var(--line-strong);
  background: linear-gradient(150deg, rgba(255, 77, 77, .1), transparent 40%), var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-panel);
}
.patch-sheet::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--danger), var(--accent), transparent 82%);
}
.patch-topline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 14px 10px 18px;
}
.patch-version {
  font-family: var(--font-mono); font-weight: 700; font-size: 11px;
  letter-spacing: .18em; color: var(--accent);
}
.patch-close {
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--text-dim); background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-strong); cursor: pointer;
  font: 18px/1 var(--font-ui);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.patch-close:hover, .patch-close:focus-visible { color: #fff; border-color: var(--accent); background: var(--accent-soft); }
body.touch .patch-close { width: 44px; height: 44px; }
#panel-patchnotes h2 {
  margin: 0; padding: 0 18px 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: .08em;
}
.patch-list { list-style: none; display: grid; gap: 8px; padding: 0 14px 16px; }
.patch-entry {
  padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); border-left: 3px solid var(--danger);
  background: rgba(255, 255, 255, .035);
}
.patch-entry[data-change="added"] { border-left-color: var(--ok); }
.patch-entry-head { display: flex; align-items: center; gap: 8px; }
.patch-removed, .patch-added {
  padding: 3px 6px; border-radius: 3px;
  font-family: var(--font-display); font-weight: 800; font-size: 11px; letter-spacing: .12em;
}
.patch-removed { color: #fff; background: rgba(255, 77, 77, .9); }
.patch-added { color: #07140c; background: var(--ok); }
.patch-entry h3 {
  font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .06em; line-height: 1.2;
}
.patch-entry p { margin: 6px 0 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.45; }
/* Too narrow for the card to sit beside the menu: it follows the menu in the
   page's flow instead of covering its buttons. */
@media (max-width: 860px) {
  #overlay.patch-open { display: block; }
  #panel-patchnotes {
    position: static; transform: none; width: auto; max-width: 440px; max-height: none;
    margin: 0 auto 24px; overflow: visible; animation-name: screen-in;
  }
  #overlay.patch-open #panel-menu { min-height: 0; padding-bottom: var(--s-5); }
}

/* ================================================================== screens */
/* Every screen other than the menu: one glass panel with a header row of
   BACK, title and a short meta line. Escape is BACK (src/ui/screens.js). */

.screen {
  width: min(880px, 100%);
  padding: var(--s-5) clamp(16px, 3vw, 32px) var(--s-5);
  background: var(--glass-strong); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-panel);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.screen-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: var(--s-4); margin-bottom: var(--s-5);
  padding-bottom: var(--s-4); border-bottom: 1px solid var(--line);
}
.screen-head h2, #panel-pause h2 {
  font-family: var(--font-display); font-weight: 800; font-size: 34px;
  letter-spacing: .06em; line-height: 1;
}
.screen-meta {
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  letter-spacing: .16em; color: var(--text-faint); text-align: right;
}
.screen-meta.credit-pill { color: var(--gold); }
.back {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 14px 0 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .12em;
  color: var(--text-dim); background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.back::before {
  content: ''; width: 7px; height: 7px; margin-left: 4px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.back::after {
  content: 'ESC'; margin-left: 4px; padding: 2px 5px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em;
  color: var(--text-faint); border: 1px solid var(--line);
}
body.touch .back::after { display: none; }
body.touch .back { min-height: 44px; }
.back:hover, .back:focus-visible { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.screen-foot {
  display: flex; justify-content: flex-end; gap: var(--s-3);
  margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--line);
  /* Stays in reach while the screen above it scrolls. */
  position: sticky; bottom: calc(-1 * var(--s-5)); padding-bottom: var(--s-5); margin-bottom: calc(-1 * var(--s-5));
  background: linear-gradient(180deg, rgba(10, 13, 18, .82), var(--glass-strong) 40%);
}

/* ==================================================================== co-op */

#panel-coop { width: min(820px, 100%); }
#mp-name { max-width: 360px; margin-bottom: var(--s-5); }
.coop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.coop-card { display: flex; flex-direction: column; gap: var(--s-3); }
.coop-card .btn { width: 100%; margin-top: auto; }
.coop-card .card-copy { margin-top: -4px; }
.hosted {
  padding: var(--s-3); border-radius: var(--r-sm);
  background: rgba(92, 200, 255, .08); border: 1px solid rgba(92, 200, 255, .35);
}
.hosted-label, .party-head {
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  letter-spacing: .22em; color: var(--text-faint);
}
.hosted-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin: 4px 0; }
.room-code {
  font-family: var(--font-mono); font-weight: 700; font-size: clamp(28px, 4vw, 40px);
  letter-spacing: .16em; color: var(--info); user-select: all; -webkit-user-select: all;
}
.hosted-sub { font-size: 12px; color: var(--text-dim); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

.mp-status {
  min-height: 0; margin: var(--s-4) 0 0; font-size: 13px; line-height: 1.45; color: var(--text-dim);
}
.mp-status:empty { margin: 0; }
.mp-status:not(:empty) { padding: 10px 12px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .04); border-left: 3px solid var(--info); }
.mp-status.err { color: var(--text); background: rgba(255, 77, 77, .1); border-left-color: var(--danger); }
.mp-status.ok { color: var(--text); background: rgba(95, 224, 140, .08); border-left-color: var(--ok); }

/* the public lobby browser */
.lobby { margin-top: var(--s-5); }
.mp-listhead {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s-2);
  font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: .1em;
}
.mp-listhead b { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--text-faint); letter-spacing: .08em; }
.mp-rooms { display: flex; flex-direction: column; gap: 6px; }
.room-btn {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 52px; padding: 0 14px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--text); cursor: pointer; text-align: left;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.room-btn:hover:not(:disabled) { background: rgba(92, 200, 255, .1); border-color: var(--info); transform: translateX(2px); }
.room-btn:disabled { opacity: .45; cursor: not-allowed; }
.room-btn b {
  font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--gold);
  padding: 3px 8px; border-radius: 4px; background: rgba(255, 207, 77, .1);
}
/* Mode is the first thing to read: co-op and a free-for-all are different
   games, and joining the wrong one is a wasted load screen. */
.room-mode {
  font-family: var(--font-display); font-weight: 800; font-size: 12px; letter-spacing: .12em;
  border: 1px solid currentColor; border-radius: 3px; padding: 3px 6px;
}
.room-mode.coop { color: var(--ok); }
.room-mode.ffa { color: var(--accent); }
.room-who {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .06em;
}
.room-who span { font-family: var(--font-mono); font-weight: 500; font-size: 12px; color: var(--text-faint); letter-spacing: .14em; }
.room-state { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; color: var(--text-dim); }
.mp-empty {
  padding: 18px 12px; text-align: center; border-radius: var(--r-sm);
  border: 1px dashed var(--line-strong); font-size: 13px; color: var(--text-faint);
}
.mp-hint { margin-top: var(--s-3); font-size: 13px; color: var(--text-dim); min-height: 1em; }

/* ================================================================== loadout */

#panel-loadout { width: min(860px, 100%); }
.loadout-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); }
.loadout-card {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  min-height: 168px; padding: var(--s-4); text-align: left; cursor: pointer;
  background: linear-gradient(160deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .015));
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--t-fast), transform var(--t-fast) var(--ease-out), background var(--t-fast);
}
.loadout-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.loadout-card[aria-checked="true"] {
  border-color: var(--accent); background: linear-gradient(160deg, rgba(255, 107, 44, .18), rgba(255, 107, 44, .03));
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.loadout-card .lo-name { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: .06em; line-height: 1; }
.loadout-card .lo-kit { display: flex; flex-wrap: wrap; gap: 4px; }
.loadout-card .lo-kit span {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  padding: 3px 6px; border-radius: 3px; background: rgba(0, 0, 0, .35); color: var(--text-dim);
}
.loadout-card .lo-kit span:first-child { color: var(--text); background: rgba(255, 255, 255, .1); }
.loadout-card .lo-blurb { font-size: 13px; line-height: 1.45; color: var(--text-dim); }
.loadout-card .lo-badge {
  position: absolute; top: 12px; right: 12px;
  font-family: var(--font-display); font-weight: 800; font-size: 11px; letter-spacing: .14em;
  color: var(--accent-ink); background: var(--accent); padding: 3px 7px; border-radius: 3px;
  opacity: 0; transition: opacity var(--t-fast);
}
.loadout-card[aria-checked="true"] .lo-badge { opacity: 1; }

/* =================================================================== account */

#panel-auth { width: min(520px, 100%); }
.note { font-size: 13.5px; line-height: 1.6; color: var(--text-dim); margin-bottom: var(--s-5); }
.auth-form .field { margin-bottom: var(--s-4); }
.auth-policy { font-size: 12px; line-height: 1.55; color: var(--text-faint); margin-bottom: var(--s-3); }
.msg { font-size: 13px; letter-spacing: .02em; min-height: 18px; margin-bottom: var(--s-3); color: var(--text-dim); }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }
.btnrow { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.btnrow .btn[hidden] { display: none; }

/* ====================================================================== shop */

#panel-shop { width: min(900px, 100%); }
.tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: var(--s-4);
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow-x: auto; scrollbar-width: none;
}
.shop-tab, .tab {
  flex: 1 0 auto; min-height: 40px; padding: 0 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .1em;
  color: var(--text-dim); background: transparent; border: 0; border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.shop-tab:hover, .tab:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.shop-tab.on, .tab[aria-selected="true"] { color: var(--accent-ink); background: var(--accent); }
.shop-tab .n { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0; opacity: .7; }
body.touch .shop-tab, body.touch .tab { min-height: 44px; }

.shop-body {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--s-5); align-items: center;
  padding: var(--s-4); margin-bottom: var(--s-4);
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: radial-gradient(ellipse at 30% 60%, rgba(120, 150, 180, .18), transparent 65%), rgba(0, 0, 0, .28);
}
.hero-shot {
  height: 190px; background-repeat: no-repeat; background-position: center; background-size: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .65));
}
.hero-guns { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.hero-gun {
  min-height: 30px; padding: 0 10px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .1em;
  color: var(--text-faint); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
}
.hero-gun:hover { color: var(--text); border-color: var(--line-strong); }
.hero-gun.on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
body.touch .hero-gun { min-height: 40px; }
.hero-meta { text-align: left; }
.hero-rar { font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: .22em; }
.hero-name { font-family: var(--font-display); font-weight: 800; font-size: 34px; letter-spacing: .04em; line-height: 1.05; margin-top: 2px; }
.hero-blurb { font-size: 13px; line-height: 1.55; color: var(--text-dim); margin-top: 8px; min-height: 40px; }
.hero-foot { display: flex; align-items: center; gap: var(--s-4); margin-top: var(--s-4); }
.hero-price { font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: .06em; color: var(--gold); }
.hero-price.owned { color: var(--ok); font-size: 16px; letter-spacing: .16em; }
.hero-price.poor { color: var(--danger); }
#hero-act { min-width: 120px; }
.armoury-note { font-size: 12px; color: var(--text-faint); margin-top: 6px; min-height: 12px; }
#shop-msg { margin: 6px 0 0; }

#shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px; max-height: 32vh; overflow-y: auto; padding: 2px;
}
.skin {
  position: relative; padding: 8px 6px 10px; cursor: pointer; text-align: center;
  color: inherit; background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line); border-top: 3px solid var(--rar, rgba(255, 255, 255, .2));
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.skin:hover { background: rgba(255, 255, 255, .08); transform: translateY(-1px); }
.skin.sel { border-color: var(--line-strong); border-top-color: var(--rar); background: rgba(255, 255, 255, .1); box-shadow: 0 0 0 1px rgba(255, 255, 255, .25) inset; }
.skin.equipped { border-color: var(--accent); border-top-color: var(--rar); background: var(--accent-soft); }
.skin .swatch { height: 30px; margin-bottom: 6px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .4); }
.skin .swatch.shot {
  height: 54px; border: 0; margin-bottom: 4px;
  background-repeat: no-repeat; background-position: center; background-size: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .55));
}
.skin .nm { font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .06em; color: var(--text); }
/* A padlock beats the word LOCKED: it needs no room and no reading. */
.skin .tag { position: absolute; top: 6px; right: 6px; font-size: 10px; line-height: 1; }
.skin.locked .swatch { opacity: .5; }
.skin.locked .nm { color: var(--text-faint); }

/* ================================================================== credits */

#panel-credits { width: min(760px, 100%); }
.credits-scroll { max-height: 60vh; overflow-y: auto; text-align: left; padding: 0 4px 8px; }
.credits-intro { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 16px; }
.credits-scroll h3 {
  font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: .14em;
  color: var(--text-faint); margin: 18px 0 8px; text-transform: uppercase;
}
.credits-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.credits-list li {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  font-size: 13px; line-height: 1.5; padding: 6px 10px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .03);
}
.credits-title { font-weight: 650; }
.credits-by { color: var(--text-dim); }
.credits-src, .credits-lic {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--info); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.credits-src:hover, .credits-lic:hover { border-bottom-color: var(--info); }
.credits-mod { font-size: 11px; color: var(--text-faint); font-style: italic; }

/* ================================================================= settings */

#panel-settings { width: min(800px, 100%); }
.settings-pane { display: none; }
.settings-pane.on { display: block; animation: screen-in var(--t-fast) var(--ease-out) both; }
.set-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 320px); align-items: center;
  gap: var(--s-4); padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }
.set-label b {
  display: block; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .06em;
}
.set-label small { display: block; font-size: 12px; line-height: 1.45; color: var(--text-faint); margin-top: 2px; }
.set-ctl { display: flex; align-items: center; gap: var(--s-3); justify-content: flex-end; }
.set-val {
  flex: 0 0 52px; text-align: right;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--text);
}
.range {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px;
  background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill, 50%), rgba(255, 255, 255, .14) var(--fill, 50%) 100%);
}
.range::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .14); }
.range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--accent);
}
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 2px var(--accent); }
body.touch .range { height: 44px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.seg button {
  min-height: 34px; padding: 0 11px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: .08em;
  color: var(--text-dim); background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.seg button:hover { color: var(--text); background: rgba(255, 255, 255, .09); }
.seg button[aria-checked="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
body.touch .seg button { min-height: 44px; }
.set-ctl .toggle { padding: 0; flex: 0 0 auto; min-width: 44px; }
.pane-note { font-size: 13px; line-height: 1.55; color: var(--text-dim); margin-bottom: var(--s-3); }
.pane-foot { display: flex; justify-content: flex-end; margin-top: var(--s-4); }

/* key bindings */
#binds { max-height: 46vh; overflow-y: auto; text-align: left; padding-right: 6px; }
.bind-group {
  font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: .22em; color: var(--text-faint);
  margin: 16px 0 4px; padding-top: 12px; border-top: 1px solid var(--line);
}
.bind-group:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.bind-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; font-size: 14px; }
.bind-row .lbl { flex: 1; color: var(--text-dim); }
/* The key itself is the button: nothing to explain, you click the thing you
   want to change. */
.bind-key {
  min-width: 100px; min-height: 34px; padding: 0 10px;
  font-family: var(--font-mono); font-weight: 700; font-size: 12px; letter-spacing: .06em; text-align: center;
  color: var(--text); background: var(--bg-3);
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; cursor: pointer;
}
div.bind-key { display: inline-flex; align-items: center; justify-content: center; }
.bind-key:hover { border-color: var(--accent); }
.bind-key.listening {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
  animation: blink .7s steps(2, start) infinite;
}
.bind-key.unbound { color: var(--danger); }
/* Fixed controls listed alongside, so the screen is the whole truth about
   what drives the game rather than only the movable half. */
.bind-row.fixed .bind-key { color: var(--text-faint); background: none; border-style: dashed; cursor: default; }
.bind-row.fixed .bind-key:hover { border-color: var(--line-strong); }
#bind-note { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; min-height: 18px; }
#bind-note.warn { color: var(--warn); }

/* =============================================================== how to play */

#panel-howto { width: min(940px, 100%); }
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.howto-card { display: grid; grid-template-columns: 48px 1fr; gap: 4px var(--s-4); align-content: start; }
.howto-card h3 { grid-column: 2; align-self: center; margin: 0; }
.howto-card > ul, .howto-card > .howto-keys { grid-column: 1 / -1; }
.howto-icon {
  grid-row: 1; width: 48px; height: 48px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid rgba(255, 107, 44, .35);
}
.howto-icon svg { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.howto-card ul { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.howto-card li { position: relative; padding-left: 16px; font-size: 13.5px; line-height: 1.5; color: var(--text-dim); }
.howto-card li::before { content: ''; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 1px; background: var(--accent); transform: rotate(45deg); }
.howto-card li b { color: var(--text); }
.howto-card li b.gold { color: var(--gold); }
.howto-secret { background: linear-gradient(150deg, rgba(92, 200, 255, .09), rgba(255, 255, 255, .02)); }
.howto-secret .howto-icon { background: rgba(92, 200, 255, .12); border-color: rgba(92, 200, 255, .35); }
.howto-secret .howto-icon svg { stroke: var(--info); }
.howto-secret li::before { background: var(--info); }
.howto-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 10px; }
.howto-key { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.howto-key .kbds { display: inline-flex; gap: 3px; flex: 0 0 auto; }

/* ===================================================================== pause */

#panel-pause { width: auto; max-width: 100%; overflow: visible; }
.pause-wrap { display: flex; gap: var(--s-4); align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.pause-main {
  width: min(380px, calc(100vw - 32px));
  padding: var(--s-5); border-radius: var(--r-lg);
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-panel);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
#panel-pause h2 { font-size: 44px; margin-bottom: var(--s-3); }
.stat-strip {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: var(--s-5);
  font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: .14em; color: var(--text-faint);
}
.stat-strip b { font-weight: 800; font-size: 18px; color: var(--text); margin-left: 5px; letter-spacing: .04em; }
.pause-actions { display: flex; flex-direction: column; gap: 2px; }
.pause-actions .btn { width: 100%; margin-bottom: var(--s-3); }
.confirm { margin-top: var(--s-2); padding: var(--s-4); border-radius: var(--r-md); border: 1px solid rgba(255, 77, 77, .45); background: rgba(255, 77, 77, .08); }
.confirm-q { font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: .06em; }
.confirm-copy { font-size: 13px; line-height: 1.5; color: var(--text-dim); margin: 6px 0 var(--s-4); }
.confirm .btn { flex: 1; }
.room-card {
  width: min(300px, calc(100vw - 32px));
  background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-panel); border-radius: var(--r-lg); padding: var(--s-5);
}
.party { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.party li {
  display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .04);
  font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .05em;
}
.party li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.party li.down::before { background: var(--warn); }
.party li.dead::before { background: var(--danger); }
.party li.you { background: rgba(92, 200, 255, .1); }
.party li small { font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--text-faint); letter-spacing: .06em; }
.party-head { margin-top: var(--s-4); }

/* ==================================================================== death */

#panel-dead { width: min(720px, 100%); text-align: center; padding: var(--s-2) 0; }
.dead-kicker { font-family: var(--font-mono); font-weight: 700; font-size: 12px; letter-spacing: .3em; color: var(--text-faint); }
#panel-dead h2 {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(64px, 11vw, 120px);
  line-height: .9; letter-spacing: .02em; color: var(--danger);
  text-shadow: 0 0 40px rgba(255, 77, 77, .35), 0 4px 0 rgba(0, 0, 0, .5);
  margin: 6px 0 8px;
}
.dead-cause { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: .12em; color: var(--text-dim); }
.dead-cause b { color: var(--text); font-weight: 800; }
.dead-best { margin: var(--s-4) 0 0; min-height: 28px; }
.best-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: .14em;
  color: var(--accent-ink); background: var(--gold); box-shadow: 0 0 24px rgba(255, 207, 77, .4);
}
.best-line { font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: .14em; color: var(--text-faint); }
.best-line b { color: var(--text); font-weight: 800; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); margin: var(--s-5) 0 var(--s-3); }
.stat {
  padding: var(--s-3) var(--s-2); border-radius: var(--r-md);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.stat b { display: block; font-family: var(--font-display); font-weight: 800; font-size: 38px; line-height: 1; letter-spacing: .02em; }
.stat span { display: block; margin-top: 6px; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .2em; color: var(--text-faint); }
.stat.gold b { color: var(--gold); }
.stat.small b { font-size: 24px; }
.dead-party { text-align: left; max-width: 420px; margin: var(--s-4) auto 0; }
.dead-actions { display: flex; justify-content: center; gap: var(--s-3); margin-top: var(--s-5); flex-wrap: wrap; }
.dead-actions .btn { min-width: 180px; }
.dead-actions .btn[hidden] { display: none; }
.dead-wait {
  font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .14em; color: var(--info);
}

/* ================================================================== layouts */

/* Short desktop windows: tighten the brand so the whole menu fits. */
@media (max-height: 720px) and (min-width: 861px) {
  #panel-menu { padding-top: 36px; padding-bottom: 8px; }
  .brand-name { font-size: clamp(44px, 5vw, 68px); }
  .menu-main { gap: 12px; }
  .menu-actions .btn-hero { min-height: 62px; margin-bottom: 8px; }
  .btn-hero-main { font-size: 28px; }
  .nav-item { min-height: 32px; font-size: 19px; }
  .howto-card li { font-size: 13px; }
  .howto-card ul { gap: 4px; }
  /* The results, party included, fit a laptop screen without scrolling. */
  #panel-dead h2 { font-size: 76px; margin: 2px 0 4px; }
  .dead-best { margin-top: var(--s-2); min-height: 0; }
  .stat-grid { margin: var(--s-3) 0 var(--s-2); }
  .stat { padding: 8px 6px; }
  .stat b { font-size: 30px; }
  .stat.small b { font-size: 20px; }
  .dead-party { max-width: none; margin-top: var(--s-2); }
  .dead-party .party { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .dead-party .party li { padding: 6px 12px; }
  .dead-actions { margin-top: var(--s-4); }
}
/* Wide desktop: a little more scale so the front screen does not look lost. */
@media (min-width: 1600px) and (min-height: 900px) {
  .menu-main { width: 500px; gap: var(--s-6); }
  .btn-hero { min-height: 88px; }
  .btn-hero-main { font-size: 40px; }
  .nav-item { min-height: 48px; font-size: 24px; }
  .brand-kicker { font-size: 18px; }
  .brand-tag { font-size: 16px; }
}
@media (max-width: 640px) {
  .coop-grid, .howto-grid { grid-template-columns: 1fr; }
  .shop-body { grid-template-columns: 1fr; gap: var(--s-3); }
  .hero-shot { height: 140px; }
  .set-row { grid-template-columns: 1fr; gap: 8px; }
  .set-ctl, .seg { justify-content: flex-start; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .screen-head { grid-template-columns: auto 1fr; }
  .screen-head .screen-meta { grid-column: 1 / -1; text-align: left; }
  .screen-head h2 { font-size: 28px; }
  .screen { padding: var(--s-4) var(--s-4) var(--s-5); }
  #mp-name { max-width: none; }
  .howto-keys { grid-template-columns: 1fr; }
  /* Five settings tabs wrap to two rows rather than hide one off the edge. */
  #settings-tabs { flex-wrap: wrap; }
  #settings-tabs .tab { flex: 1 1 28%; padding: 0 8px; font-size: 14px; }
}
@media (max-width: 420px) {
  /* Only the current loadout's name stays beside its label on a phone. */
  .nav-item small:not(#nav-loadout-name) { display: none; }
  .btn-hero-sub { font-size: 9.5px; letter-spacing: .04em; padding-right: 24px; }
}
@media (max-width: 520px) {
  #panel-menu { padding: 72px 4px 16px; align-items: flex-start; }
  .menu-main { gap: var(--s-4); }
  .brand-name { font-size: 64px; }
  .menu-corner .who { display: none; }
  .btn-hero-main { font-size: 30px; }
  .menu-corner { padding-left: 6px; }
  .dead-actions .btn { flex: 1; min-width: 0; }
}

/* ==================================================================== HUD
   In-play rules that predate the split into per-area stylesheets. They
   belong to the HUD and are left exactly as they were. */
  /* ---- coins ---- */
  #coins {
    position: fixed; top: 42px; right: 18px;
    font-size: 13px; letter-spacing: 2px; color: #9aa6b2;
  }
  #coins b { color: #ffd24a; font-size: 16px; }

  /* ---- boss bar ---- */
  #bossbar {
    position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
    width: min(560px, 62vw); text-align: center;
    pointer-events: none;
  }
  #bossbar.hidden { display: none; }
  #boss-name {
    font-size: 12px; letter-spacing: 6px; color: #ff8a8a;
    margin-bottom: 5px; text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  }
  #boss-track {
    height: 10px; border-radius: 5px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,120,120,0.4);
    overflow: hidden;
  }
  #boss-fill {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, #ff4d4d, #ffb03d);
    transition: width 0.12s linear;
  }
  #boss-fill.enraged {
    background: linear-gradient(90deg, #c04ae0, #ff4d4d);
  }

  /* ---- shop ---- */
  #shop {
    position: fixed; inset: 0; z-index: 40;
    display: flex; align-items: center; justify-content: center;
    background: rgba(4,8,12,0.55);
    backdrop-filter: blur(3px);
  }
  #shop.hidden { display: none; }
  .shop-panel {
    width: min(620px, 92vw); max-height: 86vh; overflow-y: auto;
    background: rgba(10,16,22,0.94);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 8px;
    padding: 20px 22px;
    box-shadow: 0 24px 70px rgba(0,0,0,0.6);
  }
  .shop-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; margin-bottom: 16px;
  }
  .shop-title { font-size: 20px; letter-spacing: 6px; color: #ffd24a; }
  .shop-sub { font-size: 10px; letter-spacing: 2px; color: #7e8c99; margin-top: 4px; }
  .shop-sub b { color: #cfd8dd; }
  .shop-right { text-align: right; }
  .shop-coinbox { font-size: 12px; letter-spacing: 2px; color: #9aa6b2; }
  .shop-coinbox b { color: #ffd24a; font-size: 19px; }
  #shop-timer { font-size: 10px; letter-spacing: 2px; color: #7e8c99; margin-top: 4px; }
  #shop-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
  .shop-item {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 5px; padding: 11px 14px;
    color: #e8f0f2; font: inherit; text-align: left;
    cursor: pointer;
  }
  .shop-item:hover { background: rgba(77,182,255,0.16); border-color: #4db6ff; }
  .si-name { font-size: 13px; letter-spacing: 2px; }
  .si-blurb { font-size: 10px; letter-spacing: 1px; color: #8b97a3; margin-top: 3px; }
  .si-cost { font-size: 17px; color: #ffd24a; flex: 0 0 auto; }
  /* Priced out rather than hidden: seeing what you cannot afford yet is half
     the reason to keep a wave alive. */
  .shop-item.unaffordable { opacity: 0.4; cursor: not-allowed; }
  .shop-item.unaffordable:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.10); }

  .statrule {
    border: none; border-top: 1px solid rgba(255,255,255,0.14);
    margin: 12px 0 10px;
  }

  /* ---- floating damage numbers ---- */
  #dmgnums {
    position: fixed; inset: 0; pointer-events: none; z-index: 12;
    overflow: hidden;
  }
  .dmgnum {
    position: absolute; top: 0; left: 0;
    font: 700 19px/1 ui-monospace, monospace;
    letter-spacing: 1px;
    color: #f2f6f8;
    text-shadow: 0 2px 5px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
    will-change: transform, opacity;
    pointer-events: none;
  }
  .dmgnum.headshot { color: #ffcf4d; font-size: 23px; }
  .dmgnum.weak     { color: #ff9b30; font-size: 25px; }
  .dmgnum.kill     { color: #ff5c5c; font-size: 25px; }

  .shop-divider {
    margin: 12px 0 4px;
    font-size: 10px; letter-spacing: 4px; color: #7e8c99;
    border-top: 1px solid rgba(255,255,255,0.10);
    padding-top: 10px;
  }
  .shop-item.equipped { border-color: #6fe08a; cursor: default; }
  .shop-item.equipped .si-cost { color: #6fe08a; font-size: 12px; letter-spacing: 2px; }

/* ---------- touch controls ----------
   Only ever shown when touch.js decides a finger is driving, so none of this
   is reachable on a desktop browser. The zones sit above the canvas and below
   #overlay, which is hidden during play and so never in the way -- and is
   above these while a menu is up, which is what keeps menu buttons tappable.

   touch-action: none on the zones is load-bearing: without it a drag scrolls
   or pinch-zooms the page instead of reaching pointermove. */

