@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-500-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;

  /* Colour: a near-black bench; orange and blue belong to the twins alone. */
  --night: #0b0d12;
  --scope: #07090d;
  --scope-veil: rgba(7, 9, 13, 0.8);
  --panel: #12161e;
  --panel-raised: #191e29;
  --panel-hover: #1f2532;
  --hairline: #262c39;
  --hairline-strong: #3a4252;
  --row-stripe: rgba(255, 255, 255, 0.03);
  --row-mine: rgba(243, 245, 249, 0.08);
  --ink: #e9ecf2;
  --ink-soft: #c9cfdb;
  --ink-muted: #9aa3b4;
  --white: #f3f5f9;
  --white-hot: #ffffff;
  --twin-orange: #ff8c28;
  --twin-blue: #1e78ff;
  --twin-blue-text: #3d8bff;
  --good: #7ee0a1;
  --bad: #ff7a7a;
  --map-1: #3b2a6b;
  --map-2: #8a2f8f;
  --map-3: #d94f5c;
  --map-4: #f59a3c;
  --map-5: #fbe38e;

  /* Type: display for names, system sans for prose, mono for measurements. */
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-label: 0.75rem;
  --text-small: 0.875rem;
  --text-body: 1rem;
  --text-lead: 1.125rem;
  --text-title: 1.5rem;
  --text-headline: 2rem;
  --text-readout: clamp(2.5rem, 2rem + 2vw, 3.25rem);
  --text-display: clamp(2.75rem, 1.75rem + 3.5vw, 4.25rem);

  /* Space: a 4 px base. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-pill: 999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  scrollbar-color: var(--hairline-strong) var(--night);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 var(--s4) var(--s7);
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  letter-spacing: 0.005em;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; text-wrap: balance; }
h2 { font-size: var(--text-title); letter-spacing: -0.01em; }
h3 { font-size: var(--text-lead); }
p { text-wrap: pretty; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
::selection { background: var(--white); color: var(--night); }
input { caret-color: var(--white); }
:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }

.masthead, .layout, .explain, .footer { max-width: 1120px; margin-inline: auto; }

/* Masthead */
.masthead { display: grid; gap: var(--s2) var(--s7); padding-block: var(--s6) var(--s5); }
.wordmark { font-size: var(--text-display); font-weight: 800; letter-spacing: -0.035em; line-height: 0.95; }
.wordmark .o { color: var(--twin-orange); }
.wordmark .b { color: var(--twin-blue-text); }
.lede { max-width: 46ch; font-size: var(--text-lead); line-height: 1.5; color: var(--ink-muted); }
.lede strong { color: var(--ink); font-weight: 600; }
@media (min-width: 920px) {
  .masthead { grid-template-columns: auto minmax(0, 1fr); align-items: end; }
  .lede { padding-bottom: 0.2em; }
}

/* Two columns from 920 px: the race and its map on the left, results on the right.
   Below that, one column ordered race, result, gap, leaderboard, map. */
.layout { display: flex; flex-direction: column; gap: var(--s6); }
.col { display: contents; }
.stage { order: 1; }
.result { order: 2; }
.gap-panel { order: 3; }
.board { order: 4; }
.map-panel { order: 5; }
@media (min-width: 920px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--s7); align-items: start; }
  .col { display: grid; gap: var(--s6); align-content: start; }
}

/* The race */
.stage { display: grid; gap: var(--s3); }

.scoreline { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s2) var(--s4); }
.readout { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s3); }
.readout-label { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--text-body); color: var(--ink-muted); }
.readout-value { font-family: var(--font-mono); font-weight: 500; font-size: var(--text-readout); line-height: 1; letter-spacing: -0.03em; color: var(--white); font-variant-numeric: tabular-nums; }
.readout-value .unit { margin-left: 0.25em; font-size: var(--text-lead); letter-spacing: 0; color: var(--ink-muted); }
.readout-value .point { margin-inline: -0.2em; }
.meta { display: flex; flex-direction: column; align-items: end; font-size: var(--text-small); color: var(--ink-muted); text-align: right; }
.record strong { font-weight: 600; color: var(--ink); }
.record .num { font-family: var(--font-mono); font-weight: 500; }
@media (max-width: 560px) {
  .meta { flex-direction: row; flex-wrap: wrap; gap: 0 var(--s3); align-items: baseline; text-align: left; }
}

/* The twins as one white dot that splits into orange and blue: the page's one authored motion. */
.twins { position: relative; flex: none; width: 24px; height: 12px; }
.twins i {
  position: absolute;
  top: 0;
  left: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 700ms var(--ease-out), background-color 300ms ease-out;
}
[data-state="split"] .twins i:first-child { background: var(--twin-orange); transform: translateX(-6px); }
[data-state="split"] .twins i:last-child { background: var(--twin-blue); transform: translateX(6px); }

.canvas-wrap { position: relative; }
#pendulum {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  max-height: clamp(300px, calc(100vh - 270px), 680px);
  max-height: clamp(300px, calc(100svh - 270px), 680px);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--scope);
  touch-action: none;
  cursor: grab;
}
#pendulum.dragging { cursor: grabbing; }
#pendulum.running { cursor: default; }
.status {
  position: absolute;
  left: 50%;
  bottom: var(--s3);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - var(--s5));
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  background: var(--scope-veil);
  font-size: var(--text-small);
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
  color: var(--ink-muted);
  pointer-events: none;
}
.status.bad { color: var(--bad); }

.controls { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--s2); }
@media (max-width: 560px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .controls .primary { grid-column: 1 / -1; }
}
button {
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--panel-raised);
  font-weight: 550;
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, transform 80ms ease-out;
}
button:hover:not(:disabled) { background: var(--panel-hover); border-color: var(--hairline-strong); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--white); border-color: var(--white); color: var(--night); font-weight: 650; }
button.primary:hover:not(:disabled) { background: var(--white-hot); border-color: var(--white-hot); }

.angles { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s3) var(--s4); padding-top: var(--s1); }
.angle { display: grid; gap: var(--s1); flex: 0 1 9.5rem; }
.angle-label { font-size: var(--text-small); color: var(--ink-muted); }
.field { position: relative; display: block; }
.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 2rem 0 var(--s3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--scope);
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.field input::-webkit-inner-spin-button,
.field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field input:hover { border-color: var(--hairline-strong); }
.suffix { position: absolute; top: 50%; right: var(--s3); transform: translateY(-50%); font-family: var(--font-mono); color: var(--ink-muted); pointer-events: none; }
.hint { flex: 1 1 15rem; align-self: center; font-size: var(--text-small); color: var(--ink-muted); }
@media (max-width: 560px) {
  .angle { flex: 1 1 8rem; }
}

/* Sections are separated by space and a hairline, not boxes. */
.panel { padding-top: var(--s5); border-top: 1px solid var(--hairline); }
.panel > h2 { margin-bottom: var(--s3); }
.result:not([hidden]) + .panel { padding-top: 0; border-top: 0; }
@media (min-width: 920px) {
  .col-side > .result[hidden] + .panel { padding-top: 0; border-top: 0; }
}
.caption { margin-top: var(--s2); font-size: var(--text-small); line-height: 1.5; color: var(--ink-muted); }

.panel.result {
  padding: var(--s4) var(--s5) var(--s5);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  background: var(--panel);
}
.ladder { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s3) 0 var(--s4); padding: 0; font-size: var(--text-small); }
.ladder li { padding: 2px var(--s3); border: 1px solid var(--hairline); border-radius: var(--r-pill); background: var(--scope); color: var(--ink-muted); }
.ladder b { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.ladder .unit { color: var(--ink-muted); }
.claim label { display: block; margin-bottom: var(--s1); font-size: var(--text-small); color: var(--ink-muted); }
.claim-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.claim-row input {
  flex: 1 1 12rem;
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--s3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--scope);
}
.claim-row input:hover { border-color: var(--hairline-strong); }
.claim-row input::placeholder { color: var(--ink-muted); opacity: 1; }
.claim-row button { flex: 0 0 auto; }
@media (max-width: 560px) {
  .claim-row button { flex: 1 1 100%; }
}
.claim-msg { margin-top: var(--s3); font-size: var(--text-small); }
.claim-msg:empty { display: none; }
.claim-msg.good { color: var(--good); }
.claim-msg.bad { color: var(--bad); }

#gap { display: block; width: 100%; height: 140px; border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--scope); }

/* Leaderboard */
.top { list-style: none; display: grid; gap: 2px; margin: 0; padding: 0; }
.top li {
  display: grid;
  grid-template-columns: 2.5ch minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  padding: 2px 2px 2px var(--s2);
  border-radius: var(--r-sm);
}
.top li:nth-child(odd) { background: var(--row-stripe); }
.top li.mine { background: var(--row-mine); }
.top .rank { font-family: var(--font-mono); font-size: var(--text-small); color: var(--ink-muted); text-align: right; }
.top .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .you {
  margin-left: var(--s2);
  padding: 0 6px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  font-size: var(--text-label);
  color: var(--ink-muted);
  vertical-align: 1px;
}
.top .time { font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.3; }
.top .time small { display: block; font-size: var(--text-label); color: var(--ink-muted); }
.top .time .unit, .record .num .unit { font-family: var(--font-body); font-size: var(--text-small); color: var(--ink-muted); }
.top .unb-label { font-family: var(--font-display); font-weight: 700; color: var(--white); }
.top button { display: grid; place-items: center; width: 40px; min-height: 36px; padding: 0; }
.top button svg { width: 12px; height: 12px; fill: currentColor; }
.top.bottom { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--hairline-strong); }
.top.bottom[hidden] { display: none; }
.top .empty { display: block; padding: var(--s2) 0; color: var(--ink-muted); background: none; }

/* Map */
.map-body { display: grid; gap: var(--s3); }
.map-notes .caption { margin-top: 0; }
.toggle { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; margin-bottom: var(--s2); font-size: var(--text-small); color: var(--ink); cursor: pointer; }
.toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--white); cursor: pointer; }
@media (min-width: 920px) {
  .map-body { grid-template-columns: minmax(0, 1fr) minmax(11rem, 15rem); gap: var(--s5); align-items: start; }
}
#map { display: block; width: 100%; aspect-ratio: 1; border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--scope); cursor: crosshair; touch-action: manipulation; }
#map { touch-action: pan-y; }
#map.zoomed { touch-action: none; }
#map.panning { cursor: grabbing; }
.map-zoom { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }
.map-zoom button { min-width: 36px; min-height: 36px; padding: 0 var(--s2); font-family: var(--font-mono); }
.map-zoom .zoom-level { min-width: 4ch; padding: 0 var(--s1); font-family: var(--font-mono); font-size: var(--text-small); color: var(--ink-muted); text-align: right; font-variant-numeric: tabular-nums; }
.map-key { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s5); margin-top: var(--s3); font-size: var(--text-small); color: var(--ink-muted); }
.key-item { display: inline-flex; align-items: center; gap: var(--s2); }
.map-key .ramp { width: 72px; height: 8px; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--map-1), var(--map-2), var(--map-3), var(--map-4), var(--map-5)); }
.unb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--white); outline: 2px solid var(--hairline-strong); outline-offset: 2px; }

/* Explainer */
.explain { margin-top: var(--s8); padding-top: var(--s6); border-top: 1px solid var(--hairline); }
.explain-intro { max-width: 68ch; }
.explain h2 { margin-bottom: var(--s3); font-size: var(--text-headline); letter-spacing: -0.015em; }
.explain h3 { margin-bottom: var(--s2); }
.explain p { color: var(--ink-soft); }
.explain p + p { margin-top: var(--s3); }
.explain-notes { display: grid; gap: var(--s5) var(--s6); margin-top: var(--s6); }
@media (min-width: 920px) {
  .explain-notes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.footer { margin-top: var(--s7); padding-top: var(--s4); border-top: 1px solid var(--hairline); font-size: var(--text-small); color: var(--ink-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { max-width: 1120px; margin: var(--s4) auto; color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  button, .twins i { transition: none; }
}
