/* pro28.com — the lap gate. Same black / chrome / red as the site. */

:root {
  --red: #e8112d;
  --red-hi: #ff3b4e;
  --red-lo: #9d0011;
  --pink: #fe5e89;
  --dim: #9a9aa6;
  --line: #24242b;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: #000; color: #e9e9ee;
  font-family: var(--font);
  overscroll-behavior-x: none;
  touch-action: pan-y;              /* the page scrolls; the controls do not */
}

/* the game owns the first screen, the gear rail sits under it */
#shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#stage, #pad, .pad, #stick { touch-action: none; }

/* ---------- header ---------- */

#bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px 16px; flex-wrap: wrap; padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #000;
}
#bar img { display: block; height: 84px; width: auto; }

#clocks { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.clock {
  min-width: 88px; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #0c0c0f; text-align: center;
}
.clock span {
  display: block;
  font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: #6e6e79;
}
.clock b {
  font: 700 19px/1.25 ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.clock b.over { color: var(--red-hi); }
.clock.goal { border-color: transparent; background: linear-gradient(180deg, var(--red-hi), var(--red-lo)); }
.clock.goal span { color: rgba(255,255,255,.8); }

/* ---------- class picker ---------- */

#classbar {                       /* centred in the header row */
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap;
}

/* where the chosen class sits between the slowest and quickest car */
#speedbar {
  flex-basis: 100%; order: 9;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: -6px;                 /* sits right under the class buttons */
}
#speedbar span {
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: #5c5c66;
}
#speedbar .track {
  position: relative;
  width: min(320px, 46vw); height: 14px; border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(90deg, #2a2a33, #6b1120 55%, var(--red-hi));
  background-clip: padding-box;
  border: 4px solid transparent;    /* fat hit area, thin looking bar */
}
#speedmark {
  position: absolute; top: 50%; left: 0;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,.55), 0 0 18px rgba(232,17,45,.6);
  transition: left .18s ease;
}

@media (pointer: coarse) {
  #speedbar .track { width: min(260px, 56vw); }
}
.cblabel {
  margin-right: 4px;
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: #5c5c66;
}
.cls {
  padding: 7px 15px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #101014; color: var(--dim);
  font: 700 11px/1 var(--font); letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer;
}
.cls:hover { color: #fff; border-color: #40404c; }
.cls.mode { margin-left: 14px; border-style: dashed; }
.cls.on {
  border-color: transparent; color: #fff;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 55%, var(--red-lo));
  box-shadow: 0 0 16px rgba(232,17,45,.35);
}

@media (pointer: coarse) {
  #classbar { gap: 5px; }
  .cls { padding: 6px 10px; font-size: 10px; letter-spacing: .08em; }
  .cblabel { display: none; }
  .cls.mode { display: none; }      /* a phone always gets the stick */
}

/* Narrow screens: one clean stack — logo, classes, slider, clocks. Ordering by
   flex-order across a wrapping row was unpredictable; a column is not. */
@media (max-width: 760px), (pointer: coarse) {
  #bar {
    flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    gap: 5px; padding: 8px 10px;
  }
  #bar img { order: 1; height: 44px; margin: 0 auto; }
  #classbar { order: 2; justify-content: center; gap: 5px; }
  /* flex-basis is HEIGHT in a column — 100% here ate the whole stack */
  #speedbar { order: 3; margin: 0; flex: 0 0 auto; }
  #clocks   { order: 4; justify-content: center; }
  #enterbar { display: none; }
  .cls { padding: 6px 10px; font-size: 10px; letter-spacing: .08em; }
  .cls.mode { display: none; }
  .cblabel { display: none; }
  .clock { min-width: 56px; padding: 2px 7px; }
  .clock b { font-size: 13px; }
  .clock span { font-size: 8px; letter-spacing: .12em; }
  #msg { min-height: 24px; font-size: 10px; }
  #reset { right: 8px; bottom: 0; padding: 5px 9px; font-size: 9px; }
  #fleabar { padding: 4px 10px 2px; min-height: 28px; }
}

/* ---------- stage ---------- */

#stage { position: relative; flex: 1; min-height: 0; }
#cv { display: block; }

#msg {                            /* its own strip under the board, never over it */
  flex: 0 0 auto;
  min-height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-top: 1px solid var(--line);
  background: #060607;
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--dim);
  text-align: center;
}

#help {
  position: absolute; left: 14px; top: 12px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #55555f;
  line-height: 1.9; pointer-events: none;
}
#help b { color: #8b8b96; font-weight: 600; }

#reset {
  position: absolute; right: 14px; bottom: 2px;   /* sits right on the track edge */
  padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #101014; color: var(--dim);
  font: 600 11px/1 var(--font); letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer;
}
#reset:hover { border-color: var(--red); color: #fff; }

/* ---------- touch pad ---------- */

#pad { display: none; }

/* left thumb: analog steering */
#stick {
  position: absolute; left: 14px; bottom: 14px;
  width: 132px; height: 132px; border-radius: 50%;
  border: 1px solid #2c2c36; background: rgba(14,14,18,.72);
  touch-action: none;
}
#stick::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 78px; height: 1px; margin: 0 0 0 -39px;
  background: #2c2c36;
}
#knob {
  position: absolute; left: 50%; top: 50%;
  width: 62px; height: 62px; margin: -31px 0 0 -31px;
  border-radius: 50%;
  border: 1px solid #45454f;
  background: radial-gradient(circle at 40% 35%, #3a3a44, #16161b);
  box-shadow: 0 4px 12px rgba(0,0,0,.6);
}
#stick.live #knob { border-color: var(--red-hi); background: radial-gradient(circle at 40% 35%, #ff5e6e, #9d0011); }

/* right thumb: throttle and brake */
.pad {
  position: absolute; bottom: 14px;
  width: 100px; height: 100px; border-radius: 50%;
  border: 1px solid #33333d; background: rgba(16,16,20,.82);
  display: flex; align-items: center; justify-content: center;
  font: 700 15px/1 var(--font); letter-spacing: .1em; text-transform: uppercase;
  color: #cfcfd8; user-select: none; touch-action: none;
}
.pad.down { background: rgba(232,17,45,.55); border-color: var(--red-hi); color: #fff; }
#padBrake { right: 124px; width: 86px; height: 86px; bottom: 20px; }

/* point mode: stick right, gas left, brake tucked beside it and half the size */
body.point #stick { left: auto; right: 14px; }
body.point #padGas { right: auto; left: 14px; }
body.point #padBrake {
  display: flex; right: auto; left: 122px;
  width: 64px; height: 64px; bottom: 32px;
  font-size: 11px;
}
#padGas {
  right: 16px;
  background: linear-gradient(180deg, rgba(255,59,78,.35), rgba(157,0,17,.35));
  border-color: var(--red);
}

@media (pointer: coarse) {
  #pad { display: block; }
  #help { display: none; }
  #bar img { height: 44px; }
  .clock { min-width: 56px; padding: 2px 7px; }
  .clock b { font-size: 13px; }
  .clock span { font-size: 8px; letter-spacing: .12em; }
  #msg { min-height: 24px; font-size: 10px; }
  #enterbar { padding: 7px 13px; font-size: 10px; }
  #reset { right: 8px; bottom: 0; padding: 5px 9px; font-size: 9px; }
}

/* ---------- win overlay ---------- */

#win {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.86);
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
#win[hidden] { display: none; }   /* the attribute must win over display:flex */
#win.show { opacity: 1; pointer-events: auto; }
#win .card {
  max-width: 460px; margin: 20px; padding: 34px 32px;
  text-align: center;
  border: 1px solid #33333d; border-radius: 14px;
  background: linear-gradient(180deg, #121216, #0b0b0d);
  box-shadow: 0 30px 90px rgba(0,0,0,.8), 0 0 60px rgba(232,17,45,.18);
}
#win h1 {
  margin: 0 0 6px;
  font-size: 34px; font-weight: 900; font-style: italic; text-transform: uppercase;
  background: linear-gradient(180deg, #fff, #cfd3d8 52%, #7d838c 53%, #fff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#win p { margin: 0 0 22px; color: var(--dim); font-size: 15px; }
#win .lap {
  font: 700 46px/1 ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: #fff; margin-bottom: 4px;
}
#win .lap small { font-size: 18px; color: var(--dim); }
#enter {
  display: inline-block; padding: 13px 30px;
  border: 0; border-radius: 8px;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 55%, var(--red-lo));
  color: #fff; font: 700 14px/1 var(--font); letter-spacing: .16em; text-transform: uppercase;
  cursor: pointer; box-shadow: 0 0 26px rgba(232,17,45,.4);
}
#enter:hover { filter: brightness(1.12); }

.winbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#again {
  padding: 13px 24px;
  border: 1px solid #33333d; border-radius: 8px;
  background: #121217; color: var(--dim);
  font: 700 14px/1 var(--font); letter-spacing: .16em; text-transform: uppercase;
  cursor: pointer;
}
#again:hover { border-color: var(--red); color: #fff; }

/* far right of the header, always there */
#enterbar {
  padding: 9px 18px; border: 0; border-radius: 8px;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 55%, var(--red-lo));
  color: #fff; font: 700 11px/1 var(--font); letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; box-shadow: 0 0 18px rgba(232,17,45,.35);
}
#enterbar:hover { filter: brightness(1.12); }


/* ---------- Mini-Z gear ---------- */

#gear {
  padding: 30px 20px 44px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #0a0a0c, #000);
}
.gearhead { text-align: center; margin-bottom: 20px; }
.gearhead h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3vw, 26px); font-weight: 900; font-style: italic;
  text-transform: uppercase; color: #fff;
}
.gearhead p { margin: 0 auto; max-width: 620px; color: var(--dim); font-size: 14px; }

.rail {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  max-width: 1240px; margin: 0 auto;
}
.pick {
  display: block; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(180deg, #121216, #0b0b0d);
  text-decoration: none;
}
.pick:hover { border-color: var(--red); }
.pick b {
  display: block; margin-bottom: 4px;
  font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: #fff;
}
.pick span { display: block; font-size: 12.5px; color: var(--dim); line-height: 1.5; }

.aff {
  max-width: 1240px; margin: 18px auto 0;
  text-align: center; font-size: 11px; color: #5c5c66;
}


/* ---------- the gear page ---------- */

body.gearpage { height: auto; touch-action: auto; }
#gearbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: #000;
}
#gearbar img { display: block; height: 62px; width: auto; }
#gearbar .back {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim); text-decoration: none;
}
#gearbar .back:hover { color: #fff; }

.gearpage .gearhead { padding: 34px 20px 6px; }
.gearpage .gearhead h1 {
  margin: 0 0 8px; text-align: center;
  font-size: clamp(26px, 4vw, 38px); font-weight: 900; font-style: italic;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff, #cfd3d8 52%, #7d838c 53%, #fff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.gearpage .gearhead p {
  max-width: 640px; margin: 0 auto; text-align: center; color: var(--dim); font-size: 14px;
}

.gearsec { max-width: 1240px; margin: 0 auto; padding: 26px 20px 6px; }
.gearsec h2 {
  margin: 0 0 4px;
  font-size: 17px; font-weight: 800; font-style: italic;
  text-transform: uppercase; letter-spacing: .06em; color: #fff;
}
.gearsec h2::before {
  content: ""; display: inline-block;
  width: 4px; height: 15px; margin-right: 10px; vertical-align: -2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--red-hi), var(--red-lo));
}
.secblurb { margin: 0 0 14px 14px; color: var(--dim); font-size: 13px; }

.gearmore { text-align: center; margin: 18px 0 0; }
.gearmore a {
  color: var(--red-hi); font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; text-decoration: none; font-weight: 700;
}
.gearmore a:hover { text-decoration: underline; }


/* ---------- the one banner under the track ---------- */

#gear { padding: 26px 18px 40px; border-top: 1px solid var(--line);
        background: linear-gradient(180deg, #0a0a0c, #000); }

.banner {
  display: flex; align-items: center; gap: 26px;
  max-width: 760px; margin: 0 auto; padding: 22px 26px;
  border: 1px solid var(--line2); border-radius: 14px;
  background:
    radial-gradient(600px 200px at 20% 50%, rgba(232,17,45,.16), transparent 70%),
    linear-gradient(180deg, #141418, #0b0b0d);
  text-decoration: none;
}
.banner:hover { border-color: var(--red); }

.bannerart {
  flex: 0 0 auto; width: 190px; height: 116px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.02) 0 2px, transparent 2px 9px),
    #2f3131;
  border: 3px solid var(--pink);
  overflow: hidden;
}
.bannerart img { width: 150px; height: auto; transform: rotate(-8deg); }

.bannertext { min-width: 0; }
.bannertext h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3.4vw, 30px); font-weight: 900; font-style: italic;
  text-transform: uppercase; letter-spacing: .01em;
  background: linear-gradient(180deg, #fff, #cfd3d8 52%, #7d838c 53%, #fff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.bannertext p { margin: 0 0 14px; color: var(--dim); font-size: 13.5px; line-height: 1.5; }
.go {
  display: inline-block; padding: 11px 26px; border-radius: 8px;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 55%, var(--red-lo));
  color: #fff; font: 700 13px/1 var(--font); letter-spacing: .16em; text-transform: uppercase;
  box-shadow: 0 0 22px rgba(232,17,45,.38);
}
.banner:hover .go { filter: brightness(1.12); }

@media (max-width: 620px) {
  .banner { flex-direction: column; text-align: center; gap: 16px; padding: 20px; }
  .bannerart { width: 100%; max-width: 300px; height: 132px; }
}


/* ---------- phone in landscape: nothing but the track ---------- */
/* Turn the phone sideways and the chrome gets out of the way, so the whole
   board fits on screen with the controls over it. */
@media (orientation: landscape) and (pointer: coarse),
       (orientation: landscape) and (max-height: 560px) {
  #bar, #fleabar, #msg { display: none; }
  #shell { height: 100vh; height: 100dvh; }
  #stage { flex: 1 1 auto; }
  #gear { display: none; }
  /* Held in from the screen edges: at the very edge a thumb drag catches the
     phone's own back-swipe instead of the stick. */
  /* landscape: the strip floats into the margin beside the board */
  #fleabar {
    display: flex; position: absolute; top: 2px; left: 6px; z-index: 6;
    min-height: 0; padding: 0; gap: 6px; align-items: center;
  }
  #fleabar #fs { position: static; transform: none; }
  #fleabar #reset { position: static; }
  .pad { bottom: 14px; width: 78px; height: 78px; }
  body.point #padGas { left: 42px; }
  #padBrake { width: 56px; height: 56px; bottom: 24px; left: 138px; }
  body.point #stick { right: 42px; width: 104px; height: 104px; bottom: 14px; }
  #knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  #fs { right: 42px; top: 10px; }
}


/* ---------- full screen ---------- */

#fs {                              /* lives in the strip above the board, never on it */
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 6;
  display: none;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid #33333d; border-radius: 8px;
  background: rgba(14,14,18,.8); color: #cfcfd8;
  font-size: 17px; line-height: 1; cursor: pointer;
}
#fs:hover { border-color: var(--red); color: #fff; }
@media (pointer: coarse) { #fs { display: block; } }
body.fullscreen #fs { background: rgba(232,17,45,.5); border-color: var(--red-hi); color: #fff; }
