/* CARider — player select overlay.
   Calm, restrained theme matching the character models: charcoal / navy panels, off-white
   text, pale blue-grey sky, one quiet accent (muted denim blue). */
:root {
  --charcoal: #2e3340;
  --graphite: #33373f;
  --ink: #262a31;
  --slate: #454b55;
  --denim: #4a5a74;
  --denim-2: #5d6e88;
  --denim-soft: #8d9cb4;   /* denim tint for fills on dark panels */
  --off-white: #eeeeea;
  --sky: #dfe3e9;
  --haze: #c8ced8;
  --panel: rgba(38, 42, 49, 0.86);
  --panel-line: rgba(238, 238, 234, 0.1);
  --text-dim: rgba(238, 238, 234, 0.68);
  --accent: var(--denim-2);
  --subject-x: 50%;
  --subject-y: 48%;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: "Inter", "Helvetica Neue", "Segoe UI", Roboto, "Liberation Sans", Arial, system-ui, sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--sky); color: var(--off-white);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: inherit; }
button:focus-visible { outline: 2px solid var(--off-white); outline-offset: 3px; }

/* ---------------- overlays ---------------- */
#speedlines, #vignette, #flash { position: fixed; inset: 0; pointer-events: none; }
#speedlines {
  inset: -30%;
  opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(238, 238, 234, 0) 0deg 4.2deg, rgba(238, 238, 234, 0.55) 4.2deg 4.45deg,
    rgba(238, 238, 234, 0) 4.45deg 9.1deg, rgba(238, 238, 234, 0.35) 9.1deg 9.3deg);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent 0 38%, #000 70%);
  mask-image: radial-gradient(ellipse at 50% 50%, transparent 0 38%, #000 70%);
}
#vignette { background: radial-gradient(ellipse at 50% 45%, transparent 60%, rgba(38, 42, 49, 0.22) 100%); }
#flash { background: var(--off-white); opacity: 0; }
#speedlines, #flash { will-change: transform, opacity; } /* own compositor layers: no re-raster per frame */

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.no-ui #ui, .no-ui #vignette { display: none; }

/* ---------------- brand ---------------- */
.brand {
  position: absolute; left: calc(32px + var(--safe-l)); top: calc(26px + var(--safe-t));
  padding: 14px 20px 14px 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-line);
  pointer-events: none !important;
}
.logo {
  margin: 0; line-height: 1; color: var(--off-white);
  font-size: clamp(28px, 3vw, 42px); letter-spacing: -0.02em; font-weight: 300;
}
.logo .ca { font-weight: 800; }
.logo .rider { font-weight: 300; }
.subtitle {
  margin: 8px 0 0 2px; color: var(--text-dim); font-weight: 600; text-transform: uppercase;
  font-size: clamp(11px, 1vw, 13px); letter-spacing: 0.22em;
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.subtitle::before { content: ""; width: 18px; height: 2px; background: var(--denim-soft); border-radius: 1px; }

/* ---------------- card ---------------- */
.card {
  position: absolute; left: calc(32px + var(--safe-l)); top: 50%;
  transform: translateY(-42%);
  width: min(360px, 32vw);
  padding: 20px 22px 20px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(38, 42, 49, 0.18);
}
.card.in-right { animation: card-in-r 0.38s cubic-bezier(.2, .8, .2, 1); }
.card.in-left { animation: card-in-l 0.38s cubic-bezier(.2, .8, .2, 1); }
@keyframes card-in-r { from { opacity: 0; transform: translate(16px, -42%); } to { opacity: 1; transform: translateY(-42%); } }
@keyframes card-in-l { from { opacity: 0; transform: translate(-16px, -42%); } to { opacity: 1; transform: translateY(-42%); } }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.vehicle {
  color: var(--denim-soft); font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
}
.num { font-size: 11px; color: var(--text-dim); letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.name {
  margin: 8px 0 8px; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.05;
  font-weight: 700; letter-spacing: -0.015em; color: var(--off-white);
}
.tagline {
  margin: 0 0 16px; font-weight: 400; font-size: clamp(13px, 1.05vw, 14px); line-height: 1.45; color: var(--text-dim);
}
.stats {
  list-style: none; margin: 0; padding: 14px 0 0; display: grid; gap: 9px;
  border-top: 1px solid var(--panel-line);
}
.stats li { display: grid; grid-template-columns: 84px 1fr 22px; align-items: center; gap: 10px; }
.stats .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); }
.stats .bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; height: 6px; }
.stats .bar i {
  display: block; border-radius: 2px; background: rgba(238, 238, 234, 0.12);
  transition: background-color 0.3s;
}
.stats .bar i.on { background: var(--denim-soft); }
.stats .val { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- arrows & dots ---------------- */
.arrow {
  position: absolute; top: var(--subject-y); width: 48px; height: 48px; margin-top: -24px;
  border-radius: 50%; border: 1px solid var(--panel-line);
  background: rgba(38, 42, 49, 0.78); color: var(--off-white);
  cursor: pointer; display: grid; place-items: center; padding: 0;
  transition: background-color 0.15s, transform 0.12s;
}
.arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.arrow:hover { background: rgba(38, 42, 49, 0.82); }
.arrow:active { transform: scale(0.94); }
.arrow.prev { left: calc(var(--subject-x) - min(30vh, 280px) - 24px); }
.arrow.next { left: calc(var(--subject-x) + min(30vh, 280px) - 24px); }
.dots {
  position: absolute; left: var(--subject-x); bottom: calc(36px + var(--safe-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 999px;
  background: rgba(38, 42, 49, 0.5);
}
.dot {
  width: 8px; height: 8px; padding: 0; border-radius: 4px; border: 0;
  background: rgba(238, 238, 234, 0.4); cursor: pointer; transition: width 0.25s, background-color 0.25s;
}
.dot::after { content: ""; display: block; margin: -10px; height: 28px; } /* larger hit area */
.dot.active { background: var(--off-white); width: 22px; }

/* ---------------- play ---------------- */
.play {
  position: absolute; right: calc(32px + var(--safe-r)); bottom: calc(28px + var(--safe-b));
  min-width: 200px; padding: 16px 32px; border: 0; border-radius: 12px;
  background: var(--denim); color: var(--off-white);
  font-weight: 700; font-size: 17px; letter-spacing: 0.24em; text-indent: 0.24em;
  box-shadow: 0 8px 24px rgba(38, 42, 49, 0.22);
  cursor: pointer; transition: background-color 0.15s, transform 0.12s;
}
.play:hover { background: var(--denim-2); }
.play:active { transform: translateY(1px) scale(0.99); }

/* ---------------- toast / loading ---------------- */
.toast {
  position: absolute; left: 50%; top: 20%; transform: translate(-50%, -6px);
  padding: 12px 22px; border-radius: 999px;
  background: rgba(38, 42, 49, 0.88); color: var(--off-white);
  font-size: 15px; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap;
  box-shadow: 0 10px 28px rgba(38, 42, 49, 0.2);
  opacity: 0; pointer-events: none !important;
}
.toast.show { animation: toast 2.2s ease forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 6px); }
  10%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -4px); }
}
.loading {
  position: absolute; left: 50%; bottom: 46%; transform: translateX(-50%);
  display: grid; gap: 10px; justify-items: center; color: var(--charcoal);
  font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  transition: opacity 0.4s; pointer-events: none !important;
}
.loading .progress { width: 160px; height: 2px; border-radius: 1px; background: rgba(46, 51, 64, 0.18); overflow: hidden; }
.loading .progress i { display: block; height: 100%; width: 0; background: var(--charcoal); transition: width 0.3s; }
.loading.done { opacity: 0; }

/* ---------------- portrait (phones) ---------------- */
body.portrait .brand {
  left: 50%; transform: translateX(-50%); top: calc(12px + var(--safe-t)); padding: 10px 18px 10px;
  text-align: center; display: grid; justify-items: center;
}
body.portrait .logo { font-size: clamp(30px, 9vw, 44px); }
body.portrait .subtitle { margin-top: 6px; font-size: 10px; gap: 8px; }
/* portrait: dots, card and button stack up from the bottom edge (no fixed offsets to collide) */
body.portrait #ui {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  padding: 0 calc(12px + var(--safe-r)) calc(14px + var(--safe-b)) calc(12px + var(--safe-l));
}
body.portrait .dots { position: relative; order: 1; align-self: center; left: auto; bottom: auto; transform: none; }
body.portrait .card { position: relative; order: 2; left: auto; top: auto; width: auto; transform: none; padding: 14px 16px 14px; }
body.portrait .play { position: relative; order: 3; right: auto; bottom: auto; min-width: 0; padding: 15px 0; font-size: 16px; }
body.portrait .card.in-right { animation-name: card-in-r-p; }
body.portrait .card.in-left { animation-name: card-in-l-p; }
@keyframes card-in-r-p { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes card-in-l-p { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
body.portrait .name { font-size: 22px; margin: 4px 0 4px; }
body.portrait .tagline { font-size: 12.5px; line-height: 1.4; margin-bottom: 10px; }
body.portrait .stats { gap: 6px; padding-top: 10px; }
body.portrait .stats li { grid-template-columns: 78px 1fr 20px; }
body.portrait .arrow { width: 42px; height: 42px; margin-top: -21px; }
body.portrait .arrow.prev { left: calc(10px + var(--safe-l)); }
body.portrait .arrow.next { left: auto; right: calc(10px + var(--safe-r)); }
body.portrait .toast { top: 15%; font-size: 14px; }

/* short landscape screens (phones held sideways) */
@media (orientation: landscape) and (max-height: 500px) {
  .brand { top: calc(12px + var(--safe-t)); left: calc(16px + var(--safe-l)); padding: 8px 14px; }
  .logo { font-size: 26px; }
  .subtitle { margin-top: 4px; font-size: 9px; }
  .card {
    left: calc(16px + var(--safe-l)); top: auto; bottom: calc(12px + var(--safe-b)); transform: none;
    width: min(290px, 40vw); padding: 10px 14px 12px;
  }
  .card.in-right, .card.in-left { animation-name: card-in-r-p; }
  .name { font-size: 19px; margin: 4px 0; }
  .tagline { font-size: 11.5px; margin-bottom: 8px; }
  .stats { gap: 5px; padding-top: 8px; }
  .arrow { width: 40px; height: 40px; margin-top: -20px; }
  .arrow.prev { left: calc(var(--subject-x) - min(42vh, 280px) - 20px); }
  .arrow.next { left: calc(var(--subject-x) + min(42vh, 280px) - 20px); }
  .play { min-width: 150px; font-size: 14px; padding: 12px 20px; right: calc(16px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); }
  .dots { bottom: calc(14px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) {
  .card.in-right, .card.in-left { animation: none; }
  .toast.show { animation: none; opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------- run mode: the select overlay and its effects are hidden ---------------- */
body.playing #ui, body.playing #vignette, body.playing #speedlines { display: none; }
