:root {
  color-scheme: dark;
  --bg: #06131a;
  --map-bg: #082b35;
  --sidebar: #0b141c;
  --sidebar-raised: #111d27;
  --border: rgba(185, 205, 220, 0.14);
  --border-strong: rgba(185, 205, 220, 0.24);
  --muted: #8292a2;
  --text: #edf3f8;
  --accent: #5ed9b3;
  --accent-soft: rgba(94, 217, 179, 0.11);
  --danger: #e2737c;
  --sleeping: #dfa65f;
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html,
body,
.app-shell,
.content-grid {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
}

button,
select { font: inherit; }

button { color: inherit; }

h1,
h2,
p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 27px;
  line-height: 1;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 14px;
  letter-spacing: -0.015em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  min-width: 0;
}

.map-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(31, 84, 94, 0.42), transparent 70%),
    var(--map-bg);
}

.map-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.map-viewport.dragging { cursor: grabbing; }

.map-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
  will-change: transform;
}

.map-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.map-tiles {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.map-tile {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

.map-markers {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.map-marker {
  position: absolute;
  z-index: 2;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  overflow: visible;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.marker-visual {
  position: absolute;
  top: var(--spider-y, 0px);
  left: var(--spider-x, 0px);
  display: block;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  transition: top 140ms ease-out, left 140ms ease-out;
}

.marker-avatar {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(239, 246, 251, 0.94);
  border-radius: 4px;
  object-fit: cover;
  background: #263948;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.75), 0 0 0 2px rgba(94, 217, 179, 0.34);
}

.map-marker.sleeping .marker-avatar {
  border-color: rgba(223, 166, 95, 0.95);
  filter: saturate(0.72);
}

.marker-label {
  position: absolute;
  top: 32px;
  left: 50%;
  max-width: 150px;
  overflow: hidden;
  padding: 3px 6px;
  border: 1px solid rgba(239, 246, 251, 0.17);
  border-radius: 3px;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(4, 11, 15, 0.88);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-stack-count {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 1px solid rgba(239, 246, 251, 0.8);
  border-radius: 9px;
  color: #07141a;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
}

.map-marker.spider-open .marker-stack-count { display: none; }

.map-marker:hover { z-index: 5; }
.map-marker:hover .marker-avatar { border-color: var(--accent); transform: scale(1.12); }
.map-marker:hover .marker-label { color: var(--accent); }

.map-empty {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  align-content: center;
  gap: 7px;
  color: #dce7ef;
  background: rgba(4, 14, 19, 0.72);
  text-align: center;
  pointer-events: none;
}

.map-empty.visible { display: grid; }
.map-empty strong { font-size: 14px; }
.map-empty span { color: var(--muted); font-size: 11px; }

.empty-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--accent);
  font-size: 24px;
}

.map-toolbar {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 20;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: rgba(8, 19, 25, 0.9);
  box-shadow: var(--shadow);
}

.map-control {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.map-control:last-child { border-bottom: 0; }
.map-control:hover { color: var(--accent); background: var(--accent-soft); }
.map-control:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.reset-control { color: var(--muted); font-size: 18px; }

.map-live-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(94, 217, 179, 0.35);
  border-radius: 4px;
  color: var(--accent);
  background: rgba(8, 19, 25, 0.88);
  box-shadow: var(--shadow);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.map-live-badge span,
.legend-dot,
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(94, 217, 179, 0.85);
}

.map-help {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: rgba(237, 243, 248, 0.7);
  background: rgba(6, 15, 20, 0.82);
  font-size: 10px;
  pointer-events: none;
}

.map-footer {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 260px);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: rgba(6, 15, 20, 0.84);
  box-shadow: var(--shadow);
  font-size: 10px;
  pointer-events: none;
}

.legend-item {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  color: #b9c6d1;
}

.map-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #0d1821, var(--sidebar) 45%);
  box-shadow: -12px 0 35px rgba(0, 0, 0, 0.24);
}

.topbar {
  flex: 0 0 auto;
  padding: 23px 22px 19px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 41px;
  height: 41px;
  flex: 0 0 auto;
  border: 1px solid rgba(94, 217, 179, 0.45);
  border-radius: 5px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 23px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.17em;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
}

.server-status .status-dot {
  background: var(--sleeping);
  box-shadow: 0 0 10px rgba(223, 166, 95, 0.68);
}

.server-status.online { color: var(--accent); }
.server-status.online .status-dot { background: var(--accent); box-shadow: 0 0 10px rgba(94, 217, 179, 0.85); }
.server-status.offline { color: var(--danger); }
.server-status.offline .status-dot { background: var(--danger); box-shadow: 0 0 10px rgba(226, 115, 124, 0.72); }

.sidebar-section {
  flex: 0 0 auto;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.server-count {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 3px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-size: 10px;
}

.server-picker {
  display: block;
  margin-top: 13px;
}

.server-picker select {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text);
  background: var(--sidebar-raised);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.server-picker select:focus {
  outline: 2px solid rgba(94, 217, 179, 0.55);
  outline-offset: 2px;
}

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.summary-number {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 38px;
  font-weight: 720;
  letter-spacing: -0.075em;
  line-height: 0.9;
}

.summary-number small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.summary-copy {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.player-card {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  padding-right: 8px;
  padding-bottom: 8px;
}

.player-heading {
  flex: 0 0 auto;
  padding-right: 12px;
  padding-bottom: 10px;
}

.player-list {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 1px;
  overflow-y: auto;
  padding-right: 4px;
}

.player-list::-webkit-scrollbar { width: 5px; }
.player-list::-webkit-scrollbar-track { background: transparent; }
.player-list::-webkit-scrollbar-thumb { border-radius: 8px; background: rgba(185, 205, 220, 0.2); }

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 3px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.player-row:hover,
.player-row.selected { background: var(--accent-soft); }

.player-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  object-fit: cover;
  background: #263948;
}

.player-info {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.player-name {
  overflow: hidden;
  font-size: 11px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-position {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.player-state { color: var(--accent); font-size: 8px; }
.player-state.sleeping { color: var(--sleeping); }
.list-empty { padding: 26px 10px; color: var(--muted); font-size: 10px; text-align: center; }

.sidebar-footer {
  flex: 0 0 auto;
  padding: 13px 20px 15px;
  border-top: 1px solid var(--border);
  color: #627180;
  font-size: 9px;
}

.sidebar-footer > p { margin: 8px 0 0; }

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.privacy-note p { margin: 0; line-height: 1.45; }
.privacy-icon { color: var(--accent); font-size: 15px; line-height: 1; }

@media (max-width: 820px) {
  body { overflow: auto; }

  .app-shell,
  .content-grid { height: auto; min-height: 100%; }

  .content-grid {
    grid-template-columns: 1fr;
    grid-template-rows: min(68dvh, 720px) auto;
  }

  .map-card { min-height: 420px; }

  .sidebar {
    min-height: 520px;
    overflow: visible;
    border-top: 1px solid var(--border-strong);
    border-left: 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
  }

  .player-card { max-height: 430px; }
  .player-list { max-height: 340px; }
}

@media (max-width: 520px) {
  .content-grid { grid-template-rows: 62dvh auto; }
  .map-card { min-height: 360px; }
  .map-toolbar { top: 12px; left: 12px; }
  .map-control { width: 37px; height: 37px; }
  .map-live-badge { top: 12px; right: 12px; }
  .map-help { display: none; }
  .map-footer { right: 12px; bottom: 12px; left: 12px; max-width: none; }
  .map-meta { flex: 1; }
  .marker-visual { width: 24px; height: 24px; }
  .marker-label { top: 28px; max-width: 110px; font-size: 9px; }
  .topbar { padding: 20px 18px 17px; }
  .sidebar-section { padding-right: 18px; padding-left: 18px; }
  .sidebar-footer { padding-right: 18px; padding-left: 18px; }
}
