/* Realm Striders map chrome — matches mod dashboard tokens */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --rs-primary: #66c0f4;
  --rs-primary-dark: #105ea8;
  --rs-bg: #000000;
  --rs-surface-raised: #0d0d0d;
  --rs-surface-card: #141414;
  --rs-text: #ffffff;
  --rs-text-secondary: rgba(102, 192, 244, 0.7);
  --rs-text-muted: #888888;
  --rs-border: rgba(102, 192, 244, 0.3);
  --rs-border-hover: rgba(102, 192, 244, 0.6);
  --rs-glow: 0 0 20px rgba(102, 192, 244, 0.2);
  --rs-radius: 12px;
  --rs-header-h: 3.25rem;
  --rs-footer-h: 4.5rem;
  --rs-map-inset-top: 52px;
  --rs-map-inset-side: 8px;
  --rs-map-inset-bottom: 10px;
  --rs-sidebar-width: 13.5rem;
}

html,
body.rs-shell {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--rs-bg);
  color: var(--rs-text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}

body.rs-shell {
  display: flex;
  flex-direction: column;

  /* Pl3xMap UI theme — force RS dark palette (overrides prefers-color-scheme) */
  --ui-font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-button-size: 4.2rem;
  --ui-element-spacing: 0.75rem;
  --ui-border-radius: 12px;
  --ui-border: 1px solid rgba(102, 192, 244, 0.3);
  --ui-text-shadow: none;
  --ui-outline: 2px solid #66c0f4;
  --ui-box-shadow: 0 0 16px rgba(102, 192, 244, 0.18);
  --ui-background: rgba(13, 13, 13, 0.94);
  --ui-background-disabled: #333333;
  --ui-background-hover: rgba(102, 192, 244, 0.14);
  --ui-background-active: rgba(102, 192, 244, 0.22);
  --ui-background-selected: rgba(102, 192, 244, 0.28);
  --ui-text: rgba(255, 255, 255, 0.88);
  --ui-text-hover: #ffffff;
  --ui-text-active: #ffffff;
  --ui-text-selected: #66c0f4;
  --ui-text-disabled: rgba(255, 255, 255, 0.35);
  --ui-sidebar-width: var(--rs-sidebar-width);
}

#rs-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--rs-surface-raised);
  border-bottom: 1px solid var(--rs-border);
  box-shadow: var(--rs-glow);
  z-index: 2000;
}

#rs-header .rs-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

#rs-header .rs-brand img {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
}

#rs-header .rs-brand-text {
  min-width: 0;
}

#rs-header .rs-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
}

#rs-header .rs-subtitle {
  margin: 0;
  font-size: 0.7rem;
  color: var(--rs-text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#rs-header nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rs-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.rs-pill:hover,
.rs-pill:focus-visible {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.07);
  color: var(--rs-text);
  outline: none;
}

.rs-dropdown {
  position: relative;
}

.rs-dropdown > summary {
  list-style: none;
}

.rs-dropdown > summary::-webkit-details-marker {
  display: none;
}

.rs-dropdown[open] > summary {
  border-color: var(--rs-border);
  background: rgba(102, 192, 244, 0.12);
  color: var(--rs-primary);
}

.rs-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 14rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--rs-surface-card);
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-glow);
  z-index: 2100;
}

.rs-dropdown-menu a {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: var(--rs-text);
  text-decoration: none;
  font-size: 0.8rem;
}

.rs-dropdown-menu a small {
  display: block;
  margin-top: 0.15rem;
  color: var(--rs-text-muted);
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: normal;
}

.rs-dropdown-menu a:hover,
.rs-dropdown-menu a:focus-visible {
  background: rgba(102, 192, 244, 0.12);
  color: var(--rs-primary);
  outline: none;
}

#rs-map-frame {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--rs-border);
  border-right: 1px solid var(--rs-border);
  box-shadow: inset 0 0 30px rgba(102, 192, 244, 0.06);
}

/* Premium top-center coordinates HUD */
#rs-coords-bar {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1600;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  animation: rsCoordsDrop 0.45s ease-out both;
}

@keyframes rsCoordsDrop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #rs-coords-bar {
    animation: none;
  }
}

.rs-coords-hanger {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.rs-coords-anchor {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rs-primary);
  box-shadow: 0 0 10px rgba(102, 192, 244, 0.65);
}

.rs-coords-strap {
  display: block;
  width: 2px;
  height: 10px;
  background: linear-gradient(
    180deg,
    rgba(102, 192, 244, 0.85) 0%,
    rgba(102, 192, 244, 0.25) 100%
  );
  border-radius: 1px;
}

.rs-coords-panel {
  min-width: 15rem;
  padding: 0.45rem 0.85rem 0.55rem;
  background: linear-gradient(
    180deg,
    rgba(20, 20, 20, 0.97) 0%,
    rgba(13, 13, 13, 0.94) 100%
  );
  border: 1px solid var(--rs-border);
  border-top: 1px solid rgba(102, 192, 244, 0.45);
  border-radius: 0 0 12px 12px;
  box-shadow:
    var(--rs-glow),
    inset 0 1px 0 rgba(102, 192, 244, 0.08);
  backdrop-filter: blur(8px);
}

.rs-coords-label {
  display: block;
  text-align: center;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rs-text-secondary);
  margin-bottom: 0.3rem;
}

.rs-coords-axes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  align-items: center;
}

.rs-coords-axis {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0 0.5rem;
  border-right: 1px solid rgba(102, 192, 244, 0.15);
}

.rs-coords-axis:last-child {
  border-right: none;
}

.rs-coords-key {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rs-text-muted);
}

.rs-coords-value {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--rs-primary);
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
  text-align: center;
}

/* Contain Pl3xMap inside the middle pane (not 100vh) */
body.rs-shell #rs-map-frame #map,
body.rs-shell #rs-map-frame #map.map,
body.rs-shell #rs-map-frame .map,
body.rs-shell #rs-map-frame .leaflet-container {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  background: #000000 !important;
}

body.rs-shell #rs-map-frame .leaflet-control-container {
  position: absolute;
  inset: 0;
  padding: var(--rs-map-inset-top) var(--rs-map-inset-side) var(--rs-map-inset-bottom);
  box-sizing: border-box;
  pointer-events: none;
}

body.rs-shell #rs-map-frame .leaflet-control-container * {
  pointer-events: auto;
}

/* Pl3xMap sidebar — compact floating panel (all viewports) */
body.rs-shell #sidebar {
  position: relative;
  overflow: visible;
  transform: none !important;
  transition: none;
}

body.rs-shell #sidebar.sidebar--expanded {
  transform: none !important;
}

body.rs-shell #sidebar #sidebar__buttons {
  position: relative;
  z-index: 1710;
}

body.rs-shell #sidebar #sidebar__content {
  position: absolute !important;
  top: 0 !important;
  left: calc(var(--ui-button-size) + 0.35rem) !important;
  right: auto !important;
  width: var(--rs-sidebar-width) !important;
  max-width: calc(100% - var(--ui-button-size) - 1rem) !important;
  height: auto !important;
  max-height: min(65%, 18rem) !important;
  padding: 0.55rem 0.7rem !important;
  margin: 0 !important;
  background: var(--rs-surface-card) !important;
  border: 1px solid var(--rs-border) !important;
  border-radius: var(--rs-radius) !important;
  box-shadow: var(--rs-glow);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1700;
  font-size: 0.8rem;
  transition: none;
}

body.rs-shell #sidebar #sidebar__content h2 {
  margin: 0 0 0.35rem;
  color: var(--rs-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
}

body.rs-shell #sidebar #sidebar__content h3 {
  margin: 0 0 0.3rem;
  color: var(--rs-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
}

body.rs-shell #sidebar #sidebar__content legend {
  font-size: 0.68rem;
  color: var(--rs-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

body.rs-shell #sidebar #sidebar__content .menu input + label {
  margin-bottom: 0.35rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.78rem;
  line-height: 1.3;
  border-radius: 8px;
}

body.rs-shell #sidebar #sidebar__content .menu input.renderer + label {
  width: 28px;
  height: 28px;
  margin: 0 0.25rem 0 0;
  padding: 0;
  border-radius: 8px;
}

body.rs-shell #sidebar #sidebar__content fieldset fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
}

body.rs-shell #rs-map-frame.rs-sidebar-open::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 1650;
  pointer-events: none;
}

#rs-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--rs-surface-raised);
  border-top: 1px solid var(--rs-border);
  box-shadow: var(--rs-glow);
  z-index: 2000;
}

.rs-stat {
  flex: 1 1 8rem;
  min-width: 7rem;
  padding: 0.45rem 0.65rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--rs-border);
  border-radius: 10px;
}

.rs-stat-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rs-text-secondary);
}

.rs-stat-value {
  display: block;
  margin-top: 0.15rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--rs-primary);
  line-height: 1.2;
}

.rs-stat-value.rs-loading {
  color: var(--rs-text-muted);
}

.rs-stat-value.rs-error {
  color: #ff8888;
}

#rs-tournament-slot {
  flex: 1 1 12rem;
  min-width: 10rem;
  padding: 0.45rem 0.65rem;
  background: linear-gradient(135deg, rgba(102, 192, 244, 0.08) 0%, rgba(16, 94, 168, 0.12) 100%);
  border: 1px solid var(--rs-border);
  border-radius: 10px;
}

#rs-tournament-slot .rs-stat-label {
  color: var(--rs-primary);
}

#rs-tournament-slot a {
  color: var(--rs-text);
  text-decoration: none;
}

#rs-tournament-slot a:hover {
  color: var(--rs-primary);
}

#rs-footer .rs-credit {
  flex: 1 1 100%;
  margin: 0;
  padding-top: 0.15rem;
  font-size: 0.62rem;
  color: var(--rs-text-muted);
  text-align: center;
}

/* Pl3xMap control theming */
body.rs-shell .menu input + label,
body.rs-shell button,
body.rs-shell .leaflet-control-button,
body.rs-shell #sidebar #sidebar__buttons button,
body.rs-shell .leaflet-bar a {
  box-shadow: var(--ui-box-shadow);
  font-family: var(--ui-font);
}

body.rs-shell .menu input:checked + label,
body.rs-shell .menu input[aria-pressed="true"] + label,
body.rs-shell button[aria-pressed="true"],
body.rs-shell .menu input.renderer:checked + label {
  box-shadow: var(--rs-glow);
  border-color: var(--rs-border-hover) !important;
}

body.rs-shell .leaflet-control-coordinates {
  visibility: hidden !important;
  position: absolute !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.rs-shell .leaflet-control-blockinfo {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.2rem !important;
  color: var(--rs-text) !important;
  background: rgba(13, 13, 13, 0.94) !important;
  border: 1px solid var(--rs-border) !important;
  border-radius: 10px !important;
  box-shadow: var(--rs-glow);
  padding: 0.5rem 0.75rem !important;
}

body.rs-shell .leaflet-control-link {
  box-shadow: var(--rs-glow);
}

body.rs-shell .leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.72) !important;
  color: var(--rs-text-muted) !important;
  border: 1px solid rgba(102, 192, 244, 0.15) !important;
  border-radius: 6px !important;
  font-size: 1rem !important;
}

body.rs-shell .leaflet-control-attribution a,
body.rs-shell .leaflet-control-attribution a:visited,
body.rs-shell .leaflet-control-attribution a:hover {
  color: var(--rs-primary) !important;
}

body.rs-shell .leaflet-popup-content-wrapper,
body.rs-shell .leaflet-tooltip {
  background: var(--rs-surface-card) !important;
  color: var(--rs-text) !important;
  border: 1px solid var(--rs-border) !important;
  border-radius: 10px !important;
  box-shadow: var(--rs-glow);
}

body.rs-shell .leaflet-popup-tip {
  background: var(--rs-surface-card) !important;
  border: 1px solid var(--rs-border);
}

/* Touch pan coachmark (shown via JS on touch/narrow viewports) */
#rs-touch-hint {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1550;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
}

#rs-touch-hint.rs-touch-hint-visible {
  pointer-events: auto;
}

.rs-touch-hint-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  max-width: 14rem;
  padding: 1rem 1.1rem 0.85rem;
  text-align: center;
  background: linear-gradient(
    180deg,
    rgba(20, 20, 20, 0.97) 0%,
    rgba(13, 13, 13, 0.94) 100%
  );
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius);
  box-shadow: var(--rs-glow);
  backdrop-filter: blur(8px);
}

.rs-touch-hint-icon {
  color: var(--rs-primary);
  animation: rsTouchHintPulse 2s ease-in-out infinite;
}

@keyframes rsTouchHintPulse {
  0%,
  100% {
    opacity: 0.85;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.rs-touch-hint-text {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--rs-text);
}

.rs-touch-hint-dismiss {
  margin-top: 0.15rem;
  border: 1px solid var(--rs-border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rs-primary);
  background: rgba(102, 192, 244, 0.1);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.rs-touch-hint-dismiss:hover,
.rs-touch-hint-dismiss:focus-visible {
  background: rgba(102, 192, 244, 0.18);
  border-color: var(--rs-border-hover);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .rs-touch-hint-icon {
    animation: none;
  }
}

@media (max-width: 640px) {
  #rs-header {
    flex-wrap: wrap;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  #rs-header .rs-subtitle {
    display: none;
  }

  #rs-coords-bar .rs-coords-hanger {
    display: none;
  }

  #rs-coords-bar .rs-coords-panel {
    min-width: auto;
    max-width: calc(100vw - 5rem);
    padding: 0.3rem 0.55rem 0.35rem;
    border-radius: 10px !important;
    border-top: 1px solid var(--rs-border) !important;
  }

  #rs-coords-bar .rs-coords-label {
    font-size: 0.5rem;
    margin-bottom: 0.15rem;
    letter-spacing: 0.08em;
  }

  #rs-coords-bar .rs-coords-axes {
    grid-template-columns: repeat(3, auto);
    gap: 0.35rem;
  }

  #rs-coords-bar .rs-coords-axis {
    flex-direction: row;
    gap: 0.2rem;
    padding: 0 0.25rem;
    border-right: none;
  }

  #rs-coords-bar .rs-coords-key {
    font-size: 0.5rem;
  }

  #rs-coords-bar .rs-coords-value {
    font-size: 0.75rem;
    min-width: 2.5ch;
  }

  body.rs-shell {
    --ui-button-size: 3.25rem;
    --ui-element-spacing: 0.5rem;
    --rs-sidebar-width: min(13rem, calc(100vw - 4.5rem));
  }

  body.rs-shell #sidebar #sidebar__content {
    top: 0.15rem !important;
    max-height: min(70%, 16rem) !important;
    font-size: 0.78rem;
  }

  #rs-touch-hint.rs-touch-hint-visible {
    display: flex;
  }
}

@media (hover: none) {
  #rs-touch-hint.rs-touch-hint-visible {
    display: flex;
  }
}

/* Player marker stability — markers must not animate while Leaflet runs its
   zoom transform (each marker is repositioned individually, which the players
   layer's `transition: all 0.25s` would otherwise animate as a visible slide).
   Normal walking animation between live updates is untouched; large-jump
   re-syncs/teleports are handled by the jump-guard in realm-striders.js. */
body.rs-shell .leaflet-zoom-anim div.leaflet-nameplates-pane div,
body.rs-shell .leaflet-zoom-anim div.leaflet-marker-pane img {
  transition: none !important;
}
