:root {
  color-scheme: dark;
  font-family: Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #111827;
  color: #e5e7eb;
  overflow: hidden;
}

button,
input,
label,
a {
  touch-action: manipulation;
}

.settings-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.settings-toggle.visible {
  opacity: 1;
  pointer-events: auto;
}

.top-right-toggles {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 31;
  display: flex;
  gap: 8px;
}

.players-toggle,
.loot-toggle,
.collapse-button,
.settings-toggle,
.filter-gear {
  border: 1px solid #334155;
  background: #111827;
  color: #e5e7eb;
  border-radius: 0;
  padding: 8px 12px;
  cursor: pointer;
}

.players-toggle,
.loot-toggle {
  padding: 10px 14px;
}

.label-settings-panel {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, calc(-100% - 24px));
  width: min(760px, calc(100vw - 32px));
  max-height: min(72vh, 760px);
  z-index: 35;
  border: 1px solid #1f2937;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.97);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
  overflow: hidden;
}

.label-settings-panel.open {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.label-settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #1f2937;
}

.label-settings-subtitle {
  margin-top: 4px;
  color: #94a3b8;
  font-size: 12px;
}

.label-settings-actions {
  display: flex;
  gap: 8px;
}

.label-settings-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  max-height: calc(72vh - 70px);
}

.setting-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.72);
}

.setting-title {
  color: #e5e7eb;
  font-weight: 700;
}

.setting-value {
  color: #93c5fd;
  font-size: 12px;
}

.setting-help {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.35;
}

.setting-card select,
.setting-card input[type="range"] {
  width: 100%;
}

.setting-card select {
  border: 1px solid #334155;
  background: #111827;
  color: #e5e7eb;
  border-radius: 0;
  padding: 9px 10px;
}

.toggle-setting {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-setting .setting-help {
  grid-column: 1 / -1;
}

.players-panel,
.loot-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  z-index: 30;
  border: 1px solid #1f2937;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  display: grid;
  grid-template-rows: auto auto 1fr;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.players-panel.open,
.loot-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.players-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid #1f2937;
}

.players-server {
  padding: 8px 12px;
  color: #93c5fd;
  font-size: 12px;
  border-bottom: 1px solid #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.players-list,
.loot-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.players-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  border: 1px solid #263244;
  border-radius: 0;
  background: rgba(2, 6, 23, 0.55);
  padding: 8px 10px;
  margin-bottom: 8px;
}

.players-name {
  font-family: Arial, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-weight: 600;
  white-space: pre-line;
}

.players-steam {
  grid-column: 1 / -1;
  font-size: 12px;
}

.players-steam a {
  color: #93c5fd;
  text-decoration: none;
}

.players-empty {
  color: #94a3b8;
  font-size: 13px;
  padding: 10px;
}

.loot-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  text-align: left;
  border: 1px solid rgba(51, 65, 85, 0.85);
  border-left: 4px solid var(--loot-color, #94a3b8);
  border-radius: 0;
  background: rgba(2, 6, 23, 0.68);
  color: #e5e7eb;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.loot-row.favorite {
  border-color: rgba(239, 68, 68, 0.9);
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.5), 0 0 18px rgba(239, 68, 68, 0.18);
}

.loot-name {
  font-weight: 700;
  color: var(--loot-color, #e5e7eb);
}

.loot-distance {
  color: #cbd5e1;
  font-size: 12px;
}

.loot-meta {
  grid-column: 1 / -1;
  color: #94a3b8;
  font-size: 12px;
}

.loot-section-title,
.loot-group-title {
  color: #93c5fd;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 4px 6px;
}

.loot-group-title {
  color: #cbd5e1;
  letter-spacing: 0.04em;
  padding-top: 4px;
}

.shell {
  min-height: 100vh;
}

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: min(360px, calc(100vw - 32px));
  z-index: 20;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease, opacity 0.18s ease;
  overflow: hidden;
}

.panel.collapsed {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #1f2937;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.server-badge {
  margin-top: 4px;
  color: #93c5fd;
  font-size: 12px;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-title {
  color: #93c5fd;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 8px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  margin: 0;
}

.toggle-row.compact {
  margin-top: 4px;
}

.range-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-card {
  border: 1px solid #334155;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.72);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.filter-main {
  display: grid;
  grid-template-columns: 18px 14px 1fr;
  align-items: center;
  gap: 10px;
}

.filter-main input {
  margin: 0;
}

.filter-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.3);
}

.filter-extra {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid rgba(51, 65, 85, 0.65);
  gap: 10px;
}

.filter-card.expanded .filter-extra {
  display: grid;
}

.mini-control {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
}

.mini-control strong {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}

.canvas {
  position: absolute;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
}

#tiles,
#paths,
#itemLabels,
#markers {
  position: absolute;
  inset: 0;
}

#paths {
  z-index: 7;
  pointer-events: none;
  overflow: visible;
}

#itemLabels {
  z-index: 5;
  pointer-events: none;
}

#markers {
  z-index: 10;
}

.map-tile {
  position: absolute;
  image-rendering: auto;
  user-select: none;
  -webkit-user-drag: none;
  background: #000;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.map-tile.loaded {
  opacity: 1;
}

.map-tile.loading,
.map-tile.failed {
  opacity: 0.35;
}

.entity {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.item-label-anchor {
  position: absolute;
  transform: translate(-50%, -50%);
}

.entity.layer-loot {
  z-index: 10;
}

.entity.layer-favorite {
  z-index: 20;
}

.entity.layer-entity {
  z-index: 30;
}

.entity.player-entity {
  z-index: 40;
}

.entity.local-player-entity {
  z-index: 50;
}

.marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid #000;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.marker.players {
  background: #f97316;
}

.marker.zombies {
  background: #22c55e;
}

.marker.animals {
  background: #60a5fa;
}

.marker.loot {
  background: #facc15;
  width: 8px;
  height: 8px;
}

.marker.vehicles {
  background: #a855f7;
  width: 14px;
  height: 14px;
}

.marker.bullets {
  background: #f8fafc;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(248, 250, 252, 0.65);
}

.marker.otherEntities {
  background: #94a3b8;
  width: 10px;
  height: 10px;
}

.marker.local-player {
  background: #ef4444;
  width: 16px;
  height: 16px;
}

.marker.favorite {
  box-shadow: 0 0 0 2px rgba(127, 29, 29, 0.85), 0 0 14px rgba(239, 68, 68, 0.85);
  border-color: #fee2e2;
}

.entity.bullet-phantom .marker.bullets {
  opacity: 0.45;
  box-shadow: 0 0 6px rgba(148, 163, 184, 0.45);
}

.entity.bullet-completed .marker.bullets {
  border-color: rgba(15, 23, 42, 0.8);
}

.bullet-path-actual,
.bullet-path-predicted {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.bullet-path-actual {
  opacity: 0.9;
}

.bullet-path-predicted {
  stroke-dasharray: 8 6;
  opacity: 0.7;
}

.bullet-path-phantom {
  opacity: 0.35;
}

.direction {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 28px;
  background: #f8fafc;
  transform-origin: 50% 100%;
}

.entity-direction {
  left: 0;
  top: 0;
  z-index: 1;
}

.direction::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid currentColor;
  transform: translateX(-50%);
}

.local-direction {
  color: #ef4444;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-block;
  white-space: nowrap;
  font-family: Arial, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  color: #f8fafc;
  padding: 0;
  line-height: 1.15;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(2, 6, 23, 0.9);
  pointer-events: none;
  z-index: 3;
}

.entity.player-entity .label {
  white-space: pre;
}

.label.favorite {
  text-shadow: 0 1px 2px rgba(127, 29, 29, 0.85);
}

.label-line {
  position: absolute;
  left: 0;
  top: 0;
  height: 1px;
  background: currentColor;
  transform-origin: 0 50%;
  opacity: 0.9;
  pointer-events: none;
  z-index: 2;
}

.label-line.favorite {
  opacity: 1;
}

.loot-line {
  z-index: 1;
}

.loot-label {
  z-index: 2;
}

.hint {
  color: #94a3b8;
  font-size: 13px;
}

.unauthorized {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-size: 24px;
}

@media (max-width: 900px) {
  .label-settings-panel {
    top: 12px;
    width: min(760px, calc(100vw - 24px));
  }

  .label-settings-body {
    grid-template-columns: 1fr;
  }

  .panel {
    top: 12px;
    left: 12px;
    bottom: 12px;
    width: min(340px, calc(100vw - 24px));
  }

  .mini-control {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .top-right-toggles {
    top: 12px;
    right: 12px;
  }

  .players-panel,
  .loot-panel {
    top: 64px;
    right: 12px;
    bottom: 12px;
    width: min(420px, calc(100vw - 24px));
  }
}
