:root {
  --bg: #0e0708;
  --bg-2: #1a0c0e;
  --line: #2e1a1c;
  --text: #f2f3f7;
  --muted: #9a7d80;
  --accent: #ff3b4a;
  --accent-ink: #062a1b;
  --stop: #ffd6d9;
  --stop-ink: #3a0709;
  --best: #ff3b4a;
  --worst: #ffb347;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, #3a0c12 0%, transparent 60%),
    var(--bg);
  min-height: 100dvh;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 2px 8px;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
}
.status {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: color .25s, border-color .25s;
}
.status.running { color: var(--accent); border-color: rgba(255,59,74,.4); }
.status.paused { color: #ffc861; border-color: rgba(255,200,97,.35); }

/* clock */
.clock {
  position: relative;
  display: grid;
  place-items: center;
  margin: 12px auto 22px;
  width: min(340px, 86vw);
  aspect-ratio: 1;
}
.ring, .readout { grid-area: 1 / 1; }
.ring { width: 100%; height: 100%; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.track { fill: none; stroke: var(--line); stroke-width: 3; }
.sweep {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 578.05;
  stroke-dashoffset: 578.05;
  filter: drop-shadow(0 0 6px rgba(255,59,74,.55));
  transition: stroke .3s;
}
.paused-state .sweep { stroke: #ffc861; filter: drop-shadow(0 0 6px rgba(255,200,97,.45)); }

.readout {
  text-align: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.main {
  font-size: clamp(64px, 22vw, 96px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.04em;
}
.main.long { font-size: clamp(48px, 16vw, 72px); }
.colon { opacity: .45; margin: 0 -0.04em; }
.sub {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 400;
  color: var(--muted);
}
.hours:not(:empty)::after { content: "h "; font-size: 18px; }
.lapnow {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity .3s;
}
.lapnow.show { opacity: 1; }

/* controls */
.controls {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 0 6px 18px;
}
.btn {
  appearance: none;
  border: 0;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  font: 600 17px var(--sans);
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, background .25s, color .25s, opacity .25s;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}
.btn:active:not(:disabled) { transform: scale(0.94); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.secondary { background: #2a1518; color: #f0d4d6; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #2a1518; }
.btn.primary { background: rgba(255,59,74,.16); color: var(--accent); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255,59,74,.16); }
.btn.stop { background: rgba(255,214,217,.12); color: var(--stop); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255,214,217,.12); }
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 6px; }

/* laps */
.laps {
  flex: 1;
  border-top: 1px solid var(--line);
  min-height: 0;
}
.laps-head, .lap {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1.3fr;
  align-items: center;
  padding: 0 4px;
}
.laps-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 12px;
  padding-bottom: 6px;
}
.laps-head span:not(:first-child), .lap span:not(:first-child) { text-align: right; }
.lap-list { list-style: none; margin: 0; padding: 0; }
.lap {
  height: 48px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  animation: drop .35s cubic-bezier(.2,.9,.3,1.2);
}
.lap .n { font-family: var(--sans); color: var(--muted); font-size: 15px; }
.lap .total { color: var(--muted); }
.lap.best .split, .lap.best .n { color: var(--best); }
.lap.worst .split, .lap.worst .n { color: var(--worst); }
.lap.current .split { color: var(--text); }
.lap.current .n::after { content: " •"; color: var(--accent); animation: blink 1s steps(2) infinite; }
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 28px 0;
}

@keyframes drop {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .lap, .lap.current .n::after { animation: none; }
}

@media (min-height: 820px) {
  .clock { margin-top: 28px; margin-bottom: 32px; }
}
