/* Custom radar frontend — BoltObserv-style 3-column layout + config drawer. */
:root {
  --bg: #0b0b0f;
  --bg2: #0d0d13;
  --panel: #0a0a0f;
  --card: #121217;
  --line: #1f1f2b;
  --line2: #292938;
  --t: #f0a020;    /* T — orange (team color, not branding) */
  --ct: #4a9eff;   /* CT — blue (team color, not branding) */
  --brand: #9E5CEB;      /* Ghost accent (purple) — branding + UI accents */
  --brand-2: #33DBFF;    /* Ghost cyan — gradient companion */
  --brand-glow: rgba(158, 92, 235, 0.55);
  --bomb: #ff4d4d;
  --c4: #8b1a1a;   /* planted C4 marker — dark red, distinct from HE (live red) */
  --fire: #ff7a18;
  --smoke: #9aa4b0;
  --flash: #ffe14d;
  --he: #ff5a5a;
  --good: #4ade80;
  --money: #7ee08a;
  --mute: #7f8aa0;
  /* config-driven vars (defaults = image #2) */
  --dot-scale: 1;
  --bomb-scale: 1;
  --map-opacity: 0.92;
  --radar-zoom: 1;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: #e6e9ef;
  font: 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
#topbar {
  flex: 0 0 auto;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  z-index: 20;
}
.tb-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--good);
}
.tb-live i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: blink 1.4s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }
.tb-live.off { color: var(--mute); }
.tb-live.off i { background: var(--mute); box-shadow:none; animation:none; }
.tb-brand { font-weight: 800; letter-spacing: 1.5px; color: #EBEBF2; }
.tb-brand b { color: var(--brand); }
.tb-map {
  font-weight: 600;
  color: #c8d0de;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line2);
  padding: 2px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  font-size: 11px;
}
.tb-spacer { flex: 1 1 auto; }
.tb-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
}
.tb-count .t-c { color: var(--t); }
.tb-count .ct-c { color: var(--ct); }
.tb-count .sep { color: var(--mute); font-weight: 400; }
.tb-ping, .tb-conn {
  font-size: 11px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.tb-conn.live { color: var(--good); }
.tb-conn.warn { color: var(--t); }
.tb-btn {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line2);
  background: rgba(255,255,255,0.03);
  color: #c4cbd8;
  font-size: 15px;
  cursor: pointer;
  transition: .12s;
}
.tb-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.tb-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- main 3-column ---------- */
#main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.team-panel {
  flex: 0 0 240px;
  width: 240px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}
.team-panel.ct { border-right: none; border-left: 1px solid var(--line); }

.tp-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  border-bottom: 1px solid var(--line);
}
.tp-head.t { color: var(--t); }
.tp-head.ct { color: var(--ct); }
.tp-head .acnt { display: inline-flex; align-items: center; gap: 6px; }
.tp-head .acnt i { width: 6px; height: 6px; border-radius: 50%; }
.tp-head.t .acnt i { background: var(--t); box-shadow: 0 0 6px var(--t); }
.tp-head.ct .acnt i { background: var(--ct); box-shadow: 0 0 6px var(--ct); }
.tp-head b {
  font-size: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line2);
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.tp-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #2a3344 transparent;
}
.tp-list::-webkit-scrollbar { width: 6px; }
.tp-list::-webkit-scrollbar-thumb { background: #2a3344; border-radius: 3px; }

/* ---------- player card ---------- */
.pcard {
  background: var(--card);
  border: 1px solid var(--line2);
  border-left: 3px solid var(--mute);
  border-radius: 7px;
  padding: 7px 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pcard.t { border-left-color: var(--t); }
.pcard.ct { border-left-color: var(--ct); }
.pcard.dead { opacity: 0.38; filter: grayscale(0.7); }
.pcard.local {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.22) inset;
  background: #141a25;
}
.pc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.pc-name {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}
.pc-wpn {
  font-size: 10px;
  color: var(--mute);
  letter-spacing: 0.4px;
  font-weight: 600;
  white-space: nowrap;
}
.pc-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: #c4cbd8;
}
.pc-mid b { font-weight: 700; font-variant-numeric: tabular-nums; }
.pc-hp { display: inline-flex; align-items: center; gap: 3px; }
.pc-hp i { width: 9px; height: 9px; border-radius: 2px; background: var(--good); display:inline-block; }
.pcard.low .pc-hp i { background: var(--bomb); }
.pcard.low .pc-hp b { color: var(--bomb); }
.pc-ap { display: inline-flex; align-items: center; gap: 3px; color: #c4cbd8; }
.pc-ap i { width: 9px; height: 9px; background: var(--ct); border-radius: 2px; display:inline-block; }
.pc-spacer { flex: 1 1 auto; }
.pc-money { color: var(--money); font-weight: 600; font-variant-numeric: tabular-nums; }
.pc-def {
  font-size: 9px;
  color: var(--good);
  border: 1px solid var(--good);
  padding: 0 3px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}
.pc-bar {
  height: 4px;
  background: var(--line2);
  border-radius: 2px;
  overflow: hidden;
}
.pc-bar i { display: block; height: 100%; border-radius: 2px; transition: width .2s; }
.pcard.t .pc-bar i { background: linear-gradient(90deg, var(--t), #ffd07a); }
.pcard.ct .pc-bar i { background: linear-gradient(90deg, var(--ct), #9ccdff); }
.pcard.low .pc-bar i { background: var(--bomb); }
.pc-nade { display: flex; gap: 4px; flex-wrap: wrap; }
.nade {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  color: #0b0e14;
}
.nade.smoke { background: var(--smoke); }
.nade.flash { background: var(--flash); }
.nade.he { background: var(--he); color: #fff; }
.nade.molo { background: var(--fire); }
.nade.inc { background: #ffb347; }
.nade.decoy { background: #b0b6c0; }
.nade.def { background: var(--good); color: #0b0e14; }
.nade.c4 { background: var(--c4); color: #fff; }

/* ---------- center stage ---------- */
#stage {
  flex: 1 1 auto;
  position: relative;
  display: grid;
  place-items: center;
  padding: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#radar {
  position: relative;
  width: min(100%, calc(100vh - 60px));
  height: auto;
  aspect-ratio: 1 / 1;
  background: #05070b;
  overflow: hidden;
  user-select: none;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 6px 30px rgba(0,0,0,0.5);
  transform: scale(var(--radar-zoom));
  transform-origin: center center;
  transition: transform .1s;
}
#mapimg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: var(--map-opacity);
  filter: saturate(0.85);
}
#layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#players, #bomb, #banner { position: absolute; inset: 0; pointer-events: none; }

.dot {
  position: absolute;
  width: calc(13px * var(--dot-scale));
  height: calc(13px * var(--dot-scale));
  transform: translate(-50%, 50%);
  border-radius: 50%;
  border: max(1px, calc(2px * var(--dot-scale))) solid rgba(0,0,0,0.65);
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
  background: var(--t);
}
.dot.local {
  width: calc(17px * var(--dot-scale));
  height: calc(17px * var(--dot-scale));
  border: max(1px, calc(2px * var(--dot-scale))) solid #fff;
  z-index: 5;
}
.dot.dead { opacity: 0.16; filter: grayscale(1); }
.dot.bomb { box-shadow: 0 0 0 2px var(--c4), 0 0 10px 2px rgba(139, 26, 26, 0.85); z-index: 4; }
.dot .lab {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -2px);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 0 1px 2px #000, 0 0 2px #000;
  background: rgba(5,7,11,0.55);
  padding: 0 3px;
  border-radius: 3px;
}
.dot .hp {
  position: absolute;
  right: -2px;
  top: -2px;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 1px #000;
}
.dot .flag {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 1px);
  font-size: 8px;
  letter-spacing: 0.5px;
  color: var(--flash);
  text-shadow: 0 1px 1px #000;
}
.flag.def { color: var(--good); }

/* config-driven visibility (body classes toggled by applyCfg) */
body.hide-ally-names .dot.ally .lab,
body.hide-enemy-names .dot.enemy .lab { display: none; }
body.hide-map-hp .dot .hp { display: none; }
body.hide-sidebar-hp .pcard .pc-bar { display: none; }

#bomb { color: #fff; font-weight: 800; }
#bomb .b {
  position: absolute;
  transform: translate(-50%, 50%);
  width: calc(16px * var(--bomb-scale));
  height: calc(16px * var(--bomb-scale));
  border-radius: 4px;
  background: var(--c4);
  box-shadow: 0 0 8px var(--c4);
  display: grid; place-items: center;
  font-size: 10px;
}
#bomb.crit .b { animation: pulse 0.4s infinite alternate; }
@keyframes pulse { from { transform: translate(-50%,50%) scale(1); } to { transform: translate(-50%,50%) scale(1.4); } }

#banner { display: grid; place-items: center; top: 6%; height: 0; }
#banner .t {
  background: rgba(5,7,11,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}
#banner.freeze .t { color: var(--ct); }
#banner.over .t { color: var(--t); }

.hide { display: none !important; }

/* ---------- config drawer ---------- */
#cfg-panel {
  position: fixed;
  top: 0; right: 0;
  width: 280px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(0,0,0,0.5);
  transform: translateX(100%);
  transition: transform .2s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
#cfg-panel.open { transform: translateX(0); }
.cp-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #cfd6e4;
}
.cp-close {
  border: none;
  background: transparent;
  color: var(--mute);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.cp-close:hover { color: #fff; }
.cp-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: #2a3344 transparent;
}
.cp-body::-webkit-scrollbar { width: 6px; }
.cp-body::-webkit-scrollbar-thumb { background: #2a3344; border-radius: 3px; }
.cp-sec {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--mute);
  text-transform: uppercase;
  margin: 4px 0 -6px;
}
.cp-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cp-row .cp-lbl {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #c4cbd8;
}
.cp-row .cp-val {
  color: var(--brand);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cp-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--line2);
  outline: none;
}
.cp-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
  box-shadow: 0 0 6px var(--brand-glow);
}
.cp-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
}
.cp-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #c4cbd8;
  cursor: pointer;
  user-select: none;
}
.cp-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cp-toggle .sw {
  position: relative;
  width: 34px; height: 18px;
  border-radius: 999px;
  background: #2a3344;
  transition: background .15s;
  flex: 0 0 auto;
}
.cp-toggle .sw::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  transition: left .15s;
}
.cp-toggle input:checked + .sw { background: var(--brand); }
.cp-toggle input:checked + .sw::after { left: 18px; }

/* ---------- responsive: phone = map only ---------- */
@media (max-width: 760px) {
  .team-panel { display: none; }
  #stage { padding: 0; }
  #radar {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    border: none;
  }
  .tb-brand, .tb-map { display: none; }
  #cfg-panel { width: 86vw; }
}

/* ---------- password modal ---------- */
#auth {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0e14;
  padding: 24px;
}
#auth.hide { display: none; }
.auth-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 24px;
  background: #121826;
  border: 1px solid #243049;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.auth-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #EBEBF2;
  text-align: center;
}
.auth-brand b { color: var(--brand); }
.auth-msg {
  font-size: 13px;
  color: #8b94a8;
  text-align: center;
  min-height: 16px;
}
.auth-msg.err { color: #ff6b6b; }
#auth-pw {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: #e8ecf6;
  background: #0b0e14;
  border: 1px solid #2a3344;
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
}
#auth-pw:focus { border-color: var(--brand); }
#auth-go {
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#auth-go:active { opacity: .85; }
