:root {
  --accent: #fc4c02; /* strava orange */
  --ink: #f5f7fa;
  --panel: rgba(12, 16, 22, 0.55);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app,
#app canvas {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
  background: #9fc3dd;
  font-family: "Inter", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hud {
  position: fixed;
  z-index: 10;
  color: var(--ink);
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

/* --- top right: stats --- */
.hud-top-right {
  top: 18px;
  right: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: min(60vw, 640px);
}
.stat {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 86px;
  flex: 0 1 auto;
}
.stat-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.18em;
  opacity: 0.7;
}
.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.unit {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.65;
  margin-left: 2px;
}

/* --- top center: elevation profile --- */
.hud-top-center {
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  width: min(520px, 54vw);
}
.profile {
  padding: 10px 14px 9px;
  border-radius: 12px;
}
.profile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.profile-title {
  font-size: 10px;
  letter-spacing: 0.22em;
  font-weight: 700;
  opacity: 0.75;
}
.profile-grade {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.04em;
  min-width: 50px;
  text-align: center;
}
.profile-mi {
  font-size: 12px;
  opacity: 0.85;
}
#elevation-profile {
  display: block;
  width: 100%;
  height: auto;
}
.profile-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 0.12em;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.profile-foot-mid {
  letter-spacing: 0.16em;
}

/* --- bottom right: segment + speedometer --- */
.hud-bottom-right {
  right: 22px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(360px, 40vw);
}
.speedo {
  text-align: right;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 18px 12px;
}
.speed {
  font-size: 56px;
  line-height: 0.95;
  font-weight: 800;
  font-style: italic;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.speedo .unit {
  letter-spacing: 0.28em;
  font-size: 10px;
}

/* --- segment panel --- */
.segment {
  width: 100%;
  padding: 10px 14px 11px;
}
.segment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}
.segment-tag {
  font-size: 9px;
  letter-spacing: 0.22em;
  font-weight: 700;
  opacity: 0.7;
}
.segment-name {
  font-size: 13px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.segment-live {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}
.segment-live-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.segment-live-label {
  font-size: 8px;
  letter-spacing: 0.16em;
  opacity: 0.6;
}
.segment-live-value {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.segment-live-value.accent {
  color: var(--accent);
}
.segment-live-value.ahead {
  color: #ff6b4a;
}
.segment-live-value.behind {
  color: #7fd18a;
}
.segment-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-bottom: 5px;
}
.segment-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s linear;
}
.segment-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  margin-bottom: 7px;
}
.segment-progress {
  opacity: 0.7;
}
.segment-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 6px;
  max-height: 132px;
  overflow: hidden;
}

/* --- bottom left: ghosts + controls hint --- */
.hud-bottom-left {
  left: 20px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(300px, 34vw);
}

.ghosts {
  padding: 9px 12px 10px;
}
.ghosts-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.ghosts-title {
  font-size: 9px;
  letter-spacing: 0.2em;
  font-weight: 700;
  opacity: 0.75;
}
.ghosts-rank {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.ghost-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 168px;
  overflow: hidden;
}
.ghost-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.ghost-row-name {
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ghost-row-gap {
  font-weight: 700;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}
.ghost-row-time {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ghost-row-dist {
  font-size: 9px;
  font-weight: 600;
  opacity: 0.6;
}
.ghost-row.ahead .ghost-row-gap {
  color: #ff6b4a;
}
.ghost-row.behind .ghost-row-gap {
  color: #7fd18a;
}
.ghost-row.is-you .ghost-row-name {
  color: var(--accent);
  font-weight: 800;
  opacity: 1;
}
.ghosts-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 9px;
  letter-spacing: 0.16em;
  opacity: 0.85;
}
.ghosts-lap {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.controls {
  font-size: 12px;
  opacity: 0.9;
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.key {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}
.sep {
  margin: 0 8px;
  opacity: 0.5;
}

/* --- transient hint, center bottom --- */
.hint {
  position: fixed;
  left: 50%;
  bottom: 195px;
  transform: translateX(-50%);
  z-index: 10;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.04em;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.hint.visible {
  opacity: 1;
}
