:root {
  --bg: #000000;
  --card: #101114;
  --well: #17181d;
  --ink: #f4f5f8;
  --soft: rgba(244, 245, 248, 0.52);
  --faint: rgba(244, 245, 248, 0.3);
  --line: rgba(244, 245, 248, 0.08);
  --accent: #35d980;
  --slow: #ff6f61;
  --row: 34px;
  --rows: 3;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 10px 14px;
}

.sw { position: relative; width: min(276px, 100%); padding: 18px 18px 8px; border-radius: 28px; background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 62%), linear-gradient(180deg, #15161a, var(--card)); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 30px 60px -30px color-mix(in srgb, var(--accent) 30%, transparent); }

/* every digit sits in a cell of its own width, so the time never trembles while it runs */
.d { display: inline-block; width: 0.610em; text-align: center; }
.c { display: inline-block; width: 0.290em; text-align: center; }

.sw__time { display: flex; justify-content: center; font-size: clamp(40px, 14.500vw, 50px); line-height: 1.05; font-weight: 720; font-stretch: 92%; letter-spacing: -0.02em; white-space: nowrap; }
.sw__time .is-small { color: var(--soft); }

.sw__now { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; height: 18px; font-size: 12.500px; line-height: 18px; font-weight: 600; color: var(--soft); }
.sw__nowname { height: 18px; overflow: hidden; }
.sw__nowname span { display: block; }
.sw__nowtime { color: var(--ink); font-weight: 640; white-space: nowrap; }

/* the strip: the lap in progress grows along it, the tick marks the best lap so far */
.sw__strip { position: relative; height: 5px; margin-top: 7px; border-radius: 3px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.sw__fill { position: absolute; inset: 0; border-radius: 3px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent)); transform: scaleX(0); transform-origin: 0 50%; transition: filter 0.4s ease; }
.sw__fill--echo { opacity: 0; }
.sw__strip.is-over .sw__fill:not(.sw__fill--echo) { filter: saturate(0.15) brightness(1.5); }
.sw__best { position: absolute; top: -4px; left: 0; width: 2px; height: 13px; margin-left: -1px; border-radius: 1px; background: var(--ink); opacity: 0; box-shadow: 0 0 0 2px var(--card); }

.sw__keys { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.sw__key { position: relative; height: 44px; border: 0; border-radius: 15px; background: var(--well); color: var(--ink); font: inherit; font-size: 14.500px; font-weight: 680; letter-spacing: -0.005em; cursor: pointer; outline: none; box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.06); transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.sw__key:disabled { color: var(--faint); cursor: default; }
.sw__key:focus-visible { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.sw__key--go { background: var(--accent); color: #04130b; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 20px -12px var(--accent); }
.sw__key--go.is-running { background: color-mix(in srgb, var(--slow) 16%, var(--well)); color: var(--slow); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--slow) 30%, transparent); }
.sw__keytext { display: block; height: 20px; line-height: 20px; overflow: hidden; }
.sw__keytext span { display: block; }

/* the laps: ruled like a notebook even when empty, the newest on top */
.sw__list { position: relative; list-style: none; height: calc(var(--row) * var(--rows)); margin-top: 12px; overflow: hidden; background: repeating-linear-gradient(180deg, var(--line) 0 1px, transparent 1px var(--row)); }
.sw__row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; height: var(--row); padding-top: 1px; font-size: 13.500px; font-weight: 600; white-space: nowrap; }
.sw__n { color: var(--soft); transition: color 0.35s ease; }
.sw__dl { font-size: 11.500px; font-weight: 620; color: var(--faint); }
.sw__t { font-weight: 660; transition: color 0.35s ease; }
.sw__row.is-best .sw__t, .sw__row.is-best .sw__n { color: var(--accent); }
.sw__row.is-slow .sw__t, .sw__row.is-slow .sw__n { color: var(--slow); }

.sw__say { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.ghost { position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -3px 0 0 -5px; transform-origin: 20% 15%; pointer-events: none; opacity: 0; fill: #f4f5f8; stroke: #101114; stroke-width: 1.300; stroke-linejoin: round; filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.6)); z-index: 5; }
