/* FriendShooter UI — one sci-fi visual language.
   Tokens first; every panel shares the same surface, line, radius, and blur.
   Screen modes (see public/src/uimode.ts):
     body.in-lobby      -> lobby only
     (joined, default)  -> setup chrome (.setup-only)
     body.mode-combat   -> combat HUD (.combat-only)
*/

:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #9fb2c8;
  --line: rgba(120, 200, 170, 0.2);
  --accent: #32d296;
  --accent-soft: rgba(50, 210, 150, 0.16);
  --danger: #ff4d6d;
  --amber: #fbbf24;
  --info: #38bdf8;
  --surface: linear-gradient(180deg, rgba(14, 22, 33, 0.82), rgba(6, 10, 16, 0.72));
  --surface-strong: linear-gradient(180deg, rgba(18, 25, 39, 0.94), rgba(8, 12, 20, 0.92));
  --radius: 0px;
  /* Shared corner chamfer (the angular "slant cut") — square, never rounded. */
  --chamfer: 10px;
  --blur: 12px;
  /* Single monospace stack used across the whole UI. */
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 28px rgba(0, 0, 0, 0.25);
  /* Readability floor: primary HUD text never drops below this (gate-tested). */
  --fs-hud: 14px;
  --fs-big: 17px;
  --fs-meta: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  /* dvh tracks the visible viewport on iOS Safari (excludes the bottom
     toolbar), so fixed bottom controls don't end up under the chrome. */
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #080b12;
  color: var(--ink);
  font-family: var(--font-mono);
  touch-action: none;
  /* Block pinch/double-tap zoom and rubber-band scroll on touch devices. */
  overscroll-behavior: none;
}

/* ------------------------------------------------------------------ modes */

body.in-lobby .setup-only,
body.in-lobby .combat-only {
  display: none !important;
}

body.mode-combat .setup-only {
  display: none !important;
}

body:not(.mode-combat) .combat-only {
  display: none !important;
}

body.in-lobby .controls,
body.in-lobby .stick,
body.in-lobby .lookPad,
body.in-lobby .shoot,
body.in-lobby .reticle,
body.in-lobby .settingsMenu,
body.in-lobby .settingsGear,
body.in-lobby #nameplates {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------- controls */

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 0;
  min-height: 44px;
  color: #061014;
  background: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}

button:active {
  transform: translateY(1px) scale(0.99);
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ------------------------------------------------------------------ lobby */

.panel {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 80% at 50% -10%, rgba(50, 210, 150, 0.12), transparent 60%),
    linear-gradient(180deg, rgba(6, 10, 16, 0.62), rgba(6, 10, 16, 0.86));
  backdrop-filter: blur(10px);
  overflow-y: auto;
}

/* Two columns: a big text menu on the left, the selected character (hero) on
   the right. The menu holds a comfortable reading width; the hero fills. */
#lobby {
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: max(20px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
}

.lobbyMenu {
  position: relative;
  z-index: 1;
  flex: 0 0 clamp(280px, 42%, 440px);
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
}

.lobbyHero {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Top bar: small brand on the left, tappable player name on the right. */
.lobbyBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px
    max(28px, env(safe-area-inset-left));
}

.brandSmall {
  line-height: 1;
  font-size: clamp(15px, 2.8vmin, 21px);
  font-weight: 950;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff, #5ff0bd 70%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 22px rgba(50, 210, 150, 0.3);
}

/* The name is a <button>; strip the default button chrome. */
.nameButton {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  background: transparent;
  color: var(--ink);
  clip-path: none;
  min-height: 0;
  padding: 6px 2px;
  text-align: right;
  cursor: pointer;
}

.nameButton-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--muted);
}

.nameButton-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Pencil hint that the name is editable. */
.nameButton-icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
  opacity: 0.7;
  flex-shrink: 0;
}

.nameButton-value {
  font-size: clamp(16px, 3.4vmin, 22px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: none;
}

.nameButton:hover .nameButton-value,
.nameButton:active .nameButton-value {
  text-shadow: 0 0 16px rgba(50, 210, 150, 0.55);
}

.nameButton:hover .nameButton-icon,
.nameButton:active .nameButton-icon {
  opacity: 1;
}

label span,
.caption {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 800;
  text-transform: uppercase;
}

/* Name editor overlay: a dimmed backdrop with one big input. */
.nameOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 12, 0.82);
  backdrop-filter: blur(8px);
}

.nameOverlay-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(560px, 90vw);
  padding: 28px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.nameOverlay-card label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.nameOverlay-card input {
  min-height: 64px;
  padding: 0 18px;
  font-size: clamp(26px, 6vmin, 42px);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.08em;
}

#nameDone {
  font-size: 16px;
  min-height: 48px;
}

/* ---------------------------------------------------------- big text menu */

.menu {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

/* Menu options read as big text, not filled buttons (Paladins-style). */
.menuItem {
  font-size: clamp(30px, 6.5vmin, 48px);
  font-weight: 950;
  letter-spacing: 0.03em;
  line-height: 1.04;
  text-transform: uppercase;
}

/* The primary action is a <button>; strip the button chrome, keep big text. */
.menuItem--play {
  background: transparent;
  color: var(--ink);
  clip-path: none;
  min-height: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  transition: color 0.12s ease, transform 0.12s ease;
}

.menuItem--play:hover,
.menuItem--play:active {
  color: var(--accent);
  transform: translateX(5px);
}

/* ---------------------------------------------------------- char chooser */

.charPreview {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.charNav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  /* The slant-cut surface lives on ::before so the button itself stays a plain
     rectangle. clip-path on a translateY(-50%) element mis-offsets the pointer
     hit region (top half goes dead); keeping the clip off the interactive box
     means the whole square stays clickable. */
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 1;
  isolation: isolate;
  transition: transform 0.12s;
}

.charNav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
  transition: background 0.12s, border-color 0.12s;
}

#charPrev { left: 4px; }
#charNext { right: 4px; }

.charNav:hover::before,
.charNav:active::before {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.charName {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(22px, 5vmin, 38px);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(50, 210, 150, 0.45);
  white-space: nowrap;
}

.roomList {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  max-height: 44vh;
  overflow-y: auto;
}

/* Narrow / portrait fallback: stack the menu above the character. */
@media (max-aspect-ratio: 1 / 1) {
  #lobby {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
  .lobbyMenu {
    flex: 0 0 auto;
    align-items: center;
    text-align: center;
    max-width: 460px;
  }
  .lobbyHero {
    width: 100%;
    min-height: 240px;
  }
}

.roomList-empty {
  padding: 4px 0;
  color: var(--muted);
  font-size: 15px;
}

/* Each join option matches the Create Room option: big uppercase menu text. */
.roomList-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: clamp(30px, 6.5vmin, 48px);
  font-weight: 950;
  letter-spacing: 0.03em;
  line-height: 1.04;
  text-transform: uppercase;
  transition: color 0.12s ease, transform 0.12s ease;
}

.roomList-item:hover,
.roomList-item:active {
  color: var(--accent);
  transform: translateX(5px);
}

.roomList-item .badge {
  background: var(--accent);
  color: #06121a;
  border-radius: 0;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.error {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
}

/* ---------------------------------------------------------- staging lobby */

/* A full-screen layer over the rendered arena. The arena is the backdrop; a
   translucent panel on the left holds the room code, joined players, and the
   round options, fading to transparent on the right so the map shows through
   (PUBG-style staging). Combat controls/settings are hidden in this mode. */
.lobbyStage {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  pointer-events: none;
}

body:not(.mode-combat):not(.in-lobby) .controls,
body:not(.mode-combat):not(.in-lobby) .settingsGear {
  display: none;
}

/* Chrome floats over the 3D character lineup: a small room card top-left, and a
   bottom bar so the top of the frame (the characters) stays unobstructed. */
.lobbyStage-room {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(6, 10, 16, 0.78);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.lobbyStage-code {
  display: flex;
  flex-direction: column;
}

.lobbyStage-room strong {
  font-size: 28px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(50, 210, 150, 0.45);
}

.lobbyStage-qr {
  width: 48px;
  height: 48px;
  background: #fff;
  flex-shrink: 0;
}

/* Bottom-centered, never taller than it needs to be. */
.lobbyStage-controls {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(18px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 16px));
  max-width: 96vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

/* Host option strip — wraps to a second row on narrow phones. */
.lobbyOptions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(6, 10, 16, 0.8);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.segmented {
  display: flex;
}

.segmented .seg {
  min-height: 32px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  clip-path: none;
}

.segmented .seg + .seg {
  border-left: 0;
}

.segmented .seg.active {
  background: var(--accent);
  color: #06121a;
  border-color: var(--accent);
}

.lobbyStage-start {
  display: flex;
  gap: 14px;
}

.lobbyStage-start button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  white-space: nowrap;
}

/* Match the map button's height to the segmented + start buttons: zero vertical
   padding and a small thumb keep it from growing taller. */
.lobbyStage .arenaPicker {
  min-height: 32px;
  margin: 0;
  padding: 0 8px;
  gap: 6px;
}

/* Non-host read-only view of the host's choices. */
.lobbyReadout {
  margin: 0;
  padding: 9px 16px;
  background: rgba(6, 10, 16, 0.8);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.lobbyStage-wait {
  margin: 0;
  padding: 7px 16px;
  background: rgba(6, 10, 16, 0.8);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  color: #cdd6e4;
  font-weight: 700;
}

/* Bottom-left cluster: back button, then round length / map / waiting note.
   Kept clear of the centered bottom bar so it never collides with host options. */
.lobbyStage-info {
  position: absolute;
  left: max(16px, env(safe-area-inset-left) + 12px);
  bottom: max(18px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 16px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 62vw;
  pointer-events: none;
}

.arenaPicker {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  min-height: 56px;
  background: var(--accent);
  color: #06121a;
  text-align: left;
  font-weight: 800;
}

.arenaPicker b {
  color: #06121a;
  font-weight: 950;
}

/* Non-host sees the map read-only: neutral grey with light text instead of the
   host's green action button. */
.arenaPicker:not(.host) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  box-shadow: none;
  cursor: default;
}

.arenaPicker:not(.host) b {
  color: #fff;
}

.arenaThumb {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(6, 10, 16, 0.66);
  flex-shrink: 0;
}

.arenaPickerLabel {
  flex: 1;
  font-size: 12px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.arenaCycle {
  font-size: 18px;
  color: #06121a;
  opacity: 0.85;
}

.arenaPicker:not(.host) .arenaCycle {
  display: none;
}

/* ------------------------------------------------------------- combat HUD */

/* Top-center: round timer with the objective readout stacked beneath it. */
.topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: max(10px, env(safe-area-inset-top));
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}

/* Shared angled-card chrome for the panels that still read as HUD cards. */
.timer,
.leaderboard,
.killFeed-entry {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
}

.killFeed-entry {
  border-left: 3px solid var(--accent);
}

.timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 116px;
  min-height: 40px;
  padding: 7px 22px;
  border-color: rgba(50, 210, 150, 0.4);
  box-shadow: var(--shadow), 0 0 22px rgba(50, 210, 150, 0.14);
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  font-size: var(--fs-big);
  letter-spacing: 1px;
  line-height: 1.15;
}

/* Bottom-left: health — the cockpit centerpiece. Big number + chunked gauge. */
.healthHud {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 14px));
  z-index: 3;
  width: min(288px, 42vw);
  pointer-events: none;
}

.healthHud-readout {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 5px;
  padding-left: 2px;
}

.healthHud-readout b {
  font-size: 34px;
  font-weight: 950;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(50, 210, 150, 0.35);
  transition: color 200ms ease;
}

.healthHud-unit {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--muted);
}

.healthHud-track {
  position: relative;
  height: 32px;
  border: 3px solid #04070c;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.healthHud-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(50, 210, 150, 0.6);
  transition: width 120ms ease, background 200ms ease;
}

/* Armor overlay: a blue band over the left of the bar while armor is active. */
.healthHud-armor {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #2aa8ee;
  border-right: 2px solid #bfe6ff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.65);
  transition: width 160ms ease;
  pointer-events: none;
}

/* Notches over the fill so it reads as a chunked gauge, not a progress bar. */
.healthHud-track::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0, transparent 18px, rgba(6, 10, 16, 0.85) 18px, rgba(6, 10, 16, 0.85) 21px);
}

/* Damage punch: a quick shake when the player takes a hit. */
.healthHud.dmg {
  animation: healthHud-dmg 280ms ease-out;
}

@keyframes healthHud-dmg {
  0% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  45% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

/* Critical health: pulse the big number. */
.healthHud.critical .healthHud-readout b {
  animation: healthHud-crit 700ms ease-in-out infinite;
}

@keyframes healthHud-crit {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Bottom-right: personal hill score. */
.scoreHud {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 14px));
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
  pointer-events: none;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}

.scoreHud-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--muted);
}

.scoreHud b {
  font-size: 22px;
  font-weight: 950;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

/* KOTH objective readout under the timer: a relocation bar + a live state word. */
.objective {
  width: 218px;
  padding: 6px 11px 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
  pointer-events: none;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}

.objective-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.objective-title {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.objective-state {
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.5px;
  white-space: nowrap;
  color: var(--muted);
}

.objective-state[data-kind="good"] { color: var(--accent); }
.objective-state[data-kind="bad"] { color: var(--danger); }
.objective-state[data-kind="warn"] { color: var(--amber); }

.objective-track {
  height: 6px;
  border-radius: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.objective-track i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(50, 210, 150, 0.5);
  transition: width 240ms linear;
}

/* Last few seconds before the hill moves: the bar goes amber and pulses. */
.objective.relocating .objective-track i {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.7);
  animation: objective-pulse 600ms ease-in-out infinite;
}

@keyframes objective-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.status {
  position: fixed;
  left: 50%;
  /* Sits below the top-center timer + objective readout so buffs never overlap. */
  top: max(124px, calc(env(safe-area-inset-top) + 124px));
  z-index: 3;
  display: flex;
  max-width: min(90vw, 520px);
  transform: translateX(-50%);
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.status span {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(8, 12, 20, 0.82);
  padding: 6px 12px;
  color: #fff;
  font-size: var(--fs-meta);
  font-weight: 700;
  letter-spacing: 0.5px;
  backdrop-filter: blur(var(--blur));
}

.status .winnerChip {
  border-color: rgba(251, 191, 36, 0.46);
  color: #fff7ad;
}

/* Active-buff chips, color-coded by effect. No countdown — they just show
   while the boost is live (temporary speed/damage expire server-side). */
.status .buff-armor {
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--info);
}

.status .buff-speed {
  border-color: rgba(50, 210, 150, 0.5);
  color: var(--accent);
}

.status .buff-damage {
  border-color: rgba(255, 77, 109, 0.5);
  color: var(--danger);
}

.status .buff-shield {
  border-color: rgba(251, 191, 36, 0.5);
  color: var(--amber);
}

/* Floating pickup feedback — rises from mid-screen and fades. */
.pickupFeed {
  position: fixed;
  left: 50%;
  top: 56%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.pickupToast {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  animation: pickupRise 1300ms ease-out forwards;
}

.pickup-heal { color: var(--accent); }
.pickup-armor { color: var(--info); }
.pickup-speed { color: #eafff6; }
.pickup-damage { color: var(--danger); }

@keyframes pickupRise {
  0% { opacity: 0; transform: translateY(10px) scale(0.9); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px); }
}

.leaderboard {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  /* Below the gear (top 12px, 38px tall). */
  top: max(60px, calc(env(safe-area-inset-top) + 60px));
  z-index: 3;
  width: min(250px, 46vw);
  padding: 8px;
  pointer-events: none;
}

.leaderboard div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 5px 6px;
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 800;
}

.leaderboard b {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--amber);
}

.leaderboard b em {
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
}

.leaderboard .me {
  color: #fff;
}

.leaderboard .winner {
  color: #fff7ad;
}

.minimap {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(164px, calc(env(safe-area-inset-bottom) + 164px));
  z-index: 3;
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 10, 16, 0.66);
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* -------------------------------------------------------------- kill feed */

.killFeed {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}

.killFeed-entry {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: var(--fs-meta);
  font-weight: 800;
  color: var(--muted);
  opacity: 1;
  transition: opacity 600ms ease;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}

.killFeed-entry.fading {
  opacity: 0;
}

.killFeed-entry b {
  color: #fff;
}

.killFeed-entry .me {
  color: var(--accent);
}

.killFeed-entry .bolt {
  color: var(--amber);
}

/* ----------------------------------------------------------- death overlay */

.deathOverlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(8, 11, 18, 0.25) 30%, rgba(80, 8, 24, 0.55));
  pointer-events: none;
}

.deathOverlay-inner {
  text-align: center;
  padding: 22px 38px;
  border: 1px solid rgba(255, 77, 109, 0.4);
  border-radius: var(--radius);
  background: var(--surface-strong);
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
}

.deathOverlay-title {
  font-size: 26px;
  font-weight: 950;
  letter-spacing: 4px;
  color: var(--danger);
  text-shadow: 0 0 24px rgba(255, 77, 109, 0.5);
}

.deathOverlay-killer {
  margin-top: 6px;
  font-size: var(--fs-hud);
  font-weight: 800;
  color: var(--muted);
}

.deathOverlay-killer b {
  color: #fff;
}

.deathOverlay-count {
  margin-top: 10px;
  font-size: 22px;
  font-weight: 950;
  color: var(--ink);
}

/* --------------------------------------------------------------- settings */

/* Settings live behind a gear (top-left corner). Mid-round the gear is the only
   thing showing; tapping it opens the cluster as a popover (body.settings-open),
   so no slider floats in the player's face while they fight. */
.settingsGear {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  top: max(12px, calc(env(safe-area-inset-top) + 12px));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: color 140ms ease, box-shadow 140ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1.4);
}

.settingsGear:hover {
  color: #fff;
}

/* Staging-lobby "back to main menu" button (sits atop the bottom-left info). */
.lobbyBackBtn {
  align-self: flex-start;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 16, 0.8);
  backdrop-filter: blur(var(--blur));
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  transition: color 140ms ease, border-color 140ms ease;
}

.lobbyBackBtn:hover,
.lobbyBackBtn:active {
  color: var(--accent);
  border-color: var(--accent);
}

/* Build version, tucked in the welcome screen's bottom-left. */
.appVersion {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(12px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.65;
  pointer-events: none;
}

body.settings-open .settingsGear {
  color: var(--accent);
  transform: rotate(72deg);
  box-shadow: var(--shadow), 0 0 16px rgba(50, 210, 150, 0.4);
}

/* Centered overlay menu opened by the gear: a dimmed backdrop with a card of
   options (audio, sensitivity, then a gap and the exit). */
.settingsMenu {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 7, 12, 0.6);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

body.settings-open .settingsMenu {
  display: flex;
}

.settingsMenu-card {
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: rgba(8, 12, 20, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.settingsMenu-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.settingsMenu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.settingsMenu-rowLabel {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.muteBtn {
  width: 40px;
  height: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.sensitivity input {
  flex: 1;
  min-height: 0;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

/* Visual breathing room before the destructive exit. */
.settingsMenu-gap {
  height: 4px;
}

.settingsMenu-leave {
  min-height: 48px;
  border: 1px solid rgba(251, 113, 133, 0.6);
  background: rgba(251, 113, 133, 0.12);
  color: #fb7185;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: background 140ms ease, color 140ms ease;
}

.settingsMenu-leave:hover,
.settingsMenu-leave:active {
  background: #fb7185;
  color: #1a0408;
}

/* ----------------------------------------------------- reticle & feedback */

/* Dynamic crosshair: a center dot + four arms whose gap is driven from JS
   (--gap) so it spreads on fire and recovers, and recolors when a shot would
   land on an enemy (.on-target). The container is a zero-size point at screen
   center; each arm is offset outward from it. */
.reticle {
  --gap: 5px;
  --len: 7px;
  --col: rgba(255, 247, 173, 0.94);
  --glow: rgba(251, 191, 36, 0.8);
  position: fixed;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
}

.reticle-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--col);
  box-shadow: 0 0 8px var(--glow);
}

.reticle-arm {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 0;
  background: var(--col);
  box-shadow: 0 0 10px var(--glow);
}

.reticle-up,
.reticle-down {
  width: 2px;
  height: var(--len);
}

.reticle-left,
.reticle-right {
  width: var(--len);
  height: 2px;
}

/* Six-spoke burst shown only on a headshot lock — a distinct shape, not just a
   recolor, so the head zone is unmistakable. Each spoke is the up-arm rotated
   around the reticle center by its --rot. */
.reticle-spoke {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: var(--len);
  background: var(--col);
  box-shadow: 0 0 10px var(--glow);
  transform-origin: 0 0;
  transform: rotate(var(--rot)) translate(-50%, calc(-100% - var(--gap)));
  display: none;
}

.reticle.on-head .reticle-spoke {
  display: block;
}
.reticle.on-head .reticle-arm {
  display: none;
}

.reticle-up {
  transform: translate(-50%, calc(-100% - var(--gap)));
}
.reticle-down {
  transform: translate(-50%, var(--gap));
}
.reticle-left {
  transform: translate(calc(-100% - var(--gap)), -50%);
}
.reticle-right {
  transform: translate(var(--gap), -50%);
}

/* Desktop pointer-lock: green active aim. Selector kept at the same specificity
   as the .on-target / .on-head rules below so those (later in source) win when
   the aim is on an enemy — otherwise the lock-green swallowed the lock-on cue. */
.locked .reticle {
  --col: var(--accent);
  --glow: rgba(50, 210, 150, 0.9);
}

/* A shot right now would connect: hot red lock-on, overrides everything. */
.reticle.on-target {
  --col: var(--danger);
  --glow: rgba(255, 77, 109, 0.95);
}

/* Aim sits on the headshot zone: gold lock-on, overrides the body-hit red. */
.reticle.on-head {
  --col: #ffcf3f;
  --glow: rgba(255, 207, 63, 0.95);
}

.onHillGlow {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: box-shadow 280ms ease;
}

.onHillChip {
  position: fixed;
  left: 50%;
  top: calc(50% + 22px);
  z-index: 3;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 0;
  border: 1px solid transparent;
  font-size: var(--fs-meta);
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}

.hitFlash {
  position: fixed;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 45%, rgba(255, 77, 109, 0.42));
  transition: opacity 120ms ease;
}

.hitFlash.on {
  opacity: 1;
}

/* Crosshair hitmarker: the classic confirm tick that pops when YOU land a hit.
   Four diagonal strokes drawn with two crossed bars; .on restarts the pop. */
.hitmarker {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.6);
  opacity: 0;
  pointer-events: none;
}

.hitmarker::before,
.hitmarker::after {
  content: "";
  position: absolute;
  background: #fff2a8;
  box-shadow: 0 0 8px rgba(255, 220, 130, 0.95);
}

.hitmarker::before {
  left: 10px;
  top: 0;
  width: 2px;
  height: 22px;
}

.hitmarker::after {
  left: 0;
  top: 10px;
  width: 22px;
  height: 2px;
}

.hitmarker.on {
  animation: hitmarker-pop 200ms ease-out;
}

/* Headshot: hotter gold strokes, a stronger glow, and a bigger pop. */
.hitmarker.headshot::before,
.hitmarker.headshot::after {
  background: #ffd23f;
  box-shadow: 0 0 14px rgba(255, 180, 40, 1);
}

.hitmarker.headshot.on {
  animation: hitmarker-pop-headshot 260ms ease-out;
}

@keyframes hitmarker-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0.45);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(45deg) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0.9);
  }
}

@keyframes hitmarker-pop-headshot {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0.5);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(45deg) scale(1.7);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(1.4);
  }
}

/* Directional damage indicator: a red chevron + glow swung around screen
   center to point at whoever just shot you (relative to your facing). */
.damageDir {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.damageArrow {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  /* --a is the screen rotation (0deg = threat dead ahead, top of screen). */
  transform: translate(-50%, -50%) rotate(var(--a, 0deg));
  animation: damage-dir 950ms ease-out forwards;
}

/* Soft red wash bleeding in from the threat edge. */
.damageArrow::after {
  content: "";
  position: absolute;
  left: -150px;
  top: -41vh;
  width: 300px;
  height: 130px;
  background: radial-gradient(ellipse 62% 100% at 50% 100%, rgba(255, 45, 70, 0.5), rgba(255, 45, 70, 0) 72%);
  filter: blur(1px);
}

/* Chevron pointing outward toward the threat. */
.damageArrow::before {
  content: "";
  position: absolute;
  left: -21px;
  top: calc(-41vh - 16px);
  width: 42px;
  height: 42px;
  border-top: 6px solid rgba(255, 80, 100, 0.95);
  border-right: 6px solid rgba(255, 80, 100, 0.95);
  transform: rotate(-45deg);
}

@keyframes damage-dir {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* -------------------------------------------------- rotate-to-landscape gate
   FriendShooter is a landscape game. On a touch phone held in portrait, a
   full-screen overlay asks the player to rotate. Desktop (pointer: fine) and
   any landscape device never see it. Best-effort screen.orientation.lock() in
   main.ts complements this where the platform allows it; the overlay is the
   reliable fallback on a plain (non-secure-context) LAN. */
.rotateNotice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: var(--surface-strong);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}

@media (orientation: portrait) and (pointer: coarse) {
  .rotateNotice {
    display: flex;
  }
}

.rotateNotice__phone {
  width: 52px;
  height: 90px;
  border: 3px solid var(--accent);
  border-radius: 0;
  box-shadow: 0 0 24px rgba(50, 210, 150, 0.5), inset 0 0 12px rgba(50, 210, 150, 0.25);
  transform-origin: center;
  animation: rotate-hint 1.9s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 28% {
    transform: rotate(0deg);
  }
  62%, 100% {
    transform: rotate(-90deg);
  }
}

.rotateNotice__title {
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.rotateNotice__text {
  font-size: var(--fs-hud);
  color: var(--muted);
}

/* ----------------------------------------------------------- touch controls */

.controls {
  position: fixed;
  inset: auto max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 4;
  display: grid;
  grid-template-columns: 128px 1fr 138px;
  align-items: end;
  gap: 14px;
  pointer-events: none;
}

.stick,
.lookPad,
.shoot {
  pointer-events: auto;
  user-select: none;
  /* Each control owns its touch: no browser pan/zoom gesture can steal it and
     fire pointercancel when a second finger lands. */
  touch-action: none;
}

/* Desktop (precise pointer) plays with WASD + mouse: clicking the canvas
   shoots and locks the pointer, the mouse looks. The on-screen joystick, look
   pad, and fire button are touch-only, so hide the whole cluster there. */
@media (pointer: fine) {
  .controls {
    display: none !important;
  }
}

/* Live FPS readout — small unobtrusive chip, bottom-center (clear of the
   bottom-left health and the touch thumbsticks). */
/* Diagnostics: fps + ping, always visible, bottom-right on every screen. */
.fpsCounter {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 10px));
  z-index: 30;
  padding: 2px 8px;
  border-radius: 0;
  font: 600 12px/1.4 var(--font-mono);
  color: var(--muted);
  background: rgba(8, 14, 24, 0.55);
  border: 1px solid var(--line);
  pointer-events: none;
  letter-spacing: 0.04em;
}

/* On touch the bottom-right corner is the fire button; lift the readout above
   it once the player has left the lobby (staging / combat). */
@media (pointer: coarse) {
  body:not(.in-lobby) .fpsCounter {
    bottom: max(118px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 118px));
  }
}

/* Analog move stick: an accent-rimmed base with a crosshair gate and a glowing
   knob, so it reads as a game stick rather than a translucent web circle. The
   base floats to wherever the thumb lands (positioned by input.ts). */
.stick {
  position: fixed;
  left: max(78px, calc(env(safe-area-inset-left) + 64px));
  top: calc(100% - max(78px, calc(env(safe-area-inset-bottom) + 64px)));
  transform: translate(-50%, -50%);
  width: 128px;
  height: 128px;
  border: 2px solid rgba(50, 210, 150, 0.45);
  border-radius: 50%;
  /* Crosshair gate (two thin accent lines) over a recessed well. */
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(50, 210, 150, 0.22) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(0deg, transparent calc(50% - 0.5px), rgba(50, 210, 150, 0.22) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    radial-gradient(circle at 50% 50%, rgba(50, 210, 150, 0.12), rgba(8, 14, 24, 0.34) 72%);
  backdrop-filter: blur(var(--blur));
  opacity: 0.5;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.45), 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: opacity 120ms ease, border-color 120ms ease;
}

/* Inner travel-limit ring. */
.stick::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  border: 1px dashed rgba(50, 210, 150, 0.3);
}

.stick.active {
  opacity: 1;
  border-color: rgba(50, 210, 150, 0.85);
}

.stick-nub {
  position: absolute;
  left: 42px;
  top: 42px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: radial-gradient(circle at 38% 30%, #eafff6, var(--accent) 58%, #1f9e74);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 16px rgba(50, 210, 150, 0.5);
  transition: box-shadow 120ms ease;
}

.stick.active .stick-nub {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55), 0 0 26px rgba(50, 210, 150, 0.85);
}

.lookPad {
  height: 132px;
  border: 1px dashed rgba(50, 210, 150, 0.32);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, 0.08), transparent 51%),
    linear-gradient(180deg, transparent 49%, rgba(255, 255, 255, 0.08), transparent 51%),
    rgba(255, 255, 255, 0.04);
}

/* Fire trigger: a chunky round trigger with a crosshair glyph (no web-button
   text) and a tactile press — it sinks and flares the guard ring when held. */
.shoot {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 0 9px rgba(255, 77, 109, 0.12), 0 0 28px rgba(255, 77, 109, 0.38);
  transition: transform 70ms ease, box-shadow 70ms ease, filter 70ms ease;
}

.shoot-icon {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.shoot.pressed {
  transform: scale(0.9);
  filter: brightness(1.18);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 0 0 5px rgba(255, 77, 109, 0.28), 0 0 22px rgba(255, 77, 109, 0.6);
}

/* ------------------------------------------------------------ winner banner */

.winnerBanner {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.winnerBanner-inner {
  width: min(92vw, 460px);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 28px 24px 20px;
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.6);
}

.winnerBanner-title {
  text-align: center;
  font-size: 26px;
  font-weight: 950;
  letter-spacing: 3px;
  color: var(--amber);
  text-shadow: 0 0 28px rgba(251, 191, 36, 0.5);
  margin-bottom: 18px;
}

.bannerRow {
  display: grid;
  grid-template-columns: 26px 1fr 44px 72px 44px;
  gap: 8px;
  align-items: center;
  padding: 8px 4px;
  font-size: var(--fs-hud);
  font-weight: 800;
  color: var(--muted);
}

.bannerRow + .bannerRow {
  border-top: 1px solid var(--line);
}

.bannerRow-me {
  color: #fff;
  background: var(--accent-soft);
  border-radius: 0;
  margin: 2px -4px;
  padding: 8px 8px;
}

.bannerRank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  text-align: center;
  line-height: 22px;
  font-size: 10px;
  font-weight: 900;
  flex-shrink: 0;
}

.bannerRow:first-child .bannerRank {
  background: var(--amber);
  color: #000;
}

.bannerName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bannerScore {
  font-size: var(--fs-big);
  font-weight: 950;
  color: var(--amber);
  text-align: right;
}

.bannerBar {
  height: 5px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bannerBar div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--amber));
}

.bannerKd {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

/* ------------------------------------------------------------- nameplates */

.nameplates {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.nameplate {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  font-family: inherit;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  will-change: transform, left, top;
}

.nameplate.npc .nameplate-name {
  color: #fde68a;
}

.nameplate-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
  white-space: nowrap;
  padding: 0 2px;
}

.nameplate-bar {
  width: 56px;
  height: 4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 0;
  overflow: hidden;
}

.nameplate-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.12s ease, background-color 0.12s ease;
}

/* Staging lineup: names read as floating labels, no health bars. */
.nameplate.lobby .nameplate-bar {
  display: none;
}

.nameplate.lobby .nameplate-name {
  font-size: 15px;
  padding: 3px 10px;
  background: rgba(6, 10, 16, 0.72);
  border: 1px solid var(--line);
}

.nameplate.lobby.me .nameplate-name {
  color: #06121a;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------------------------------------------------------------- loading */

.loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #080b12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.loadingBrand {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.loadingBarTrack {
  width: 200px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 0;
  overflow: hidden;
}

.loadingBarFill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 0;
  transition: width 0.15s ease;
}

/* ------------------------------------------------------------- small phones */

@media (max-width: 720px) {
  /* The kill feed owns the top-right strip; keep status chips centered but
     clear of it. */
  .status {
    top: max(108px, calc(env(safe-area-inset-top) + 108px));
    max-width: 70vw;
  }

  .killFeed-entry {
    padding: 4px 9px;
  }

  .minimap {
    width: 104px;
    height: 104px;
    bottom: max(168px, calc(env(safe-area-inset-bottom) + 168px));
  }

  .settingsMenu-card {
    padding: 16px;
  }

  .deathOverlay-title {
    font-size: 22px;
  }

}

/* Touch devices (phones/tablets, any orientation — landscape phones exceed the
   720px breakpoint) drop the join QR: it's a host-screen affordance for others
   to scan, not something you scan on the device you're already playing on.
   The thumbstick layout also lives here (not under a width breakpoint) so
   landscape phones, which clear 720px, still get the correct control layout. */
@media (pointer: coarse) {
  /* The right half of the canvas handles look (yaw + pitch), so the dedicated
     lookPad is redundant — hide it and let stick + trigger stand alone. */
  .lookPad {
    display: none;
  }

  .controls {
    /* iOS Safari positions `position: fixed` elements relative to the layout
       viewport (vh), which includes the area behind the bottom toolbar. So
       `bottom: 14px` ends up under the chrome. `100vh - 100dvh` resolves to
       the chrome height (0 when hidden), giving us exact clearance. */
    bottom: max(14px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 14px));
    grid-template-columns: 0 1fr 0;
    gap: 0;
  }

  .stick {
    width: 132px;
    height: 132px;
    left: max(82px, calc(env(safe-area-inset-left) + 68px));
    top: calc(100dvh - max(82px, calc(env(safe-area-inset-bottom) + 68px)));
  }

  .stick-nub {
    left: 44px;
    top: 44px;
    width: 44px;
    height: 44px;
  }

  /* `.stick` is position:fixed, so it leaves the grid; auto-placing the
     remaining .shoot into a 0px column with `justify-self: end` pushed it
     off the left edge. Pin the trigger to the bottom-right explicitly. */
  .shoot {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, calc(100vh - 100dvh + env(safe-area-inset-bottom) + 20px));
    margin-bottom: 0;
    width: 86px;
    height: 86px;
  }

  /* On a phone you don't scan your own screen — drop the join QR in the lobby. */
  .lobbyStage-qr {
    display: none;
  }

  /* The host setup controls share one compact styling across desktop and mobile
     (see the base .lobbyOptions / .segmented / .arenaPicker rules). On phones,
     only the layout differs: force a single non-wrapping row and anchor it to
     the right so it clears the bottom-left Main Menu / readout cluster. */
  .lobbyStage-controls {
    left: auto;
    right: max(12px, env(safe-area-inset-right));
    transform: none;
    align-items: flex-end;
    max-width: calc(100vw - 24px);
  }

  .lobbyOptions {
    flex-wrap: nowrap;
    padding: 6px 8px;
  }

  /* On touch the thumbs own the bottom corners (stick + fire), so the
     bottom-anchored cockpit readouts move to the top instead — and shrink, to
     leave the center of the screen clear for play. */
  .healthHud {
    left: max(58px, calc(env(safe-area-inset-left) + 46px));
    top: max(12px, env(safe-area-inset-top));
    bottom: auto;
    width: min(150px, 30vw);
  }

  .healthHud-readout {
    margin-bottom: 3px;
  }

  .healthHud-readout b {
    font-size: 20px;
  }

  .healthHud-unit {
    font-size: 9px;
    letter-spacing: 1.5px;
  }

  .healthHud-track {
    height: 16px;
    border-width: 2px;
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
  }

  .healthHud-track::after {
    background: repeating-linear-gradient(90deg, transparent 0, transparent 12px, rgba(6, 10, 16, 0.85) 12px, rgba(6, 10, 16, 0.85) 14px);
  }

  .scoreHud {
    top: max(12px, env(safe-area-inset-top));
    bottom: auto;
  }

  /* Merge the timer and KOTH status into a single top-center block so they read
     as one compact panel instead of two stacked cards. */
  .topbar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(72vw, 218px);
    gap: 0;
    border: 1px solid rgba(50, 210, 150, 0.4);
    background: var(--surface);
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow), 0 0 22px rgba(50, 210, 150, 0.14);
    clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
  }

  /* Children become sections of the shared block: drop their own chrome. */
  .topbar .timer {
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 4px 16px 3px;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    font-size: 22px;
  }

  .topbar .objective {
    width: 100%;
    padding: 5px 11px 7px;
    border: 0;
    border-top: 1px solid var(--line);
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    clip-path: none;
  }

  /* Leaderboard is too busy alongside thumbsticks; the kill feed carries the
     who's-winning signal on phones. */
  .leaderboard {
    display: none;
  }
}
