* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; width: 100%; overflow: hidden; font-family: 'Segoe UI', system-ui, sans-serif; }
#map { width: 100%; height: 100%; background: #1a1810; }

.page-load-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.page-load-overlay.ready {
  pointer-events: none;
  animation: fade-out-overlay 2s ease-out forwards;
}
.page-load-nineball {
  animation: nineball-bounce 0.6s ease-in-out infinite;
}
.page-load-nineball img {
  display: block;
  width: 64px;
  height: auto;
}
@keyframes nineball-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-24px); }
}
@keyframes fade-out-overlay {
  to { opacity: 0; }
}
.top-center-bar {
  position: fixed;
  top: 24px;
  left: calc(24px + min(380px, 85vw));
  right: calc(24px + var(--right-panel-width, min(220px, 28vw)));
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.top-bar-btn {
  display: inline-block;
  padding: 10px 18px;
  background: rgba(26, 24, 16, 0.95);
  border: 1px solid #4a4228;
  border-radius: 8px;
  color: #e6b800;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.top-bar-btn:hover {
  background: rgba(74, 66, 40, 0.4);
  border-color: #e6b800;
  color: #f0c820;
}
.top-center-logo {
  pointer-events: auto;
  cursor: default;
}
.top-center-logo img {
  height: 96px;
  width: auto;
  display: block;
  transition: transform 0.1s ease-out;
}
.top-center-logo:hover img {
  animation: logo-wiggle 0.5s ease-in-out;
}
@keyframes logo-wiggle {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-6deg); }
  30% { transform: rotate(5deg); }
  45% { transform: rotate(-4deg); }
  60% { transform: rotate(3deg); }
  75% { transform: rotate(-2deg); }
}
.top-left-panel {
  position: fixed;
  top: 24px;
  left: 24px;
  width: min(380px, 85vw);
  z-index: 1000;
}
.top-left-panel .segment-legend { width: 100%; box-sizing: border-box; }
.peers-detail-overlay {
  display: none;
  position: fixed;
  top: 24px;
  left: calc(24px + min(380px, 85vw) + 8px);
  width: min(380px, 85vw);
  max-height: calc(100vh - 48px);
  background: rgba(26, 24, 16, 0.97);
  border: 1px solid #4a4228;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 1001;
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.peers-detail-overlay:hover {
  border-color: rgba(230, 184, 0, 0.5);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(230, 184, 0, 0.25), 0 0 12px rgba(230, 184, 0, 0.35), 0 0 24px rgba(230, 184, 0, 0.2), 0 0 40px rgba(230, 184, 0, 0.1);
}
.peers-detail-overlay.visible { display: block; }
.peers-detail-header {
  padding: 12px 16px;
  background: rgba(230, 184, 0, 0.12);
  border-bottom: 1px solid #4a4228;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.peers-detail-header h2 { color: #e6b800; font-size: 1rem; font-weight: 600; }
.peers-detail-body {
  padding: 12px 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  font-size: 0.8rem;
  color: #c4b896;
}
.peers-detail-body .peer-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(74, 66, 40, 0.5);
}
.peers-detail-body .peer-row:last-child { border-bottom: none; }
.peers-detail-body .peer-as { font-weight: 600; color: #e6b800; min-width: 4em; }
.peers-detail-body .peer-name { flex: 1; min-width: 0; color: #d4c89c; }
.peers-detail-body .peer-links { display: flex; gap: 8px; }
.peers-detail-body .peer-links a { color: #8a9bab; text-decoration: none; }
.peers-detail-body .peer-links a:hover { color: #e6b800; }
.top-right-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  width: var(--right-panel-width, min(220px, 28vw));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
:root {
  --right-panel-width: min(220px, 28vw);
}
.bottom-right-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: var(--right-panel-width);
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: stretch;
  max-width: 100%;
  box-sizing: border-box;
}
.bottom-right-panel .segment-legend {
  width: 100%;
}
.pop-peers-panel { flex-shrink: 0; }
.pop-peers-list {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #a89868;
  line-height: 1.5;
}
.pop-peers-list .pop-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid rgba(74, 66, 40, 0.5);
}
.pop-peers-list .pop-item:last-child { border-bottom: none; }
.pop-peers-list .pop-item { cursor: pointer; }
.pop-peers-list .pop-item:hover { background: rgba(74, 66, 40, 0.4); }
.pop-peers-list .pop-item.highlighted { background: rgba(230, 184, 0, 0.2); color: #e6b800; }
.pop-peers-list .pop-item.highlighted .pop-name { color: #e6b800; }
.pop-peers-list .pop-name { color: #d4c89c; flex: 1; min-width: 0; padding-left: 8px; }
.pop-peers-list .pop-count { color: #e6b800; font-weight: 600; flex-shrink: 0; }
.pop-peers-list .loading, .pop-peers-list .error { font-style: italic; color: #8a9bab; }
.city-insets-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.city-inset {
  flex: 0 0 auto;
  padding: 10px 12px;
  background: rgba(26, 24, 16, 0.95);
  border: 1px solid #4a4228;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.city-inset:hover {
  border-color: rgba(230, 184, 0, 0.5);
  box-shadow: 0 0 0 1px rgba(230, 184, 0, 0.25), 0 0 12px rgba(230, 184, 0, 0.35), 0 0 24px rgba(230, 184, 0, 0.2), 0 0 40px rgba(230, 184, 0, 0.1);
}
.city-inset-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e6b800;
  margin-bottom: 6px;
}
.city-inset-map {
  height: 120px;
  width: 100%;
  border-radius: 6px;
  background: #1a1810;
  overflow: hidden;
}
.city-insets-panel .leaflet-tile-pane { filter: brightness(0.9) contrast(1.05) saturate(0.8) sepia(0.08); }
.city-insets-panel .leaflet-control-zoom { display: none !important; }
.leaflet-tile-pane { filter: brightness(0.9) contrast(1.05) saturate(0.8) sepia(0.08); }
.leaflet-control-zoom { display: none !important; }
.leaflet-control-attribution {
  background: rgba(26, 24, 16, 0.9) !important;
  color: #a89868 !important;
  font-size: 0.7rem !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  border: 1px solid #4a4228 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}
.leaflet-control-attribution a {
  color: #e6b800 !important;
}
.leaflet-control-attribution a:hover {
  color: #f0c820 !important;
}
.leaflet-marker-shadow { display: none !important; }
.leaflet-div-icon,
.leaflet-div-icon.pop-marker-wrap,
.pop-marker-wrap {
  background: none !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}
.pop-marker-wrap {
  overflow: hidden;
  border-radius: 50%;
}
.pop-marker {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  display: block;
}
.pop-marker img {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: block;
  border: none !important;
  outline: none !important;
  background: transparent !important;
}
.pop-marker:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
}
.pop-marker-wrap.marker-highlighted .pop-marker {
  transform: scale(1.2);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}
.leaflet-div-icon.konami-nineball-wrap,
.konami-nineball-wrap {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.konami-nineball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: block;
  filter: drop-shadow(0 0 6px rgba(230, 184, 0, 0.8));
}
.konami-nineball img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
}
.overlay-panel {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, 90vw);
  max-height: 80vh;
  background: linear-gradient(160deg, #2a2618 0%, #1a1810 100%);
  border: 1px solid #4a4228;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(230, 184, 0, 0.15);
  z-index: 9999;
  overflow: hidden;
  animation: overlayIn 0.25s ease-out;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.overlay-panel:hover {
  border-color: rgba(230, 184, 0, 0.5);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(230, 184, 0, 0.25), 0 0 12px rgba(230, 184, 0, 0.35), 0 0 24px rgba(230, 184, 0, 0.2), 0 0 40px rgba(230, 184, 0, 0.1);
}
.overlay-panel.visible { display: block; }
.overlay-panel.overlay-panel--link {
  position: relative;
  top: auto; right: auto; left: auto; bottom: auto;
  transform: none;
  order: 1;
  width: 100%;
  max-height: 40vh;
}
.overlay-panel.overlay-panel--link .overlay-body { max-height: 30vh; }
@keyframes overlayIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
.overlay-panel.overlay-panel--link.visible {
  animation: overlayInLink 0.2s ease-out;
}
@keyframes overlayInLink {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.overlay-header {
  padding: 16px 20px;
  background: rgba(230, 184, 0, 0.12);
  border-bottom: 1px solid #4a4228;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.overlay-header h2 { color: #e6b800; font-size: 1.25rem; font-weight: 600; }
.overlay-link-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
}
.overlay-link-title #link-overlay-title-main {
  color: #e6b800;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overlay-link-subtitle {
  color: #c4b896;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overlay-close {
  width: 32px; height: 32px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #b8a84a;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}
.overlay-close:hover { background: rgba(230, 184, 0, 0.2); color: #e6b800; }
.overlay-body {
  padding: 20px;
  color: #c4b896;
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}
.overlay-body p { margin-bottom: 0.75em; }
.overlay-body p:last-child { margin-bottom: 0; }
.pop-overlay-logo {
  margin-bottom: 12px;
}
.pop-overlay-logo img {
  display: block;
  max-height: 48px;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.pop-overlay-address {
  color: #c4b896;
  font-size: 0.9rem;
}
.overlay-body table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.overlay-body th, .overlay-body td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #3a3520; }
.overlay-body th { color: #e6b800; font-weight: 600; font-size: 0.85em; }
.overlay-body td { color: #d4c89c; }
.link-overlay-graph-wrap {
  width: 100%;
  margin-top: 8px;
  background: rgba(20, 18, 12, 0.6);
  border-radius: 8px;
  padding: 8px;
  box-sizing: border-box;
}
.link-overlay-graph-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 4px;
}
.link-pill-wrap {
  display: flex !important;
  justify-content: center;
  align-items: center;
  width: 72px;
  height: 20px;
  background: none !important;
  border: none !important;
  pointer-events: none;
  overflow: visible;
}
.link-pill {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(26, 24, 16, 0.95);
  border: 1px solid #4a4228;
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 600;
  color: #e6b800;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transform-origin: 50% 50%;
}
.link-pill-fade-in {
  opacity: 0;
  animation: linkPillFadeIn 2s ease-out forwards;
}
@keyframes linkPillFadeIn {
  to { opacity: 1; }
}
#map.link-loading .leaflet-overlay-pane path {
  stroke: rgba(255, 255, 255, 1);
  stroke-dasharray: 20 10;
  animation: linkWave 0.35s linear infinite, linkPulse 0.35s ease-in-out infinite;
}
@keyframes linkWave {
  to { stroke-dashoffset: -30; }
}
@keyframes linkPulse {
  0%, 100% { stroke-opacity: 0.35; }
  50% { stroke-opacity: 1; }
}
.bottom-left-panel {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: min(380px, 85vw);
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: stretch;
}
.segment-legend {
  padding: 12px 16px;
  background: rgba(26, 24, 16, 0.95);
  border: 1px solid #4a4228;
  border-radius: 10px;
  font-size: 0.8rem;
  color: #a89868;
  width: 100%;
  box-sizing: border-box;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.segment-legend:hover {
  border-color: rgba(230, 184, 0, 0.5);
  box-shadow: 0 0 0 1px rgba(230, 184, 0, 0.25), 0 0 12px rgba(230, 184, 0, 0.35), 0 0 24px rgba(230, 184, 0, 0.2), 0 0 40px rgba(230, 184, 0, 0.1);
}
.segment-legend .title { color: #e6b800; margin-bottom: 6px; font-weight: 600; }
.segment-legend .scale-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgb(255, 248, 180), rgb(255, 120, 0));
  margin-top: 6px;
}
.segment-legend .scale-labels { display: flex; justify-content: space-between; width: 100%; margin-top: 2px; }
.traffic-graph-legend .title { margin-bottom: 4px; }
.traffic-graph-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 6px;
  align-items: center;
}
.traffic-graph-controls--single-line {
  flex-wrap: nowrap;
  gap: 0 2px;
  margin-top: 4px;
}
.traffic-graph-controls--single-line .traffic-links { flex-shrink: 0; gap: 0 2px; }
.traffic-graph-controls--single-line .traffic-link { padding: 2px 4px; font-size: 0.75rem; }
.traffic-sep { color: #6a6240; font-size: 0.7rem; padding: 0 1px; user-select: none; }
.traffic-control-label { font-size: 0.75rem; color: #a89868; }
.traffic-links { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.traffic-graph-legend-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.traffic-graph-legend-head .title { margin-bottom: 0; }
.traffic-realtime-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(26, 24, 16, 0.95);
  border: 1px solid #4a4228;
  color: #e6b800;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}
.traffic-realtime-pill:hover { border-color: rgba(230, 184, 0, 0.5); }
.traffic-link {
  padding: 2px 8px;
  background: none;
  border: none;
  color: #8a9bab;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  border-radius: 4px;
}
.traffic-link:hover { color: #d4c89c; text-decoration: underline; }
.traffic-link.active { color: #e6b800; font-weight: 600; text-decoration: none; }
.traffic-link.active:hover { text-decoration: underline; }
.traffic-graph-wrap {
  width: 100%;
  margin-top: 6px;
  background: rgba(20, 18, 12, 0.6);
  border-radius: 6px;
  padding: 4px;
  box-sizing: border-box;
}
#traffic-graph-click-wrap { cursor: pointer; }
#traffic-graph-click-wrap:focus { outline: 2px solid rgba(230, 184, 0, 0.5); outline-offset: 2px; }
.traffic-graph {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80px;
  border-radius: 4px;
}
.traffic-graph-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 2px;
  font-size: 0.7rem;
  color: #8a9bab;
}
.traffic-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: calc(24px + min(380px, 85vw));
  right: calc(24px + var(--right-panel-width, min(220px, 28vw)));
  width: min(900px, 95vw);
  max-height: 90vh;
  margin-left: auto;
  margin-right: auto;
  transform: translateY(-50%);
  z-index: 10000;
  overflow: visible;
}
.traffic-modal.visible { display: block; animation: overlayInTraffic 0.25s ease-out; }
@keyframes overlayInTraffic {
  from { opacity: 0; transform: translateY(-48%); }
  to { opacity: 1; transform: translateY(-50%); }
}
.traffic-modal .overlay-header { padding: 12px 16px; }
.traffic-modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(90vh - 60px);
}
.traffic-modal-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-bottom: 12px;
}
.traffic-modal-controls .traffic-control-label { font-size: 0.85rem; }
.traffic-modal-controls .traffic-link { font-size: 0.9rem; padding: 4px 10px; }
.traffic-zoom-reset {
  padding: 6px 12px;
  background: rgba(230, 184, 0, 0.15);
  border: 1px solid #4a4228;
  border-radius: 6px;
  color: #e6b800;
  font-size: 0.85rem;
  cursor: pointer;
}
.traffic-zoom-reset:hover { background: rgba(230, 184, 0, 0.25); }
.traffic-modal-graph-wrap {
  position: relative;
  width: 100%;
  background: rgba(20, 18, 12, 0.6);
  border-radius: 8px;
  padding: 8px;
  box-sizing: border-box;
  margin-bottom: 6px;
}
.traffic-graph-wrap.loading,
.traffic-modal-graph-wrap.loading {
  position: relative;
}
.traffic-graph-wrap.loading::after,
.traffic-modal-graph-wrap.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0, rgba(230, 184, 0, 0.20), transparent 60%);
  pointer-events: none;
  animation: traffic-loading 1s linear infinite;
}
@keyframes traffic-loading {
  0% { opacity: 0.2; }
  50% { opacity: 0.5; }
  100% { opacity: 0.2; }
}
.traffic-modal-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 4px;
  cursor: crosshair;
}
.traffic-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 6px 10px;
  background: rgba(26, 24, 16, 0.98);
  border: 1px solid #4a4228;
  border-radius: 6px;
  color: #e6b800;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.traffic-tooltip[aria-hidden="true"] {
  display: none;
}
.traffic-tooltip[aria-hidden="false"] {
  display: block;
}
.traffic-tooltip--mini {
  font-size: 0.7rem;
  padding: 4px 6px;
}
#traffic-graph-tooltip {
  position: fixed;
  z-index: 10001;
}
.traffic-graph-wrap { position: relative; }
.leaflet-interactive { cursor: pointer; }
