:root {
  color-scheme: dark;
  --bg: #120808;
  --bg-2: #1d0907;
  --panel: rgba(26, 10, 10, 0.84);
  --panel-strong: rgba(35, 12, 11, 0.94);
  --panel-soft: rgba(55, 18, 15, 0.72);
  --stroke: rgba(255, 120, 88, 0.18);
  --stroke-strong: rgba(255, 120, 88, 0.4);
  --text: #fff0ea;
  --muted: #d0a59b;
  --accent: #ff6a3d;
  --accent-dark: #8f2316;
  --accent-warm: #ffb703;
  --danger: #ff6b6b;
  --friend: #8ecae6;
  --layer: #8ecae6;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
  --mono: "IBM Plex Mono", monospace;
  --display: "Chakra Petch", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(255, 106, 61, 0.24), transparent 24%),
    radial-gradient(circle at 85% 12%, rgba(255, 183, 3, 0.18), transparent 18%),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: var(--display);
}

h1,
h2,
h3,
p,
pre {
  margin: 0;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 106, 61, 0.16), transparent 35%),
    linear-gradient(180deg, rgba(3, 10, 14, 0.94), rgba(2, 7, 10, 0.98));
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.boot-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.boot-panel {
  width: min(720px, 100%);
  min-height: 280px;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--stroke-strong);
  background: rgba(2, 18, 24, 0.92);
  box-shadow: var(--shadow);
}

.boot-title,
.boot-log,
.pill,
.label,
input,
textarea,
select,
button,
.value,
.status,
.intro,
.hud-copy,
.friend-item,
.layer-toggle small {
  font-family: var(--mono);
}

.boot-title {
  color: var(--accent);
  letter-spacing: 0.14em;
  font-size: 13px;
}

.boot-log {
  margin-top: 18px;
  white-space: pre-wrap;
  color: #ffd3c6;
  line-height: 1.65;
  min-height: 220px;
}

.page-shell {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  min-height: 100vh;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.page-shell.is-loading {
  opacity: 0.15;
}

.command-panel {
  padding: 28px 22px;
  border-right: 1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(255, 106, 61, 0.08), transparent 14%),
    linear-gradient(180deg, rgba(4, 18, 24, 0.94), rgba(3, 14, 19, 0.92));
  backdrop-filter: blur(22px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  align-items: center;
}

.brand-logo {
  width: 92px;
  height: 92px;
  border-radius: 24px;
  object-fit: cover;
  border: 1px solid var(--stroke-strong);
  box-shadow: 0 0 34px rgba(255, 106, 61, 0.18);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

h1 {
  margin-top: 6px;
  font-size: 40px;
  line-height: 0.96;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intro {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.brand-actions {
  margin-top: 14px;
}

.card {
  padding: 18px;
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(255, 106, 61, 0.06), transparent 24%),
    var(--panel-strong);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.section-head,
.toggle-row,
label,
.friend-item,
.layer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 120, 88, 0.22);
  background: rgba(255, 106, 61, 0.1);
  color: #ffd7ca;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.value {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
}

label {
  align-items: flex-start;
  flex-direction: column;
}

label span {
  font-size: 13px;
  color: var(--text);
}

.toggle-row {
  flex-direction: row;
  align-items: center;
}

input[type="text"],
input[type="number"],
input[type="color"],
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 120, 88, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  padding: 11px 12px;
}

select {
  appearance: none;
  background:
    linear-gradient(180deg, rgba(255, 106, 61, 0.16), rgba(255, 255, 255, 0.04)),
    linear-gradient(45deg, transparent 50%, rgba(255, 214, 202, 0.9) 50%),
    linear-gradient(135deg, rgba(255, 214, 202, 0.9) 50%, transparent 50%),
    rgba(255, 255, 255, 0.04);
  background-position:
    0 0,
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px),
    0 0;
  background-size:
    auto,
    6px 6px,
    6px 6px,
    auto;
  background-repeat: no-repeat;
  padding-right: 36px;
  border-color: rgba(255, 120, 88, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-family: var(--display);
  font-weight: 600;
}

select option {
  background: #2a0d0b;
  color: #fff0ea;
}

textarea {
  resize: vertical;
}

input[type="color"] {
  min-height: 46px;
  padding: 6px;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff8f5;
  background: linear-gradient(135deg, var(--accent), #ff9b6f);
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(143, 35, 22, 0.28);
}

.button.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.button.ghost {
  color: var(--text);
  background: rgba(255, 107, 107, 0.08);
  box-shadow: none;
}

.button.link {
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

.button.external-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.button.small {
  padding: 8px 12px;
  font-size: 12px;
}

.button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  box-shadow: none;
}

.status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.status.error {
  color: #ffb3b3;
}

.account-block,
.stack-form,
.friend-list,
.account-meta,
.admin-entry-list,
.admin-entry-list-block {
  display: grid;
  gap: 12px;
}

.admin-panel {
  padding: 20px;
}

.admin-panel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-panel-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 120, 88, 0.12);
  background: linear-gradient(180deg, rgba(255, 106, 61, 0.04), transparent 28%), var(--panel-soft);
}

.admin-panel-section-wide {
  min-width: 0;
}

.admin-category-delete-block {
  display: grid;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 120, 88, 0.12);
}

.admin-entry-meta {
  align-items: end;
}

.admin-entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 120, 88, 0.12);
  background: var(--panel-soft);
}

.admin-entry-item strong {
  display: block;
  font-size: 13px;
}

.admin-entry-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}

.admin-entry-item .button {
  flex: none;
  min-width: 92px;
}

.account-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.account-name {
  font-size: 24px;
  font-weight: 700;
}

.account-badge {
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 183, 3, 0.12);
  border: 1px solid rgba(255, 183, 3, 0.24);
  color: #ffe3a3;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.section-copy,
.account-copy,
.empty-copy,
.layer-toggle small {
  color: var(--muted);
  line-height: 1.5;
  font-size: 12px;
}

.friend-item,
.layer-toggle {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 120, 88, 0.12);
  background: var(--panel-soft);
}

.friend-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.friend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  background: var(--friend-color, var(--friend));
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--friend-color, var(--friend)) 20%, transparent), 0 0 12px var(--friend-glow, rgba(142, 202, 230, 0.35));
}

.friend-code-inline {
  margin-left: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}

.layer-toggle {
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 10px;
  min-height: 42px;
}

.layer-toggle-name {
  display: inline-block;
  order: 2;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text);
}

.layer-toggle-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 10px;
}

.layer-toggle input {
  order: 1;
  width: 16px;
  height: 16px;
  margin: 0;
}

.layer-toggle input {
  flex: none;
}

.stack-inline {
  display: flex;
  gap: 10px;
}

.stack-inline > * {
  flex: 1;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 2400;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 7, 10, 0.72);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(180deg, rgba(255, 106, 61, 0.08), transparent 24%), var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-actions .button {
  flex: 1;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row .button {
  flex: 1;
}

.is-hidden {
  display: none !important;
}

.map-column {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.map-stage {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-radius: 36px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(255, 106, 61, 0.08), rgba(0, 0, 0, 0.05)),
    rgba(0, 0, 0, 0.35);
  box-shadow: var(--shadow);
  padding: 18px;
}

.map-surface {
  position: relative;
  min-height: calc(85vh - 44px);
  border-radius: 28px;
  overflow: hidden;
  background: rgba(6, 18, 23, 0.42);
}

#map {
  width: 100%;
  height: 100%;
  min-height: calc(85vh - 44px);
}

.map-data-strip {
  padding: 14px 16px;
}

.leaflet-container {
  background: radial-gradient(circle at center, #3a1815, #100504 72%);
  font-family: var(--display);
}

.leaflet-control-zoom {
  border: 1px solid var(--stroke) !important;
  border-radius: 18px !important;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leaflet-control-zoom a {
  background: rgba(6, 18, 23, 0.88) !important;
  color: var(--text) !important;
  border-bottom-color: var(--stroke) !important;
}

.map-hud {
  z-index: 700;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 120, 88, 0.16);
  background: rgba(27, 9, 9, 0.78);
  backdrop-filter: blur(20px);
}

.top-hud {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 18px;
}

.bottom-hud {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  align-items: end;
}

.hud-title {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
}

.hud-copy {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.hud-meta,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.legend span.is-hidden {
  display: none;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.self {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(255, 106, 61, 0.6);
}

.dot.friend {
  background: var(--friend);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.45);
}

.dot.layer {
  background: var(--layer);
}

.gps-guide-line {
  pointer-events: none;
}

.gps-guide-label {
  display: block;
  min-width: 40px;
  padding: 0;
  color: rgba(255, 230, 222, 0.92);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.84);
}

.gps-guide-label.x-axis {
  text-align: center;
}

.gps-guide-label.y-axis {
  min-width: 48px;
  text-align: right;
  transform: translateX(calc(-100% - 10px));
}

.trail-line {
  pointer-events: none;
  animation: trail-flow 1.4s linear infinite;
}

.trail-line.self {
  filter: drop-shadow(0 0 8px rgba(255, 106, 61, 0.4));
}

.trail-line.friend {
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.35));
}

.trail-arrow {
  display: block;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 14px solid var(--arrow-color, var(--accent));
  filter: drop-shadow(0 0 8px var(--arrow-glow, rgba(255, 106, 61, 0.45)));
  transform-origin: 50% 50%;
}

.trail-arrow.friend {
  border-left-color: var(--arrow-color, var(--friend));
  filter: drop-shadow(0 0 8px var(--arrow-glow, rgba(255, 209, 102, 0.42)));
}

@keyframes trail-flow {
  from {
    stroke-dashoffset: 24;
  }

  to {
    stroke-dashoffset: 0;
  }
}

.map-marker {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.78);
}

.map-marker.self {
  background: radial-gradient(circle at 30% 30%, #ffe2d8, var(--marker-color, var(--accent)));
  box-shadow: 0 0 0 8px var(--marker-halo, rgba(255, 106, 61, 0.15)), 0 0 24px var(--marker-glow, rgba(255, 106, 61, 0.32));
}

.map-marker.friend {
  background: radial-gradient(circle at 30% 30%, #fff8d8, var(--marker-color, var(--friend)));
  box-shadow: 0 0 0 8px var(--marker-halo, rgba(255, 209, 102, 0.14)), 0 0 24px var(--marker-glow, rgba(255, 209, 102, 0.28));
}

.map-label {
  background: rgba(27, 9, 9, 0.9);
  color: var(--text);
  border: 1px solid rgba(255, 120, 88, 0.24);
  border-radius: 10px;
  padding: 4px 8px;
  box-shadow: none;
  font-family: var(--mono);
  font-size: 11px;
}

.entity-name-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.entity-name-label::before {
  display: none;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(3, 17, 22, 0.96);
  color: var(--text);
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-family: var(--mono);
}

.leaflet-popup-close-button {
  color: var(--muted) !important;
}

@media (max-width: 1100px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .command-panel {
    border-right: 0;
    border-bottom: 1px solid var(--stroke);
  }

  .map-column {
    padding-top: 0;
  }

  .admin-panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .command-panel,
  .map-column {
    padding: 16px;
  }

  .brand-block {
    grid-template-columns: 72px 1fr;
  }

  .brand-logo {
    width: 72px;
    height: 72px;
  }

  h1 {
    font-size: 34px;
  }

  .map-surface,
  #map {
    min-height: 72vh;
    height: 72vh;
  }

  .map-hud {
    left: 12px;
    right: 12px;
    padding: 12px 14px;
    flex-direction: column;
  }

  .bottom-hud {
    align-items: flex-start;
  }

  .status-grid,
  .button-row,
  .stack-inline {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .layer-toggle {
    min-width: 0;
  }

  .layer-toggle-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .map-column {
    padding: 14px;
  }

  .map-stage {
    padding: 14px;
    gap: 14px;
  }

  .map-surface,
  #map {
    height: 65vh;
    min-height: 65vh;
  }

  .map-hud,
  .brand-block,
  .bottom-hud {
    grid-template-columns: 1fr;
    display: grid;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 34px;
  }

  .brand-block {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
  }
}