:root {
  --bg: #0b0f14;
  --panel: rgba(8, 14, 22, 0.78);
  --panel-solid: rgba(10, 16, 26, 0.94);
  --panel-border: rgba(92, 225, 255, 0.28);
  --text: #eef6ff;
  --muted: #8aa0b8;
  --accent: #5ce1ff;
  --accent-2: #b8ff3d;
  --gold: #ffcc33;
  --danger: #ff4d6a;
  --hud-glow: 0 0 18px rgba(92, 225, 255, 0.18);
  /* Keep root rem at 16px so join/admin Tailwind spacing matches.
     Game HUD uses px or is scoped under #app. */
}
/* box-sizing only — do not zero margin/padding here; that beats Tailwind
   utilities (unlayered CSS wins over @layer) and flattens the join UI. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
}
/* Game chrome only — do not inherit into #join-root / SiteShell */
#app,
.hud-box,
#chatPanel,
#mappingPanel,
#tunePanel,
#mixPanel,
#shopPanel,
#pipFrame {
  font-family: Rajdhani, "Segoe UI", sans-serif;
  font-weight: 600;
}
#app { position: fixed; inset: 0; font-size: 15px; }
canvas { display: block; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
.hud-box, #chatPanel, #mappingPanel, #tunePanel, #mixPanel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  box-shadow: var(--hud-glow);
}
.hud-box {
  position: fixed; z-index: 10; padding: 12px 14px 12px 16px; font-size: 13px;
  clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
#statusBox {
  top: 12px; left: 12px; line-height: 1.45; width: 280px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 290px); overflow-y: auto;
}
#playerList { margin-top: 8px; }
.player-row {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); line-height: 1.45; font-size: 13px;
}
.player-row .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .ppts {
  flex: 0 0 auto; color: var(--gold); font-variant-numeric: tabular-nums;
  font-family: Orbitron, sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 0.4px;
  min-width: 2.5em; text-align: right;
}
#statusBox .dot {
  display: inline-block; width: 7px; height: 7px; margin-right: 7px;
  background: var(--danger); box-shadow: 0 0 8px var(--danger);
}
#statusBox .dot.ok { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
#connText {
  font-family: Orbitron, sans-serif; font-size: 10px; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent);
}
.spectate-btn {
  flex: 0 0 auto; width: 22px; height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.spectate-btn:hover { color: var(--text); border-color: var(--panel-border); background: rgba(92,225,255,0.08); }
.spectate-btn.active { color: var(--gold); border-color: rgba(255,204,51,0.45); background: rgba(255,204,51,0.12); }
.eye-icon { width: 14px; height: 14px; display: block; }
#chatPanel {
  position: fixed; bottom: 12px; left: 12px; z-index: 10;
  width: min(360px, calc(100vw - 24px)); height: 248px;
  display: flex; flex-direction: column;
  padding: 10px 12px 12px;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
#chatPanel.hidden { display: none !important; }
.chat-head {
  font-family: Orbitron, sans-serif; font-size: 9px; letter-spacing: 2.4px;
  text-transform: uppercase; color: var(--accent); margin: 0 0 8px; font-weight: 600;
}
#chatLog {
  flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.35;
  padding-right: 6px; margin-bottom: 8px;
}
#chatLog::-webkit-scrollbar { width: 6px; }
#chatLog::-webkit-scrollbar-thumb { background: rgba(92,225,255,0.28); }
.chat-line {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px;
  margin-bottom: 5px; word-break: break-word; transition: opacity 1.5s ease;
}
.chat-line.fading { opacity: 0; }
.chat-line .who {
  flex: 0 0 auto; color: var(--accent); font-weight: 700; font-size: 13px;
  letter-spacing: 0.2px; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-line .who.me { color: var(--gold); }
.chat-line .who::after { content: ":"; color: var(--muted); font-weight: 600; margin-left: 1px; }
.chat-line .body { flex: 1 1 8em; min-width: 0; color: var(--text); font-weight: 500; }
.chat-line .hitpts { flex: 0 0 auto; color: var(--accent-2); font-variant-numeric: tabular-nums; font-weight: 700; }
.chat-line.system {
  gap: 8px; padding: 4px 8px; margin-bottom: 6px;
  background: rgba(184, 255, 61, 0.08);
  border-left: 2px solid var(--accent-2);
}
.chat-line.system .who { color: var(--accent-2); max-width: none; white-space: nowrap; }
.chat-line.system .who::after { content: none; }
.chat-line.system .body { color: #e8ffc4; font-weight: 600; }
#scoreBoard, #objBoard {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(92,225,255,0.16);
  font-size: 12px; line-height: 1.4;
}
#scoreBoard h3, #objBoard h3 {
  font-family: Orbitron, sans-serif; font-size: 9px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--accent); margin: 0 0 5px; font-weight: 600;
}
#scoreBoard .score-row { display: flex; justify-content: space-between; gap: 8px; }
#scoreBoard .score-row.me { color: var(--gold); font-weight: 700; }
#scoreBoard .pts { font-variant-numeric: tabular-nums; color: var(--accent-2); }
.obj-hp {
  height: 10px; background: rgba(0,0,0,0.45); overflow: hidden; margin: 5px 0 6px;
  border: 1px solid rgba(92,225,255,0.22);
}
#objHpFill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--danger), var(--gold) 50%, var(--accent-2));
  transform-origin: left center;
  box-shadow: 0 0 10px rgba(184,255,61,0.35);
}
#redHpFill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #5a1010, var(--danger));
  transform-origin: left center;
}
#shopPanel {
  position: fixed; right: 14px; bottom: 14px; z-index: 11;
  width: 260px; padding: 12px 14px; pointer-events: auto;
}
#shopPanel h3 { font-family: Orbitron, sans-serif; font-size: 9px; letter-spacing: 2px; color: var(--gold); margin: 0 0 8px; }
#shopPanel .shop-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
#shopPanel kbd {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 6px;
  border: 1px solid rgba(92,225,255,0.35); font-size: 11px; font-family: Orbitron, sans-serif;
  color: var(--accent); letter-spacing: 0;
}
#shopPanel button {
  border: 1px solid var(--panel-border); background: rgba(92,225,255,0.1); color: var(--text);
  padding: 6px 10px; cursor: pointer; font-family: inherit; font-weight: 700;
}
#shopHint { font-size: 11px; color: var(--muted); margin-top: 6px; }
.obj-meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-variant-numeric: tabular-nums; font-family: Orbitron, sans-serif; font-size: 11px;
  letter-spacing: 1px;
}
#objTime { color: var(--gold); }
#chatCompose { display: flex; gap: 6px; align-items: center; position: relative; }
#chatInput {
  flex: 1; min-width: 0; padding: 8px 10px; font-family: inherit; font-weight: 600;
  background: rgba(0,0,0,0.4); border: 1px solid rgba(92,225,255,0.22);
  color: var(--text); font-size: 13px; outline: none;
}
#chatInput:focus { border-color: var(--gold); }
#emojiBtn, #chatSend {
  flex: 0 0 auto; width: 34px; height: 34px; padding: 0;
  border: 1px solid rgba(92,225,255,0.22);
  background: rgba(92,225,255,0.08); color: var(--text); cursor: pointer;
  font-size: 16px; line-height: 1;
}
#emojiBtn:hover, #chatSend:hover { border-color: var(--gold); color: var(--gold); }
#emojiPicker {
  position: absolute; left: 0; bottom: 42px; z-index: 12;
  width: 100%; max-height: 120px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  padding: 8px; background: var(--panel-solid); border: 1px solid var(--panel-border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
#emojiPicker.hidden { display: none !important; }
#emojiPicker button {
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1.4; padding: 2px;
}
#emojiPicker button:hover { background: rgba(255,255,255,0.08); }
#centerMsg {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%); z-index: 15;
  padding: 14px 36px; background: rgba(6,10,16,0.82); border: 1px solid var(--gold);
  font-family: Orbitron, sans-serif; font-size: 22px; font-weight: 800;
  letter-spacing: 2px; text-transform: uppercase; color: var(--gold); text-align: center;
  text-shadow: 0 0 16px rgba(255,204,51,0.45);
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}
#roundBanner {
  position: fixed; top: 16%; left: 50%; transform: translateX(-50%); z-index: 18;
  min-width: min(520px, calc(100vw - 32px)); padding: 22px 40px 18px;
  background: rgba(6, 10, 16, 0.92); border: 2px solid var(--gold);
  text-align: center; pointer-events: none;
  clip-path: polygon(18px 0, 100% 0, calc(100% - 18px) 100%, 0 100%);
  box-shadow: 0 0 40px rgba(255,204,51,0.25);
}
#roundBanner.hidden { display: none !important; }
#roundBanner.win { border-color: var(--accent-2); box-shadow: 0 0 40px rgba(184,255,61,0.28); }
#roundBanner.lose { border-color: var(--danger); box-shadow: 0 0 40px rgba(255,77,106,0.28); }
#roundTitle {
  font-family: Orbitron, sans-serif; font-size: clamp(28px, 5vw, 42px); font-weight: 800;
  letter-spacing: 4px; text-transform: uppercase; line-height: 1.15;
}
#roundBanner.win #roundTitle { color: var(--accent-2); text-shadow: 0 0 22px rgba(184,255,61,0.45); }
#roundBanner.lose #roundTitle { color: var(--danger); text-shadow: 0 0 22px rgba(255,77,106,0.45); }
#roundSub {
  margin-top: 10px; font-family: Rajdhani, sans-serif; font-size: 18px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; color: var(--text);
}
#roundCount {
  margin-top: 6px; font-family: Orbitron, sans-serif; font-size: 22px; font-weight: 800;
  letter-spacing: 2px; color: var(--gold);
}
#roundScores {
  margin-top: 14px; text-align: left; max-height: 40vh; overflow: auto;
  font-family: Rajdhani, sans-serif; font-size: 16px; font-weight: 700;
}
#roundScores .round-score {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.08);
}
#roundScores .round-score.me { color: var(--gold); }
#topRight {
  position: fixed; top: 12px; right: 12px; z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 52vw;
}
.hud-btn {
  padding: 7px 12px; border: 1px solid rgba(92,225,255,0.28);
  background: rgba(8,14,22,0.82); color: var(--text); cursor: pointer;
  font-family: Rajdhani, sans-serif; font-size: 12px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.hud-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(255,204,51,0.1); }
#pipFrame {
  position: fixed; z-index: 5; cursor: pointer;
  border: 2px solid var(--accent); box-shadow: var(--hud-glow), 0 8px 30px rgba(0,0,0,0.5);
}
#pipFrame:hover { border-color: var(--gold); }
#pipLabel {
  position: absolute; top: -20px; left: 0; font-size: 10px; letter-spacing: 2.5px;
  color: var(--accent); text-transform: uppercase; font-family: Orbitron, sans-serif;
}

/* ---------- FPV HUD overlay ---------- */
#fpvHud {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
  color: #7dffb3; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 4px rgba(0,0,0,0.85), 0 1px 2px rgba(0,0,0,0.8);
}
#fpvHud.hidden { display: none !important; }
.fpv-tape {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: min(46vh, 340px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.fpv-tape-speed { left: max(18px, 3vw); }
.fpv-tape-alt { right: max(18px, 3vw); }
.fpv-tape-track {
  flex: 1; width: 10px; position: relative;
  border: 1px solid rgba(125,255,179,0.55);
  background: rgba(0,0,0,0.28);
  border-radius: 2px; overflow: hidden;
}
.fpv-tape-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, rgba(125,255,179,0.25), rgba(125,255,179,0.85));
}
.fpv-tape-marker {
  position: absolute; left: -4px; right: -4px; height: 2px;
  background: #fff; box-shadow: 0 0 4px rgba(0,0,0,0.8);
  transform: translateY(50%);
}
.fpv-tape-readout {
  font-size: 15px; font-weight: 700; letter-spacing: 0.5px; text-align: center; line-height: 1.15;
}
.fpv-tape-readout small {
  display: block; font-size: 10px; font-weight: 600; letter-spacing: 1px;
  opacity: 0.8; text-transform: uppercase;
}
.fpv-horizon-stage {
  position: absolute; left: 50%; top: 50%;
  width: min(52vw, 480px); height: min(48vh, 360px);
  transform: translate(-50%, -50%);
  overflow: hidden; pointer-events: none;
}
#fpvHorizon {
  position: absolute; left: 50%; top: 50%;
  width: 220%; height: 4px;
  transform-origin: center center;
  will-change: transform;
}
.fpv-hz-left, .fpv-hz-right {
  position: absolute; top: 50%; height: 2px; margin-top: -1px;
  background: #7dffb3; box-shadow: 0 0 5px rgba(0,0,0,0.75);
}
.fpv-hz-left { left: 4%; right: calc(50% + 34px); }
.fpv-hz-right { left: calc(50% + 34px); right: 4%; }
.fpv-hz-tick {
  position: absolute; width: 2px; height: 12px; top: 50%;
  margin-top: -6px; background: #7dffb3;
  box-shadow: 0 0 4px rgba(0,0,0,0.7);
}
.fpv-hz-left .fpv-hz-tick { right: 0; }
.fpv-hz-right .fpv-hz-tick { left: 0; }
/* pitch ladder ticks above/below horizon (fixed to horizon bank) */
.fpv-pitch-ladder {
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  transform-origin: center center;
  will-change: transform;
}
.fpv-pitch-rung {
  position: absolute; left: 50%; height: 2px;
  background: rgba(125,255,179,0.7);
  box-shadow: 0 0 3px rgba(0,0,0,0.6);
  transform: translateX(-50%);
}
.fpv-pitch-rung.major { width: 56px; }
.fpv-pitch-rung.minor { width: 28px; opacity: 0.55; }
.fpv-reticle {
  position: absolute; left: 50%; top: 50%; width: 28px; height: 28px;
  transform: translate(-50%, -50%);
}
.fpv-reticle::before, .fpv-reticle::after {
  content: ""; position: absolute; background: #7dffb3;
  box-shadow: 0 0 4px rgba(0,0,0,0.75);
}
.fpv-reticle::before { left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); }
.fpv-reticle::after { top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-50%); }
.fpv-reticle-ring {
  position: absolute; inset: 4px;
  border: 2px solid #7dffb3; border-radius: 50%;
  box-shadow: 0 0 4px rgba(0,0,0,0.75);
}
.fpv-reticle-ring::before {
  content: ""; position: absolute; inset: 7px;
  border: 1px solid rgba(125,255,179,0.55); border-radius: 50%;
}
#bombHud {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
  color: #ffcc55; text-shadow: 0 0 4px rgba(0,0,0,0.85);
}
#bombHud.hidden { display: none !important; }
.bomb-reticle {
  position: absolute; left: 50%; top: 50%; width: 220px; height: 220px;
  transform: translate(-50%, -50%);
}
.bomb-ring {
  position: absolute; border: 2px solid rgba(255,204,85,0.85); border-radius: 50%;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
.bomb-ring.r1 { inset: 18px; }
.bomb-ring.r2 { inset: 52px; opacity: 0.7; }
.bomb-ring.r3 { inset: 88px; opacity: 0.45; }
.bomb-cross-h, .bomb-cross-v {
  position: absolute; background: #ffcc55; box-shadow: 0 0 4px rgba(0,0,0,0.75);
}
.bomb-cross-h { left: 8%; right: 8%; top: 50%; height: 2px; transform: translateY(-50%); }
.bomb-cross-v { top: 8%; bottom: 8%; left: 50%; width: 2px; transform: translateX(-50%); }
.bomb-dot {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 8px;
  margin: -4px 0 0 -4px; border-radius: 50%; background: #ffcc55;
}
#bombCount {
  position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%);
  font-family: Orbitron, sans-serif; font-size: 13px; letter-spacing: 3px;
}

/* ---------- Controls / mapping panel ---------- */
#mappingPanel {
  position: fixed; top: 56px; right: 12px; width: 380px; max-height: calc(100vh - 80px);
  overflow-y: auto; z-index: 30; padding: 16px 18px;
  clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
#mappingPanel h2, #tunePanel h2 {
  font-family: Orbitron, sans-serif; font-size: 13px; letter-spacing: 3px;
  text-transform: uppercase; margin-bottom: 6px; color: var(--gold);
}
#mappingPanel .gp-status {
  font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.5;
  white-space: pre-line;
}
.map-row { display: grid; grid-template-columns: 78px 1fr 62px 44px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 12px; }
.map-row .fn { color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.map-bar { position: relative; height: 16px; background: rgba(0,0,0,0.4); overflow: hidden; border: 1px solid rgba(92,225,255,0.18); }
.map-bar .fill { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: 0.85; }
.map-bar .binding { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.map-detect { padding: 3px 0; font-size: 11px; border: 1px solid var(--panel-border); background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; }
.map-detect.listening { border-color: var(--gold); color: var(--gold); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
.map-inv { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; }
#mappingPanel .note { font-size: 11px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
#mappingPanel .note b { color: var(--text); }
#mixPanel {
  position: fixed; top: 56px; right: 12px; width: 280px; z-index: 30; padding: 16px 18px;
  clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
#mixPanel h2 {
  font-family: Orbitron, sans-serif; font-size: 11px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--accent); margin: 0 0 12px;
}
#mixMute {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  color: var(--muted); font-size: 12px; cursor: pointer;
}
#mixMute input { accent-color: var(--gold); }
#tunePanel {
  position: fixed; top: 56px; right: 12px; width: 360px; max-height: calc(100vh - 80px);
  overflow-y: auto; z-index: 30; padding: 16px 18px;
  clip-path: polygon(0 10px, 10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
#tunePanel h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--accent); margin: 16px 0 8px;
}
#tunePanel .hint { font-size: 12px; color: var(--muted); margin-bottom: 4px; line-height: 1.45; }
.cam-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.cam-mode {
  padding: 8px 6px; border: 1px solid rgba(92,225,255,0.2);
  background: rgba(92,225,255,0.05); color: var(--text); font-size: 12px; cursor: pointer;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}
.cam-mode:hover { background: rgba(92,225,255,0.12); }
.cam-mode.active { border-color: var(--gold); background: rgba(255,204,51,0.14); color: var(--gold); }
.tune-row {
  display: grid; grid-template-columns: 64px 1fr 52px; gap: 8px; align-items: center;
  margin-bottom: 8px; font-size: 12px;
}
.tune-row label { color: var(--muted); }
.tune-row input[type="range"] { width: 100%; accent-color: var(--gold); }
.tune-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--accent-2); }
.tune-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tune-actions .hud-btn { flex: 1; min-width: 120px; }
kbd {
  padding: 1px 5px; font-size: 11px; font-family: Orbitron, sans-serif;
  background: rgba(92,225,255,0.1); border: 1px solid rgba(92,225,255,0.28); color: var(--accent);
}
