/* ═══════════════════════════════════════════════════════════
   BATTLE TERRITORY PLUGIN  —  battle-territory.css
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Share+Tech+Mono&display=swap');

:root {
  --bt-panel-bg:  rgba(8, 12, 20, 0.97);
  --bt-border:    rgba(0, 200, 255, 0.18);
  --bt-accent:    #00c8ff;
  --bt-danger:    #ff3b3b;
  --bt-success:   #00ff88;
  --bt-font:      'Rajdhani', sans-serif;
  --bt-mono:      'Share Tech Mono', monospace;
  --bt-z:         10000;
  --bt-width:     520px;
}

/* ── Toggle button ─────────────────────────────────────────── */
.bt-toggle-btn {
  position: fixed;
  top: 76px;
  right: 54px;
  z-index: calc(var(--bt-z) + 50);
  background: linear-gradient(135deg, #0d1520, #1a2535);
  border: 1px solid var(--bt-accent);
  border-radius: 6px;
  padding: 1px 2px;
  color: var(--bt-accent);
  font-family: var(--bt-font);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 14px rgba(0,200,255,0.2);
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}
.bt-toggle-btn:hover {
  background: linear-gradient(135deg, #152030, #243045);
  box-shadow: 0 0 22px rgba(0,200,255,0.4);
}

/* ── Battle UI wrapper ─────────────────────────────────────── */
.bt-ui {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: var(--bt-z);
  pointer-events: none;
}
body.bt-active .bt-ui { display: flex !important; }

/* ── Side panel ────────────────────────────────────────────── */
.bt-side-panel {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--bt-width);
  background: var(--bt-panel-bg);
  border-right: 1px solid var(--bt-border);
  pointer-events: all;
  display: flex;
  flex-direction: column;
  font-family: var(--bt-font);
  overflow: hidden;
  backdrop-filter: blur(14px);
  box-shadow: 4px 0 40px rgba(0,0,0,0.7);
}

.bt-panel-header {
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--bt-border);
  background: rgba(0,200,255,0.04);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bt-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--bt-accent);
  letter-spacing: 3px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bt-panel-title::before {
  content: '';
  display: block;
  width: 4px; height: 18px;
  background: var(--bt-accent);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--bt-accent);
}
.bt-panel-subtitle {
  font-size: 10px;
  color: rgba(0,200,255,0.35);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: var(--bt-mono);
}

.bt-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,200,255,0.2) transparent;
}
.bt-panel-body::-webkit-scrollbar { width: 4px; }
.bt-panel-body::-webkit-scrollbar-thumb { background: rgba(0,200,255,0.2); border-radius: 2px; }

/* ── Sections ──────────────────────────────────────────────── */
.bt-section {
  border: 1px solid var(--bt-border);
  border-radius: 5px;
  overflow: visible;
}
.bt-section-title {
  padding: 5px 12px;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(0,200,255,0.45);
  background: rgba(0,200,255,0.04);
  border-bottom: 1px solid var(--bt-border);
  font-family: var(--bt-mono);
}

/* ── How it works — collapsible ────────────────────────────── */
.bt-howto {
  padding: 8px 12px;
  font-size: 11px;
  color: rgba(200,210,230,0.5);
  font-family: var(--bt-mono);
  line-height: 1.6;
}

/* ── Stats grid ────────────────────────────────────────────── */
.bt-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--bt-border);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--bt-border);
  flex-shrink: 0;
}
.bt-stat-cell {
  background: var(--bt-panel-bg);
  padding: 8px 6px;
  text-align: center;
}
.bt-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--bt-accent);
  font-family: var(--bt-font);
  line-height: 1;
}
.bt-stat-label {
  font-size: 9px;
  color: rgba(200,210,230,0.3);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: var(--bt-mono);
  margin-top: 2px;
}

/* ── Clan list ─────────────────────────────────────────────── */
.bt-clan-list { padding: 6px 8px; display: flex; flex-direction: column; gap: 5px; max-height: 200px; overflow-y: auto; }

.bt-clan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.06);
  transition: all 0.15s ease;
  background: rgba(255,255,255,0.02);
}
.bt-clan-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12); }
.bt-clan-item.active { border-color: currentColor; background: rgba(255,255,255,0.06); }

.bt-clan-swatch {
  width: 28px; height: 28px;
  border-radius: 4px; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.bt-clan-info { flex: 1; min-width: 0; }
.bt-clan-name {
  font-size: 14px; font-weight: 700; color: #e8f0ff;
  letter-spacing: 1px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.bt-clan-stats { font-size: 10px; color: rgba(200,210,230,0.38); font-family: var(--bt-mono); margin-top: 1px; }

.bt-clan-radio {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18); flex-shrink: 0; transition: all 0.15s;
}
.bt-clan-item.active .bt-clan-radio {
  background: currentColor; border-color: currentColor; box-shadow: 0 0 6px currentColor;
}

/* ── Add clan ──────────────────────────────────────────────── */
.bt-add-clan { padding: 8px 10px; display: flex; flex-direction: column; gap: 7px; }

.bt-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--bt-border);
  border-radius: 4px;
  color: #e8f0ff;
  font-family: var(--bt-font);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.bt-input:focus { border-color: var(--bt-accent); box-shadow: 0 0 0 2px rgba(0,200,255,0.1); }
.bt-input::placeholder { color: rgba(200,210,230,0.2); }

.bt-color-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; flex-direction: row; }
.bt-color-label { font-size: 10px; color: rgba(200,210,230,0.38); letter-spacing: 1px; flex-shrink: 0; }
#bt-color-picker {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.bt-color-dot {
  width: 20px; height: 20px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent; transition: all 0.15s; flex-shrink: 0;
}
.bt-color-dot.selected { border-color: #fff; transform: scale(1.25); box-shadow: 0 0 7px rgba(255,255,255,0.4); }

/* ── Buttons ───────────────────────────────────────────────── */
.bt-btn {
  padding: 6px 12px;
  border-radius: 4px; border: 1px solid;
  font-family: var(--bt-font); font-weight: 700;
  font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; white-space: nowrap;
}
.bt-btn-primary { background: rgba(0,200,255,0.08); border-color: var(--bt-accent); color: var(--bt-accent); }
.bt-btn-primary:hover { background: rgba(0,200,255,0.18); }
.bt-btn-danger  { background: rgba(255,59,59,0.08);  border-color: var(--bt-danger); color: var(--bt-danger); }
.bt-btn-danger:hover  { background: rgba(255,59,59,0.18); }
.bt-btn-warn    { background: rgba(255,150,0,0.08);  border-color: #ff9600; color: #ff9600; }
.bt-btn-warn:hover    { background: rgba(255,150,0,0.18); }
.bt-btn-sm { padding: 4px 8px; font-size: 10px; width: auto; letter-spacing: 1px; }

/* ── Inline row of buttons ─────────────────────────────────── */
.bt-btn-row {
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.bt-btn-row .bt-btn { flex: 1; }

/* ── Node list ─────────────────────────────────────────────── */
.bt-node-list {
  max-height: 200px; overflow-y: auto;
  padding: 5px 8px 8px;
  display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin; scrollbar-color: rgba(0,200,255,0.2) transparent;
}
.bt-node-list::-webkit-scrollbar { width: 4px; }
.bt-node-list::-webkit-scrollbar-thumb { background: rgba(0,200,255,0.2); border-radius: 2px; }

.bt-node-row {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
  font-size: 11px;
}
.bt-node-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid; }
.bt-node-name {
  flex: 1; color: #c8d8e8; font-family: var(--bt-mono);
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bt-node-clan-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  font-family: var(--bt-mono); white-space: nowrap; flex-shrink: 0;
}
.bt-node-mode-tag {
  font-size: 9px; color: rgba(200,210,230,0.28);
  font-family: var(--bt-mono); flex-shrink: 0;
}
.bt-node-assign-btn {
  font-size: 9px; padding: 2px 6px; border-radius: 3px;
  border: 1px solid rgba(255,59,59,0.35); color: var(--bt-danger);
  background: rgba(255,59,59,0.05); cursor: pointer;
  font-family: var(--bt-font); font-weight: 700; transition: all 0.15s; flex-shrink: 0;
}
.bt-node-assign-btn:hover { background: rgba(255,59,59,0.18); }

/* ── Scan row ──────────────────────────────────────────────── */
.bt-scan-row {
  padding: 7px 10px;
  display: flex; gap: 10px; align-items: center;
}
.bt-scan-row .bt-btn { flex: 1; }
.bt-last-scan {
  font-size: 10px; color: rgba(200,210,230,0.3);
  font-family: var(--bt-mono); white-space: nowrap;
}

/* ── Leaderboard ───────────────────────────────────────────── */
.bt-leaderboard { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; max-height: 150px; overflow-y: auto; }
.bt-lb-row { display: flex; align-items: center; gap: 8px; }
.bt-lb-rank { font-size: 10px; color: rgba(200,210,230,0.28); font-family: var(--bt-mono); width: 14px; text-align: center; flex-shrink: 0; }
.bt-lb-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.bt-lb-name { flex: 1; font-size: 12px; font-weight: 600; color: #c8d8e8; }
.bt-lb-bar-wrap { flex: 2; height: 5px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.bt-lb-bar { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.bt-lb-pct { font-size: 10px; font-family: var(--bt-mono); color: rgba(200,210,230,0.45); width: 20px; text-align: right; flex-shrink: 0; }

/* ── HUD ───────────────────────────────────────────────────── */
.bt-hud {
  position: absolute;
  top: 10px;
  left: calc(var(--bt-width) + 16px);
  right: 16px;
  display: flex; align-items: center; gap: 10px;
  pointer-events: none;
  flex-wrap: wrap;
}
.bt-hud-pill {
  background: rgba(8,12,20,0.88);
  border: 1px solid var(--bt-border); border-radius: 5px;
  padding: 6px 14px; color: var(--bt-accent);
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  font-weight: 700; backdrop-filter: blur(8px); white-space: nowrap;
  pointer-events: all; display: flex; align-items: center; gap: 7px;
  font-family: var(--bt-font);
}
.bt-hud-blink {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bt-success); animation: bt-blink 1.5s ease-in-out infinite;
}
@keyframes bt-blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.bt-hud-selected-clan {
  background: rgba(8,12,20,0.88); border: 1px solid var(--bt-border);
  border-radius: 5px; padding: 5px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
  backdrop-filter: blur(8px); pointer-events: all;
  display: flex; align-items: center; gap: 7px;
  font-family: var(--bt-font);
}
.bt-hud-clan-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── Context menu ──────────────────────────────────────────── */
.bt-context-menu {
  position: fixed; z-index: calc(var(--bt-z) + 100);
  background: rgba(8,12,20,0.98); border: 1px solid var(--bt-border);
  border-radius: 6px; min-width: 210px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  font-family: var(--bt-font); overflow: hidden; backdrop-filter: blur(14px);
  animation: bt-menu-in 0.12s ease;
}
@keyframes bt-menu-in { from{opacity:0;transform:scale(0.95)} to{opacity:1;transform:scale(1)} }
.bt-context-header {
  padding: 7px 14px; font-size: 10px; letter-spacing: 1.5px;
  color: rgba(0,200,255,0.45); border-bottom: 1px solid var(--bt-border);
  font-family: var(--bt-mono); text-transform: uppercase;
}
.bt-context-item {
  padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
  color: #c8d8e8; display: flex; align-items: center; gap: 9px;
  transition: background 0.1s; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.bt-context-item:last-child { border-bottom: none; }
.bt-context-item:hover { background: rgba(0,200,255,0.1); }
.bt-ctx-swatch { width: 13px; height: 13px; border-radius: 3px; flex-shrink: 0; }

/* ── Pulse animation ───────────────────────────────────────── */
@keyframes bt-pulse {
  0%,100% { box-shadow: 0 0 8px currentColor, 0 0 20px rgba(0,0,0,0.4); }
  50%      { box-shadow: 0 0 18px currentColor, 0 0 40px rgba(0,0,0,0.2); }
}

/* ── Toast ─────────────────────────────────────────────────── */
.bt-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(8,12,20,0.97); border: 1px solid var(--bt-border);
  border-radius: 5px; padding: 9px 20px;
  font-family: var(--bt-font); font-size: 13px; font-weight: 600;
  color: var(--bt-accent); letter-spacing: 1px;
  z-index: calc(var(--bt-z) + 200); opacity: 0;
  transition: all 0.25s ease; pointer-events: none;
  backdrop-filter: blur(12px); box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  white-space: nowrap;
}
.bt-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --bt-width: 100%; }
  .bt-side-panel { width: 100%; height: 55%; bottom: 0; top: auto; border-right: none; border-top: 1px solid var(--bt-border); }
  .bt-hud { left: 8px; top: 8px; }
  .bt-toggle-btn { top: auto; bottom: calc(55% + 10px); right: 10px; }
}