:root {
  --bg-main: #05070a;
  --bg-panel: rgba(12, 16, 23, 0.92);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(59, 139, 235, 0.5);
  --accent: #3b8beb;
  --accent-glow: rgba(59, 139, 235, 0.25);
  --text-main: #e8ecf4;
  --text-muted: #7a8295;
  --team: #3dba6e;
  --enemy: #e84545;
  --loot: #e8a72a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  font-family: 'JetBrains Mono', monospace;
}

body, html {
  width: 100%; height: 100%;
  background: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  touch-action: none;
}

/* ── App Header ── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(52px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 12px; padding-right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(8, 10, 14, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 8px;
}
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #6a7080;
  transition: all 0.25s ease;
}
.live-dot.active {
  background: #3dba6e;
  box-shadow: 0 0 10px #3dba6e;
}
.brand-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.1em;
  color: #fff;
}
.live-badge {
  font-size: 10px; color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px; border-radius: 8px;
}

.header-controls {
  display: flex; align-items: center; gap: 6px;
}

.map-dropdown {
  height: 32px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #b0b8c8; font-size: 11px;
  padding: 0 10px; outline: none;
  max-width: 110px;
}

.pill-btn {
  height: 32px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted); font-size: 11px;
  padding: 0 10px; display: flex; align-items: center; gap: 4px;
  cursor: pointer; transition: all 0.15s ease;
}
.pill-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: #7aaaff;
}

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #b0b8c8; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s ease;
}
.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

/* ── Category Quick Bar ── */
.quick-category-bar {
  position: fixed; top: calc(54px + var(--safe-top)); left: 0; right: 0;
  display: flex; gap: 6px; padding: 6px 12px;
  overflow-x: auto; scrollbar-width: none;
  z-index: 30; pointer-events: auto;
}
.quick-category-bar::-webkit-scrollbar { display: none; }

.cat-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 12px;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; cursor: pointer; transition: all 0.15s ease;
}
.cat-pill.active {
  color: #fff;
  border-color: var(--cat-color, var(--accent));
  box-shadow: 0 0 10px rgba(0,0,0,0.6);
}
.cat-pill.inactive {
  opacity: 0.35;
  text-decoration: line-through;
}

/* ── Radar Canvas Viewport ── */
.radar-container {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
#radar-canvas {
  width: 100%; height: 100%;
  display: block;
}

/* ── Tooltip ── */
.tactical-tooltip {
  position: fixed; display: none; pointer-events: none; z-index: 50;
  background: rgba(10, 14, 20, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 6px 10px;
  font-size: 11px; color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
  transform: translate(-50%, -130%); white-space: nowrap;
}
.tactical-tooltip.visible { display: block; }

/* ── Footer Status & Zoom ── */
.app-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding-bottom: var(--safe-bottom);
  height: calc(44px + var(--safe-bottom));
  padding-left: 12px; padding-right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(8, 10, 14, 0.7);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 30; pointer-events: none;
}
.hud-status {
  font-size: 11px; color: var(--text-muted);
  pointer-events: auto;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hud-controls {
  display: flex; align-items: center; gap: 8px;
  pointer-events: auto;
}
.hud-btn {
  height: 28px; padding: 0 10px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff; font-size: 11px; cursor: pointer;
}
.zoom-pill {
  height: 28px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  display: flex; align-items: center;
  overflow: hidden;
}
.zoom-pill button {
  width: 26px; height: 100%; border: none; background: none;
  color: #fff; font-size: 13px; cursor: pointer;
}
.zoom-pill button:active { background: rgba(255,255,255,0.2); }
.zoom-pill span {
  font-size: 10px; color: var(--text-muted); min-width: 32px; text-align: center;
}

/* ── Bottom Sheet Drawer ── */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.drawer-overlay.active {
  opacity: 1; pointer-events: auto;
}

.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-height: 82vh; background: var(--bg-panel);
  border-top-left-radius: 20px; border-top-right-radius: 20px;
  border: 1px solid var(--border-subtle); border-bottom: none;
  z-index: 70; display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: calc(10px + var(--safe-bottom));
}
.bottom-sheet.active {
  transform: translateY(0);
}

.sheet-handle {
  width: 38px; height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  margin: 10px auto 4px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border-subtle);
}
.sheet-header h3 { font-size: 13px; font-weight: 600; color: #fff; }
.sheet-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; padding: 4px; cursor: pointer;
}
.sheet-content {
  overflow-y: auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 14px;
}

/* Setting rows */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: #b0b8c8;
}
.switch {
  position: relative; display: inline-block; width: 44px; height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 24px; transition: .2s;
}
.switch .slider:before {
  position: absolute; content: ""; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background-color: white;
  border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* Range slider */
.slider-block {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.slider-info {
  display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted);
}
.slider-info strong { color: var(--accent); }
.mobile-range {
  width: 100%; height: 6px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.15); outline: none;
  -webkit-appearance: none; appearance: none;
}
.mobile-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

/* Preset buttons */
.preset-buttons {
  display: flex; gap: 8px;
}
.preset-btn {
  flex: 1; padding: 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border-subtle);
  color: var(--text-muted); font-size: 11px; cursor: pointer;
}
.preset-btn.highlight {
  border-color: rgba(232, 167, 42, 0.4); color: #e8a72a;
}
.preset-btn:active { background: rgba(255, 255, 255, 0.15); }

/* Search & Item list */
.search-wrap input {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border-subtle);
  color: #fff; font-size: 11px; outline: none;
}
.items-list {
  display: flex; flex-direction: column; gap: 4px;
}
.cat-group-title {
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; padding: 8px 0 4px;
  display: flex; justify-content: space-between;
}
.cat-item-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.02); font-size: 11px;
}
.cat-item-name {
  display: flex; align-items: center; gap: 8px;
  color: #b0b8c8; max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-color-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* PIN Modal */
.pin-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(5, 7, 10, 0.96); z-index: 100;
  align-items: center; justify-content: center; padding: 20px;
}
.pin-modal.active { display: flex; }
.pin-card {
  width: 100%; max-width: 320px; background: var(--bg-panel);
  border: 1px solid var(--border-subtle); border-radius: 16px;
  padding: 24px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}
.pin-card h2 { font-size: 16px; margin-bottom: 8px; color: #fff; }
.pin-card p { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.pin-card input {
  width: 100%; padding: 10px; border-radius: 8px; text-align: center;
  font-size: 18px; letter-spacing: 4px; color: #fff;
  background: rgba(0,0,0,0.5); border: 1px solid var(--border-subtle);
  margin-bottom: 16px; outline: none;
}
.pin-card button {
  width: 100%; padding: 10px; border-radius: 8px;
  background: var(--accent); border: none; color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
