/* ============================================================
   LIVE / follower view
   ============================================================ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(340px, 1fr);
  gap: 14px;
  align-items: start;
}

/* ------------------------------------------------------------ map */
.map-card {
  position: sticky;
  top: 74px;
  height: min(680px, calc(100vh - 96px));
  min-height: 420px;
  overflow: hidden;
  padding: 0;
  background: #0a0f13;
}

#map {
  position: absolute;
  inset: 0;
  background: #0a0f13;
  z-index: 0;
}

.map-top,
.map-bottom {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px;
  pointer-events: none;
}

.map-top {
  top: 0;
  background: linear-gradient(180deg, rgba(5, 7, 9, 0.82), transparent);
}

.map-bottom {
  bottom: 0;
  align-items: flex-end;
  background: linear-gradient(0deg, rgba(5, 7, 9, 0.8), transparent);
  padding-bottom: 14px;
}

.map-top > *,
.map-bottom > * {
  pointer-events: auto;
}

.map-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pill.name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 3px;
  max-width: 260px;
  color: #e6ece9;
  font-weight: 500;
}

.pill.name img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.28);
  flex: 0 0 auto;
}

.pill.name .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.pill.name .bib {
  color: var(--yellow);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pill.name .wave {
  font-size: 9.5px;
  font-weight: 700;
  color: #0a0c0d;
  background: var(--yellow);
  border-radius: 4px;
  padding: 1px 4px;
  letter-spacing: 0.03em;
}

@media (max-width: 560px) {
  .pill.name .nm {
    display: none;
  }
  .pill.name {
    max-width: none;
    padding-right: 8px;
  }
}

.pill.ghost {
  background: rgba(8, 11, 14, 0.68);
  border-color: rgba(255, 255, 255, 0.12);
  color: #dbe3e0;
  font-weight: 500;
}

.pill.ghost:hover {
  background: rgba(20, 26, 32, 0.9);
}

.pill.warn {
  border-color: rgba(255, 179, 64, 0.45);
  color: #ffcf8a;
}

.pill.stale {
  border-color: rgba(255, 179, 64, 0.5);
  color: #ffd399;
}

.pill.stale .dot {
  background: var(--amber);
  animation: none;
}

/* leaflet chrome */
.leaflet-container {
  background: #0a0f13;
  font-family: var(--font);
  outline: none;
}

.leaflet-control-attribution {
  background: rgba(6, 8, 10, 0.7) !important;
  color: #65727c !important;
  font-size: 9.5px !important;
  padding: 2px 7px !important;
  border-radius: 6px 0 0 0;
  backdrop-filter: blur(6px);
}

.leaflet-control-attribution a {
  color: #8d9aa5 !important;
}

.leaflet-control-zoom {
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.6) !important;
  margin-left: 12px !important;
  margin-bottom: 74px !important;
}

.leaflet-control-zoom a {
  background: rgba(10, 14, 18, 0.9) !important;
  color: #dfe6e3 !important;
  border-color: var(--line) !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
  font-size: 16px !important;
}

.leaflet-control-zoom a:hover {
  background: #1a222a !important;
}

/* runner marker */
.runner-marker {
  position: relative;
  width: 26px;
  height: 26px;
}

.runner-dot {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--yellow);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.55);
}

.runner-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(242, 228, 0, 0.35);
  animation: runner-pulse 2.2s ease-out infinite;
}

@keyframes runner-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  80%,
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

.map-label {
  background: rgba(8, 11, 14, 0.82) !important;
  border: 1px solid var(--line) !important;
  color: #cdd6d2 !important;
  font-size: 10px !important;
  font-weight: 500;
  padding: 2px 7px !important;
  border-radius: 6px !important;
  box-shadow: none !important;
  white-space: nowrap;
}

.map-label::before {
  display: none !important;
}

.km-label {
  color: #7f8d97 !important;
  font-size: 9px !important;
  background: transparent !important;
  border: 0 !important;
}

.km-label::before {
  display: none !important;
}

.start-pin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #eef4f1;
  border: 3px solid #0b1014;
  box-shadow: 0 0 0 2px #eef4f1;
}

/* ------------------------------------------------------------ side */
.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* progress */
.progress .card-body {
  padding-top: 16px;
}

.progress-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.km {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}

.km #km {
  font-size: clamp(40px, 7vw, 56px);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.km-total {
  font-size: 13px;
  color: var(--muted-2);
  font-weight: 500;
}

.remain {
  text-align: right;
  padding-bottom: 4px;
}

.remain b {
  display: block;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.1;
}

.remain small {
  font-size: 10.5px;
  color: var(--muted-2);
}

.track {
  position: relative;
  height: 10px;
  margin: 18px 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

#fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9cd00, var(--yellow));
  box-shadow: 0 0 18px rgba(242, 228, 0, 0.4);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.track .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(6, 8, 10, 0.55);
}

.track-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--muted-2);
  letter-spacing: 0.03em;
}

/* stats */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  padding: 13px 15px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.006)), var(--panel);
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  margin-top: 5px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--muted-2);
}

.stat.accent {
  background: linear-gradient(160deg, rgba(242, 228, 0, 0.1), rgba(242, 228, 0, 0.02)), var(--panel);
  border-color: rgba(242, 228, 0, 0.22);
}

.stat.accent b {
  color: var(--yellow);
}

.stat.wide {
  grid-column: 1 / -1;
}

.stat.wide b {
  font-size: 26px;
}

/* cutoff */
.cutoff-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 0;
}

.cutoff-head h3 {
  margin: 3px 0 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok {
  background: var(--teal-soft);
  border-color: rgba(92, 225, 185, 0.3);
  color: var(--teal);
}

.badge.tight {
  background: var(--amber-soft);
  border-color: rgba(255, 179, 64, 0.35);
  color: var(--amber);
}

.badge.behind {
  background: var(--red-soft);
  border-color: rgba(255, 95, 95, 0.35);
  color: var(--red);
}

.cutoff-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 0;
}

.cutoff-main b {
  display: block;
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}

.cutoff-main small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted-2);
}

.cutoff-main .cutoff-need {
  text-align: right;
}

.cutoff-main .cutoff-need b {
  font-size: 17px;
}

.cutoff-bar {
  height: 5px;
  margin: 14px 18px 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.cutoff-bar div {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--teal);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s;
}

.cutoff.bad .cutoff-bar div {
  background: var(--red);
}

.cutoff.warn .cutoff-bar div {
  background: var(--amber);
}

.cutoff-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 18px 16px;
  font-size: 10.5px;
  color: var(--muted-2);
}

/* ------------------------------------------------------------ lower */
.lower {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.split-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 32px;
}

.splits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.splits-table th {
  text-align: right;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.splits-table th:first-child,
.splits-table td:first-child {
  text-align: left;
}

.splits-table td {
  text-align: right;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #aeb9b4;
  font-variant-numeric: tabular-nums;
}

.splits-table tr:last-child td {
  border-bottom: 0;
}

.splits-table tr.done td {
  color: var(--text);
}

.splits-table tr.latest td {
  color: var(--yellow);
}

.splits-table td:first-child {
  font-weight: 600;
}

.splits-table .pending {
  color: #495460;
}

/* elevation */
.elev-wrap {
  position: relative;
  margin-top: 6px;
}

#elevSvg {
  display: block;
  width: 100%;
  height: 118px;
  overflow: visible;
}

.elev-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(242, 228, 0, 0.7);
  transition: left 0.5s ease, top 0.5s ease;
  pointer-events: none;
}

.elev-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 9.5px;
  color: var(--muted-2);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 10px;
  color: var(--muted-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* footer */
.foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted-2);
}

.foot a {
  color: var(--muted);
  border-bottom: 1px dotted rgba(255, 255, 255, 0.2);
}

/* enter key */
.gate {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 6, 8, 0.94);
  backdrop-filter: blur(8px);
}

.gate-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.gate h1 {
  font-size: 22px;
  margin: 12px 0 6px;
}

.gate p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

.gate input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: center;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.gate input:focus {
  outline: none;
  border-color: rgba(242, 228, 0, 0.5);
  box-shadow: 0 0 0 3px rgba(242, 228, 0, 0.1);
}

.gate .btn {
  width: 100%;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .split-cols {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .split-cols table + table thead {
    display: none;
  }

  .map-card {
    position: relative;
    top: 0;
    height: 54vh;
    min-height: 320px;
    max-height: 460px;
  }

  .lower {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .stat b {
    font-size: 19px;
  }

  .km #km {
    font-size: 44px;
  }

  .cutoff-main b {
    font-size: 26px;
  }

  .splits-table {
    font-size: 12.5px;
  }
}
