/* =============================================
   WOLFCHAT — CS:GO-meets-mobile-esports dark UI
   ============================================= */
:root {
  --bg: #0D0D0D;
  --red: #FF2D2D;
  --blue: #2D8BFF;
  --gold: #FFB800;
  --green: #00C853;
  --hud-orange: #FFA000;      /* CS 1.6 HUD readout orange */
  --ch-green: #1EFF1E;        /* CS 1.6 crosshair green */
  --panel: rgba(0,0,0,0.80);
  --border: rgba(255,255,255,0.08);
  --text: #F0F0F0;
  --mono: 'Courier New', ui-monospace, Menlo, Consolas, monospace;
  --led: 'DSEG7', 'Courier New', ui-monospace, monospace;
}

/* Self-hosted 7-segment LED face (OFL — see /fonts/DSEG-LICENSE.txt) for the
   1.6-style digital HUD numerals. Digits only ever pass through it. */
@font-face {
  font-family: 'DSEG7';
  src: url('../fonts/DSEG7Classic-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--mono); }
body { letter-spacing: 0.3px; }
/* Page-level touch-action: none (html/body ONLY — never a global * rule): stops
   the browser's own touch/scroll handling from fighting pointer-lock mouse look
   on desktop. Inner scrollable panels (feed, player lists) still scroll on
   Android because the touch-action chain stops at the nearest scroll container. */
html, body {
  touch-action: none;
}
/* FPS surfaces that need raw touch (canvas + control zones) keep their own
   explicit touch-action: none, independent of the page-level rule above. */
#three-container canvas,
#joystick-zone,
#look-zone,
#fire-btn {
  touch-action: none;
}
.hidden { display: none !important; }
.tcol-red { color: var(--red); } .tcol-blue { color: var(--blue); }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: flex; }

/* ===================== LOBBY ===================== */
#lobby-screen { flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.grid-bg {
  position: absolute; inset: -50%;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  animation: gridpan 18s linear infinite;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
@keyframes gridpan { from { transform: translate(0,0); } to { transform: translate(44px,44px); } }

.muzzle-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.muzzle-particles::before, .muzzle-particles::after {
  content: ''; position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: var(--gold); box-shadow:
    20vw 30vh 0 0 rgba(255,184,0,0.6), 70vw 20vh 0 1px rgba(255,45,45,0.5),
    40vw 70vh 0 0 rgba(255,184,0,0.4), 85vw 60vh 0 1px rgba(45,139,255,0.4),
    10vw 80vh 0 0 rgba(255,184,0,0.5), 55vw 45vh 0 0 rgba(255,45,45,0.4);
  animation: floatUp 7s ease-in-out infinite;
}
.muzzle-particles::after { animation-delay: 3.5s; opacity: 0.6; }
@keyframes floatUp { 0%,100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-22px); opacity: 1; } }

.lobby-container { position: relative; z-index: 2; width: 100%; max-width: 700px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.lobby-card { max-width: 420px; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo-mark {
  width: 56px; height: 56px; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 900;
  box-shadow: 0 0 0 4px rgba(255,45,45,0.18), 6px 6px 0 #7a0000;
}
.logo-text { font-size: 40px; font-weight: 900; letter-spacing: 6px; }
.logo-text span { color: var(--red); }
.tagline { font-size: 11px; letter-spacing: 5px; color: rgba(255,255,255,0.45); margin-top: -6px; }

.lobby-card { width: 100%; background: var(--panel); border: 1px solid var(--border); padding: 22px; display: flex; flex-direction: column; gap: 16px; backdrop-filter: blur(4px); }
.field label { display: block; font-size: 10px; letter-spacing: 3px; color: rgba(255,255,255,0.5); margin-bottom: 6px; }
.field input { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: #fff; font-family: var(--mono); font-size: 16px; padding: 13px 14px; outline: none; }
.field input:focus { border-color: var(--red); background: rgba(255,45,45,0.06); }
.room-row { display: flex; gap: 8px; } .room-row input { flex: 1; }

/* ===== AVATAR PICKER (lobby) — compact + collapsible ===== */
.avatar-label { display: block; cursor: pointer; user-select: none; }
.avatar-row { display: flex; align-items: center; gap: 12px; }
.avatar-preview { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; background: #FF2D2D; box-shadow: 0 0 0 2px rgba(255,255,255,0.15); }
.avatar-pickers { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.avatar-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 2px; }
.av-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.av-color.on { border-color: #fff; }
.av-color.on::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 900; text-shadow: 0 0 2px #000; }
.av-emoji { width: 100%; height: 36px; border-radius: 6px; border: 1px solid var(--border); background: rgba(255,255,255,0.05); font-size: 20px; cursor: pointer; padding: 0; line-height: 1; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.av-emoji.on { border-color: #fff; background: rgba(255,255,255,0.18); }

/* avatar circle in the FPS squad sidebar (replaces the plain team dot) */
.pav { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; line-height: 1; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(0,0,0,0.3); }
.btn-ghost { background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: rgba(255,255,255,0.7); font-family: var(--mono); font-size: 12px; letter-spacing: 1px; padding: 0 14px; cursor: pointer; }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-join { width: 100%; background: var(--red); border: none; color: #fff; font-family: var(--mono); font-weight: 700; font-size: 17px; letter-spacing: 4px; padding: 16px; cursor: pointer; transition: transform .08s, box-shadow .12s; box-shadow: 0 0 0 0 rgba(255,45,45,0.5); }
.btn-join:hover { box-shadow: 0 0 24px rgba(255,45,45,0.5); }
.btn-join:active { transform: translateY(2px); }
.lobby-hint { font-size: 10px; color: rgba(255,255,255,0.35); text-align: center; line-height: 1.6; }

.control-hints { position: relative; z-index: 2; display: flex; gap: 22px; }
.hint { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10px; color: rgba(255,255,255,0.4); }
.hint-key { font-size: 11px; font-weight: 700; color: var(--text); border: 1px solid var(--border); padding: 4px 8px; letter-spacing: 1px; }

/* ===================== MIC MODAL ===================== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.78); backdrop-filter: blur(6px); }
.modal-card { width: 92%; max-width: 440px; background: #111; border: 1px solid var(--border); padding: 34px 28px; text-align: center; }
.mic-icon { font-size: 58px; margin-bottom: 10px; filter: drop-shadow(0 0 16px rgba(0,200,83,0.5)); }
.modal-card h2 { font-size: 19px; line-height: 1.5; font-weight: 700; letter-spacing: 1px; }
.modal-sub { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 12px; line-height: 1.6; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.btn-allow { background: var(--green); color: #06210f; border: none; font-family: var(--mono); font-weight: 800; font-size: 15px; letter-spacing: 3px; padding: 15px; cursor: pointer; }
.btn-allow:active { transform: translateY(2px); }
.btn-grey { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); border: 1px solid var(--border); font-family: var(--mono); font-size: 13px; letter-spacing: 2px; padding: 13px; cursor: pointer; }
.mic-help { margin-top: 18px; font-size: 12px; color: var(--gold); line-height: 1.7; }

/* ===================== LOADING SCREEN ===================== */
#loading-screen { position: fixed; inset: 0; z-index: 300; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; }
#loading-screen .loading-logo { display: flex; align-items: center; gap: 14px; }
#loading-screen .logo-mark { width: 52px; height: 52px; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 900; box-shadow: 0 0 0 4px rgba(255,45,45,0.18); }
#loading-screen .logo-text { font-size: 34px; font-weight: 900; letter-spacing: 6px; }
#loading-screen .logo-text span { color: var(--red); }
.load-track { width: 280px; max-width: 70vw; height: 8px; background: rgba(255,255,255,0.1); overflow: hidden; }
#load-bar { height: 100%; width: 0%; background: var(--red); transition: width 0.2s ease; box-shadow: 0 0 12px rgba(255,45,45,0.6); }
.load-text { font-size: 12px; letter-spacing: 3px; color: rgba(255,255,255,0.55); }

/* ===================== TAP-TO-FULLSCREEN PROMPT (mobile) ===================== */
#fullscreen-prompt {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: rgba(255,255,255,0.8);
  font-family: var(--mono); font-size: 11px; line-height: 14px; letter-spacing: 2px;
  padding: 15px 20px; border-radius: 22px; z-index: 500;   /* 14 + 30 = 44px tall */
  pointer-events: all; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  cursor: pointer; display: none;
}

/* ===================== ONE-TIME PERMISSION SCREEN ===================== */
#permission-screen { position: fixed; inset: 0; background: #0D0D0D; display: flex; align-items: center; justify-content: center; z-index: 9999; }
.permission-card { text-align: center; padding: 40px 24px; max-width: 320px; }
.permission-icon { font-size: 48px; margin-bottom: 16px; }
.permission-title { font-family: var(--mono); font-size: 20px; letter-spacing: 4px; color: #fff; margin-bottom: 12px; }
.permission-text { font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,0.6); line-height: 1.6; letter-spacing: 1px; margin-bottom: 8px; }
.permission-sub { font-family: var(--mono); font-size: 11px; color: rgba(255,255,255,0.35); letter-spacing: 1px; }
.permission-note { font-family: var(--mono); font-size: 10px; color: rgba(255,255,255,0.35); text-align: center; letter-spacing: 1px; margin-top: 6px; }

/* ===================== ASSET LOADING OVERLAY ===================== */
/* Plain black screen with pulsing "LOADING ASSETS…" while map textures + the
   blaster GLB load. Sits above everything; toggled by .hidden from game3d.js. */
#asset-loading { position: fixed; inset: 0; z-index: 1500; background: #000; display: flex; align-items: center; justify-content: center; }
#asset-loading .al-text { font-family: var(--mono); font-size: 14px; letter-spacing: 4px; color: rgba(255,255,255,0.7); animation: alpulse 1.2s ease-in-out infinite; }
@keyframes alpulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ===================== GAME 3D LAYER ===================== */
/* dvh tracks the dynamic viewport so the canvas fills the screen whether or not
   the Chrome address bar is showing. */
#game-screen { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }
#three-container { position: absolute; inset: 0; z-index: 0; height: 100dvh; }
#three-container canvas { display: block; width: 100% !important; height: 100% !important; pointer-events: none; }
#label-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
/* Name tag: readable dark label, full name (no truncation), team-colour left border */
.name-label { position: absolute; top: 0; left: 0; font-family: var(--mono); font-size: 14px; font-weight: bold; letter-spacing: 1px; white-space: nowrap; padding: 3px 10px; background: rgba(0,0,0,0.8); border-radius: 4px; color: #fff; border-left: 3px solid #fff; pointer-events: none; will-change: transform, opacity; transition: opacity .2s ease; }
.name-label.enemy { border-left-color: var(--red); }
.name-label.ally  { border-left-color: var(--blue); }

/* dynamic crosshair — four lines that spread (--spread) + center dot */
#crosshair { --spread: 4px; position: absolute; top: 50%; left: 50%; width: 0; height: 0; z-index: 8; pointer-events: none; }
#crosshair .ch-line { position: absolute; left: 0; top: 0; background: var(--ch-green); box-shadow: 0 0 0 1px rgba(0,0,0,0.7); transition: transform .12s ease, background .1s; }
#crosshair .ch-top, #crosshair .ch-bottom { width: 2px; height: 8px; margin-left: -1px; }
#crosshair .ch-left, #crosshair .ch-right { width: 8px; height: 2px; margin-top: -1px; }
#crosshair .ch-top    { transform: translate(-50%,-50%) translateY(calc(0px - var(--spread) - 7px)); }
#crosshair .ch-bottom { transform: translate(-50%,-50%) translateY(calc(var(--spread) + 7px)); }
#crosshair .ch-left   { transform: translate(-50%,-50%) translateX(calc(0px - var(--spread) - 7px)); }
#crosshair .ch-right  { transform: translate(-50%,-50%) translateX(calc(var(--spread) + 7px)); }
#crosshair .ch-dot { position: absolute; left: 0; top: 0; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: var(--ch-green); box-shadow: 0 0 0 1px rgba(0,0,0,0.7); transition: background .1s, box-shadow .1s; }
#crosshair.hit .ch-line, #crosshair.hit .ch-dot { background: #FF3030; }
#crosshair.kill-glow .ch-line, #crosshair.kill-glow .ch-dot { background: #FFD040; box-shadow: 0 0 7px #FFD040; }
#hit-marker { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(1.6); z-index: 9; font-size: 26px; font-weight: 900; color: #fff; pointer-events: none; }
#hit-marker.pop { animation: hmpop .2s ease-out; }
@keyframes hmpop { 0% { transform: translate(-50%,-50%) scale(2.2); opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1); opacity: 0.2; } }

/* damage flash */
body.dmg #three-container::after { content:''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(255,0,0,0.4) 100%); pointer-events: none; }

/* ===== VISUAL FX OVERLAY (vignette, below HUD, no input) ===== */
/* The CRT scanline layer was removed — retro-CRT read against the tactical
   direction, and mix-blend-mode: overlay cost a full-screen compositing pass. */
#fx-vignette { position: absolute; inset: 0; z-index: 7; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.34) 100%); transition: background .35s; }
body.lowhp #fx-vignette { background: radial-gradient(ellipse at center, rgba(0,0,0,0) 38%, rgba(150,0,0,0.5) 100%); }

/* ===================== INLINE SVG ICON SET ===================== */
/* One weight, one style: 24x24 viewBox, 2px stroke, round caps/joins, currentColor.
   Paths live in the <svg class="ico-defs"> sprite in index.html; everything else
   references them with <use>. No icon font, no external requests. */
.ico-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex-shrink: 0; }
.ico-xs { width: 11px; height: 11px; }
.ico-sm { width: 13px; height: 13px; }
.ico-md { width: 20px; height: 20px; }
.ico-lg { width: 24px; height: 24px; }
.ico-xl { width: 30px; height: 30px; }

/* ===================== HUD TOUCH-TARGET FLOOR ===================== */
/* Mobile-first Android Chrome in landscape: every interactive HUD control keeps
   a >= 44px touch target. Where the painted control is deliberately smaller
   (the sidebar tab), the area is expanded with a transparent ::after hit box —
   never by shrinking the target. */
#fps-exit-btn, #fps-exit-mobile, #sfx-btn, .mute-btn, #fire-btn {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
/* #fullscreen-prompt is shown via an inline style="display:block" from JS, so it
   cannot rely on flex centering — its 44px comes from padding instead. */
#fullscreen-prompt { min-width: 44px; min-height: 44px; }
.sidebar-toggle { position: relative; }
.sidebar-toggle::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}
/* Collapsed, the tab sits flush against the left screen edge, so a centred hit
   box would put half of itself off-screen (measured: only 32px usable). Anchor
   it to the tab's left edge instead so the full 44px stays reachable. */
#players-sidebar.collapsed .sidebar-toggle::after {
  left: 0; transform: translate(0, -50%);
}

/* low-HP HP bar glow */
#health-bar.hp-low { animation: hpPulse 0.8s ease-in-out infinite; }
@keyframes hpPulse { 0%,100% { box-shadow: 0 0 4px rgba(255,45,45,0.5); } 50% { box-shadow: 0 0 14px 2px rgba(255,45,45,0.9); } }

/* score change bump */
.score-num.bump { animation: scoreBump .2s ease-out; }
@keyframes scoreBump { 0% { transform: scale(1.4); } 100% { transform: scale(1); } }

/* ===================== HUD TOP (corner-anchored overlay, not a bar) ===================== */
/* Was a 52px opaque bar. Now a transparent, zero-height flex rail: the 3D view
   runs edge to edge behind it and only the clusters themselves paint. The rail
   takes no input; each cluster re-enables it, so the gaps between them are free
   for look-drag. Safe-area insets keep the corners clear of landscape cutouts
   and the gesture bar. */
#hud-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: none; border: none;
  pointer-events: none;
}
#hud-top > *, #hud-bottom > * { pointer-events: auto; }
.hud-right { display: flex; align-items: center; gap: 8px; }

/* Soft gradient scrim — sits directly behind text/numerals that would otherwise
   wash out against bright sky, and fades to nothing at its own edges so it never
   reads as a panel. */
.hud-plate {
  border-radius: 10px; padding: 5px 11px;
  background: radial-gradient(115% 150% at 50% 50%, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.40) 55%, rgba(0,0,0,0) 100%);
}
/* The plates are readouts, not controls — they must not eat a look-drag that
   starts on them. Descendant selector (1,1,0) so this outranks the
   `#hud-top > *` pointer-events:auto rule (1,0,0) above.
   .hud-right is included because it is a flex WRAPPER around the BLUE plate and
   the two buttons: left hit-testable it would swallow clicks over the plate on
   the wrapper's own box. Its buttons re-enable themselves (#sfx-btn and
   #fps-exit-btn both set pointer-events explicitly), so they stay clickable. */
#hud-top .hud-plate, #hud-bottom .hud-plate, #hud-top .hud-right { pointer-events: none; }
.score-num, #health-num, .hp-label, #room-display, .voice-mini, .score-tag {
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
/* simple always-visible EXIT button (top-right). Inline onclick + touch-action
   manipulation make it tap reliably on every mobile browser incl. Brave. */
#fps-exit-btn {
  background: rgba(150,0,0,0.42); border: 1px solid rgba(255,80,80,0.5);
  color: rgba(255,255,255,0.9); font-family: var(--mono); font-size: 11px;
  letter-spacing: 2px; padding: 5px 12px; border-radius: 6px; cursor: pointer;
  pointer-events: all !important; z-index: 99999 !important; position: relative;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  outline: none; -webkit-appearance: none;
  user-select: none; -webkit-user-select: none;
}
#fps-exit-btn:active { background: rgba(255,0,0,0.35); }
/* game SFX on/off toggle (top-right cluster) */
#sfx-btn {
  background: rgba(0,0,0,0.42); border: 1px solid var(--border); color: #fff;
  line-height: 1; padding: 0; border-radius: 8px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; pointer-events: all;
  user-select: none; -webkit-user-select: none;
}
#sfx-btn:active { transform: scale(0.92); }
#sfx-btn.off { opacity: 0.5; }
/* kill the persistent green tap-dot / focus ring on every mobile browser */
#fps-exit-btn:focus,
#fps-exit-btn:active,
#fps-exit-btn:focus-visible { outline: none; box-shadow: none; }

/* Snappy taps on every in-game HUD button — no 300ms delay, no tap-flash. */
#fps-exit-btn, #mute-btn, #fire-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  will-change: transform;
}
.score { display: flex; align-items: center; gap: 10px; }
.score-num { font-family: var(--led); font-size: 24px; font-weight: 700; line-height: 1; display: inline-block; }
.score-red .score-num { color: var(--red); } .score-blue .score-num { color: var(--blue); }
.score-tag { font-size: 11px; letter-spacing: 3px; opacity: 0.65; }
.hud-center { text-align: center; }
#room-display { font-size: 10px; letter-spacing: 3px; color: rgba(255,255,255,0.5); }
.voice-mini { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: 1px; color: rgba(255,255,255,0.5); margin-top: 3px; }
.vdot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.3); animation: vdotpulse 1.6s ease-in-out infinite; }
.vdot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.vdot.connecting { background: var(--gold); }
.vdot.off { background: var(--red); animation: none; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ===================== EXIT PILL (all modes) ===================== */
.exit-pill {
  position: fixed; top: 56px; left: 8px; z-index: 1000;   /* well above the canvas (0) and HUD (~20); modal sits at 2000 */
  pointer-events: auto;
  background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7); font-family: var(--mono); font-size: 11px;
  letter-spacing: 2px; padding: 6px 12px; border-radius: 4px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.exit-pill:hover { color: #fff; border-color: rgba(255,255,255,0.45); background: rgba(0,0,0,0.85); }
.exit-pill:active { transform: scale(0.95); }
/* inline variant sits in the video top bar flow rather than fixed-position */
.exit-pill-inline { position: static; top: auto; left: auto; }

/* ===================== KILL STREAK BANNER ===================== */
.streak-banner {
  position: absolute; top: calc(50% + 40px); left: 50%; z-index: 42;
  transform: translate(-50%, -24px); opacity: 0; pointer-events: none;
  background: var(--gold); color: #1a1200; font-weight: 900;
  font-size: 24px; letter-spacing: 4px; padding: 10px 26px; border-radius: 6px;
  white-space: nowrap; box-shadow: 0 0 30px rgba(255,184,0,0.55);
  transition: opacity .25s ease, transform .25s cubic-bezier(.2,.8,.2,1);
}
.streak-banner.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== KILL FEED ===================== */
#kill-feed { position: absolute; top: 60px; right: max(14px, env(safe-area-inset-right)); z-index: 20; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; pointer-events: none; }
.kf .ico { opacity: 0.85; }
.kf { background: rgba(0,0,0,0.72); border-left: 3px solid; padding: 5px 10px; font-size: 12px; transform: translateX(120%); opacity: 0; transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .35s; }
.kf.in { transform: translateX(0); opacity: 1; }
.kf.red { border-color: var(--red); } .kf.blue { border-color: var(--blue); }
.kf b { font-weight: 800; }
.kf.streak { border: none; background: var(--gold); color: #1a1200; font-weight: 900; letter-spacing: 1px; font-size: 13px; padding: 7px 14px; align-self: center; box-shadow: 0 0 20px rgba(255,184,0,0.5); }

/* ===================== PLAYERS SIDEBAR ===================== */
/* starts below the EXIT pill (top:56px, ~28px tall) so they never overlap */
#players-sidebar { position: absolute; left: env(safe-area-inset-left); top: 90px; width: 160px; z-index: 18; background: rgba(0,0,0,0.5); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); border-radius: 0 0 6px 0; transition: width .15s; }
.sidebar-head { font-size: 8px; letter-spacing: 3px; color: rgba(255,255,255,0.4); padding: 4px 8px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-toggle { display: block; background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 12px; flex-shrink: 0; }
/* collapsed: shrink to a tiny semi-transparent arrow tab that stays out of the way */
#players-sidebar.collapsed { width: 20px; background: rgba(0,0,0,0.28); border-color: transparent; }
#players-sidebar.collapsed #players-list,
#players-sidebar.collapsed .sidebar-title { display: none; }
#players-sidebar.collapsed .sidebar-head { justify-content: center; padding: 0; border-bottom: none; }
#players-sidebar.collapsed .sidebar-toggle {
  width: 20px; height: 20px; padding: 0; line-height: 20px; font-size: 11px;
  color: rgba(255,255,255,0.45);
}
.prow { display: flex; align-items: center; gap: 6px; padding: 3px 8px; font-size: 10px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.prow.dead { opacity: 0.4; }
.pdot { width: 8px; height: 8px; flex-shrink: 0; }
.pdot.red { background: var(--red); } .pdot.blue { background: var(--blue); }
.pskull { flex: 0 0 auto; display: inline-flex; align-items: center; line-height: 1; color: rgba(255,255,255,0.75); }
/* full names — wrap rather than truncate so long callsigns stay readable */
.pname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: rgba(255,255,255,0.85); }
/* Desktop: sidebar stays expanded and wide enough to show full names untruncated. */
@media (min-width: 768px) {
  #players-sidebar { width: 180px; }
  #players-sidebar .pname { white-space: normal; overflow: visible; text-overflow: clip; font-size: 12px; }
}
.pkd { flex: 0 0 auto; font-size: 9px; font-weight: 700; color: rgba(255,255,255,0.55); }
.viz { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.viz i { width: 2px; height: 3px; background: rgba(255,255,255,0.25); transition: height .08s, background .08s; }
.prow.speaking .viz i { background: var(--green); box-shadow: 0 0 4px var(--green); }
.prow.speaking .viz i:nth-child(1){ animation: viz .5s -.0s infinite; }
.prow.speaking .viz i:nth-child(2){ animation: viz .5s -.1s infinite; }
.prow.speaking .viz i:nth-child(3){ animation: viz .5s -.2s infinite; }
.prow.speaking .viz i:nth-child(4){ animation: viz .5s -.15s infinite; }
.prow.speaking .viz i:nth-child(5){ animation: viz .5s -.05s infinite; }
@keyframes viz { 0%,100% { height: 3px; } 50% { height: 12px; } }

/* ===================== VOICE STATUS BAR ===================== */
/* Compact centered pill just above the HP bar (not a full-width bar over the view).
   The id background overrides the .vs-* class backgrounds, so it stays dark while
   the state class still tints the text colour. */
#voice-status-bar { position: absolute; left: 50%; bottom: calc(60px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: auto; max-width: 90%; padding: 4px 12px; z-index: 100; display: flex; align-items: center; justify-content: center; font-size: 10px; letter-spacing: 1px; font-weight: 700; white-space: nowrap; background: rgba(0,0,0,0.7); border-radius: 20px; pointer-events: none; }
.vs-on { background: rgba(0,200,83,0.14); color: var(--green); }
.vs-connecting { background: rgba(255,184,0,0.14); color: var(--gold); }
.vs-off { background: rgba(255,45,45,0.14); color: var(--red); }
.vs-waiting { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5); }

/* ===================== HUD BOTTOM (corner-anchored overlay, not a bar) ===================== */
/* Was a 64px opaque bar (52px on phones). Same treatment as #hud-top: transparent
   rail, clusters float at the bottom corners, safe-area insets clear the gesture
   bar and landscape cutouts. */
#hud-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  padding: 0 max(14px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: none; border: none;
  pointer-events: none;
}
#hud-bottom .mute-btn { order: -1; }                 /* mic to the far left, off the centered gun barrel */
#hud-bottom #player-team-badge { margin-left: auto; }  /* team badge pinned to the right */
/* Mobile-only EXIT in the bottom bar (left group, by the thumb). Desktop keeps the
   top-right corner button; this one is hidden on desktop. */
#fps-exit-mobile {
  order: -1;                       /* sit with the mic on the left */
  position: relative; z-index: 30; /* above the look-zone / canvas so taps always land */
  background: rgba(180,0,0,0.75); border: 1px solid rgba(255,80,80,0.6);
  color: #fff; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 2px;
  padding: 12px 16px; border-radius: 6px; flex-shrink: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
  pointer-events: all !important; cursor: pointer; display: none;
}
#fps-exit-mobile:active { background: rgba(220,0,0,0.85); }
@media (max-width: 900px) {
  /* inline-flex (not block) so the 44px min-height stays vertically centred */
  #fps-exit-mobile { display: inline-flex; }   /* show on phones */
  #fps-exit-btn { display: none; }             /* hide the unreachable corner button */
}
/* 1.6-style readout: orange LED numerals, label + bar tinted to match */
.hp-wrap { display: flex; align-items: center; gap: 9px; }
.hp-label { font-size: 11px; letter-spacing: 2px; color: var(--hud-orange); opacity: 0.85; }
.hp-track { width: 120px; height: 10px; background: rgba(255,160,0,0.15); }
#health-bar { height: 100%; width: 100%; background: var(--hud-orange); transition: width .25s, background .25s; }
#health-num { font-family: var(--led); font-size: 20px; font-weight: 700; min-width: 52px; color: var(--hud-orange); }
.badge { font-size: 12px; letter-spacing: 3px; font-weight: 800; padding: 6px 14px; border: 1px solid; }
.badge.red { color: var(--red); border-color: var(--red); background: rgba(255,45,45,0.14); box-shadow: inset 0 0 10px rgba(255,45,45,0.35); }
.badge.blue { color: var(--blue); border-color: var(--blue); background: rgba(45,139,255,0.14); box-shadow: inset 0 0 10px rgba(45,139,255,0.35); }

.mute-btn { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.25); background: var(--green); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; box-shadow: 0 0 22px rgba(0,200,83,0.45); transition: background .15s, box-shadow .15s; }
.mute-btn .mute-icon { display: flex; align-items: center; justify-content: center; line-height: 1; }
.mute-btn .mute-label { font-size: 8px; font-weight: 800; letter-spacing: 1px; }
.mute-btn.muted { background: var(--red); box-shadow: 0 0 22px rgba(255,45,45,0.5); }
.mute-btn:active { transform: scale(0.94); }

/* ===================== MUTED BANNER ===================== */
#muted-banner { position: absolute; top: 52px; left: 50%; transform: translateX(-50%) translateY(-120%); z-index: 30; background: var(--red); color: #fff; font-weight: 800; letter-spacing: 2px; font-size: 13px; padding: 8px 22px; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
#muted-banner:not(.hidden) { transform: translateX(-50%) translateY(0); }

/* ===================== KILLCAM + DEATH ===================== */
#killcam-banner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); z-index: 40; font-size: 20px; letter-spacing: 3px; font-weight: 800; color: #fff; text-shadow: 0 2px 12px #000; }
#killcam-banner span { color: var(--red); }
#death-screen { position: absolute; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; }
.death-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(120,0,0,0.25) 0%, rgba(80,0,0,0.7) 100%); }
.death-inner { position: relative; text-align: center; }
.death-title { font-size: 40px; font-weight: 900; letter-spacing: 6px; color: #fff; text-shadow: 0 0 30px rgba(255,0,0,0.8); animation: deathpulse 0.8s ease-in-out infinite alternate; }
@keyframes deathpulse { from { opacity: 0.75; } to { opacity: 1; } }
.death-by { margin-top: 12px; font-size: 15px; letter-spacing: 2px; color: rgba(255,255,255,0.8); }
.death-respawn { margin-top: 26px; font-size: 14px; letter-spacing: 3px; color: rgba(255,255,255,0.6); }
.death-respawn span { font-family: var(--led); font-size: 36px; font-weight: 700; color: var(--hud-orange); display: block; margin-top: 6px; }

/* ===================== MOBILE CONTROLS ===================== */
#mobile-controls { display: none; }
/* Look/aim overlay: covers the middle of the screen only — it starts below the
   HUD top bar (52px) and stops above the bottom HUD bar (~60px) so taps on the ≡
   menu, scores, mic and badge always reach those controls. Joystick/fire (z16)
   sit above it; the canvas (z0) gets no touch. */
/* Look/aim overlay: full viewport, inset only by the device safe areas. The old
   52px/112px offsets existed to dodge the opaque HUD bars; those are gone, and
   at z5 this sits UNDER every interactive control (joystick/fire z16, sidebar
   z18, HUD clusters z20, exit z30/99999), so hit-testing still resolves taps to
   the controls and only falls through to here on open view. */
#look-zone {
  position: fixed;
  top: env(safe-area-inset-top); left: env(safe-area-inset-left);
  right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom);
  width: auto; height: auto;
  z-index: 5; touch-action: none;
}
#joystick-zone { position: absolute; left: 20px; bottom: 100px; width: 150px; height: 150px; z-index: 16; display: flex; align-items: center; justify-content: center; }
#joystick-base { width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; }
#joystick-thumb { width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.3); border: 2px solid rgba(255,255,255,0.5); }
#fire-btn { position: absolute; right: 20px; bottom: 100px; width: 72px; height: 72px; border-radius: 50%; background: var(--red); border: 3px solid rgba(255,255,255,0.3); font-size: 28px; z-index: 16; cursor: pointer; box-shadow: 0 0 0 0 rgba(255,45,45,0.4); transition: box-shadow .1s, transform .08s; }
#fire-btn:active { transform: scale(0.92); box-shadow: 0 0 28px 6px rgba(255,45,45,0.5); }

@media (max-width: 767px) {
  #mobile-controls { display: block; }
  #players-sidebar { width: 160px; }
  #players-sidebar.collapsed { width: 28px; }
  #players-sidebar .sidebar-toggle { display: block; }
  .logo-text { font-size: 32px; }
}

/* ===================== TOAST ===================== */
#toast { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 60; background: rgba(0,0,0,0.88); border: 1px solid var(--border); color: #fff; font-size: 12px; letter-spacing: 1px; padding: 9px 16px; pointer-events: none; }

/* unified toast host — top center, below the HUD top bar, slides down on show */
#toast-host { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: 90vw; }
.toast {
  background: rgba(0,0,0,0.9); border: 1px solid var(--border); border-left: 3px solid rgba(255,255,255,0.6);
  color: #fff; font-family: var(--mono); font-size: 12px; letter-spacing: 1px; line-height: 1.4;
  padding: 9px 16px; border-radius: 8px; text-align: center; max-width: 90vw;
  opacity: 0; transform: translateY(-14px); transition: opacity .28s ease, transform .28s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast-info    { border-left-color: rgba(255,255,255,0.6); }
.toast-success { border-left-color: var(--green); color: #d6ffe6; }
.toast-error   { border-left-color: var(--red);   color: #ffd6d6; }
.toast-warning { border-left-color: var(--gold);  color: #ffeec2; }

/* ===================== CONFIRM MODAL ===================== */
.cm-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.78); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: 20px; }
.cm-card { width: 100%; max-width: 360px; background: #131313; border: 1px solid var(--border); border-radius: 14px; padding: 26px 24px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: cmIn .18s ease-out; }
@keyframes cmIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.cm-title { font-size: 20px; font-weight: 900; letter-spacing: 3px; color: #fff; }
.cm-body { font-size: 13px; color: rgba(255,255,255,0.6); letter-spacing: 1px; margin-top: 12px; line-height: 1.5; }
.cm-actions { display: flex; gap: 12px; margin-top: 24px; }
.cm-btn { flex: 1; font-family: var(--mono); font-weight: 800; letter-spacing: 2px; font-size: 13px; padding: 14px; border-radius: 8px; cursor: pointer; border: none; transition: transform .08s, box-shadow .12s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cm-btn:active { transform: translateY(2px); }
.cm-grey { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.8); border: 1px solid var(--border); }
.cm-danger { background: var(--red); color: #fff; }
.cm-danger:hover { box-shadow: 0 0 22px rgba(255,45,45,0.45); }
.cm-primary { background: var(--green); color: #06210f; }

/* ===================== LOBBY STEPS (3-step flow) ===================== */
.lobby-step { display: none; width: 100%; flex-direction: column; align-items: center; gap: 18px; }
.lobby-step.active { display: flex; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.auth-error { color: var(--red); font-size: 12px; margin-top: 8px; letter-spacing: 0.5px; }
.conn-status { font-size: 11px; letter-spacing: 1px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 7px; }
.conn-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn-status.connecting { color: var(--gold); }
.conn-status.connecting::before { animation: blink 1s infinite; }
.conn-status.connected { color: var(--green); }
.conn-status.failed { color: var(--red); }
.conn-status .conn-retry { background: rgba(255,45,45,0.15); border: 1px solid var(--red); color: var(--red); font-family: var(--mono); font-size: 10px; letter-spacing: 1px; padding: 3px 9px; border-radius: 5px; cursor: pointer; }
.field input.shake { animation: shake .3s; border-color: var(--red); }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }
.step-title { font-size: 18px; font-weight: 800; letter-spacing: 3px; text-align: center; line-height: 1.5; }
.step-sub { font-size: 13px; color: rgba(255,255,255,0.55); text-align: center; margin-top: -8px; }
.btn-back { background: none; border: none; color: rgba(255,255,255,0.45); font-family: var(--mono); font-size: 12px; letter-spacing: 2px; cursor: pointer; padding: 8px; }
.btn-back:hover { color: #fff; }

/* mode-selection cards — MOBILE FIRST: horizontal (icon left, text right), all
   four identical 130px height so they fit a phone screen without scrolling. */
.mode-cards { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 480px; }
.mode-card {
  height: 110px; min-height: 110px; max-height: 110px; box-sizing: border-box;
  display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
  gap: 14px; padding: 0 18px; border-radius: 6px; cursor: pointer;
  font-family: var(--mono); color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.mode-card:active { transform: scale(0.98); }
.mode-card .mode-icon { font-size: 34px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 1; }
.mode-card .mode-text { display: flex; flex-direction: column; gap: 3px; text-align: left; min-width: 0; }
.mode-card .mode-title { font-size: 16px; font-weight: 800; letter-spacing: 2px; color: #fff; margin: 0; line-height: 1; }
.mode-card .mode-subtitle { font-size: 11px; color: rgba(255,255,255,0.6); letter-spacing: 1px; margin: 0; line-height: 1.3; }
.mode-card .mode-desc { font-size: 10px; color: rgba(255,255,255,0.4); margin: 0; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* DESKTOP — vertical cards in a 2x2 grid (original feel). */
@media (min-width: 769px) {
  .mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 760px; }
  .mode-card { height: 200px; min-height: 200px; max-height: 200px; flex-direction: column; justify-content: center; align-items: center; gap: 12px; padding: 24px; }
  .mode-card .mode-icon { font-size: 52px; width: auto; height: auto; }
  .mode-card .mode-text { text-align: center; align-items: center; }
}
.mode-game { background: rgba(255,45,45,0.06); border: 2px solid rgba(255,45,45,0.3); }
.mode-game:hover { border-color: var(--red); background: rgba(255,45,45,0.12); transform: translateY(-2px); }
.mode-video { background: rgba(45,139,255,0.06); border: 2px solid rgba(45,139,255,0.3); }
.mode-video:hover { border-color: var(--blue); background: rgba(45,139,255,0.12); transform: translateY(-2px); }
.mode-trivia { background: rgba(147,51,234,0.06); border: 2px solid rgba(147,51,234,0.3); }
.mode-trivia:hover { border-color: #9333EA; background: rgba(147,51,234,0.12); transform: translateY(-2px); }
.mode-draw { background: rgba(255,184,0,0.06); border: 2px solid rgba(255,184,0,0.3); }
.mode-draw:hover { border-color: var(--gold); background: rgba(255,184,0,0.12); transform: translateY(-2px); }

/* camera-permission step */
.cam-icon { font-size: 72px; line-height: 1; }
.cam-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.cam-actions .btn-allow, .cam-actions .btn-grey { width: 100%; }

/* ===================== VIDEO CALL SCREEN ===================== */
/* Mobile-first FaceTime/Meet-style layout: column flexbox stack —
   top bar · voice status · stage (prominent self + grid) · controls. */
#video-screen { background: #0D0D0D; flex-direction: column; }

/* --- TOP BAR (48px) --- */
#video-top { flex: 0 0 48px; height: 48px; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: rgba(10,10,10,0.9); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-bottom: 1px solid rgba(255,255,255,0.06); }
.vt-logo { display: flex; align-items: center; }
.logo-mark.sm { width: 16px; height: 16px; font-size: 11px; border-radius: 3px; box-shadow: none; }
.vt-center { font-size: 11px; letter-spacing: 2px; color: rgba(255,255,255,0.75); }
.vt-timer { font-size: 12px; letter-spacing: 1px; color: var(--green); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

/* --- VOICE STATUS BAR (28px) --- */
#vc-status-bar { flex: 0 0 28px; height: 28px; display: flex; align-items: center; justify-content: center; gap: 7px; background: transparent; font-size: 10px; letter-spacing: 2px; font-weight: 700; }
.vc-vdot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: vdotpulse 1.6s ease-in-out infinite; }
@keyframes vdotpulse { 0%,100% { opacity: 0.4; transform: scale(1); } 50% { opacity: 1; transform: scale(1.3); } }
#vc-status-bar.vs-on   { color: var(--green); }
#vc-status-bar.vs-on .vc-vdot { background: var(--green); }
#vc-status-bar.vs-connecting { color: var(--gold); }
#vc-status-bar.vs-connecting .vc-vdot { background: var(--gold); }
#vc-status-bar.vs-waiting { color: rgba(255,255,255,0.5); }
#vc-status-bar.vs-waiting .vc-vdot { background: rgba(255,255,255,0.4); }
#vc-status-bar.vs-off { color: rgba(255,255,255,0.35); }
#vc-status-bar.vs-off .vc-vdot { background: rgba(255,255,255,0.25); animation: none; }

/* --- STAGE: prominent self tile + grid of others --- */
#video-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px; }
#video-self { flex: 0 0 45%; min-height: 0; }
#video-self .vtile { width: 100%; height: 100%; }
#video-grid { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 8px; }

/* --- TILE --- */
.vtile { position: relative; min-height: 0; background: #141414; border-radius: 12px; border: 1.5px solid rgba(255,255,255,0.06); overflow: hidden; animation: tileIn 0.2s ease-out; transition: border-color 0.15s, box-shadow 0.15s; }
.vtile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; } /* default; JS sets cover/contain per video orientation */
.vtile.self video { transform: scaleX(-1); }
.vtile.speaking { border-color: #00C853; box-shadow: 0 0 0 2px #00C853, 0 0 16px rgba(0,200,83,0.35); animation: tileIn 0.2s ease-out, speakpulse 1.2s ease-in-out infinite; }
@keyframes tileIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes speakpulse { 0%,100% { box-shadow: 0 0 0 2px #00C853, 0 0 16px rgba(0,200,83,0.35); } 50% { box-shadow: 0 0 0 2px #00C853, 0 0 26px rgba(0,200,83,0.6); } }

/* camera-off overlay */
.vtile-camoff { display: none; position: absolute; inset: 0; background: #141414; align-items: center; justify-content: center; }
.vtile.camoff .vtile-camoff { display: flex; }
.vtile-camoff .psn { width: 48px; height: 48px; fill: rgba(255,255,255,0.2); }

/* name badge */
.vtile-badge { position: absolute; bottom: 8px; left: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,0.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); border-radius: 6px; padding: 4px 10px; font-size: 12px; font-family: var(--mono); color: #fff; }
.vtile-dot { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: #666; }
.vtile-badge.red .vtile-dot { background: var(--red); }
.vtile-badge.blue .vtile-dot { background: var(--blue); }
.vtile-bname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* muted indicator on a tile */
.vtile-muted { display: none; position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; padding: 4px; border-radius: 7px; background: rgba(0,0,0,0.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); color: #fff; }
.vtile-muted svg { width: 100%; height: 100%; display: block; }
.vtile.muted .vtile-muted { display: block; }

/* waiting / empty placeholder tile — minimal, no border, no shadow */
.vtile-empty { background: #0D0D0D; border: none; box-shadow: none; animation: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.vtile-empty .psn { width: 32px; height: 32px; fill: rgba(255,255,255,0.15); }
.vtile-waiting { font-size: 10px; letter-spacing: 1px; color: rgba(255,255,255,0.25); font-family: var(--mono); }

/* muted banner (slides in from top) */
#vc-muted-banner { position: absolute; top: 76px; left: 50%; transform: translateX(-50%) translateY(-160%); z-index: 30; background: var(--red); color: #fff; font-weight: 800; letter-spacing: 2px; font-size: 13px; padding: 8px 22px; border-radius: 8px; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
#vc-muted-banner:not(.hidden) { transform: translateX(-50%) translateY(0); }

/* --- CONTROLS BAR (88px) — 4 buttons: MIC · FLIP · CAM · LEAVE --- */
#vc-controls { flex: 0 0 88px; height: 88px; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 10px; background: rgba(10,10,10,0.95); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 1px solid rgba(255,255,255,0.06); }
.vc-ctrl { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vc-btn { width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; transition: background .15s, transform .08s; }
.vc-btn:active { transform: scale(0.92); }
.vc-icon { display: flex; }
.vc-icon svg { width: 24px; height: 24px; display: block; }
.vc-leave .vc-icon svg { width: 22px; height: 22px; }
.vc-label { font-size: 10px; font-family: var(--mono); letter-spacing: 1px; color: rgba(255,255,255,0.6); }
.vc-mic-on { background: var(--green); } .vc-mic-off { background: var(--red); }
.vc-cam-on { background: var(--green); } .vc-cam-off { background: #444; }
.vc-flip { background: rgba(255,255,255,0.12); }
.vc-screen { background: rgba(255,255,255,0.12); color: #fff; }
.vc-screen.sharing { background: #9333EA; color: #fff; }     /* purple while sharing */
@media (max-width: 767px) { #video-screen-share-btn, .vc-screen-ctrl { display: none !important; } }   /* screen share is desktop-only */
.vc-flip[hidden] { display: none; }
.vc-speaker-on { background: var(--green); color: #fff; }    /* loudspeaker active (default) — same green as MIC ON */
.vc-speaker-off { background: #333; color: rgba(255,255,255,0.45); }   /* earpiece mode — dark grey */
.vc-flip-ctrl[hidden] { display: none; }
.vc-flip-wide { margin-top: 1px; font-size: 8px; font-weight: 800; letter-spacing: 1px; color: var(--gold); background: rgba(255,184,0,0.16); padding: 1px 5px; border-radius: 4px; line-height: 1.4; }
.vc-flip-wide[hidden] { display: none; }
.vc-leave { background: var(--red); }

/* tap-to-fullscreen tile + its close button + connection-quality dot */
.tile-fullscreen { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; z-index: 200 !important; border-radius: 0 !important; transition: all 0.25s ease; }
.vtile-close { display: none; position: absolute; top: 16px; right: 16px; z-index: 210; width: 40px; height: 40px; border: none; border-radius: 50%; background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #fff; cursor: pointer; align-items: center; justify-content: center; }
.tile-fullscreen .vtile-close { display: flex; }
.vtile-quality { position: absolute; top: 8px; left: 8px; z-index: 5; width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.3); box-shadow: 0 0 0 2px rgba(0,0,0,0.4); transition: background .3s; }
.vtile-quality.good { background: var(--green); }
.vtile-quality.degraded { background: var(--gold); }
.vtile-quality.connecting { background: rgba(255,255,255,0.35); }
/* self tile has no remote connection to measure */
.vtile.self .vtile-quality { display: none; }

/* ===================== VIDEO CALL — PORTRAIT PHONE ===================== */
/* Phone cameras deliver PORTRAIT streams; the old full-width tiles were
   landscape, so object-fit:cover cropped the video into a zoomed close-up.
   Make the tiles portrait too: the self tile is a centered 3:4 tile and the
   others grid is 3 columns of tall tiles, so faces show head-and-shoulders. */
@media (max-width: 767px) and (orientation: portrait) {
  #video-self { display: flex; justify-content: center; }
  #video-self .vtile { width: auto; aspect-ratio: 3 / 4; max-width: 100%; }
  #video-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===================== VIDEO CALL — DESKTOP ===================== */
/* Wide screens get a desktop look: a centered 16:9 self tile instead of a
   stretched full-width strip, and others-grid tiles sized ~370px wide so a
   portrait phone stream fills a tallish tile (object-fit cover via fitVideo)
   rather than floating letterboxed inside one huge rectangle. */
@media (min-width: 768px) and (min-height: 501px) {
  #video-stage { padding: 16px; gap: 12px; }
  #video-self { display: flex; justify-content: center; }
  #video-self .vtile { width: auto; height: 100%; aspect-ratio: 16 / 9; max-width: 100%; }
  #video-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
}

/* ===================== VIDEO CALL — LANDSCAPE PHONE ===================== */
@media (orientation: landscape) and (max-height: 500px) {
  #video-top { flex-basis: 40px; height: 40px; }
  #vc-status-bar { flex-basis: 22px; height: 22px; }
  #video-stage { flex-direction: row; }
  #video-self { flex: 0 0 50%; }
  #video-grid { flex: 1 1 auto; grid-template-columns: 1fr 1fr; }
  #vc-muted-banner { top: 50px; }
  #vc-controls { flex-basis: 64px; height: 64px; gap: 18px; }
  .vc-btn { width: 46px; height: 46px; }
  .vc-icon svg { width: 22px; height: 22px; }
  .vc-label { display: none; }
}
/* (mode-cards are mobile-first column by default now — see the .mode-cards rule) */

/* Video call uses dynamic viewport height so it adjusts when the Chrome UI /
   permission bar appears and disappears (no collapse). */
#video-screen { height: 100dvh; height: -webkit-fill-available; }

/* Lobby, mode selection and the draw lobby / podium stay portrait and scroll
   if the content is taller than the (portrait) viewport on a phone. */
@media (max-width: 768px) {
  #lobby-screen, #mode-screen, #draw-lobby-screen, #podium-screen {
    min-height: 100dvh;
    justify-content: center;
    justify-content: safe center;      /* centred when content fits; falls back to
                                          top-aligned + scrollable when it overflows
                                          (keeps the login form centred AND the tall
                                          mode-card screen's logo reachable) */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
}

/* ===================== FORCE LANDSCAPE ON MOBILE ===================== */
/* Rotate reminder on the lobby (portrait phones only; toggled by JS). */
#rotate-banner {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.75); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7); font-family: var(--mono); font-size: 12px;
  letter-spacing: 1px; padding: 8px 16px; border-radius: 20px; white-space: nowrap;
  z-index: 100; display: none;
}

/* Full-screen "rotate your phone" overlay (shown in portrait when the
   orientation lock is unavailable / denied). */
#rotate-prompt {
  position: fixed; inset: 0; background: #0D0D0D; z-index: 999;
  display: none; align-items: center; justify-content: center; flex-direction: column;
  gap: 16px; color: #fff; font-family: var(--mono); letter-spacing: 3px; text-align: center;
}
.rotate-content { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rotate-content .rp-icon { font-size: 64px; animation: rpspin 2.2s ease-in-out infinite; }
@keyframes rpspin { 0%,55%,100% { transform: rotate(0); } 30% { transform: rotate(-90deg); } }
.rotate-content .rp-sub { font-size: 12px; opacity: 0.5; letter-spacing: 1px; }

/* FIX 5 — compact HUD + landscape control placement on phones.
   (Applies to portrait phones in the rotated frame and to real landscape phones.) */
@media (max-width: 767px), (max-height: 520px) {
  #mobile-controls { display: block; }
  /* (the old #hud-top 40px / #hud-bottom 52px bar heights are gone — both rails
     are transparent and size to their clusters now) */
  .hp-label, #health-num { font-size: 11px; }
  .score-num { font-size: 20px; }
  #joystick-zone { left: 20px; right: auto; bottom: 100px; width: 130px; height: 130px; }   /* same height as fire for two-thumb play */
  #fire-btn { right: 20px; left: auto; bottom: 100px; width: 72px; height: 72px; }
  .mute-btn { width: 52px; height: 52px; }   /* compact, bottom-left corner */
}

/* ===================== MOBILE LOBBY (fit in one viewport, no scroll) ===================== */
/* Covers narrow phones (portrait) and short viewports (landscape phones). */
@media (max-width: 767px), (max-height: 600px) {
  .lobby-container { padding: 12px; gap: 9px; }
  .logo { gap: 9px; }
  .logo-mark { width: 38px; height: 38px; font-size: 24px; box-shadow: 0 0 0 3px rgba(255,45,45,0.18), 4px 4px 0 #7a0000; }
  .logo-text { font-size: 26px; letter-spacing: 4px; }
  .tagline { font-size: 9px; letter-spacing: 3px; margin-top: -3px; }

  .lobby-card { padding: 14px; gap: 9px; }
  .field label { font-size: 9px; letter-spacing: 2px; margin-bottom: 4px; }
  .field input { font-size: 16px; padding: 9px 11px; }   /* keep 16px so iOS doesn't zoom on focus */
  .btn-join { font-size: 15px; padding: 11px; letter-spacing: 3px; }
  .lobby-hint { font-size: 9px; line-height: 1.5; }
  #https-note { line-height: 1.5 !important; }

  /* mode-selection + camera steps stay compact too — all 4 cards fit a phone
     screen (~720px) without scrolling: ~150px each. */
  .step-title { font-size: 14px; letter-spacing: 3px; margin: 8px 0; }
  .step-sub { font-size: 11px; margin-top: -4px; }
  /* mode cards handled by the mobile-first .mode-card rules above */
  .cam-icon { font-size: 46px; }
  .cam-actions .btn-allow, .cam-actions .btn-grey { padding: 11px; font-size: 13px; }
  .btn-back { font-size: 11px; padding: 6px; }
}
