:root {
  --accent: #ffcb05;
  --panel: rgba(11, 19, 30, 0.78);
  --glass: rgba(24, 37, 55, 0.56);
  --rim: rgba(255, 255, 255, 0.22);
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1320;
  color: #fff;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  user-select: none;
}

#game-wrap { position: fixed; inset: 0; }
canvas { display: block; width: 100%; height: 100%; background: linear-gradient(#8cc8ff, #b6e0ff 45%, #85b86c 46%, #578259 100%); }
.hidden { display: none !important; }
.muted { color: #95a7bf; font-size: 14px; }

button {
  border: none;
  border-radius: 10px;
  padding: 13px 28px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--accent);
  color: #1b1400;
  cursor: pointer;
  box-shadow: 0 5px 0 #c79e00;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
button:hover { transform: translateY(-2px); }
button:active { transform: translateY(3px); box-shadow: 0 2px 0 #c79e00; }
button.secondary { background: #2b3550; color: #fff; box-shadow: 0 5px 0 #1a2034; }

kbd {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  margin-right: 4px;
  padding: 2px 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(14, 24, 40, 0.76), rgba(8, 12, 20, 0.94));
  text-align: center;
}

.menu-shell {
  width: min(1180px, 96vw);
  margin: auto;
  padding: 28px;
  border-radius: 24px;
  background: rgba(10, 17, 28, 0.72);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.menu-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: stretch;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 8px 6px;
  text-align: left;
}

.eyebrow {
  color: #a3b8d5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.menu-shell h1 {
  font-size: clamp(44px, 9vw, 82px);
  letter-spacing: 4px;
  line-height: 0.94;
}
.menu-shell h1 span { color: var(--accent); }

.tagline {
  color: #c5d3e6;
  line-height: 1.6;
  max-width: 640px;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-pill,
.panel-chip,
.server-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #dce8f8;
}

.server-badge {
  background: rgba(255,203,5,0.16);
  border-color: rgba(255,203,5,0.28);
  color: #ffe28b;
}

.panel-chip.subtle {
  background: rgba(255,255,255,0.06);
  color: #c5d3e6;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.menu-panel {
  border-radius: 18px;
  padding: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.menu-panel h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.menu-panel p {
  color: #d4ddeb;
  line-height: 1.6;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.player-card {
  display: flex;
  flex-direction: column;
}

.picker-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #9caac0;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#share-link {
  width: 100%;
  padding: 12px 16px;
  border-radius: 9px;
  border: 2px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 16px;
}

#share-link:focus { outline: none; border-color: var(--accent); }

.btn-row { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }

/* #plane-picker / #plane-swatches / .plane-swatch removed — replaced by #hangar-overlay */

.menu-note { margin-top: 12px; }

.play-panel {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.play-panel button { align-self: flex-start; }
.panel-foot {
  margin-top: auto;
  color: #95a7bf !important;
  font-size: 13px;
}

/* P2P section inside LAN panel */
#host-left-overlay .fatal-card {
  text-align: center;
}

/* ─── LOCAL WI-FI PARTY ─────────────────────────────────────────────────────── */
.local-wifi {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--rim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.local-room-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.local-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.local-room-row:hover,
.local-room-row:focus {
  background: rgba(255,255,255,0.13);
  border-color: var(--accent);
  outline: none;
}
.local-room-row:active {
  background: rgba(255,255,255,0.18);
}

.local-room-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.local-room-row-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.local-room-row-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.52);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.local-room-join-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--accent);
  color: #1b1400;
  box-shadow: 0 3px 0 #c79e00;
}
.local-room-join-btn:hover { transform: translateY(-1px); }
.local-room-join-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c79e00; }

.local-rescan-btn {
  align-self: flex-start;
  margin-top: 4px;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
}

.local-empty {
  padding: 6px 0;
}

/* Landscape-short phones: tighten the list */
@media (max-height: 440px) {
  .local-room-list { max-height: 140px; }
  .local-wifi { gap: 8px; padding: 12px; }
}

/* ─── P2P MIGRATING OVERLAY ─────────────────────────────────────────────────── */
#p2p-migrating-overlay {
  z-index: 98;
  background: radial-gradient(circle at center, rgba(10, 20, 40, 0.82), rgba(4, 8, 20, 0.94));
}
.migrating-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.migrating-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.18);
  border-top-color: #49c0ff;
  border-radius: 50%;
  animation: migrating-spin 0.9s linear infinite;
}
@keyframes migrating-spin {
  to { transform: rotate(360deg); }
}
.migrating-label {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  letter-spacing: 0.03em;
  margin: 0;
}

.controls-panel {
  grid-column: 1 / -1;
}

.controls-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 0;
}
.controls-block {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  text-align: left;
}
.controls-block h2,
.controls-block h3 {
  color: var(--accent);
  font-size: 15px;
  margin-bottom: 6px;
}
.controls-block p { line-height: 1.8; color: #d4ddeb; }
.status-line { min-height: 20px; margin-top: 12px; }

/* ─── HUD (minimal, edge-anchored, non-obstructive) ─────────────────────── */
#hud {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  padding: 8px 12px;
  pointer-events: none;
}
.hud-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.hud-item {
  padding: 4px 9px;
  border-radius: 7px;
  background: rgba(11, 19, 30, 0.55);
  backdrop-filter: blur(4px);
  font-size: 11px;
  font-weight: 700;
  color: rgba(184, 196, 216, 0.85);
  letter-spacing: 0.8px;
}
.hud-item span { color: var(--accent); margin-left: 4px; }
.icon-btn {
  pointer-events: auto;
  background: rgba(11, 19, 30, 0.55);
  color: #fff;
  box-shadow: none;
  padding: 4px 9px;
  font-size: 15px;
}
.icon-btn:hover, .icon-btn:active { transform: none; box-shadow: none; }

/* #leaderboard base — overridden fully below by the late-pass rules */
#leaderboard { transition: opacity 0.2s; }
.lb-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}
.lb-row.me { color: var(--accent); font-weight: 700; }
/* TDM team color dot in leaderboard/final-board rows */
.lb-team-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Power chip: compact, right-edge anchor to avoid blocking center */
#power-chip {
  position: absolute;
  top: 8px;
  right: max(14px, env(safe-area-inset-right));
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(11, 19, 30, 0.58);
  min-width: 120px;
  pointer-events: none;
}
#power-chip .pc-label { display: flex; gap: 5px; align-items: center; font-size: 11px; font-weight: 700; }
#power-chip .pc-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
#power-chip .pc-fill { display: block; height: 100%; transition: width 0.1s linear; }

/* Health bar: bottom-center, slimmer */
#healthbar {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(200px, 44vw);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(11, 19, 30, 0.5);
  border: 1px solid rgba(255,255,255,0.1);
}
#healthfill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff5858, #ffd35f 55%, #59ff9b);
  transition: width 0.12s ease;
}

/* On touch devices: pull HUD stat row and leaderboard further from the touch buttons */
@media (max-height: 600px) {
  #hud { padding: 6px 10px; }
  .hud-item { padding: 3px 7px; font-size: 10px; }
  #leaderboard { font-size: 10px; padding: 4px 7px; top: 140px; }
  #power-chip { font-size: 10px; }
}

#killfeed {
  position: absolute;
  top: 168px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  pointer-events: none;
  max-width: 48vw;
}
.kill-msg {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
}
.kill-msg.mine { color: var(--accent); }
.kill-msg .vic { color: #ff8d8d; }

/* ── Kill / death card ─────────────────────────────────────────────────── */
#respawn {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  padding: 18px 26px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(10, 17, 28, 0.94) 0%, rgba(6, 10, 18, 0.92) 100%);
  border: 1px solid rgba(255, 80, 80, 0.4);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 60, 60, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  min-width: 180px;
  pointer-events: none;
  animation: ksFadeIn 0.22s ease-out forwards, ksCardGlow 1s ease-in-out 0.22s infinite;
}
@keyframes ksCardGlow {
  0%, 100% { box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 60, 60, 0.16); }
  50% { box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 50px rgba(255, 60, 60, 0.34); }
}
@media (prefers-reduced-motion: reduce) {
  #respawn { animation: ksFadeIn 0.22s ease-out forwards !important; }
}
@keyframes ksFadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.84); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.ks-burst {
  font-size: 38px;
  animation: ksPulse 1s ease-in-out infinite;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(255, 90, 60, 0.5));
}
@keyframes ksPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2) rotate(-4deg); }
}
.ks-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ff4040;
  font-style: oblique -6deg;
  -webkit-text-stroke: 1px rgba(10, 0, 0, 0.6);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 60, 60, 0.7);
  line-height: 1.1;
  animation: ksTitlePulse 1s ease-in-out infinite;
}
@keyframes ksTitlePulse {
  0%, 100% {
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 60, 60, 0.7);
  }
  50% {
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 34px rgba(255, 60, 60, 1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ks-title { animation: none !important; }
}
.ks-by {
  font-size: 14px;
  color: rgba(200, 215, 230, 0.72);
  font-weight: 500;
  min-height: 18px;
}
.ks-count {
  font-size: 12px;
  color: rgba(170, 190, 210, 0.6);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.04em;
}

#share-bar {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: stretch;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 25; /* above lobby-screen (20) so it shows while waiting in lobby */
}
.share-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #dce8f8;
}
.share-actions {
  display: flex;
  gap: 8px;
}
#share-link {
  width: min(320px, 46vw);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.28);
  color: #fff;
}
#copy-btn { padding: 8px 14px; font-size: 13px; }
#qr-btn,
#share-qr-copy,
#share-qr-close { padding: 8px 14px; font-size: 13px; }

#share-qr-overlay {
  z-index: 35;
}

.share-qr-card {
  width: min(92vw, 360px);
  padding: 20px;
  border-radius: 20px;
  background: rgba(10, 17, 28, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#share-qr-room {
  margin: 0;
}

#share-qr-canvas {
  display: block;
  width: min(70vw, 256px);
  height: auto;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
}

#share-qr-link {
  width: 100%;
  text-align: center;
  font-size: 14px;
}

#share-qr-note {
  text-align: center;
}

#touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.touch-left,
.touch-right {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
.touch-left { left: max(18px, env(safe-area-inset-left)); }
.touch-right { right: max(18px, env(safe-area-inset-right)); }
.touch-stack { display: flex; gap: 12px; }
.touch-stack.vertical { flex-direction: column; }

.tbtn {
  pointer-events: auto;
  border-radius: 999px;
  border: 2px solid var(--rim);
  color: #fff;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.18), var(--glass) 72%);
  box-shadow: var(--shadow);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.tbtn.pressed { transform: scale(0.92); filter: brightness(1.2); }
.tbtn.arrow, .tbtn.climb, .tbtn.dive {
  width: 72px;
  height: 72px;
  font-size: 26px;
}
.tbtn.boost {
  width: 78px;
  height: 78px;
  font-size: 13px;
  border-color: rgba(255, 200, 80, 0.55);
  background:
    radial-gradient(circle at 42% 26%, rgba(255, 255, 255, 0.5), transparent 32%),
    radial-gradient(circle at 50% 30%, rgba(255, 224, 150, 0.7), rgba(255, 170, 30, 0.66) 72%);
  box-shadow: var(--shadow), inset 0 0 16px rgba(255, 180, 60, 0.3);
}
.tbtn.fire {
  width: 96px;
  height: 96px;
  font-size: 18px;
  border-color: rgba(255, 100, 70, 0.6);
  background:
    radial-gradient(circle at 42% 26%, rgba(255, 255, 255, 0.5), transparent 32%),
    radial-gradient(circle at 50% 30%, rgba(255, 140, 110, 0.72), rgba(255, 50, 30, 0.68) 72%);
  box-shadow: var(--shadow), inset 0 0 18px rgba(255, 60, 30, 0.35);
}

/* ─── JOYSTICK CONTROL ───────────────────────────────────────────────────── */
.joy-left {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-base {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.07), rgba(24,37,55,0.45) 80%);
  border: 2px solid var(--rim);
  box-shadow: var(--shadow);
  touch-action: none;
  pointer-events: auto;
  flex-shrink: 0;
}

#joystick-base.active {
  border-color: rgba(255,255,255,0.45);
}

#joystick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.45), rgba(180,200,255,0.28) 72%);
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: none;
}

/* ─── TILT CONTROL ───────────────────────────────────────────────────────── */
.tilt-left {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: center;
}

.tbtn.tilt-cal {
  width: 80px;
  height: 80px;
  font-size: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.tbtn.tilt-cal span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ─── SETTINGS: CONTROL SCHEME PICKER ───────────────────────────────────── */
.scheme-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.scheme-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #d4ddeb;
  cursor: pointer;
}
.scheme-opt input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 160px 40px rgba(255,30,30,0);
  transition: box-shadow 0.4s ease;
}
#vignette.hit { box-shadow: inset 0 0 180px 75px rgba(255,30,30,0.55); transition: box-shadow 0.08s ease; }
#vignette.low { animation: lowpulse 1.1s ease-in-out infinite; }
@keyframes lowpulse {
  0%, 100% { box-shadow: inset 0 0 120px 30px rgba(255,40,40,0.14); }
  50% { box-shadow: inset 0 0 160px 60px rgba(255,40,40,0.38); }
}

#callout {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 0 18px rgba(255,203,5,0.45);
  opacity: 0;
  pointer-events: none;
}
#callout.show { animation: calloutPop 1.1s ease-out; }
@keyframes calloutPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}

#minimap {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  width: 140px;
  height: 140px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0.92;
  pointer-events: none;
}
#popup-layer { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.popup3d {
  position: absolute;
  transform: translate(-50%, -50%);
  color: #cfe7ff;
  font-size: 15px;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
  opacity: 1;
  transition: transform 1s ease-out, opacity 1s ease-out;
}
.popup3d.mine { color: var(--accent); font-size: 22px; }
.popup3d.go { transform: translate(-50%, -170%); opacity: 0; }

#rotate-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(8, 12, 20, 0.97);
  z-index: 40;
}
#rotate-overlay .rot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.rot-icon {
  font-size: 64px;
  line-height: 1;
  animation: rotSpin 1.8s ease-in-out infinite;
}
@keyframes rotSpin {
  0%   { transform: rotate(-30deg); }
  50%  { transform: rotate(30deg); }
  100% { transform: rotate(-30deg); }
}
.rot-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
}
.rot-sub {
  font-size: 15px;
  color: #9ab0c8;
  font-weight: 400;
}
#rotate-overlay.show { display: flex; }

.winner { color: var(--accent); font-size: 18px; font-weight: 800; }
#final-board {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(320px, 86vw);
}
#final-board li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--panel);
}
#final-board li.me { color: #fff; font-weight: 700; }
#final-board li.win { color: var(--accent); }

@media (max-width: 1080px) {
  .menu-hero { grid-template-columns: 1fr; }
  .play-panel { grid-column: span 6; }
}

@media (max-width: 820px) {
  #minimap { width: 112px; height: 112px; }
  #killfeed { top: 140px; }
  #share-link { width: 160px; max-width: 30vw; }
  .menu-shell { padding: 22px 18px; }
  .menu-panel { padding: 16px; }
}

@media (max-width: 640px) {
  .menu-shell { width: min(100vw - 12px, 1000px); padding: 18px 14px; }
  .menu-grid { grid-template-columns: 1fr; }
  .play-panel,
  .controls-panel { grid-column: auto; }
  .play-panel button { width: 100%; }
  .touch-only { display: block; }
  #share-bar { flex-wrap: wrap; max-width: 90vw; }
  .share-copy { width: 100%; }
  .share-actions { width: 100%; }
  .share-actions button { flex: 1; }
  #share-link { max-width: 100%; width: 100%; }
  /* #leaderboard: right-anchored absolute, no min-width override needed */
}

@media (min-width: 641px) {
  .touch-only { display: none; }
}

body.touch-device #share-bar {
  left: 50%;
  top: max(78px, calc(env(safe-area-inset-top) + 12px));
  bottom: auto;
  transform: translateX(-50%);
  width: min(92vw, 360px);
}

/* ─── BOOT OVERLAY ─────────────────────────────────────────────────────────── */
#boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1320;
  transition: opacity 0.4s ease;
}
#boot-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.boot-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 203, 5, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.boot-label {
  color: #9ab0c8;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* ─── FATAL OVERLAY ─────────────────────────────────────────────────────────── */
#fatal-overlay {
  z-index: 99;
  background: radial-gradient(circle at center, rgba(40, 10, 10, 0.9), rgba(8, 4, 4, 0.97));
}
.fatal-card {
  width: min(92vw, 440px);
  padding: 32px 28px;
  border-radius: 20px;
  background: rgba(30, 10, 10, 0.88);
  border: 1px solid rgba(255, 80, 80, 0.28);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.fatal-card h2 { color: #ff8d8d; }
#fatal-msg { max-width: 360px; }
.fatal-card button { background: #c0392b; color: #fff; box-shadow: 0 5px 0 #7b241c; }

/* ─── MENU SHELL HEAD (settings gear row) ──────────────────────────────────── */
.menu-shell-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -4px;
}

/* ─── MENU LEADERBOARD PANEL ────────────────────────────────────────────────── */
.menu-lb-panel {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── LOBBY SCREEN ──────────────────────────────────────────────────────────── */
#lobby-screen {
  z-index: 20;
}
.lobby-card {
  width: min(92vw, 520px);
  padding: 24px;
  border-radius: 20px;
  background: rgba(10, 17, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lobby-roster {
  min-height: 80px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lobby-actions {
  justify-content: flex-start;
}
#lobby-start-btn {
  background: var(--accent);
  color: #1b1400;
}
#lobby-ready-btn.active {
  background: #2d7a3e;
  color: #d8ffe0;
  box-shadow: 0 5px 0 #1a4a26;
}

/* Lobby roster rows */
.lobby-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.lobby-row--me {
  background: rgba(255, 203, 5, 0.08);
  border-color: rgba(255, 203, 5, 0.22);
}
.lobby-row-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
}
.lobby-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Small badge chips inside roster rows */
.lobby-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}
.lobby-badge--host {
  background: rgba(255, 203, 5, 0.18);
  border: 1px solid rgba(255, 203, 5, 0.32);
  color: #ffe28b;
}
.lobby-badge--bot {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #9caac0;
}

/* Ready checkmark indicator */
.lobby-ready-mark {
  font-size: 16px;
  font-weight: 700;
  color: #5a6a80;
  width: 22px;
  text-align: center;
}
.lobby-ready-mark.is-ready {
  color: #4cd87a;
}

/* Kick button — compact, secondary style */
.lobby-kick-btn {
  padding: 4px 10px;
  font-size: 12px;
  box-shadow: 0 3px 0 #1a2034;
}

/* ─── SETTINGS SCREEN ───────────────────────────────────────────────────────── */
#settings-screen {
  z-index: 30;
  background: radial-gradient(circle at center, rgba(14, 24, 40, 0.82), rgba(8, 12, 20, 0.96));
}
.settings-card {
  width: min(92vw, 500px);
  max-height: min(90vh, 680px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 20px;
  background: rgba(10, 17, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #9caac0;
  margin-bottom: 2px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.settings-label {
  font-size: 14px;
  color: #d4ddeb;
  flex-shrink: 0;
}
.settings-card input[type="range"] {
  flex: 1;
  min-width: 100px;
  accent-color: var(--accent);
  cursor: pointer;
}
.settings-check {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}
.settings-quality {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.quality-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #d4ddeb;
  cursor: pointer;
}
.quality-opt input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
#settings-close-btn2 { align-self: center; }

/* ─── RESPONSIVE ADDITIONS ──────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .menu-lb-panel { grid-column: span 6; }
}
@media (max-width: 820px) {
  .menu-lb-panel { grid-column: span 6; }
}
@media (max-width: 640px) {
  .menu-lb-panel { grid-column: auto; }
  .settings-card { padding: 18px 14px; }
  .lobby-card { padding: 18px 14px; }
}

/* ─── CROSSHAIR ──────────────────────────────────────────────────────────────── */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 7;
}
.ch-h {
  position: absolute;
  top: 0;
  left: -18px;
  width: 36px;
  height: 2px;
  background: rgba(255, 203, 5, 0.55);
  border-radius: 1px;
  margin-top: -1px;
}
.ch-v {
  position: absolute;
  top: -18px;
  left: 0;
  width: 2px;
  height: 36px;
  background: rgba(255, 203, 5, 0.55);
  border-radius: 1px;
  margin-left: -1px;
}

/* ─── OUT-OF-BOUNDS WARNING ──────────────────────────────────────────────────── */
#oob-warning {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(180, 20, 20, 0.78);
  border: 1px solid rgba(255, 80, 80, 0.5);
  color: #ffdddd;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.2px;
  pointer-events: none;
  z-index: 8;
  animation: oobpulse 0.9s ease-in-out infinite;
}
@keyframes oobpulse {
  0%, 100% { opacity: 0.82; }
  50% { opacity: 1; }
}

/* ─── BOOST BAR ──────────────────────────────────────────────────────────────── */
.hud-boost-wrap { display: flex; align-items: center; gap: 6px; }
.boost-bar {
  display: inline-block;
  width: 52px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  vertical-align: middle;
  margin-left: 2px;
}
#boost-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffc107, #ff9800);
  border-radius: 4px;
  transition: width 0.06s linear;
}

/* ─── PLAYER NAME LABELS ─────────────────────────────────────────────────────── */
#name-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}
.name-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(10, 18, 34, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(220, 232, 248, 0.9);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform, left, top;
}

/* ─── TDM TEAM SCORE BAR ─────────────────────────────────────────────────────── */
.hud-team-score {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(0,0,0,0.45);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  pointer-events: none;
  margin-top: 4px;
}
.hud-team {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hud-team--blue { color: #4aa3ff; }
.hud-team--red  { color: #ff5a5a; }
.hud-team-sep   { color: rgba(255,255,255,0.45); font-size: 11px; }
/* Local team indicator: bold border on your own team chip */
.hud-team--blue.is-my-team,
.hud-team--red.is-my-team  { text-shadow: 0 0 10px currentColor; }

/* ─── LOW-TIME WARNING ───────────────────────────────────────────────────────── */
#hud-time.low {
  color: #ff4444;
  animation: timepulse 0.6s ease-in-out infinite;
}
@keyframes timepulse {
  0%, 100% { color: #ff4444; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 60, 60, 0.6); }
  50% { color: #ff8888; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 60, 60, 0.95); }
}

/* ─── ROUND-START COUNTDOWN ──────────────────────────────────────────────────── */
#countdown {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: clamp(64px, 14vw, 120px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.4), 0 0 28px rgba(255, 255, 255, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 9;
}
#countdown.pop {
  animation: countdownPop 0.85s ease-out forwards;
}
@keyframes countdownPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.14); }
  55%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.95); }
}
#countdown.go {
  color: var(--accent);
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.4), 0 0 32px rgba(255, 203, 5, 0.6);
}

/* ─── TOAST / ANNOUNCEMENT SYSTEM ──────────────────────────────────────────── */
#toast {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 15;
}
.toast-item {
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(8, 15, 26, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transition: opacity 160ms ease, transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-item.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: toastSlamIn 320ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes toastSlamIn {
  0% { opacity: 0; transform: translateY(-8px) scale(1.15); }
  60% { opacity: 1; transform: translateY(0) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .toast-item.show { animation: none !important; }
}
/* Multi-kill: gold accent */
.toast-item.toast--multi {
  border-color: rgba(255, 200, 40, 0.65);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 26px rgba(255, 195, 30, 0.45);
  color: #ffe58a;
}
/* Streak: orange */
.toast-item.toast--streak {
  border-color: rgba(255, 130, 30, 0.65);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 26px rgba(255, 120, 20, 0.4);
  color: #ffb060;
}
/* Leader change: blue/cyan */
.toast-item.toast--leader {
  border-color: rgba(90, 190, 255, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 26px rgba(80, 180, 255, 0.38);
  color: #8fd4ff;
}
/* Kill-feed verb styling */
.kf-verb {
  color: rgba(180, 195, 215, 0.65);
  font-size: 11px;
  font-weight: 500;
  text-transform: lowercase;
}

/* ─── HANGAR OVERLAY ─────────────────────────────────────────────────────────── */
/*
 * Layout: card anchored to the LEFT edge, leaving the right 50%+ clear so the
 * rotating 3D plane is the visual centrepiece.
 * On narrow portrait screens (≤520px wide) the card drops to the bottom instead.
 */
.hangar-overlay {
  background: rgba(4, 8, 16, 0.38);
  z-index: 28;
  /* Row layout: card left, plane preview fills the rest */
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  gap: 0;
}

/* The card column */
.hangar-card {
  /* Fixed width panel anchored to the left */
  width: min(340px, 46vw);
  min-width: 260px;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 18px;
  border-radius: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(8, 14, 24, 0.92);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
}

/* The clear preview zone to the right of the card (plane lives here) */
.hangar-preview-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0 28px 0;
  pointer-events: none;
  user-select: none;
}

.hangar-preview-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.hangar-open-btn {
  align-self: flex-start;
  margin-top: 4px;
  padding: 10px 20px;
  font-size: 14px;
}

/* ── Portrait / narrow-screen fallback ──────────────────────────────────────── */
/* On narrow screens the card snaps to the bottom, plane visible above */
@media (max-width: 520px) {
  .hangar-overlay {
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
  }
  .hangar-card {
    width: 100%;
    min-width: unset;
    height: auto;
    max-height: 60vh;
    border-radius: 20px 20px 0 0;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    background: rgba(8, 14, 24, 0.97);
  }
  .hangar-preview-zone {
    flex: 0 0 auto;
    height: 40vh;
    padding: 0;
    justify-content: flex-end;
    padding-bottom: 12px;
  }
}

/* Tab row */
.hangar-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hangar-tab {
  flex: 1 1 auto;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #9caac0;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.12s ease, color 0.12s ease;
}
.hangar-tab:hover { background: rgba(255, 255, 255, 0.10); color: #dce8f8; transform: none; box-shadow: none; }
.hangar-tab:active { transform: none; box-shadow: none; }
.hangar-tab.active {
  background: rgba(255, 203, 5, 0.15);
  border-color: rgba(255, 203, 5, 0.35);
  color: #ffe28b;
}

/* Section panels */
.hangar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* .hidden already handles display:none; active just makes it flex */
.hangar-section.active { display: flex; }

.hangar-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #7a8da5;
}

/* Color / accent / trail swatch grids */
.hangar-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hangar-swatch {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  padding: 0;
  transition: transform 0.08s ease, border-color 0.08s ease;
}
.hangar-swatch:hover { transform: translateY(-2px) scale(1.08); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35); }
.hangar-swatch:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.hangar-swatch.selected {
  border-color: #fff;
  transform: translateY(-2px) scale(1.12);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3), 0 4px 0 rgba(0, 0, 0, 0.4);
}

/* Body shape button grid */
.hangar-shape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hangar-shape-btn {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #c5d3e6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
  letter-spacing: 0.4px;
  transition: background 0.1s ease, color 0.1s ease, transform 0.08s ease;
}
.hangar-shape-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; transform: translateY(-1px); box-shadow: none; }
.hangar-shape-btn:active { transform: translateY(1px); box-shadow: none; }
.hangar-shape-btn.selected {
  background: rgba(255, 203, 5, 0.18);
  border-color: rgba(255, 203, 5, 0.40);
  color: #ffe28b;
  box-shadow: none;
}

/* Livery pattern button grid */
.hangar-livery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hangar-livery-btn {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: #c5d3e6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
  letter-spacing: 0.3px;
  transition: background 0.1s ease, color 0.1s ease, transform 0.08s ease;
}
.hangar-livery-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; transform: translateY(-1px); box-shadow: none; }
.hangar-livery-btn:active { transform: translateY(1px); box-shadow: none; }
.hangar-livery-btn.selected {
  background: rgba(255, 203, 5, 0.18);
  border-color: rgba(255, 203, 5, 0.40);
  color: #ffe28b;
  box-shadow: none;
}

/* Done button — full width primary */
#hangar-done {
  width: 100%;
  padding: 13px;
  font-size: 15px;
}

/* Hint text */
.hangar-hint {
  text-align: center;
  font-size: 12px;
}

/* Lobby color dot */
.lobby-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

/* Lobby host settings panel */
.lobby-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-bottom: 10px;
}
.lobby-settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lobby-settings-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex: 0 0 90px;
}
.lobby-settings-input,
.lobby-settings-select {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  padding: 6px 10px;
  outline: none;
  font-family: inherit;
}
.lobby-settings-input:focus,
.lobby-settings-select:focus {
  border-color: rgba(255, 203, 5, 0.5);
  background: rgba(255, 255, 255, 0.10);
}
.lobby-settings-select option {
  background: #1b1400;
  color: #fff;
}
.lobby-settings-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  flex: 1;
}
.lobby-settings-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #ffcb05;
  cursor: pointer;
  flex-shrink: 0;
}

/* Responsive: on very small screens make livery grid 2-col and allow card to grow */
@media (max-width: 400px) {
  .hangar-livery-grid { grid-template-columns: repeat(2, 1fr); }
  .hangar-card { padding: 16px 14px; }
}

/* ─── SHARE QR CODE (big room code displayed in the QR overlay) ─────────────── */
.share-qr-code {
  font-size: clamp(32px, 10vmin, 52px);
  font-weight: 900;
  letter-spacing: 0.22em;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--accent);
  text-shadow: 0 2px 12px rgba(255, 203, 5, 0.35);
  text-align: center;
  user-select: all;
  cursor: text;
  padding: 4px 0;
  min-height: 1.1em;
}

.share-qr-caption {
  font-size: 12px;
  letter-spacing: 0.5px;
  text-align: center;
  opacity: 0.85;
}

/* ─── SCAN OVERLAY ───────────────────────────────────────────────────────────── */
#scan-overlay {
  z-index: 40;
  background: rgba(4, 8, 16, 0.97);
}

.scan-card {
  width: min(92vw, 420px);
  padding: 22px 20px;
  border-radius: 20px;
  background: rgba(8, 14, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.scan-viewport {
  position: relative;
  width: min(70vmin, 320px);
  height: min(70vmin, 320px);
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

#scan-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 18px;
}

#scan-canvas {
  display: none;
}

/* Scan reticle: four corner brackets overlaid on the video */
.scan-reticle {
  position: absolute;
  inset: 12%;
  pointer-events: none;
  border-radius: 4px;
}
.scan-reticle::before,
.scan-reticle::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--accent);
  border-style: solid;
}
.scan-reticle::before {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}
.scan-reticle::after {
  bottom: 0;
  right: 0;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}
/* Extra two corners via a pseudo-wrapper */
.scan-viewport::before,
.scan-viewport::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--accent);
  border-style: solid;
  z-index: 2;
  pointer-events: none;
}
.scan-viewport::before {
  top: calc(12% + 0px);
  right: calc(12% + 0px);
  border-width: 3px 3px 0 0;
  border-radius: 0 4px 0 0;
}
.scan-viewport::after {
  bottom: calc(12% + 0px);
  left: calc(12% + 0px);
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 4px;
}

.scan-status {
  text-align: center;
  max-width: 320px;
  line-height: 1.6;
  min-height: 3em;
  font-size: 14px;
}

/* Landscape: shrink the video to fit alongside the card header */
@media (max-height: 500px) {
  .scan-viewport {
    width: min(50vmin, 220px);
    height: min(50vmin, 220px);
  }
  .scan-card { padding: 14px 16px; gap: 10px; }
}

/* ── In-game hamburger menu button ──────────────────────────────────────── */
#ingame-menu-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 10;          /* above canvas (z-index:auto), below overlays */
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  background: rgba(11, 19, 30, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #dce8f8;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  transition: background .1s ease, transform .08s ease, box-shadow .08s ease;
}
#ingame-menu-btn:hover {
  background: rgba(24, 37, 55, 0.80);
  border-color: rgba(255, 255, 255, 0.30);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
  transform: none; /* don't lift — it's a compact HUD btn */
}
#ingame-menu-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Keep the hud-menu-btn class alias available if needed */
.hud-menu-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 10;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  background: rgba(11, 19, 30, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #dce8f8;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  transition: background .1s ease, transform .08s ease, box-shadow .08s ease;
}
.hud-menu-btn:hover {
  background: rgba(24, 37, 55, 0.80);
  border-color: rgba(255, 255, 255, 0.30);
}
.hud-menu-btn:active {
  transform: scale(0.92);
}

.panel-surface {
  position: relative;
  border-radius: 22px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(20, 34, 52, 0.84), rgba(10, 18, 31, 0.92)),
    rgba(12, 20, 34, 0.92);
  border: 1px solid rgba(214, 231, 248, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 44px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.panel-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.05), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 203, 5, 0.08), transparent 24%);
  pointer-events: none;
}

.eyebrow,
.deck-label,
.preset-label {
  font-family: "Bahnschrift SemiCondensed", "Arial Narrow", "Trebuchet MS", sans-serif;
}

.preset-card h4,
.panel-head h3 {
  font-family: "Bahnschrift Condensed", "Arial Narrow", "Trebuchet MS", sans-serif;
}

.preset-copy {
  color: #cad7e7;
  line-height: 1.55;
}

.summary-grid,
.preset-grid,
.option-grid {
  display: grid;
  gap: 12px;
}

.summary-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-chip span {
  font-size: 11px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: rgba(202, 215, 231, 0.7);
}

.summary-chip strong,
.summary-grid-row strong {
  color: #fff;
  font-size: 14px;
}

.summary-grid-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.summary-grid-row span {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(202, 215, 231, 0.68);
}

.local-room-list {
  gap: 10px;
  max-height: 300px;
}

.local-room-row {
  padding: 14px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.local-room-row-meta {
  color: rgba(255, 255, 255, 0.62);
}

.local-empty {
  padding: 14px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.14);
}

.local-rescan-btn {
  align-self: flex-start;
}

.preset-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-grid {
  grid-template-columns: 1fr;
}

.preset-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preset-card.is-active {
  border-color: rgba(255, 203, 5, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 203, 5, 0.16);
}

.preset-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.preset-state {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #d8e6f6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.preset-swatch-row {
  display: flex;
  gap: 6px;
  margin: 10px 0 12px;
}

.preset-swatch {
  width: 24px;
  height: 8px;
  border-radius: 999px;
  background: var(--swatch);
}

.option-grid {
  grid-template-columns: 1fr;
}

.option-btn {
  width: 100%;
  text-align: left;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.option-btn strong {
  display: block;
  font-size: 15px;
  color: #fff;
}

.option-btn span {
  display: block;
}

.option-btn--card,
.option-btn--swatch {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: #cfe0f2;
}

.option-btn--card span,
.option-copy span {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.45;
  color: #9fb2c9;
}

.option-btn--swatch {
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-swatch {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--swatch);
  border: 2px solid rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.option-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.option-btn.is-selected {
  border-color: rgba(255, 203, 5, 0.42);
  background: linear-gradient(180deg, rgba(255, 203, 5, 0.12), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 1px rgba(255, 203, 5, 0.12);
}

.option-btn.is-selected strong,
.option-btn.is-selected .option-copy strong {
  color: #ffe28b;
}

@media (min-width: 900px) {
  .option-grid--cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-grid--swatches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .panel-surface {
    padding: 15px;
    border-radius: 18px;
  }

  .preset-actions {
    flex-direction: column;
  }

  .option-grid--cards,
  .option-grid--swatches {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPLETE OPS UI REDESIGN
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --ops-ink: #05111c;
  --ops-deck: #0d2031;
  --ops-panel: rgba(11, 23, 36, 0.9);
  --ops-panel-strong: rgba(15, 31, 47, 0.94);
  --ops-line: rgba(208, 229, 248, 0.16);
  --ops-line-strong: rgba(255, 193, 61, 0.34);
  --ops-copy: #d9e6f4;
  --ops-muted: #95adc5;
  --ops-amber: #ffc13d;
  --ops-cyan: #6ed6ff;
  --ops-coral: #ff7b6b;
}

button {
  border-radius: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #ffd560, var(--ops-amber));
  color: #241700;
  box-shadow: 0 6px 0 #ba8708;
  font-family: "Bahnschrift SemiCondensed", "Arial Narrow", "Trebuchet MS", sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
button.secondary {
  background: linear-gradient(180deg, rgba(48, 67, 89, 0.95), rgba(25, 38, 56, 0.95));
  color: #eff7ff;
  box-shadow: 0 6px 0 #162334;
}
button:hover { transform: translateY(-2px); }
button:active { transform: translateY(3px); }
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(110, 214, 255, 0.8);
  outline-offset: 2px;
}

input,
select {
  border-radius: 14px;
  border: 1px solid rgba(220, 236, 250, 0.14);
  background: rgba(4, 11, 19, 0.54);
  color: #fff;
}

.lobby-meta-strip,
.pause-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.signal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(220, 236, 250, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e6f1fb;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.signal-chip--ready {
  border-color: rgba(255, 193, 61, 0.32);
  background: rgba(255, 193, 61, 0.12);
  color: #ffe7a6;
}
.signal-chip.subtle {
  color: #c8d9ea;
  background: rgba(255, 255, 255, 0.05);
}

.panel-surface,
.ops-modal,
.share-qr-card,
.scan-card,
.settings-card,
.lobby-card,
.fatal-card {
  background:
    linear-gradient(180deg, rgba(19, 34, 50, 0.95), rgba(8, 16, 27, 0.97)),
    var(--ops-panel);
  border: 1px solid var(--ops-line);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 50px rgba(0, 0, 0, 0.42);
}

.panel-head {
  margin-bottom: 0;
}
.panel-head h3,
.ops-modal h2,
.settings-card h2,
.scan-card h2,
.share-qr-card h2 {
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lobby-roster-panel {
  gap: 12px;
}

.local-state-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
}
.local-state-card h4 {
  margin: 4px 0 8px;
  font-family: "Bahnschrift Condensed", "Arial Narrow", "Trebuchet MS", sans-serif;
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.local-room-row-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.local-room-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(110, 214, 255, 0.12);
  color: #b9efff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#hud {
  top: 0;
  left: 0;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  display: grid;
  gap: 10px;
}
.hud-cluster {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(7, 15, 25, 0.6), rgba(14, 27, 42, 0.46));
  border: 1px solid rgba(210, 231, 248, 0.1);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
  width: max-content;
  max-width: min(760px, calc(100vw - 28px));
}
/* ── De-clutter pass: on phones, drop secondary stats.
   Leaderboard is now right-anchored and visible on all devices. ── */
body.touch-device .hud-item--secondary { display: none; }
.hud-cluster-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
#hud-room-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  max-width: 160px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(11, 19, 30, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #dce8f8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: none;
  cursor: pointer;
}
#hud-room-chip:hover { transform: none; box-shadow: none; background: rgba(24, 37, 55, 0.80); }
#hud-room-chip:active { transform: scale(0.96); box-shadow: none; }
.hud-context {
  color: rgba(228, 240, 252, 0.72);
  font-family: "Bahnschrift SemiCondensed", "Arial Narrow", "Trebuchet MS", sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hud-row {
  gap: 8px;
}
.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #d6e4f2;
}
.hud-item-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(214, 228, 242, 0.72);
}
.hud-item strong {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
}
#hud-score,
#hud-time {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 0.6px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 193, 61, 0.22);
}
.hud-boost-wrap {
  padding-right: 12px;
}
.boost-bar {
  width: 72px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
}
#boost-fill {
  background: linear-gradient(90deg, #ffd35c, #ff9543);
}
/* ── Live in-game leaderboard: right-side, below minimap (~18px top + 140px) ── */
#leaderboard {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  top: 168px;
  margin-top: 0;
  display: grid;
  gap: 3px;
  width: 140px;
  padding: 7px 9px;
  border-radius: 12px;
  background: rgba(8, 15, 25, 0.75);
  border: 1px solid rgba(214, 231, 248, 0.1);
  opacity: 0.88;
  pointer-events: none;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity 0.2s;
}
#leaderboard:hover { opacity: 1; }
#leaderboard .lb-header {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(180, 200, 220, 0.55);
  margin-bottom: 3px;
}
#leaderboard .lb-row {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 11px;
}
#leaderboard .lb-row:last-child {
  border-bottom: 0;
}
#leaderboard .lb-row.me {
  color: #ffe08f;
  font-weight: 700;
}
#power-chip {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(10, 18, 29, 0.84), rgba(4, 10, 18, 0.74));
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 160px;
}
#power-chip::before {
  content: "System boost";
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(214, 228, 242, 0.68);
}
#healthbar {
  width: min(260px, 56vw);
  height: 14px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(7, 15, 25, 0.72);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.22);
}
#healthbar::before {
  content: "Hull";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  color: rgba(214, 228, 242, 0.72);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#healthfill {
  border-radius: 999px;
}
/* killfeed: shifted left so it doesn't overlap the right-side leaderboard (140px wide) */
#killfeed {
  top: max(164px, calc(env(safe-area-inset-top) + 120px));
  right: calc(max(10px, env(safe-area-inset-right)) + 154px);
  gap: 8px;
}
.kill-msg {
  padding: 8px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(9, 17, 28, 0.86), rgba(6, 11, 19, 0.76));
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
  animation: killMsgPopIn 260ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes killMsgPopIn {
  0% { opacity: 0; transform: translateX(28px); }
  100% { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .kill-msg { animation: none !important; }
}
#oob-warning {
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 22px 40px rgba(0,0,0,0.32);
}
#share-bar {
  left: auto;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(10, 20, 31, 0.92), rgba(7, 13, 22, 0.9));
  border: 1px solid rgba(214, 231, 248, 0.12);
}
.share-copy {
  gap: 10px;
}
.share-label,
.share-link-label {
  font-family: "Bahnschrift SemiCondensed", "Arial Narrow", "Trebuchet MS", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.share-link-wrap {
  display: grid;
  gap: 6px;
}
.share-actions {
  gap: 10px;
}
.share-qr-card {
  width: min(92vw, 420px);
  padding: 22px;
}
#share-qr-link {
  background: rgba(3, 8, 14, 0.52);
}
#minimap {
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  border: 1px solid rgba(214, 231, 248, 0.18);
  background: rgba(7, 15, 25, 0.42);
}
.ops-modal {
  width: min(92vw, 960px);
  padding: 24px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ops-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.ops-modal-copy {
  max-width: 540px;
  color: var(--ops-muted);
  line-height: 1.6;
}
.results-modal,
.lobby-modal {
  width: min(96vw, 980px);
}
.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 16px;
}
.results-board-panel,
.results-side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#final-board {
  min-width: 0;
  gap: 10px;
}
#final-board li {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}
#final-board li.win {
  border-color: rgba(255, 193, 61, 0.28);
  background: linear-gradient(180deg, rgba(255, 193, 61, 0.12), rgba(255,255,255,0.04));
}
.pause-modal,
.conn-modal {
  width: min(92vw, 620px);
}
.conn-actions,
.pause-actions {
  justify-content: flex-start;
}
.lobby-modal {
  max-height: min(92vh, 860px);
  overflow-y: auto;
}
.lobby-meta-strip {
  margin-top: -4px;
}
.lobby-settings,
.lobby-roster-panel {
  background: rgba(255,255,255,0.04);
}
.lobby-roster-panel {
  padding: 18px;
}
.lobby-roster {
  min-height: 140px;
  background: transparent;
  border: 0;
  padding: 0;
}
.lobby-row {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
}
.lobby-row--me {
  background: linear-gradient(180deg, rgba(255, 193, 61, 0.12), rgba(255,255,255,0.04));
}
#settings-screen,
#scan-overlay,
#intermission,
#pause-screen,
#conn-lost,
#lobby-screen,
#host-left-overlay,
#p2p-migrating-overlay,
#share-qr-overlay {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.settings-card {
  width: min(92vw, 680px);
  max-height: min(92vh, 840px);
  padding: 24px;
  border-radius: 28px;
}
.settings-card .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.settings-section {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.settings-actions {
  justify-content: flex-end;
}
.scan-card {
  width: min(92vw, 500px);
  padding: 24px;
  border-radius: 28px;
}
.fatal-card.host-left-card,
.migrating-card {
  min-width: min(92vw, 360px);
  padding: 26px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(28, 14, 17, 0.92), rgba(14, 6, 8, 0.94));
  border: 1px solid rgba(255, 123, 107, 0.24);
}
.migrating-card {
  align-items: center;
  text-align: center;
}
#hud .icon-btn,
.hud-menu-btn {
  border-radius: 14px;
}
@media (max-width: 900px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
  #share-bar {
    right: 50%;
    transform: translateX(50%);
    width: min(92vw, 420px);
  }
}
@media (max-width: 640px) {
  .ops-modal,
  .settings-card,
  .scan-card,
  .share-qr-card {
    padding: 18px;
    border-radius: 22px;
  }
  .ops-modal-head,
  .panel-head--split,
  .lobby-meta-strip,
  .pause-hints {
    flex-direction: column;
    align-items: flex-start;
  }
  .hud-cluster {
    width: 100%;
  }
  .hud-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud-item,
  .hud-boost-wrap {
    width: 100%;
    justify-content: space-between;
  }
  #leaderboard {
    width: 128px;
  }
  #healthbar {
    width: min(280px, 72vw);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
body.touch-device #share-bar {
  left: 50%;
  right: auto;
  top: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 420px);
}
.panel-surface,
.ops-modal,
.share-qr-card,
.scan-card,
.settings-card,
.fatal-card {
  text-align: left;
}
.results-modal .winner,
.pause-modal,
.conn-modal,
.fatal-card,
.migrating-card {
  text-align: left;
}
.migrating-card { text-align: center; }
@media (max-width: 520px) {
  .server-badge {
    font-size: 11px;
    padding: 6px 10px;
  }
}

