:root {
  --bg0: #05060c;
  --bg1: #0b1020;
  --accent: #7dd3ff;
  --accent-dim: #3a7ca5;
  --warn: #ffb347;
  --text: #e8eef7;
  --muted: #8b97ad;
  --panel: rgba(8, 12, 24, 0.72);
  --line: rgba(125, 211, 255, 0.22);
  --font-display: "Orbitron", sans-serif;
  --font-body: "Space Grotesk", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-body);
}

.hidden {
  display: none !important;
}

.panel {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.lobby-bg {
  position: absolute;
  inset: 0;
  /* Key art with a dark left-side wash so the panel stays readable. */
  background:
    linear-gradient(
      105deg,
      rgba(4, 6, 12, 0.92) 0%,
      rgba(4, 6, 12, 0.55) 45%,
      rgba(4, 6, 12, 0.15) 100%
    ),
    url("/textures/lobby-hero.png") center / cover no-repeat;
  pointer-events: none;
  animation: lobby-hero-drift 40s ease-in-out infinite alternate;
}

/* Very slow key-art zoom drift (alternate: gently breathe in and out). */
@keyframes lobby-hero-drift {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lobby-bg {
    animation: none;
  }
}

.lobby-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0.5px, transparent 0.6px);
  background-size: 4px 4px;
  opacity: 0.08;
  animation: drift 40s linear infinite;
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-80px);
  }
}

.lobby-content {
  position: relative;
  width: min(440px, 100%);
  padding: 2rem 1.75rem;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
}

/* SING-45: every lobby tab shares the Play view's footprint — the active
   view scrolls independently instead of stretching the panel. */
@media (min-width: 641px) {
  #lobby {
    display: grid;
    place-items: center;
  }

  .lobby-content {
    height: min(860px, calc(100vh - 4rem));
    display: flex;
    flex-direction: column;
  }

  .lobby-content > .tab-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    /* SING-45: expanding the private section must never introduce a
       horizontal scrollbar — rows shrink, the view only scrolls vertically. */
    overflow-x: hidden;
    /* SING-47: the gutter is reserved even before a scrollbar appears, so
       expanding the private section (which makes the view scroll) can no
       longer shift the Create with code / Join / Sign in buttons sideways. */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-dim) transparent;
    padding-right: 0.75rem;
  }

  .lobby-content > .lobby-tabs {
    flex: none;
  }
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

.brand {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.field span {
  font-size: 0.8rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  border-radius: 2px;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.skin-section {
  margin-bottom: 1rem;
}

.skin-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.4rem;
  max-height: 160px;
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.skin-option {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  padding: 0.35rem 0.2rem;
  font-size: 0.62rem;
  line-height: 1.2;
  text-align: center;
  border-radius: 2px;
}

.skin-option .swatch {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 0.25rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.skin-option.selected {
  border-color: var(--accent);
  background: rgba(125, 211, 255, 0.12);
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 2px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn.primary {
  flex: 1;
  background: linear-gradient(120deg, #1a3a55, #0d2238);
  border-color: var(--accent-dim);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}

.btn.secondary {
  width: 100%;
  background: rgba(125, 211, 255, 0.08);
}

.btn.ghost {
  color: var(--muted);
}

.btn.small {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

.auth-panel {
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tab {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.45rem;
  cursor: pointer;
  font: inherit;
}

.tab.active {
  color: var(--text);
  border-color: var(--line);
}

.status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--warn);
}

.session-line {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--accent);
}

/* SING-14: signed-in player's career stats, tucked under the session line */
.stats-line {
  margin: -1rem 0 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.leaderboard-section h2 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* SING-14: all-time/weekly board tabs, styled like the lobby mode tabs */
#lb-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

#lb-weekly-hint {
  margin: 0.5rem 0 0;
}

#global-leaderboard {
  margin: 0;
  padding-left: 1.2rem;
  max-height: 180px;
  overflow: auto;
}

#global-leaderboard li {
  margin-bottom: 0.35rem;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

#hud-left {
  pointer-events: none;
  /* SING-48 follow-up: the banner nudge below animates in and back out. */
  transition: margin-top 0.35s ease;
}

.hud-brand {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  font-size: 0.95rem;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(125, 211, 255, 0.35);
}

#hud-stats {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--text);
  text-shadow: 0 1px 4px #000;
}

#room-leaderboard {
  margin: 0;
  padding: 0.75rem 1rem;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  min-width: 180px;
  pointer-events: none;
  transition: margin-top 0.35s ease;
}

#room-leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

/* While the session-start ad banner is on screen (#ad-banner lives in the DOM
   from mount until its slide-out transition ends), hold the centered room
   leaderboard below it instead of under it: banner is top 0.5rem + 90px
   creative => bottom edge ~98px; the nudged board starts at ~124px. Releasing
   the nudge after dismissal eases back via the margin-top transition. */
body:has(#ad-banner) #room-leaderboard {
  margin-top: 6.75rem;
}

/* SING-48 follow-up: the brand + stats line drops below the banner too — the
   score/target, round clock and lives readouts must stay readable while ads
   show (same banner geometry as the leaderboard nudge above). */
body:has(#ad-banner) #hud-left {
  margin-top: 6.75rem;
}

#leave-btn {
  pointer-events: auto;
  align-self: flex-start;
}

.banner {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  padding: 0.9rem 1.4rem;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--accent);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
}

#kill-feed {
  position: absolute;
  top: 16.5rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  pointer-events: none;
}

.kill-feed-entry {
  padding: 0.35rem 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text);
  text-shadow: 0 1px 4px #000;
  white-space: nowrap;
  animation: kill-feed-fade 4s ease-in forwards;
}

@keyframes kill-feed-fade {
  0%,
  65% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#death-overlay {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: 1rem 1.6rem;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid var(--warn);
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-align: center;
  pointer-events: none;
  white-space: pre-line;
  line-height: 1.5;
}

/* ===== SING-48: end-of-round screen — winner headline + final standings.
   Centered card over the arena; auto-hidden after a few seconds (the server
   resets the round 4s after match_end) and always hidden on leave. ===== */
#round-end-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 10, 0.55);
  pointer-events: none;
  z-index: 5;
}

.round-end-card {
  min-width: min(420px, 92vw);
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.4rem 1.8rem;
  background: rgba(3, 6, 14, 0.92);
  border: 1px solid var(--accent-dim);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
}

#round-end-title {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  color: var(--accent);
}

#round-end-standings {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3rem;
  text-align: left;
  font-size: 0.92rem;
}

#round-end-standings li {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.18rem 0.45rem;
}

#round-end-standings li.me {
  background: rgba(125, 211, 255, 0.12);
  outline: 1px solid var(--accent-dim);
}

#round-end-standings .place {
  color: var(--muted);
  min-width: 1.6rem;
  text-align: right;
}

#round-end-standings .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#round-end-standings .score {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text);
}

.round-end-hint {
  margin: 0.9rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Non-blocking connection-status banner (unexpected disconnect while playing) */
.connection-banner {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  padding: 0.6rem 1.1rem;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid var(--warn);
  color: var(--warn);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  pointer-events: none;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Lobby: live list of open arenas */
.room-list {
  margin-bottom: 1rem;
}

/* SING-10: lobby mode tabs (FFA | Teams), styled like the auth tabs */
#mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.mode-tab {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.45rem;
  cursor: pointer;
  font: inherit;
}

.mode-tab.active {
  color: var(--text);
  border-color: var(--line);
  background: rgba(125, 211, 255, 0.08);
}

/* Teams arenas get a subtle darker tint; declared before .recommended so a
   recommended teams row keeps its accent highlight. */
.room-row.teams {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.06);
}

.room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  color: var(--text);
}

.room-row + .room-row {
  margin-top: 0.35rem;
}

.room-row.recommended {
  border-color: var(--accent);
  background: rgba(125, 211, 255, 0.08);
}

.room-row .room-tag {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.room-row.full {
  color: var(--muted);
}

#lobby-notice {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--warn);
}

/* SING-8/SING-9: HUD settings toggles (grouped with the Leave button) */
#hud-actions {
  pointer-events: auto;
  align-self: flex-start;
  display: flex;
  gap: 0.4rem;
}

/* Dimmed look while a setting is toggled off */
.btn.off {
  opacity: 0.45;
}

/* SING-9: bottom-right minimap, square, dark translucent, thin border */
#minimap {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 176px;
  height: 176px;
  background: rgba(5, 6, 12, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  pointer-events: none;
}

/* ===== SING-25: release alignment (lobby footer, HUD chip, ad slot) ===== */

/* Lobby becomes a content row + pinned footer row; the panel is exactly
   viewport-high and the content scrolls inside its row, so the footer stays
   visible without scrolling at any screen size. */
#lobby {
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
}

.lobby-content {
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

/* Lobby footer — "Powered by MyBTS.io", subtle but legible on the hero art. */
.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.9rem 0 0.35rem;
}

.site-footer-link {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  transition: color 0.15s ease;
}

/* SING-32: the "Report an issue" link is a <button> styled like its neighbor. */
button.site-footer-link {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.site-footer-sep {
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer-link:hover {
  color: var(--text);
}

/* The global .brand rule is the huge gradient h1; scoped reset for footer use. */
.site-footer-link .brand {
  margin: 0;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--accent);
}

/* In-game "Powered by MyBTS.io" chip, bottom-left of the HUD — clear of the
   bottom-right minimap, the top ad slot and the top-right toggles. */
.hud-footer-chip {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  pointer-events: auto;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  text-shadow: 0 1px 4px #000;
  transition: color 0.15s ease;
}

.hud-footer-chip:hover {
  color: var(--text);
}

.hud-footer-chip .brand {
  margin: 0;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 600;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--accent);
}

/* SING-32: in-game report entry sits directly above the MyBTS chip — same
   visual weight, still chrome rather than a new HUD widget. */
button.hud-footer-chip {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  bottom: calc(1rem + 1.7em);
}

/* Generic top-center ad slot; its creation/logic lives in src/ads.ts. Adding
   the .dismissed class slides the banner up and out of view. */
#ad-banner {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(728px, 96vw);
  z-index: 40;
  pointer-events: auto;
  transition:
    transform 0.35s ease,
    opacity 0.35s ease;
}

#ad-banner.dismissed {
  transform: translate(-50%, -130%);
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 640px) {
  #room-leaderboard {
    display: none;
  }

  #kill-feed {
    top: 8rem; /* keep clear of the top-center ad banner */
  }

  /* SING-25: small screens — tighter panel, HUD stacking, footer visibility */
  .panel {
    padding: 1rem 0.9rem;
  }

  .lobby-content {
    padding: 1.25rem 1rem;
  }

  /* Drop the brand/stats below a top-anchored ad banner (top 0.5rem + 90px
     creative => bottom edge ~98px; 16px hud padding + 5.75rem clears it). */
  #hud-left {
    margin-top: 5.75rem;
  }

  #hud-stats {
    font-size: 0.8rem;
  }

  /* Park the toggles above the 120px mobile minimap, bottom-right. */
  #hud-actions {
    position: absolute;
    right: 1rem;
    bottom: 9.5rem;
  }

  #death-overlay {
    max-width: calc(100vw - 2rem);
    font-size: 0.9rem;
  }

  .hud-footer-chip {
    left: 0.75rem;
    bottom: 0.75rem;
  }

  button.hud-footer-chip {
    bottom: calc(0.75rem + 1.7em);
  }
}

@media (max-width: 640px) {
  #minimap {
    width: 120px;
    height: 120px;
  }
}

/* ===== SING-32 bug report overlay — dark aesthetic, mobile-first sizing ===== */

.report-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 4, 10, 0.82);
  backdrop-filter: blur(4px);
}

.report-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.report-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.req {
  color: var(--warn);
  font-style: normal;
}

.report-card .field textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  border-radius: 2px;
  resize: vertical;
  min-height: 5.5rem;
}

.report-attachments {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.report-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.report-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.report-check .btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
}

.report-file-name {
  font-size: 0.75rem;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.report-context {
  margin-bottom: 0.9rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.report-context summary {
  cursor: pointer;
  color: var(--accent-dim);
  letter-spacing: 0.02em;
}

.report-context summary:hover {
  color: var(--accent);
}

.report-context ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.25rem;
  overflow-wrap: anywhere;
}

.report-note {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-style: italic;
  color: var(--muted);
}

/* Honeypot: rendered off-screen (display:none would tip off some bots). */
.report-hpot {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

.report-status {
  min-height: 1.3em;
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
}

.report-status.error {
  color: var(--warn);
}

.report-status.success {
  color: #7ff0b2;
}

.report-actions {
  display: flex;
  gap: 0.75rem;
}

.report-actions .btn.ghost {
  flex: none;
}

.report-actions .btn.primary {
  flex: 1;
}

@media (max-width: 640px) {
  .report-overlay {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .report-card {
    padding: 1rem 0.9rem 0.85rem;
  }
}

/* ===== Admin panel (apps/client/admin.html) — everything below is scoped to
   .admin-* classes and the #admin-root shell; no game styles are touched. ===== */

/* The global shell is overflow:hidden for the game canvas; the admin page is
   a normal scrolling document, so #admin-root becomes the scroll container. */
#admin-root {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(58, 124, 165, 0.16), transparent 60%), var(--bg0);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 6, 12, 0.6);
}

.admin-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(120deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-session-line {
  font-size: 0.85rem;
  color: var(--accent);
}

.admin-main {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.admin-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 1.25rem 1.5rem;
  border-radius: 2px;
}

.admin-card-title {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-signin {
  width: min(420px, 100%);
  margin: 2.5rem auto 0;
}

.admin-signin-hint {
  margin: -0.4rem 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.admin-forbidden-text {
  margin: 0;
  color: var(--warn);
}

.admin-refresh-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--warn);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.admin-stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
}

.admin-stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-stat-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(125, 211, 255, 0.25);
}

.admin-stat-value.warn {
  color: var(--warn);
  text-shadow: none;
}

.admin-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 860px) {
  .admin-columns {
    grid-template-columns: 1fr;
  }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(125, 211, 255, 0.12);
  text-align: left;
  overflow-wrap: anywhere;
}

.admin-table th {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.admin-table tbody tr:hover {
  background: rgba(125, 211, 255, 0.05);
}

.admin-table .admin-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table th.admin-num {
  color: var(--muted);
}

.admin-empty {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-field {
  display: grid;
  gap: 0.3rem;
}

.admin-field span {
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  border-radius: 2px;
}

.admin-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  font-size: 0.92rem;
}

.admin-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

/* "Ads enabled" rides the same field grid as the ads fields (grouped like the
   tuning form); align it with the input row instead of the label row. */
.tuning-grid .admin-check {
  margin-bottom: 0;
  align-self: end;
  padding-bottom: 0.55rem;
}

.admin-hint {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-form-actions .btn {
  min-width: 140px;
}

/* A lone Save button must not stretch into a full-width bar like the lobby's
   flex:1 primary; every admin section shows the same compact button width. */
.admin-form-actions .btn.primary {
  flex: 0 0 auto;
}

.admin-feedback {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--accent);
}

.admin-feedback.error {
  color: var(--warn);
}

/* Loading feedback: while a dashboard fetch is in flight the affected card
   content dims (tables swap their empty line for "Loading…" until first
   render); save flows already disable their buttons. */
.admin-stats-grid .admin-stat-value,
.admin-columns .admin-table,
#admin-ads-form,
#admin-tuning-form {
  transition: opacity 0.2s ease;
}

.admin-stats-grid.is-loading .admin-stat-value,
.admin-columns.is-loading .admin-table,
#admin-ads-form.is-loading,
#admin-tuning-form.is-loading {
  opacity: 0.5;
}

.admin-footer {
  display: flex;
  justify-content: center;
  padding: 1.25rem 0 1.5rem;
}

.admin-footer-link {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: color 0.15s ease;
}

.admin-footer-link:hover {
  color: var(--text);
}

.admin-footer-brand {
  color: var(--accent);
  font-weight: 600;
}

/* ===== Game tuning form (#admin-tuning-form) — scoped .tuning-* additions ===== */

.tuning-groups {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.tuning-group {
  margin: 0;
  padding: 0.6rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.25);
}

.tuning-group legend {
  padding: 0 0.45rem;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Compact field grid inside each group; shares .admin-field inputs. */
.tuning-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.7rem 1rem;
}

.admin-field input.tuning-invalid {
  border-color: var(--warn);
  background: rgba(248, 113, 113, 0.08);
}

/* ===== SING-36 private arenas ===== */

.private-section {
  margin-bottom: 1rem;
}

.private-actions {
  margin-bottom: 0.55rem;
}

.private-actions .btn {
  flex: 1;
}

.private-join {
  display: flex;
  gap: 0.55rem;
}

.private-join input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  border-radius: 2px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.private-join .btn {
  flex: none;
}

#private-notice {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--warn);
}

.hud-private-chip {
  position: absolute;
  left: 1rem;
  bottom: calc(1rem + 3.4em);
  pointer-events: auto;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-shadow: 0 1px 4px #000;
}

/* SING-37 spectator chip. */
.hud-spectator-chip {
  position: absolute;
  left: 1rem;
  bottom: calc(1rem + 5.1em);
  pointer-events: auto;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--warn);
  text-shadow: 0 1px 4px #000;
}

/* ===== SING-38 ranked seasons ===== */

.season-label {
  margin-left: 0.6rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.tier-badge {
  display: inline-block;
  margin-right: 0.45rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid currentcolor;
  border-radius: 2px;
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 1px;
}

/* ===== SING-40 achievements & missions ===== */

.progression-section {
  margin-bottom: 1.25rem;
}

.progression-section h2 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.mission-list,
.achievement-list {
  display: grid;
  gap: 0.3rem;
}

.mission-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--text);
}

.mission-row .progress {
  color: var(--accent);
  white-space: nowrap;
}

.mission-row.done span {
  color: #7ff0b2;
}

.achievement-row {
  display: grid;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.75rem;
}

.achievement-row.locked {
  opacity: 0.45;
}

.achievement-row .name {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.achievement-row.unlocked .name {
  color: #7ff0b2;
}

.achievement-row .desc {
  color: var(--muted);
}

.achievement-row .session-tag {
  color: var(--warn);
  font-size: 0.62rem;
}

/* SING-40 achievement/mission toasts ride the kill feed. */
.progress-toast {
  color: #7ff0b2;
  border-color: rgba(127, 240, 178, 0.4);
}

/* ===== SING-41 cosmetics shop ===== */

.trail-list {
  display: grid;
  gap: 0.35rem;
}

.trail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.78rem;
}

.trail-row.equipped {
  border-color: var(--accent);
}

.trail-row .trail-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.trail-row .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.trail-row .actions {
  display: flex;
  gap: 0.35rem;
  margin: 0;
}

.trail-row button {
  padding: 0.22rem 0.55rem;
  font-size: 0.7rem;
}

/* ===== SING-42 lobby tab bar ===== */

.tab-view {
  display: grid;
  align-content: start;
  gap: 0.25rem;
}

.lobby-tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.lobby-tab {
  appearance: none;
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.2rem;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 2px;
  font: inherit;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.lobby-tab:hover {
  color: var(--text);
}

.lobby-tab.active {
  color: var(--accent);
  border-color: var(--line);
  background: rgba(125, 211, 255, 0.07);
}

.lobby-tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.lobby-tab-label {
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* SING-43/44: tab icons are generated art on black — screen-blend drops the
   black background onto the dark panel; active tabs brighten + glow. */
.lobby-tab-icon img {
  width: 26px;
  height: 26px;
  display: block;
  margin: 0 auto;
  object-fit: cover;
  mix-blend-mode: screen;
  opacity: 0.5;
  filter: saturate(0.75);
  transition:
    opacity 0.15s ease,
    filter 0.15s ease;
}

.lobby-tab:hover .lobby-tab-icon img {
  opacity: 0.8;
}

.lobby-tab.active .lobby-tab-icon img {
  opacity: 1;
  filter: saturate(1.15) drop-shadow(0 0 5px rgba(125, 211, 255, 0.55));
}

/* SING-44: trail swatch orbs (one generated orb, hue-shifted per trail). */
.trail-orb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  mix-blend-mode: screen;
  background: #000;
}

/* SING-43: join-by-code row — the global .btn.secondary width:100% rule
   collapsed the input to nothing; the Join button now sizes to its content. */
.private-join {
  align-items: stretch;
  min-width: 0;
}

.private-join .btn.secondary {
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
  padding: 0.55rem 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.private-join input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.private-actions .btn {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* SING-45: private arena collapsed by default. */
.private-section summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.private-section summary::before {
  content: "B8";
  color: var(--accent-dim);
  transition: transform 0.15s ease;
}

.private-section[open] summary::before {
  transform: rotate(90deg);
}

.private-section .actions,
.private-section .private-join {
  margin-top: 0.55rem;
}
