:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html, body, #map {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
html, body {
  height: 100dvh;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body { background: #111; }
#map {
  display: block;
  image-rendering: pixelated;
  cursor: grab;
  touch-action: none;
}
#map.dragging { cursor: grabbing; }
#toolbar {
  position: fixed;
  z-index: 20;
  top: max(14px, var(--safe-top));
  left: max(14px, var(--safe-left));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #171717e8;
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 4px 18px #0008;
}
#toolbar strong {
  color: #f5be32;
  margin-right: 3px;
}
#map-controls {
  position: fixed;
  z-index: 21;
  top: max(14px, var(--safe-top));
  right: max(14px, var(--safe-right));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  background: #171717e8;
  border: 1px solid #444;
  border-radius: 10px;
  box-shadow: 0 4px 18px #0008;
}
#map-controls button {
  width: 36px;
  height: 36px;
  min-width: 36px;
}
button, select {
  height: 32px;
  border: 1px solid #555;
  border-radius: 5px;
  background: #292929;
  color: #fff;
  padding: 0 10px;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
button, select { touch-action: manipulation; }
button {
  font-size: 18px;
  min-width: 34px;
  padding: 0 8px;
  cursor: pointer;
}
button:hover:not(:disabled), select:hover { background: #363636; }
button:disabled { cursor: default; }
#coords {
  min-width: 120px;
  color: #ccc;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.player {
  position: fixed;
  z-index: 10;
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.player[hidden] { display: none; }
.pointer {
  position: absolute;
  inset: 0;
  width: 16px;
  height: 16px;
  transform-origin: center;
  image-rendering: pixelated;
}
.off-map { display: none; }
.edge .on-map { display: none; }
.edge .off-map { display: block; }
.player span {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 5px;
  border-radius: 3px;
  background: #111d;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
}
.edge span { display: none; }
#player-panel {
  position: fixed;
  z-index: 19;
  top: 66px;
  left: max(14px, var(--safe-left));
  width: 240px;
  max-height: min(460px, calc(100dvh - 82px - var(--safe-bottom)));
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 8px;
  background: #171717ed;
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 4px 18px #0008;
  -webkit-user-select: auto;
  user-select: auto;
}
#player-panel[hidden] { display: none; }
.panel-title {
  padding: 2px 5px 8px;
  color: #ddd;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.player-entry {
  width: 100%;
  height: auto;
  min-height: 42px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  margin: 0 0 5px;
  padding: 6px 9px;
  text-align: left;
  font-size: 13px;
}
.player-entry span { font-weight: 600; }
.player-entry small {
  color: #aaa;
  font-size: 11px;
}
.player-entry.other-world { opacity: .55; }
.player-entry.unavailable { opacity: .3; }
.no-players {
  padding: 12px 6px;
  color: #888;
  font-size: 12px;
}
#empty {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(18px, calc(var(--safe-bottom) + 8px));
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 5px;
  background: #111b;
  color: #bbb;
  font-size: 12px;
  pointer-events: none;
  text-align: center;
}
@media (max-width: 720px) {
  #toolbar {
    right: max(14px, var(--safe-right));
    flex-wrap: wrap;
  }
  #toolbar strong { display: none; }
  #coords {
    order: 2;
    width: 100%;
    min-width: 0;
  }
  #map-controls {
    top: auto;
    bottom: max(24px, calc(var(--safe-bottom) + 12px));
    gap: 10px;
  }
  #map-controls button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 22px;
  }
  #toolbar button, #toolbar select {
    min-height: 40px;
    height: 40px;
  }
  #player-panel {
    top: 108px;
    right: max(14px, var(--safe-right));
    width: auto;
  }
  #empty {
    left: max(14px, var(--safe-left));
    right: auto;
    transform: none;
    max-width: calc(100% - 110px);
  }
}
