:root {
  --fondo: #ffffff;
  --carta: #ffffff;           /* the card */
  --bordo: #ececee;           /* hairlines */
  --campo: #f4f4f5;           /* the race picker track, the slider rail */
  --inchiostro: #121214;      /* the text, the knob dot, the save button */
  --testo-2: #8b8b93;         /* labels, ends, units */
  --testo-3: #c3c3c9;         /* ticks, the dim zone bars */
  --accento: #ff5a1a;         /* one accent: the filled rail, the halo, the zone, the split line */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

/* ---- the card ---- */
.calc {
  --gap: clamp(9px, 2.4vh, 16px);
  width: min(380px, calc(100vw - 24px));
  padding: clamp(12px, 3vh, 18px) clamp(14px, 4vw, 20px) clamp(12px, 3vh, 18px);
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: 22px;
  box-shadow:
    0 1px 1px rgba(18, 18, 20, 0.03),
    0 6px 14px -6px rgba(18, 18, 20, 0.08),
    0 26px 50px -26px rgba(18, 18, 20, 0.16);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  user-select: none;
  -webkit-user-select: none;
}

.calc__head { display: flex; align-items: center; justify-content: space-between; height: 22px; }
.calc__title { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 580; font-stretch: 92%; }
.calc__icon { width: 17px; height: 17px; fill: none; stroke: var(--inchiostro); stroke-width: 1.6; stroke-linecap: round; overflow: visible; }
.calc__hand { stroke: var(--accento); }
.calc__brand { font-size: 12px; font-weight: 640; font-stretch: 112%; letter-spacing: 0.04em; text-transform: uppercase; color: var(--testo-2); }

/* ---- the race picker: four pills with a white indicator that slides ---- */
.races {
  position: relative;
  display: grid;
  grid-template-columns: 0.8fr 0.9fr 1fr 1.5fr;
  padding: 3px;
  height: 38px;
  background: var(--campo);
  border-radius: 999px;
}
.races__pill {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: 60px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(18, 18, 20, 0.08), 0 3px 8px -2px rgba(18, 18, 20, 0.08);
  will-change: transform, width;
}
.race {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 540;
  font-stretch: 96%;
  color: var(--testo-2);
  border-radius: 999px;
  transition: color 0.3s ease;
}
.race[aria-checked="true"] { color: var(--inchiostro); font-weight: 620; }
.race:focus-visible { outline: 2px solid var(--accento); outline-offset: -2px; }
@media (hover: hover) { .race:hover { color: var(--inchiostro); } }

/* ---- the big target time ---- */
.goal { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.goal__label { font-size: 12.5px; color: var(--testo-2); font-weight: 520; }
.goal__time {
  font-size: clamp(32px, min(11vw, 8.4vh), 46px);
  font-weight: 640;
  font-stretch: 88%;
  letter-spacing: -0.02em;
}

/* rolling numbers: one reel per digit, the colons stay */
.roll { display: inline-flex; line-height: 1; height: 1em; overflow: hidden; }
.roll__reel { display: inline-block; height: 1em; overflow: hidden; width: 0.57em; text-align: center; }
.roll__strip { display: flex; flex-direction: column; will-change: transform; }
.roll__strip span { display: block; height: 1em; }
.roll__sep { display: inline-block; width: 0.26em; text-align: center; }
.roll--small .roll__reel { width: 0.6em; }

/* ---- the slider of the target time ---- */
.slider { position: relative; height: 46px; touch-action: none; cursor: pointer; }
.slider__rail {
  position: absolute; left: 12px; right: 12px; top: 14px;
  height: 6px;
  border-radius: 99px;
  background: var(--campo);
  overflow: hidden;
}
.slider__fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accento); border-radius: 99px; }
.slider__ticks { position: absolute; left: 12px; right: 12px; top: 25px; height: 6px; }
.slider__ticks i { position: absolute; top: 0; width: 1px; height: 5px; background: var(--testo-3); transform-origin: 50% 0; }
.slider__ticks i.is-major { height: 7px; background: var(--testo-2); }
.slider__ends {
  position: absolute; left: 12px; right: 12px; bottom: 0;
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--testo-2);
}
.slider__handle {
  position: absolute; top: 17px; left: 12px;
  width: 0; height: 0;
  outline: none;
}
.slider__halo {
  position: absolute; left: -19px; top: -19px; width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accento);
  opacity: 0;
  transform: scale(0.6);
}
.slider__knob {
  position: absolute; left: -12px; top: -12px; width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(18, 18, 20, 0.08), 0 2px 4px rgba(18, 18, 20, 0.12), 0 6px 14px -4px rgba(18, 18, 20, 0.18);
  display: grid; place-items: center;
}
.slider__grip { width: 8px; height: 8px; border-radius: 50%; background: var(--inchiostro); }
.slider__handle:focus-visible .slider__knob { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accento); }

/* ---- the pace ---- */
.pace { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding-top: 2px; border-top: 1px solid var(--bordo); padding-top: var(--gap); }
.pace__main { display: flex; flex-direction: column; gap: 4px; }
.pace__label { font-size: 12.5px; color: var(--testo-2); font-weight: 520; }
.pace__value { display: inline-flex; align-items: baseline; gap: 4px; font-size: clamp(24px, min(8vw, 6vh), 30px); font-weight: 640; font-stretch: 90%; letter-spacing: -0.015em; }
.pace__unit { font-size: 13px; font-weight: 520; color: var(--testo-2); letter-spacing: 0; }
.pace__side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pace__mile { display: inline-flex; align-items: baseline; gap: 3px; font-size: 12.5px; color: var(--testo-2); font-weight: 520; }
.zone { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--accento); }
.zone__bar { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.zone__bar i { display: block; width: 3px; border-radius: 1px; background: var(--testo-3); }
.zone__bar i:nth-child(1) { height: 4px; }
.zone__bar i:nth-child(2) { height: 6px; }
.zone__bar i:nth-child(3) { height: 8.5px; }
.zone__bar i:nth-child(4) { height: 11px; }
.zone__bar i.is-on { background: var(--accento); }
.zone__name { display: inline-block; min-width: 3.8em; text-align: right; }

/* ---- the split times along the race ---- */
.splits { position: relative; height: 44px; margin: 0 4px; }
.splits__rail { position: absolute; left: 0; right: 0; top: 19px; height: 2px; background: var(--campo); border-radius: 2px; overflow: hidden; }
.splits__fill { position: absolute; inset: 0; background: var(--accento); transform-origin: 0 50%; opacity: 0.9; }
.split { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0; }
.split__at { font-size: 10.5px; font-weight: 560; color: var(--testo-2); height: 14px; line-height: 14px; white-space: nowrap; }
.split__mark { width: 8px; height: 8px; margin-top: 1px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px var(--accento); }
.split__time { margin-top: 3px; font-size: 12px; font-weight: 600; letter-spacing: -0.01em; height: 14px; }
.split__time .roll__reel { width: 0.58em; }
.split--end .split__mark { background: var(--accento); }

/* ---- save ---- */
.save {
  position: relative;
  height: clamp(42px, 6.4vh, 48px);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  isolation: isolate;
}
.save__bg { position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--inchiostro); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.save__txt, .save__done { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.save__done { opacity: 0; }
.save__done svg { width: 16px; height: 16px; fill: none; stroke: var(--accento); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.save__done path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.save:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }
@media (hover: hover) { .save:hover .save__bg { background: #26262a; } }

@media (max-width: 360px) {
  .race { font-size: 12px; }
  .split__at { font-size: 9.5px; }
  .split__time { font-size: 11px; }
}
