/* pedalmania.cc: the game's look, made for a browser.
   Apollo palette (AdamCYounis), the game's 5×7 pixel font, panels over a dawn sky.
   --s is the art scale (whole CSS px per game pixel for the sky and sprites); UI chrome is drawn at 2×. */

@font-face {
  font-family: "Pedal Pixel";
  src: url("/fonts/pedal-pixel.woff2") format("woff2");
  font-display: block;
}

:root {
  color-scheme: dark;
  --pixel: "Pedal Pixel", ui-monospace, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --s: 1;

  /* Apollo */
  --ink: #090a14; --night: #10141f; --shade: #151d28; --slate: #202e37; --slate2: #394a50;
  --grey: #577277; --grey2: #819796; --muted: #a8b5b2; --light: #c7cfcc; --pale: #ebede9;
  --b0: #172038; --b1: #253a5e; --b2: #3c5e8b; --b3: #4f8fba; --b4: #73bed3; --b5: #a4dddb;
  --g0: #19332d; --g1: #25562e; --g2: #468232; --g3: #75a743; --g4: #a8ca58; --g5: #d0da91;
  --br0: #4d2b32; --br1: #7a4841; --br2: #ad7757; --br3: #c09473; --br4: #d7b594; --br5: #e7d5b3;
  --au0: #341c27; --au1: #602c2c; --au2: #884b2b; --au3: #be772b; --au4: #de9e41; --au5: #e8c170;
  --r0: #241527; --r1: #411d31; --r2: #752438; --r3: #a53030; --r4: #cf573c; --r5: #da863e;
  --p0: #1e1d39; --p1: #402751; --p2: #7a367b; --p3: #a23e8c; --p4: #c65197; --p5: #df84a5;

  /* the game's UI */
  --panel: rgba(23, 32, 56, 0.94);       /* #172038 over the sky (RouteSelect.PANEL_BG) */
  --well: rgba(16, 20, 31, 0.75);        /* #10141f inset fields and idle tabs */
  --zebra: #1c2a48;
  --line: var(--b2);
  --gold: var(--au5);
  --amber: var(--au4);
  --focus: #f0d030;                      /* UiTheme.FOCUS: the title's focused button */
  --btn: #292839; --btn-edge: #080818; --btn-hover: #39384a; --btn-text: #e7e7e7;
  --up: var(--g3);
  --down: #ef7d63;
}
@media (min-width: 760px) and (min-height: 600px) { :root { --s: 2; } }
@media (min-width: 1880px) and (min-height: 1040px) { :root { --s: 3; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--b0);
  color: var(--pale);
  font: 16px/1.55 var(--sans);
  overflow-x: hidden;
}
img, svg { display: block; }
a { color: var(--b4); }
a:hover { color: var(--b5); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pixelated, .flag, .sprite, .island, .island__part, .islet, .cloud, .shot { image-rendering: pixelated; image-rendering: crisp-edges; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -64px; z-index: 50; }
.skip:focus { top: 16px; }

/* --- type ---------------------------------------------------------------------------------------- */

.px { font-family: var(--pixel); font-size: 16px; line-height: 24px; font-weight: 400; letter-spacing: 0; text-transform: none; -webkit-font-smoothing: none; font-smooth: never; }
.px-8 { font-size: 8px; line-height: 12px; }
.px-24 { font-size: 24px; line-height: 32px; }
.px-32 { font-size: 32px; line-height: 40px; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.small { font-size: 13px; }

/* SkyBackdrop.draw_heading: gold, a 1 px plum outline and an ink drop shadow, in game pixels (--o). */
.heading {
  --o: 2px;
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: 32px;
  line-height: 40px;
  color: var(--gold);
  -webkit-font-smoothing: none;
  text-shadow:
    calc(-1 * var(--o)) 0 var(--r0), var(--o) 0 var(--r0), 0 calc(-1 * var(--o)) var(--r0), 0 var(--o) var(--r0),
    var(--o) var(--o) var(--r0), calc(-1 * var(--o)) var(--o) var(--r0),
    var(--o) calc(2 * var(--o)) var(--ink);
}
.heading--24 { font-size: 24px; line-height: 32px; }
.heading--16 { font-size: 16px; line-height: 24px; }
/* SkyBackdrop.draw_outlined: light text with a 1 px dark outline, readable over the sky. */
.outlined {
  font-family: var(--pixel);
  -webkit-font-smoothing: none;
  text-shadow: -2px 0 var(--b0), 2px 0 var(--b0), 0 -2px var(--b0), 0 2px var(--b0);
}

/* --- the dawn sky (SkyBackdrop) ------------------------------------------------------------------ */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(
    var(--b0) 0 16.667%, var(--b1) 0 33.333%, var(--b2) 0 50%, var(--b3) 0 66.667%, var(--b4) 0 83.333%, var(--b5) 0
  );
}
/* Bands meet in a 4-row checkerboard dither, as in the game. */
.sky__seam {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--k) * 100% / 6 - 2px * var(--s));
  top: round(down, calc(var(--k) * 100% / 6 - 2px * var(--s)), calc(1px * var(--s)));
  height: calc(4px * var(--s));
  background-size: calc(2px * var(--s)) calc(2px * var(--s));
  image-rendering: pixelated;
}
.star {
  position: absolute;
  width: calc(1px * var(--s));
  height: calc(1px * var(--s));
  background: var(--light);
  animation: twinkle 3.696s step-end infinite;
}
/* a = 0.5 + 0.5 sin(1.7 t + phase): bright above 0.35, a sparkle above 0.92, dim below. */
@keyframes twinkle {
  0% { background: var(--light); box-shadow: none; }
  15.9% {
    background: var(--pale);
    box-shadow: calc(-1px * var(--s)) 0 var(--pale), calc(1px * var(--s)) 0 var(--pale), 0 calc(-1px * var(--s)) var(--pale), 0 calc(1px * var(--s)) var(--pale);
  }
  34.1% { background: var(--light); box-shadow: none; }
  54.9% { background: var(--grey); }
  95.2% { background: var(--light); }
}
.cloud {
  position: absolute;
  left: 0;
  top: calc(var(--y) / 360 * 100%);
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  animation: drift var(--dur) linear var(--delay) infinite;
  will-change: transform;
}
@keyframes drift {
  from { transform: translateX(calc(var(--w) * var(--s) * -1px)); }
  to { transform: translateX(100vw); }
}
/* round(sin(t) * 2): the island, the islets and the title's letters move whole pixels. */
@keyframes bob {
  0% { transform: translateY(0); }
  4.02% { transform: translateY(calc(1px * var(--s))); }
  13.5% { transform: translateY(calc(2px * var(--s))); }
  36.5% { transform: translateY(calc(1px * var(--s))); }
  45.98% { transform: translateY(0); }
  54.02% { transform: translateY(calc(-1px * var(--s))); }
  63.5% { transform: translateY(calc(-2px * var(--s))); }
  86.5% { transform: translateY(calc(-1px * var(--s))); }
  95.98% { transform: translateY(0); }
}

/* --- the landing page's hero: the title screen, bigger ------------------------------------------ */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  justify-items: center;
  padding: calc(18px * var(--s)) 16px calc(14px * var(--s));
  overflow: hidden;
}
.title {
  --o: calc(1px * var(--s));
  margin: 0;
  display: flex;
  font-size: calc(32px * var(--s));
  line-height: calc(40px * var(--s));
  white-space: nowrap;
}
.title span { display: inline-block; animation: bob 2.856s step-end infinite; animation-delay: calc(var(--i) * 0.25s - 2.856s); }
.title span.sp { width: calc(6px * 4 * var(--s)); }
.slogan {
  margin: calc(6px * var(--s)) 0 0;
  font-size: 16px;
  line-height: 24px;
  color: var(--pale);
  text-align: center;
}
/* The 640×360 title frame's middle band, centred even when it's wider than the screen. */
.stage {
  position: relative;
  align-self: center;
  justify-self: start;
  left: 50%;
  width: calc(640px * var(--s));
  height: calc(222px * var(--s));
  margin: calc(6px * var(--s)) 0 calc(6px * var(--s)) calc(-320px * var(--s));
}
.island {
  position: absolute;
  left: calc(var(--x) * var(--s) * 1px);
  top: calc(var(--y) * var(--s) * 1px);
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  background: url("/assets/hero/island.png") 0 0 / 100% 100% no-repeat;
  animation: bob 7.854s step-end infinite;
}
.island__part {
  position: absolute;
  left: calc(var(--x) * var(--s) * 1px);
  top: calc(var(--y) * var(--s) * 1px);
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  background-image: url("/assets/hero/island-anim.png");
  background-size: calc(var(--sw) * var(--s) * 1px) calc(var(--sh) * var(--s) * 1px);
  background-position-x: 0;
  background-position-y: calc(var(--sy) * var(--s) * -1px);
  animation: play var(--dur) steps(var(--n)) infinite;
}
@keyframes play { to { background-position-x: calc(var(--w) * var(--n) * var(--s) * -1px); } }
.islet {
  position: absolute;
  left: calc(var(--x) * var(--s) * 1px);
  top: calc(var(--y) * var(--s) * 1px);
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  opacity: 0.55;   /* the game veils them with the sky at 45% */
  animation: bob var(--dur) step-end var(--delay) infinite;
}
.menu {
  display: flex;
  gap: calc(8px * var(--s));
  justify-content: center;
  flex-wrap: wrap;
}
.menu .btn { width: calc(112px * var(--s)); min-height: calc(24px * var(--s)); padding: 0 8px; font-size: calc(8px * var(--s)); line-height: calc(12px * var(--s)); border-width: calc(1px * var(--s)); }
.hero__more {
  position: absolute;
  bottom: 8px;
  left: 50%;
  margin-left: -9px;
  animation: bob 1.6s step-end infinite;
}
@media (max-width: 979px) {
  .menu { display: grid; grid-template-columns: repeat(2, auto); }
}
@media (max-width: 759px), (max-height: 599px) {
  .hero { padding-top: 40px; }
  .title { font-size: 40px; line-height: 48px; --o: 2px; }
  .title span.sp { width: 30px; }
  .slogan { max-width: 22em; }
  .stage { left: auto; justify-self: center; margin: 6px 0; width: 100%; max-width: 640px; height: calc(222px + 24px); }
  .stage .island { left: 50%; margin-left: -144px; top: 30px; }
  .stage .islet[data-k="0"] { left: -24px; top: 4px; }
  .stage .islet[data-k="1"] { left: auto; right: -12px; top: 150px; }
  .menu { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 420px; gap: 8px; }
  .menu .btn { width: auto; min-height: 48px; font-size: 16px; line-height: 24px; border-width: 2px; }
}

/* --- buttons (UiTheme) -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: none;
  color: var(--btn-text);
  background: var(--btn);
  border: 2px solid var(--btn-edge);
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); color: #fff; }
.btn:focus-visible, .btn.is-focus { outline: none; border-color: var(--focus); color: var(--focus); background: var(--btn-hover); box-shadow: 0 0 0 2px var(--focus); }
.menu .btn.is-focus, .menu .btn:focus-visible { box-shadow: none; border-width: calc(2px * var(--s)); }
.btn:active { background: var(--btn-edge); }
/* RouteSelect._style_primary: amber with plum ink. */
.btn--primary { background: var(--amber); border-color: var(--r0); color: var(--r0); }
.btn--primary:hover { background: var(--gold); color: var(--r0); }
.btn--primary:focus-visible { background: var(--gold); color: var(--r0); border-color: var(--r0); box-shadow: 0 0 0 2px var(--focus), 0 0 0 4px var(--r0); }
.btn--quiet { background: var(--b1); border-color: var(--ink); box-shadow: inset 0 2px 0 var(--line); }
.btn--quiet:hover { background: var(--line); }
.btn--danger { background: var(--r2); border-color: var(--ink); color: var(--pale); }
.btn--danger:hover { background: var(--r3); }
.btn--small { min-height: 32px; padding: 2px 10px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.arrow::after { content: ">"; margin-left: 4px; }

/* --- page frame -------------------------------------------------------------------------------- */

.wrap { width: 100%; max-width: 1152px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 760px) { .wrap { padding: 0 24px; } }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--b0);   /* solid: tables scrolling under it must not show through */
  border-bottom: 2px solid var(--ink);
  box-shadow: inset 0 -2px 0 var(--b1), 0 2px 0 rgba(9, 10, 20, 0.35);
}
.topbar__in { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 32px; height: 32px; border: 2px solid var(--ink); }
.brand .heading { --o: 2px; font-size: 16px; line-height: 24px; }
.nav { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.nav .btn { min-height: 40px; padding: 6px 12px; }
.nav .btn[aria-current="page"] { border-color: var(--gold); color: var(--gold); }
@media (max-width: 559px) {
  .topbar { position: static; }
  .nav { width: 100%; margin-left: 0; display: grid; grid-template-columns: repeat(3, 1fr); }
  .nav .btn { padding: 6px 4px; }
}
main { flex: 1 0 auto; }
/* Anchored headings land below the sticky top bar. */
main [id] { scroll-margin-top: 84px; }
main.page { padding: 28px 0 56px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin: 4px 0 20px; }
.page-head .outlined { color: var(--muted); }
.crumbs { margin: 0 0 8px; font-size: 13px; }
.crumbs a { color: var(--muted); }
.footer { margin-top: 32px; }
/* The footer is the edge of an island: critters on the grass, a dirt cliff, then the panel. */
.ground { height: 24px; background:
  linear-gradient(var(--g4) 0 2px, var(--g3) 2px 8px, var(--g2) 8px 10px, transparent 10px),
  repeating-linear-gradient(90deg, var(--br1) 0 30px, var(--br0) 30px 32px) 0 10px / 100% 14px no-repeat;
  border-bottom: 2px solid var(--ink); }
.footer__panel { background: #151d28; }
.footer__in { display: grid; gap: 16px; padding-top: 20px; padding-bottom: 28px; font-size: 13px; color: var(--muted); }
@media (min-width: 760px) { .footer__in { grid-template-columns: 1fr auto; align-items: end; } }
.footer a { color: var(--light); }
.footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.meadow { position: relative; height: 80px; overflow: hidden; }
.meadow .sprite { position: absolute; bottom: -6px; }
@media (max-width: 559px) { .meadow .sprite:nth-child(3) { display: none; } }

/* --- panels (RoutePreview, SettingsScreen) ----------------------------------------------------- */

.panel {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--line);
  padding: 20px;
}
@media (max-width: 559px) { .panel { padding: 16px; } }
.panel + .panel, .panel + .tabs, .stack > * + * { margin-top: 20px; }
.panel h2, .panel h3 { margin-top: 0; }
.panel p { margin: 0 0 12px; }
.panel--well { background: var(--well); box-shadow: none; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.lede { font-size: 17px; color: var(--light); max-width: 40em; }

/* Folder tabs: closed tabs sit lower; the open one joins the panel with a gold bar on top. */
.tabs { display: flex; align-items: flex-end; gap: 4px; overflow-x: auto; scrollbar-width: thin; padding: 0 2px; margin-bottom: -2px; position: relative; z-index: 1; }
.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px;
  margin-top: 6px;
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: none;
  color: var(--muted);
  background: var(--well);
  border: 2px solid var(--ink);
  border-bottom: 0;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--pale); background: rgba(37, 58, 94, 0.9); }
.tab[aria-current] { position: relative; margin-top: 0; padding: 10px 14px 6px; color: var(--gold); background: #172038; }
.tab[aria-current]::before { content: ""; position: absolute; left: 2px; right: 2px; top: 2px; height: 4px; background: var(--gold); view-transition-name: tabbar; }
.tab svg { flex: none; }
.tabs + .panel { border-top-color: var(--ink); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Badges: RoutePreview._badge. */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.badge {
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--b1);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--line);
}
.badge__label { font-family: var(--pixel); font-size: 16px; line-height: 20px; color: var(--muted); -webkit-font-smoothing: none; }
.badge__value { grid-column: 2; font-family: var(--pixel); font-size: 16px; line-height: 20px; color: var(--pale); -webkit-font-smoothing: none; }
.badge__value--big { font-size: 24px; line-height: 32px; }
.badge svg { grid-row: span 2; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; min-height: 28px; font-family: var(--pixel); font-size: 16px; line-height: 24px; -webkit-font-smoothing: none; background: var(--b1); border: 2px solid var(--ink); color: var(--pale); white-space: nowrap; }
.chip--live { background: var(--g1); color: var(--pale); box-shadow: inset 0 2px 0 var(--g2); }
.chip--upcoming { background: var(--b2); }
.chip--finished { background: var(--slate2); color: var(--light); }
.chip--gold { background: var(--amber); color: var(--r0); }
.chip--cat { color: var(--ink); }
.dot { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--ink); background: var(--muted); }

/* Key caps: SettingsScreen.draw_key. */
.key {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 6px 4px;
  text-align: center;
  font-family: var(--pixel);
  -webkit-font-smoothing: none;
  color: var(--pale);
  background: var(--b1);
  border: 2px solid var(--ink);
  box-shadow: inset 0 -2px 0 var(--line);
}
.key--inline { font-size: 16px; line-height: 18px; padding: 0 5px 2px; margin: 0 2px; vertical-align: 1px; }
.results.results--fit { min-width: 0; }
.code-caps { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.code-caps .key { font-size: 32px; line-height: 40px; padding: 6px 10px 10px; }
.code-caps .dash { font-family: var(--pixel); font-size: 32px; line-height: 52px; color: var(--muted); }
.code-caps--small { justify-content: flex-start; gap: 4px; }
.code-caps--small .key { font-size: 16px; line-height: 24px; padding: 2px 6px 4px; }
.code-caps--small .dash { font-size: 16px; line-height: 32px; }
@media (max-width: 420px) { .code-caps .key { font-size: 24px; line-height: 32px; padding: 4px 6px 8px; } .code-caps { gap: 4px; } }

/* --- forms (SettingsScreen rows) --------------------------------------------------------------- */

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label, legend.label { font-family: var(--pixel); font-size: 16px; line-height: 24px; color: var(--gold); -webkit-font-smoothing: none; padding: 0; }
.hint { font-size: 13px; color: var(--muted); }
.input, .select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font: 16px/24px var(--sans);
  color: var(--pale);
  background: var(--well);
  border: 2px solid var(--ink);
  border-radius: 0;
}
.input--px { font-family: var(--pixel); -webkit-font-smoothing: none; }
.input--code { font-family: var(--pixel); font-size: 32px; line-height: 40px; letter-spacing: 6px; text-align: center; text-transform: uppercase; max-width: 340px; }
.input:focus, .select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px var(--focus); }
.input::placeholder { color: var(--grey2); }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(-45deg, transparent 50%, var(--gold) 50%); background-position: right 16px top 50%, right 10px top 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.select option { background: var(--b0); color: var(--pale); }
.row2 { display: grid; gap: 16px; }
@media (min-width: 640px) { .row2 { grid-template-columns: 1fr 1fr; } .row3 { grid-template-columns: 1fr 1fr 1fr; } }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.errors { margin: 0 0 16px; padding: 12px 16px; background: rgba(117, 36, 56, 0.55); border: 2px solid var(--r3); }
.errors p { margin: 0; }
.errors ul { margin: 4px 0 0; padding-left: 20px; }
.notice { margin: 0 0 16px; padding: 12px 16px; background: rgba(70, 130, 50, 0.35); border: 2px solid var(--g2); }
.dev-hint { margin: 12px 0 0; padding: 8px 12px; border: 2px dashed var(--grey); color: var(--light); font-size: 13px; }

/* Segmented choice: a sliding amber slab (Row.CHOICE). */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { display: inline-block; min-height: 36px; padding: 6px 12px; font-family: var(--pixel); font-size: 16px; line-height: 20px; -webkit-font-smoothing: none; color: var(--muted); background: var(--well); border: 2px solid var(--ink); cursor: pointer; }
.seg input:checked + label { background: var(--amber); color: var(--r0); box-shadow: inset 0 2px 0 var(--gold); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Switch: Row.TOGGLE. */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-family: var(--pixel); font-size: 16px; -webkit-font-smoothing: none; }
.switch input { appearance: none; position: relative; width: 52px; height: 28px; margin: 0; background: var(--slate2); border: 2px solid var(--ink); cursor: pointer; transition: background 0.15s steps(3); }
.switch input::before { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: var(--pale); border: 2px solid var(--ink); box-shadow: inset 0 -2px 0 var(--muted); transition: left 0.15s steps(4); }
.switch input:checked { background: var(--g2); }
.switch input:checked::before { left: 26px; }
.switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* --- flags, jerseys, sprites -------------------------------------------------------------------- */

/* Flags.draw: an 18×12 cell of the atlas inside a 1 px #090a14 frame. */
.flag {
  --k: 1;
  display: inline-block;
  flex: none;
  box-sizing: content-box;
  width: calc(18px * var(--k));
  height: calc(12px * var(--k));
  border: calc(1px * var(--k)) solid var(--ink);
  background-image: url("/assets/flags/flags.png");
  background-size: calc(288px * var(--k)) calc(156px * var(--k));
  background-position: calc(var(--fx) * var(--k) * -1px) calc(var(--fy) * var(--k) * -1px);
  vertical-align: -2px;
}
.flag--2 { --k: 2; }
.flag--3 { --k: 3; }
.flag--4 { --k: 4; }
.flag--none { background: var(--slate2); color: var(--muted); font: 8px/12px var(--pixel); text-align: center; }
.flag--2.flag--none { font-size: 16px; line-height: 24px; }
/* Flags.draw_waving: each column rides a travelling wave. */
.flagpole { position: relative; display: inline-block; width: calc(26px * var(--k)); height: calc(40px * var(--k)); --k: 3; }
.flagpole__pole { position: absolute; left: calc(1px * var(--k)); top: calc(2px * var(--k)); width: calc(1px * var(--k)); bottom: 0; background: var(--light); box-shadow: calc(1px * var(--k)) 0 var(--grey2); }
.flagpole__finial { position: absolute; left: 0; top: 0; width: calc(3px * var(--k)); height: calc(3px * var(--k)); background: var(--gold); }
.flagpole__cloth { position: absolute; left: calc(3px * var(--k)); top: calc(3px * var(--k)); display: flex; }
.flagpole__cloth i {
  display: block;
  width: calc(1px * var(--k));
  height: calc(12px * var(--k));
  background-image: url("/assets/flags/flags.png");
  background-size: calc(288px * var(--k)) calc(156px * var(--k));
  background-position: calc((var(--fx) + var(--c)) * var(--k) * -1px) calc(var(--fy) * var(--k) * -1px);
  box-shadow: 0 calc(-1px * var(--k)) 0 var(--ink), 0 calc(1px * var(--k)) 0 var(--ink);
  animation: wave 1.571s step-end infinite;
  animation-delay: calc(var(--c) * 0.1375s - 1.571s);
}
.flagpole__cloth i:last-child { box-shadow: 0 calc(-1px * var(--k)) 0 var(--ink), 0 calc(1px * var(--k)) 0 var(--ink), calc(1px * var(--k)) 0 0 var(--ink); }
/* sin(4t − 0.55x) · (x/18) · 1.6: the far columns swing a pixel up and down, darker in the troughs. */
@keyframes wave {
  0% { transform: translateY(0); filter: none; }
  8.3% { transform: translateY(calc(var(--amp) * var(--k) * 1px)); }
  25% { filter: brightness(0.86); }
  41.7% { transform: translateY(0); }
  58.3% { transform: translateY(calc(var(--amp) * var(--k) * -1px)); }
  75% { filter: none; }
  91.7% { transform: translateY(0); }
}
.jersey { display: inline-block; vertical-align: -3px; }
.sprite {
  display: block;
  width: calc(var(--fw) * var(--k) * 1px);
  height: calc(var(--fh) * var(--k) * 1px);
  background-image: var(--img);
  background-size: calc(var(--fw) * var(--n) * var(--k) * 1px) calc(var(--fh) * var(--k) * 1px);
  animation: sprite var(--dur) steps(var(--n)) infinite;
  --k: 2;
}
@keyframes sprite { to { background-position-x: calc(var(--fw) * var(--n) * var(--k) * -1px); } }
.sprite--ghost { opacity: 0.5; filter: saturate(0.2) brightness(1.5); }
.shot { width: 100%; height: auto; border: 2px solid var(--ink); }
.shot--smooth { image-rendering: auto; }
.feel-card { max-width: 448px; justify-self: center; width: 100%; }
.icon { display: inline-block; vertical-align: middle; }

/* --- route cards and profiles ------------------------------------------------------------------- */

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.cards > * { min-width: 0; }
@media (max-width: 559px) { .cards { grid-template-columns: 1fr; } }
.card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 12px 12px 12px 16px;
  color: var(--pale);
  text-decoration: none;
  background: var(--panel);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--b1);
}
.card:hover { background: rgba(37, 58, 94, 0.92); color: var(--pale); }
.card:hover::before, .card:focus-visible::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--gold); }
.card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--gold); }
.card__head { display: flex; align-items: center; gap: 10px; }
.card__name { font-family: var(--pixel); font-size: 16px; line-height: 24px; color: var(--pale); -webkit-font-smoothing: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.card:hover .card__name { color: var(--gold); }
.card__meta { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; font-family: var(--pixel); font-size: 16px; line-height: 20px; color: var(--muted); -webkit-font-smoothing: none; }
.card__meta .mountains { margin-left: auto; }
.card__leader { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 20px; }
.card__leader b { color: var(--pale); font-weight: 600; }
.profile { width: 100%; height: auto; border: 2px solid var(--ink); }
.profile-wrap { max-width: calc(var(--pw) * 2px + 4px); }
.mountains { display: inline-flex; gap: 2px; }
.minimap { width: 100%; height: auto; border: 2px solid var(--ink); }
@media (prefers-reduced-motion: reduce) { .rider-dot { display: none; } }

/* --- results tables, after ProCyclingStats ------------------------------------------------------- */

.table-scroll { overflow-x: auto; margin: 0 -2px; border: 2px solid var(--ink); background: var(--b0); scrollbar-width: thin; }
.results { width: 100%; min-width: 560px; border-collapse: collapse; font: 14px/1.3 var(--sans); font-variant-numeric: tabular-nums; }
@media (max-width: 599px) { .results { min-width: 0; } .results .opt { display: none; } .results td, .results th { padding-left: 6px; padding-right: 6px; } .results .ag { display: none; } }
.results th {
  padding: 8px 8px 6px;
  font: 11px/1.2 var(--sans);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  background: var(--b1);
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
.results td { padding: 5px 8px; height: 30px; border-top: 1px solid rgba(9, 10, 20, 0.6); white-space: nowrap; }
.results tbody tr:nth-child(odd) { background: var(--zebra); }
.results tbody tr:nth-child(even) { background: var(--b0); }
.results tbody tr:hover { background: var(--b1); }
.results tr.is-me { background: rgba(190, 119, 43, 0.28) !important; box-shadow: inset 4px 0 0 var(--gold); }
.results tr.is-split td { border-top: 2px dashed var(--grey); }
.results .num { text-align: right; }
.results .rank { width: 40px; text-align: right; font-weight: 700; color: var(--pale); }
.results .chg { width: 46px; font-size: 12px; }
.results .rider { width: 100%; }
.results .rider a { color: var(--pale); text-decoration: none; }
.results .rider a:hover { color: var(--gold); text-decoration: underline; }
.results .rider b { font-weight: 700; letter-spacing: 0.01em; }
.results .ag { margin-left: 6px; font-size: 11px; color: var(--muted); }
.results .time { text-align: right; font-weight: 600; }
.results .time--gap { font-weight: 400; color: var(--light); }
.results .same { color: var(--muted); }
.results .pts { text-align: right; font-weight: 700; color: var(--gold); }
.results .date { color: var(--muted); font-size: 13px; }
.results .ride-link { color: var(--b4); }
.results .partial td { color: var(--muted); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.chg .up { color: var(--up); }
.chg .down { color: var(--down); }
.chg .same { color: var(--grey2); }
.chg svg { display: inline-block; margin-right: 3px; vertical-align: 0; }
.pause-mark { display: inline-block; margin-left: 4px; color: var(--muted); font-size: 11px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin: 12px 0; }
.filters .field { gap: 2px; min-width: 130px; flex: 1 1 130px; }
.filters .field > label { font-size: 16px; line-height: 20px; color: var(--muted); }
.filters .select { min-height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; }
.js .filters .apply { display: none; }
.provisional { display: inline-flex; gap: 6px; align-items: center; color: var(--gold); font-size: 13px; }

/* --- landing sections --------------------------------------------------------------------------- */

.section { padding: 28px 0; }
.section--first { padding-top: 40px; }
.split { display: grid; gap: 24px; align-items: center; }
.split > * { min-width: 0; }
/* The game's screenshots stay at 1× (or 2× on a Retina screen) wherever they fit. */
.split .shot, .devices .shot { max-width: 644px; margin: 0 auto; }
@media (min-width: 1180px) { .split { grid-template-columns: minmax(0, 1fr) 644px; } .split--rev { grid-template-columns: 644px minmax(0, 1fr); } }
@media (max-width: 699px) { .shot { image-rendering: auto; } }
.feature-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.feature-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; color: var(--light); }
.feature-list svg { margin-top: 4px; }
.road {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--b1);
  aspect-ratio: 16 / 9;
}
.road img.shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.road .rider { position: absolute; transform: translate(-50%, -100%); }
.nameplate {
  position: absolute;
  transform: translate(-50%, 0);
  padding: 0 4px;
  font: 8px/12px var(--pixel);
  -webkit-font-smoothing: none;
  background: rgba(9, 10, 20, 0.82);
  border: 1px solid var(--ink);
  color: var(--pale);
  white-space: nowrap;
}
@media (min-width: 560px) { .nameplate { font-size: 16px; line-height: 20px; padding: 0 6px; border-width: 2px; } }
.ridelist { position: absolute; right: 8px; top: 8px; display: grid; gap: 4px; }
.ridelist div { display: grid; grid-template-columns: auto auto; gap: 8px; justify-content: space-between; padding: 2px 8px; min-width: 150px; font: 16px/20px var(--pixel); -webkit-font-smoothing: none; background: rgba(9, 10, 20, 0.82); border: 2px solid var(--ink); }
@media (max-width: 559px) { .ridelist div { font-size: 8px; line-height: 12px; min-width: 96px; padding: 1px 4px; border-width: 1px; } }
.ridelist .ahead { color: var(--down); }
.ridelist .behind { color: var(--up); }
.feel { width: 100%; height: auto; border: 2px solid var(--ink); }
.slider { position: relative; height: 18px; margin: 10px 0 4px; background: var(--well); border: 2px solid var(--ink); }
.slider span { position: absolute; inset: 0 50% 0 0; background: var(--amber); box-shadow: inset 0 2px 0 var(--gold); }
.slider i { position: absolute; left: calc(50% - 7px); top: -8px; width: 14px; height: 30px; background: var(--pale); border: 2px solid var(--ink); box-shadow: inset 0 -2px 0 var(--muted); }
.devices { display: grid; gap: 16px; align-items: end; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .devices { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
@media (min-width: 1180px) { .devices { grid-template-columns: 668px minmax(0, 1fr); } }
.device { position: relative; background: var(--slate); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--slate2); padding: 12px; }
.device--mac { padding: 10px 10px 0; }
.device--mac::after { content: ""; display: block; height: 14px; margin: 10px -24px 0; background: var(--slate2); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--grey2); }
.device--ipad { padding: 16px; }
.device .shot { border: 2px solid var(--ink); }
.later { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.cta { display: grid; gap: 24px; align-items: center; }
@media (min-width: 900px) { .cta { grid-template-columns: auto 1fr auto; } }
.cta__flag { justify-self: center; }

/* Free and Pro. */
.plans { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
@media (min-width: 760px) { .plans { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.plan { display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--well); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--b1); }
.plan--pro { background: rgba(37, 58, 94, 0.55); border-color: var(--au3); box-shadow: inset 0 2px 0 var(--au4); }
.plan__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.plan__big { margin: 4px 0 0; font-size: 32px; line-height: 40px; color: var(--pale); }
.plan__big .muted { font-size: 16px; }
.plan__sub { margin: 0; color: var(--light); }
.plan .feature-list { margin: 6px 0 4px; }
.plan__foot { margin-top: auto; padding-top: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.plans__note { margin: 12px 0 0; }
.pro-badge { display: inline-block; padding: 2px 8px 4px; font: 16px/20px var(--pixel); -webkit-font-smoothing: none; color: var(--r0); background: var(--gold); border: 2px solid var(--r0); box-shadow: inset 0 -2px 0 var(--amber), 2px 2px 0 var(--ink); }
.pro-badge--big { font-size: 24px; line-height: 32px; padding: 2px 12px 6px; box-shadow: inset 0 -4px 0 var(--amber), 2px 4px 0 var(--ink); }
.btn--primary[disabled], .btn--primary[disabled]:hover { background: var(--slate2); border-color: var(--ink); color: var(--light); opacity: 1; }

/* --- signed-in pages ---------------------------------------------------------------------------- */

.grid2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .grid2--wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.grid2--top { align-items: start; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bars { width: 100%; height: auto; }
.list { margin: 0; padding: 0; list-style: none; }
.list a, .results td a { color: var(--pale); text-decoration: none; }
.list a:hover, .results td a:hover { color: var(--gold); text-decoration: underline; }
.list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid rgba(60, 94, 139, 0.45); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.rider-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.rider-head h1 { font-family: var(--sans); font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: 0.01em; }
.rider-head h1 b { font-weight: 800; }
.rider-head h1 span { font-weight: 400; }
.rider-head .meta { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--light); margin-top: 6px; }
.round-strip { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.round { display: grid; gap: 4px; align-content: start; padding: 10px 12px; background: var(--panel); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--b1); color: var(--pale); text-decoration: none; }
.round .chip { font-size: 8px; line-height: 12px; min-height: 0; padding: 2px 4px; border-width: 1px; vertical-align: 3px; }
.round:hover { background: var(--b1); color: var(--pale); }
.round[aria-current] { border-color: var(--gold); }
.round__n { font-family: var(--pixel); font-size: 16px; line-height: 20px; color: var(--gold); -webkit-font-smoothing: none; }
.round small { color: var(--muted); }
.rounds-form { display: grid; gap: 12px; }
.round-row { display: grid; gap: 10px; padding: 14px; background: var(--well); border: 2px solid var(--ink); }
@media (min-width: 900px) { .round-row { grid-template-columns: 34px 2fr 1.3fr 1.3fr 1.4fr auto; align-items: end; } }
.round-row .n { font-family: var(--pixel); font-size: 24px; line-height: 44px; color: var(--gold); -webkit-font-smoothing: none; }
.charts { display: grid; gap: 16px; }
.chart { width: 100%; height: auto; border: 2px solid var(--ink); }
/* Charts and the big profile come in two drawings, so each stays at a whole-number scale. */
.narrow-only { display: none; }
@media (max-width: 699px) { .wide-only { display: none; } .narrow-only { display: block; } }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 6px; }
.legend { font-size: 13px; color: var(--muted); }
.prose { max-width: 44em; }
.prose h2 { font-family: var(--pixel); font-weight: 400; font-size: 16px; line-height: 24px; color: var(--gold); margin: 28px 0 8px; -webkit-font-smoothing: none; }
.prose p, .prose li { color: var(--light); }
.center { text-align: center; }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.big-404 { font-size: calc(64px * var(--s)); line-height: 1; }

/* --- motion ------------------------------------------------------------------------------------- */

@view-transition { navigation: auto; }
::view-transition-group(tabbar) { animation-duration: 0.18s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  @view-transition { navigation: none; }
}
