/* ------------------------------------------------------------------ base -- */
:root {
  --cyan: #35e6ff;
  --magenta: #ff3fa8;
  --amber: #ffbe33;
  --lime: #9dff4d;
  --ice: #d8f4ff;
  --ink: #04060f;
  --panel: rgba(8, 14, 30, 0.82);
  --line: rgba(80, 200, 255, 0.28);
  --font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--ice);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------- hud -- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 0 10px rgba(53, 230, 255, 0.35);
}

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}

.cluster { display: flex; flex-direction: column; gap: 4px; }
.cluster.right { align-items: flex-end; text-align: right; }
.cluster.center { flex: 1; align-items: center; max-width: 46vw; }

.label {
  font-size: 10px;
  letter-spacing: 0.22em;
  opacity: 0.55;
  text-transform: uppercase;
}

.value { font-size: 18px; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: baseline; gap: 8px; }

.clock {
  font-size: 44px;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 0 18px rgba(53, 230, 255, 0.75), 0 0 46px rgba(53, 230, 255, 0.3);
}

.delta { font-size: 14px; font-variant-numeric: tabular-nums; }
.delta.ahead { color: var(--lime); }
.delta.behind { color: var(--magenta); }

/* progress */
.progress { position: relative; width: 100%; height: 8px; background: rgba(255,255,255,0.1); border-radius: 6px; overflow: visible; }
.progress-bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  box-shadow: 0 0 16px rgba(53,230,255,0.8);
  border-radius: 6px;
  transition: width 0.18s ease-out;
}
.progress-dots { position: absolute; inset: -3px 0; }
.progress-dots i {
  position: absolute; top: 3px; width: 2px; height: 8px;
  background: rgba(216,244,255,0.5);
  transform: translateX(-1px);
}
.progress-dots i.done { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.gate-name {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* bottom */
.hud-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}
.speedo { align-items: flex-start; min-width: 150px; }
.speed {
  font-size: 34px; line-height: 1; font-weight: 700;
  font-variant-numeric: tabular-nums; color: #fff;
}
.speed.fast { color: var(--amber); text-shadow: 0 0 20px rgba(255,190,51,0.8); }
.dash { margin-top: 8px; width: 120px; height: 5px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden; }
.dash-bar { height: 100%; width: 100%; background: var(--amber); box-shadow: 0 0 12px var(--amber); transition: width 0.05s linear; }
.dash-bar.ready { background: var(--lime); box-shadow: 0 0 12px var(--lime); }

/* momentum readout: how much of your flow you are carrying */
.flow { margin-top: 7px; width: 120px; }
.flow-head { display: flex; justify-content: space-between; align-items: baseline; }
.flow .label { opacity: 0.55; letter-spacing: 0.16em; }
.flow-mult {
  font-size: 12px; font-weight: 700; color: var(--cyan);
  font-variant-numeric: tabular-nums; transition: color 0.15s;
}
.flow-mult.hot { color: var(--amber); text-shadow: 0 0 14px rgba(255,190,51,0.85); }
.flow-track { margin-top: 3px; width: 120px; height: 4px; }
.flow-bar {
  width: 0%; background: linear-gradient(90deg, var(--cyan), #7ef9ff 60%, var(--amber));
  box-shadow: 0 0 10px rgba(53, 230, 255, 0.7); transition: none;
}

.keys { font-size: 11px; line-height: 1.7; opacity: 0.6; text-align: right; }
.keys b { color: #fff; opacity: 0.95; }

/* live section splits, directly under the clock in the top-left */
.splits-live {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.55;
  min-width: 230px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.splits-live .s {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 1px 6px 1px 0;
  border-left: 2px solid rgba(53, 230, 255, 0.35);
  padding-left: 7px;
}
.splits-live .s span:nth-child(2) { font-variant-numeric: tabular-nums; opacity: 0.95; }
.splits-live .s span:nth-child(3) { font-variant-numeric: tabular-nums; min-width: 68px; text-align: right; }
.splits-live .s.ahead { color: var(--lime); border-left-color: var(--lime); }
.splits-live .s.behind { color: var(--magenta); border-left-color: var(--magenta); }
.splits-live .s:first-child { opacity: 0.8; }

/* endless readout: metres, not a clock */
.clock.distance {
  font-size: 44px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- panels -- */
.panel {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 40px));
  padding: 26px 30px 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  box-shadow: 0 0 60px rgba(20, 80, 140, 0.35), inset 0 0 40px rgba(30, 120, 200, 0.12);
  text-align: center;
  z-index: 20;
  pointer-events: auto;
}

.panel h1 {
  margin: 0 0 6px;
  font-size: 46px;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 26px rgba(53,230,255,0.85), 0 0 70px rgba(53,230,255,0.35);
}
.panel h1 span { color: var(--magenta); text-shadow: 0 0 26px rgba(255,63,168,0.85); }
.panel h2 {
  margin: 0 0 14px;
  font-size: 30px;
  letter-spacing: 0.2em;
  color: var(--lime);
  text-shadow: 0 0 26px rgba(157,255,77,0.7);
}
.panel .tag { margin: 0 0 18px; font-size: 13px; opacity: 0.75; line-height: 1.6; }
.panel .tips { margin: 0 0 22px; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.95; opacity: 0.85; text-align: left; }
.panel .tips b { color: var(--cyan); }
.panel .fine { font-size: 11px; opacity: 0.5; margin: 14px 0 0; }

/* ---------------------------------------------------------- track picker -- */
.maps-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  letter-spacing: 0.22em;
  opacity: 0.6;
  margin: 0 2px 8px;
}
.maps-head .hint { letter-spacing: 0.06em; opacity: 0.75; }
.maps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin: 0 0 12px;
}
.map-btn {
  pointer-events: auto;
  font: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: #cfe6ff;
  background: rgba(10, 22, 44, 0.65);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
  text-align: left;
}
.map-btn:hover { background: rgba(24, 58, 96, 0.8); transform: translateY(-1px); }
.map-btn b { font-weight: 700; }
.map-btn span { opacity: 0.62; font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-btn.endless { border-color: rgba(255, 190, 51, 0.4); }
.map-btn.selected {
  border-color: var(--cyan);
  background: rgba(24, 78, 122, 0.85);
  box-shadow: 0 0 22px rgba(53, 230, 255, 0.35);
}
.panel .blurb {
  margin: 0 0 16px;
  min-height: 30px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--cyan);
  opacity: 0.9;
}

.cta {
  pointer-events: auto;
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.16em;
  padding: 13px 34px;
  color: #04121a;
  background: linear-gradient(180deg, #7ff0ff, var(--cyan));
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 0 26px rgba(53,230,255,0.55);
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 0 38px rgba(53,230,255,0.85); }
.cta:active { transform: translateY(1px); }
kbd {
  font: inherit; font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
}
.ghost-btn {
  display: block; margin: 14px auto 0; font: inherit; font-size: 11px;
  background: none; border: 1px solid rgba(255,255,255,0.18); color: var(--ice);
  padding: 7px 14px; border-radius: 7px; cursor: pointer; opacity: 0.7;
}
.ghost-btn:hover { opacity: 1; }

.result { display: flex; justify-content: space-around; gap: 12px; margin: 6px 0 18px; }
.result .label { display: block; margin-bottom: 5px; }
.big { font-size: 30px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.big2 { font-size: 19px; opacity: 0.9; font-variant-numeric: tabular-nums; }

.splits { max-height: 150px; overflow-y: auto; font-size: 12px; text-align: left; margin: 0 auto 18px; max-width: 340px; }
.splits .s { display: flex; justify-content: space-between; padding: 2px 4px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.splits .s.ahead { color: var(--lime); }
.splits .s.behind { color: var(--magenta); }

/* ------------------------------------------------------------ countdown -- */
.overlay-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 15;
}
#countdownText {
  font-size: 130px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 40px var(--cyan), 0 0 100px rgba(53,230,255,0.55);
  animation: pop 0.42s ease-out;
}
#countdownText.go { color: var(--lime); text-shadow: 0 0 50px var(--lime), 0 0 130px rgba(157,255,77,0.6); }
@keyframes pop {
  from { transform: scale(1.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------- toast -- */
.toast {
  position: absolute;
  left: 50%; top: 22%;
  transform: translateX(-50%);
  font-size: 16px;
  letter-spacing: 0.2em;
  padding: 10px 22px;
  background: rgba(6,12,26,0.8);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 16;
  animation: toastIn 0.3s ease-out;
}
.toast.good { color: var(--lime); border-color: rgba(157,255,77,0.5); }
.toast.bad { color: var(--magenta); border-color: rgba(255,63,168,0.5); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; } }

/* --------------------------------------------------------- post effects -- */
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 8;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 42%, rgba(0,0,0,0.55) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.10) 0 1px, rgba(0,0,0,0) 1px 3px);
  mix-blend-mode: multiply;
  opacity: 0.85;
}
.flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 9;
  background: radial-gradient(ellipse at center, rgba(255,63,168,0.0) 30%, rgba(255,63,168,0.45) 100%);
  opacity: 0;
  transition: opacity 0.35s ease-out;
}
.flash.on { opacity: 1; transition: opacity 0.05s; }

/* ---------------------------------------------------------- touch input -- */
.touch { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
.stick {
  position: absolute; left: 26px; bottom: 26px;
  width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
  pointer-events: auto;
  touch-action: none;
}
.stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(53,230,255,0.35);
  border: 1px solid rgba(53,230,255,0.7);
  box-shadow: 0 0 22px rgba(53,230,255,0.5);
}
.touch-buttons { position: absolute; right: 24px; bottom: 30px; display: flex; align-items: flex-end; gap: 16px; }
.tbtn {
  pointer-events: auto; touch-action: none;
  font: inherit; font-size: 14px; letter-spacing: 0.1em;
  width: 96px; height: 96px; border-radius: 50%;
  color: #04121a; background: rgba(53,230,255,0.8);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 0 26px rgba(53,230,255,0.45);
}
.tbtn.small { width: 72px; height: 72px; background: rgba(255,190,51,0.8); box-shadow: 0 0 22px rgba(255,190,51,0.4); }
.tbtn:active { transform: scale(0.96); }

@media (max-width: 720px) {
  .clock { font-size: 30px; }
  .keys, .splits-live { display: none; }
  .hud-top { padding: 12px 14px; }
  .hud-bottom { padding: 12px 14px 12px 170px; }
}
