@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-italic-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  font-style: italic;
}
@font-face {
  font-family: "Archivo Black";
  src: url("../fonts/archivo-black-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  font-style: normal;
}

/* TrackRage — design system and pages.

   The palette, the heavy italic display type and the slash markers are
   taken from the game's own menus (main menu, lobby, options screens) so
   the site reads as the same product rather than as marketing about it. */

:root {
  /* Slate blue-grey, as in the game's UI panels over the track. */
  --ink-900: #171c23;
  --ink-850: #1e242c;
  --ink-800: #262d36;
  --ink-700: #313a45;
  --ink-600: #3c4653;
  --line: #4a5665;
  --line-soft: #333d4a;

  --text: #f2f5f8;
  --text-dim: #a9b3bf;
  --text-faint: #77828f;

  --rage: #f47b31;          /* the menu highlight, and the brand */
  --rage-bright: #ff8f45;
  --volt: #f5d03b;          /* the yellow marker bar */
  --cool: #56c5da;          /* the "online" tab */
  --good: #5bc26a;          /* the green marker */
  --bad: #ef5a5a;

  --shell: min(1180px, 100% - 2.5rem);
  --radius: 6px;            /* the game's boxes are nearly square */
  --radius-sm: 4px;
  --shadow: 0 24px 60px -30px rgb(0 0 0 / 0.85);

  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Archivo Black", "Archivo", system-ui, sans-serif;

  --step-0: clamp(0.95rem, 0.92rem + 0.15vw, 1.02rem);
  --step-1: clamp(1.15rem, 1.05rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.5rem, 1.3rem + 0.9vw, 2.1rem);
  --step-3: clamp(2rem, 1.6rem + 2vw, 3.2rem);
  --step-4: clamp(2.8rem, 1.9rem + 4.4vw, 5.4rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink-850);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
p { margin: 0 0 1rem; }
a { color: inherit; }
img, svg { max-width: 100%; height: auto; }

.shell { width: var(--shell); margin-inline: auto; }
.muted { color: var(--text-dim); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--rage); color: #10141a; padding: 0.75rem 1.25rem; font-weight: 700; }
.skip:focus { left: 0; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--volt); outline-offset: 3px; border-radius: 2px;
}

/* The game marks every selectable row with a thin slanted bar. It is the
   single most recognisable thing in its interface, so it carries over. */
.mark { position: relative; padding-left: 1.1rem; }
.mark::before {
  content: ""; position: absolute; left: 0; top: 0.25em; bottom: 0.25em;
  width: 4px; background: var(--rage); transform: skewX(-12deg);
}
.mark[data-tone="volt"]::before { background: var(--volt); }
.mark[data-tone="cool"]::before { background: var(--cool); }
.mark[data-tone="good"]::before { background: var(--good); }

/* Orange over yellow, exactly as under the game's screen titles. */
.rule { display: flex; gap: 6px; margin-bottom: 1.25rem; }
.rule::before, .rule::after { content: ""; height: 4px; transform: skewX(-12deg); }
.rule::before { width: 56px; background: var(--rage); }
.rule::after { width: 26px; background: var(--volt); }

/* --- header ------------------------------------------------------------ */

.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--ink-900) 88%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 68px; }

.brand { display: inline-flex; align-items: baseline; gap: 0.35rem; text-decoration: none; margin-right: auto; }
.brand-mark { width: 5px; height: 22px; background: var(--rage); transform: skewX(-12deg); align-self: center; margin-right: 0.45rem; }
.brand-text { font-family: var(--font-display); font-size: 1.2rem; letter-spacing: 0.01em; }
.brand-text em { font-style: italic; font-family: var(--font-body); font-weight: 900; color: var(--rage); }

.site-nav { display: flex; align-items: center; gap: 1.5rem; }
.site-nav a, .site-nav button {
  text-decoration: none; color: var(--text-dim);
  font-weight: 700; font-size: 0.86rem; letter-spacing: 0.08em; text-transform: uppercase;
  background: none; border: 0; font-family: inherit; cursor: pointer;
}
.site-nav a:hover, .site-nav button:hover { color: var(--text); }
.site-nav .btn { color: #16191f; }
.nav-toggle { display: none; }

/* --- buttons ------------------------------------------------------------ */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  font: inherit; font-weight: 800; font-size: 0.88rem;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  text-decoration: none; cursor: pointer;
  transition: background-color 130ms ease, border-color 130ms ease, transform 130ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { --btn-bg: var(--rage); --btn-fg: #171c23; }
.btn-primary:hover { --btn-bg: var(--rage-bright); }
.btn-secondary { border-color: var(--line); --btn-bg: color-mix(in srgb, var(--ink-700) 80%, transparent); }
.btn-secondary:hover { border-color: var(--rage); }
.btn-ghost { --btn-fg: var(--text-dim); padding-inline: 0.25rem; }
.btn-ghost:hover { --btn-fg: var(--text); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

/* --- hero --------------------------------------------------------------- */

.hero {
  position: relative; isolation: isolate; overflow: hidden;
  padding: clamp(3.5rem, 8vw, 7rem) 0 clamp(3rem, 6vw, 5rem);
}
/* A frame from the game itself, pushed back far enough that white text on
   it still clears contrast without a flat black scrim. */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: url("../img/race-night.webp") center/cover no-repeat;
  opacity: 0.5;
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(105deg, var(--ink-850) 28%, color-mix(in srgb, var(--ink-850) 70%, transparent) 58%, transparent 92%),
    linear-gradient(0deg, var(--ink-850), transparent 45%);
}
.hero-inner { display: grid; gap: clamp(2rem, 5vw, 4rem); grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--rage); margin-bottom: 1rem;
}
.eyebrow::before { content: ""; width: 5px; height: 15px; background: currentColor; transform: skewX(-12deg); }

.hero h1 { text-shadow: 0 6px 30px rgb(0 0 0 / 0.55); }
.hero h1 span { display: block; color: var(--rage); }
.hero-lede { font-size: var(--step-1); color: var(--text-dim); max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.8rem; }
.tagline {
  font-weight: 800; font-size: 0.78rem; letter-spacing: 0.34em;
  text-transform: uppercase; color: var(--text-dim); margin-top: 1.4rem;
}

.hero-panel {
  background: color-mix(in srgb, var(--ink-800) 92%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.4rem;
}
.hero-panel h2 {
  font-size: 0.76rem; letter-spacing: 0.18em; font-style: normal; font-weight: 800;
  color: var(--text-faint); margin-bottom: 1rem;
}
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.ladder li {
  display: grid; grid-template-columns: 2rem 1fr auto; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.7rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--ink-700) 75%, transparent);
  border-left: 4px solid var(--line);
}
.ladder li:nth-child(1) { border-left-color: var(--rage); }
.ladder li:nth-child(2) { border-left-color: var(--volt); }
.ladder li:nth-child(3) { border-left-color: var(--cool); }
.ladder .rank { font-weight: 900; font-style: italic; color: var(--text-faint); }
.ladder li:first-child .rank { color: var(--rage); }
.ladder .time { font-variant-numeric: tabular-nums; font-weight: 700; }

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

.section { padding: clamp(3.5rem, 8vw, 6rem) 0; }
.section-alt { background: var(--ink-800); border-block: 1px solid var(--line-soft); }
.section-head { max-width: 58ch; margin-bottom: clamp(2rem, 4vw, 3rem); }

.feature-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  background: var(--ink-800); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 1.5rem;
  border-top: 3px solid var(--rage);
}
.card:nth-child(4n+2) { border-top-color: var(--cool); }
.card:nth-child(4n+3) { border-top-color: var(--volt); }
.card:nth-child(4n+4) { border-top-color: var(--good); }
.card h3 { font-size: var(--step-1); }
.card p:last-child { margin-bottom: 0; }
.card-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm); margin-bottom: 0.9rem;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--rage) 20%, transparent); color: var(--rage);
}

.shot {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: block;
}
.shot img { display: block; width: 100%; }

.stat-band { background: var(--ink-900); border-block: 1px solid var(--line-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line-soft); }
.stat { background: var(--ink-900); padding: clamp(1.6rem, 4vw, 2.5rem) 1.5rem; text-align: center; }
.stat dt { font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.stat dd { margin: 0.35rem 0 0; font-weight: 900; font-style: italic; font-size: var(--step-3); font-variant-numeric: tabular-nums; }

.split { display: grid; gap: clamp(2rem, 5vw, 4rem); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: center; }

.cta {
  position: relative; text-align: center; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(2.5rem, 6vw, 4rem) 1.5rem;
  background: linear-gradient(120deg, color-mix(in srgb, var(--rage) 26%, var(--ink-800)), var(--ink-850));
}
.cta .hero-actions { justify-content: center; }

/* --- tables and boards --------------------------------------------------- */

.board { width: 100%; border-collapse: collapse; }
.board th, .board td { padding: 0.8rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
.board th { font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); font-weight: 800; }
.board td.num, .board th.num { text-align: right; font-variant-numeric: tabular-nums; }
.board tbody tr:hover { background: color-mix(in srgb, var(--ink-700) 60%, transparent); }
.board .self { background: color-mix(in srgb, var(--rage) 14%, transparent); }
.table-wrap { overflow-x: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }
select, input, textarea {
  font: inherit; color: var(--text);
  background: var(--ink-700); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.65rem 0.85rem; width: 100%;
}
select { max-width: 220px; }
label { display: block; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 0.35rem; font-weight: 700; }

/* --- forms and auth ------------------------------------------------------ */

.auth-wrap { display: grid; place-items: center; padding: clamp(2.5rem, 7vw, 5rem) 0; }
.panel {
  width: min(480px, 100%);
  background: var(--ink-800); border: 1px solid var(--line);
  border-top: 3px solid var(--rage);
  border-radius: var(--radius); padding: clamp(1.6rem, 4vw, 2.4rem);
  box-shadow: var(--shadow);
}
.panel h1 { font-size: var(--step-2); }
.field { margin-bottom: 1rem; }
.field-hint { font-size: 0.82rem; color: var(--text-faint); margin: 0.35rem 0 0; }
.field-error { font-size: 0.85rem; color: var(--bad); margin: 0.35rem 0 0; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 0.8rem; font-size: 0.9rem; color: var(--text-dim); text-transform: none; letter-spacing: 0; font-weight: 400; }
.check input { width: auto; margin-top: 0.2rem; }
.form-foot { margin-top: 1.4rem; font-size: 0.9rem; color: var(--text-dim); }

.notice {
  border-radius: var(--radius-sm); padding: 0.85rem 1rem; margin-bottom: 1.2rem;
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  background: var(--ink-700); font-size: 0.92rem;
}
.notice[data-kind="error"] { border-left-color: var(--bad); color: #ffdcdc; }
.notice[data-kind="success"] { border-left-color: var(--good); color: #ddf7e4; }
.notice[hidden] { display: none; }

/* --- link (device) page --------------------------------------------------- */

.code-input {
  font-weight: 900; font-style: italic; font-size: var(--step-2);
  letter-spacing: 0.22em; text-align: center; text-transform: uppercase;
}
.device-facts { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.45rem; font-size: 0.9rem; color: var(--text-dim); }
.device-facts li { position: relative; padding-left: 1rem; }
.device-facts li::before { content: ""; position: absolute; left: 0; top: 0.45em; width: 3px; height: 0.9em; background: var(--rage); transform: skewX(-12deg); }
.device-facts strong { color: var(--text); }

/* --- profile -------------------------------------------------------------- */

.profile-head { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; padding-block: clamp(2rem, 5vw, 3.5rem); }
.avatar {
  width: 82px; height: 82px; border-radius: var(--radius); display: grid; place-items: center;
  font-weight: 900; font-style: italic; font-size: 2rem;
  background: linear-gradient(145deg, var(--rage), #c9541b); color: #171c23;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 800;
  padding: 0.35rem 0.7rem; border-radius: var(--radius-sm);
  background: var(--ink-700); border: 1px solid var(--line); color: var(--text-dim);
  border-left: 3px solid var(--line);
}
.chip[data-tone="gold"] { color: var(--volt); border-left-color: var(--volt); }

/* --- legal ---------------------------------------------------------------- */

.prose { max-width: 72ch; padding-block: clamp(2.5rem, 6vw, 4rem); }
.prose h1 { font-size: var(--step-3); }
.prose h2 { font-size: var(--step-1); margin-top: 2.5rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.4rem; }
.prose .placeholder {
  background: color-mix(in srgb, var(--volt) 12%, transparent);
  border-left: 4px solid var(--volt); padding: 0.75rem 1rem; margin: 1rem 0;
  font-size: 0.92rem; color: var(--text-dim);
}

/* --- footer ---------------------------------------------------------------- */

.site-footer { border-top: 1px solid var(--line-soft); background: var(--ink-900); padding-top: clamp(2.5rem, 5vw, 3.5rem); }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); padding-bottom: 2.5rem; }
.footer-grid h2 { font-family: var(--font-body); font-style: normal; font-size: 0.74rem; letter-spacing: 0.18em; color: var(--text-faint); font-weight: 800; }
.footer-grid nav { display: grid; gap: 0.5rem; align-content: start; }
.footer-grid a { color: var(--text-dim); text-decoration: none; font-size: 0.92rem; }
.footer-grid a:hover { color: var(--rage); }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
  border-top: 1px solid var(--line-soft); padding-block: 1.2rem;
  font-size: 0.84rem; color: var(--text-faint);
}
.footer-bottom p { margin: 0; }

/* --- errors ----------------------------------------------------------------- */

.error-page { display: grid; place-items: center; text-align: center; min-height: 60vh; padding: 2rem 0; }
.error-code { font-weight: 900; font-style: italic; font-size: clamp(5rem, 18vw, 10rem); line-height: 1; color: var(--rage); margin: 0; }

/* --- responsive --------------------------------------------------------------- */

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .nav-toggle {
    display: grid; place-items: center; width: 42px; height: 42px;
    background: var(--ink-700); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
  }
  .nav-toggle-bar, .nav-toggle-bar::before, .nav-toggle-bar::after {
    content: ""; display: block; width: 18px; height: 2px; background: var(--text); position: relative;
  }
  .nav-toggle-bar::before { position: absolute; top: -6px; }
  .nav-toggle-bar::after { position: absolute; top: 6px; }
  .site-nav {
    position: fixed; inset: 68px 0 auto; flex-direction: column; align-items: stretch;
    gap: 0; padding: 0.5rem 1.25rem 1.25rem;
    background: var(--ink-900); border-bottom: 1px solid var(--line);
    transform: translateY(-130%); transition: transform 200ms ease;
  }
  .site-nav a, .site-nav button { padding: 0.9rem 0; text-align: left; border-bottom: 1px solid var(--line-soft); }
  .site-nav[data-open="true"] { transform: translateY(0); }
  .hero::before { opacity: 0.32; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover { transform: none; }
}
