:root {
  color-scheme: dark;
  --paper: #fff3e0;
  --muted: #d6c6bd;
  --orange: #ff644a;
  --cream: #ffcc9a;
  --ice: #8fe6f5;
  --menu-ink: #101b2a;
  --menu-edge: #34495c;
  --menu-row: #1b2b3c;
  --panel: rgba(15, 16, 29, .87);
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #100e19; color: var(--paper); }
body { user-select: none; }
#stage {
  position: absolute;
  width: min(100vw, 177.7778vh);
  height: min(100vh, 56.25vw);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: #211823;
  font-size: min(1.48vw, 2.63vh);
}
#view, #game-ui, .screen, #hud, .title-shade { position: absolute; inset: 0; width: 100%; height: 100%; }
#view { display: block; }
.screen { z-index: 3; }
#loading {
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 62% 24%, #234256, #101b2a 64%, #09121e);
}
.loading-panel { width: min(22em, 80%); }
.brand-icon { display: block; width: 3em; height: 3em; border: 1px solid #6c8795; border-radius: .24em; }
.loading-panel .brand-icon { margin-bottom: .85em; }
.loading-panel p { margin: .55em 0; font-size: 1.75em; font-weight: 850; }
.loading-bar { height: .23em; overflow: hidden; background: #34495c; }
.loading-bar::before { content: ""; display: block; width: 35%; height: 100%; background: linear-gradient(90deg, var(--orange), var(--cream)); }
.title-shade {
  background: linear-gradient(100deg, #0d1726 4%, rgba(14,24,39,.91) 27%, rgba(15,30,44,.32) 53%, transparent 76%),
    linear-gradient(0deg, rgba(9,19,31,.96), transparent 25%);
}
.title-body { position: absolute; left: 6.05%; top: 9.5%; }
.eyebrow { display: flex; align-items: center; gap: .75em; font-weight: 800; font-size: .79em; letter-spacing: .22em; color: var(--cream); }
.eyebrow span { width: 1.65em; height: .23em; background: var(--orange); transform: skewX(-23deg); }
.title-brand { color: var(--ice); }
h1 {
  margin: .25em 0 .30em -.04em;
  font-size: 5.25em;
  line-height: .80;
  font-weight: 950;
  font-style: italic;
  letter-spacing: -.075em;
  text-shadow: .035em .035em #382437;
}
h1 em { font-size: 1.27em; font-style: inherit; color: var(--orange); }
.title-line { width: 7em; height: .20em; transform: skewX(-25deg); background: linear-gradient(90deg,var(--orange) 36%,var(--ice) 36% 63%,#3a5265 63%); margin-bottom: 1.2em; }
button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 2.47em;
  padding: .38em .80em;
  border: .10em solid var(--menu-edge);
  border-radius: .18em;
  background: var(--menu-row);
  color: var(--paper);
  font: inherit;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}
button span { font-size: .88em; color: #b6d2dd; padding-left: 1em; }
button.primary { border-color: var(--orange); background: var(--orange); color: #1d1322; }
button.primary span { color: #301b26; }
button:focus { outline: .13em solid var(--ice); outline-offset: .12em; }
button[aria-disabled="true"] { color: #bac3ce; background-color: #17212f; border-color: #34404e; }
.back-button { background: var(--menu-ink); }
.title-body button { width: 12em; font-size: 1.10em; }
.title-body button + button { margin-top: .48em; }
button:disabled { opacity: .67; cursor: default; }
.best { margin-top: .9em; font-size: .87em; color: var(--cream); font-weight: 750; letter-spacing: .04em; }
.best:empty { display: none; }
.title-controls {
  position: absolute;
  left: 6.05%;
  right: 6.05%;
  bottom: 5.5%;
  padding-top: .8em;
  border-top: 1px solid rgba(255,235,215,.3);
  color: #d3dfe5;
  font-size: .84em;
  font-weight: 700;
}
.title-controls b { color: var(--paper); margin-left: 1.55em; margin-right: .38em; }
.title-controls b:first-child { margin-left: 0; }
.drift-help { margin-left: 1.65em; }
#hud {
  --hud-bg: rgba(12, 16, 25, .66);
  --hud-text: #f7fafc;
  --hud-muted: #bdc9d4;
  --hud-accent: #ff765e;
  --hud-cyan: #56dcff;
  color: var(--hud-text);
  pointer-events: none;
}
.race-info, .dash {
  position: absolute;
  top: 3%;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(160deg, rgba(28,38,53,.71) 0%, var(--hud-bg) 56%, rgba(10,14,24,.57) 100%);
  text-shadow: 0 1px 2px #090e17, 0 1px 4px #090e17;
}
.race-info {
  left: 2.5%;
  width: 9.25em;
  padding: .32em .78em .44em .54em;
  border-top: .11em solid var(--hud-accent);
  clip-path: polygon(0 0, 100% 0, 100% 78%, 91% 100%, 0 100%);
}
.race-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .28em;
  white-space: nowrap;
}
.race-readout small, .speed small, .charge-label, #map-sector {
  color: var(--hud-muted);
  font-size: .64em;
  font-weight: 800;
  letter-spacing: .10em;
}
.position {
  align-items: center;
  min-height: 2.18em;
}
.position small {
  padding: .29em .53em;
  background: var(--hud-accent);
  color: #28151b;
  text-shadow: none;
  font-style: italic;
  transform: skewX(-10deg);
}
.place-value { display: flex; align-items: baseline; gap: .13em; }
.position strong, .race-time strong, .speed strong {
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  letter-spacing: -.055em;
}
.position strong { font-size: 2.25em; }
.position span { color: var(--hud-muted); font-weight: 800; font-size: .82em; }
.position .trial strong { font-size: 1.29em; }
.race-time {
  margin-top: .23em;
  padding-top: .36em;
  border-top: 1px solid rgba(216,230,242,.23);
}
.race-time strong { font-size: 1.20em; }
.course-progress {
  display: flex;
  align-items: center;
  gap: .45em;
  margin-top: .38em;
}
.progress, .charge-meter { overflow: hidden; background: rgba(203,217,231,.23); }
.progress { position: relative; flex: 1; height: .17em; transform: skewX(-15deg); }
.progress div, .charge-meter div { width: 0; height: 100%; background: var(--hud-accent); }
.progress i { position: absolute; width: 1px; height: 100%; top: 0; background: rgba(247,250,252,.72); }
#progress-percent {
  min-width: 2.8ch;
  font-size: .62em;
  color: var(--hud-muted);
  font-weight: 800;
  text-align: right;
}
.mirror-panel {
  position: absolute;
  top: 3%;
  left: 50%;
  width: 14.5em;
  padding: .14em .22em .28em;
  transform: translateX(-50%);
  background: transparent;
}
#mirror-view {
  display: block;
  width: 100%;
  background: transparent;
  clip-path: polygon(0 0, 100% 0, 96% 86%, 92% 100%, 8% 100%, 4% 86%);
}
.navigation-panel {
  position: absolute;
  bottom: 3.2%;
  left: 2.5%;
  width: 10.6em;
  border: 1px solid #53677a;
  border-radius: .53em;
  overflow: hidden;
  background: rgba(12,19,29,.28);
  box-shadow: 0 .30em .7em rgba(0,0,0,.26);
}
.navigation-cue {
  display: flex;
  align-items: center;
  gap: .36em;
  padding: .27em .58em;
  min-height: 1.61em;
  background: rgba(13,39,59,.73);
  border-bottom: 1px solid #407184;
  white-space: nowrap;
}
#map-arrow { width: 1.18em; flex: none; text-align: center; color: var(--hud-cyan); font-weight: 900; }
#map-instruction { flex: 1; font-size: .66em; letter-spacing: .06em; }
#map-distance { font-size: .65em; color: #b7eeff; font-weight: 800; font-variant-numeric: tabular-nums; }
.navigation-view { position: relative; }
#map-view { display: block; width: 100%; }
#map-sector {
  position: absolute;
  right: .6em;
  bottom: .44em;
  max-width: calc(100% - 1.2em);
  padding: .24em .44em;
  background: rgba(10,24,36,.72);
  border-radius: .28em;
  color: var(--hud-text);
  white-space: nowrap;
}
.result-time, .speed, #perf, #finish-perf { font-variant-numeric: tabular-nums; }
.dash {
  right: 2.5%;
  width: 10em;
  padding: .25em .56em .49em .90em;
  border-top: .11em solid var(--hud-cyan);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 9% 100%, 0 80%);
}
.speed { display: flex; align-items: baseline; justify-content: flex-end; gap: .39em; }
.speed strong { font-size: 2.85em; }
.speed small { font-size: .58em; }
.charge { padding-left: .14em; }
.charge-meter {
  height: .31em;
  margin-top: .27em;
  transform: skewX(-17deg);
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 11.45%, transparent 11.45% 12.5%);
  mask-image: repeating-linear-gradient(90deg, #000 0 11.45%, transparent 11.45% 12.5%);
}
#nitro-value { background: linear-gradient(90deg,#2c9bdf,#a1f4ff); transition: width .10s linear; }
.dash.boosting { border-top-color: #ff9768; }
.dash.boosting #nitro-value { background: linear-gradient(90deg,#ff643e,#ffdb8d); }
.dash.boosting #nitro-label { color: #ffcb9c; }
.charge-label { display: flex; justify-content: space-between; align-items: baseline; gap: .20em; margin-top: .23em; }
.charge-label strong { color: #b5efff; }
.charge-label small { font-size: .92em; color: var(--hud-text); font-weight: 800; }
#nitro-status { display: block; margin-top: .32em; color: var(--cream); font-size: .60em; font-weight: 800; letter-spacing: .07em; }
#nitro-status:empty { display: none; }
#perf { position: absolute; bottom: 3%; right: 2.5%; padding: .55em .7em; background: var(--hud-bg); font-size: .74em; font-weight: 750; white-space: pre-line; line-height: 1.4; }
#warning {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  padding: .39em 1.16em .44em;
  border-top: .12em solid var(--hud-accent);
  background: linear-gradient(165deg, rgba(51,32,40,.78), rgba(11,17,27,.73) 64%);
  text-shadow: 0 1px 3px #0a0c10;
  clip-path: polygon(0 0, 100% 0, 95% 100%, 5% 100%);
  text-align: center;
  white-space: nowrap;
  font-size: .90em;
  font-weight: 900;
  font-style: italic;
  color: var(--cream);
  letter-spacing: .08em;
}
#warning small {
  display: block;
  margin-top: .27em;
  color: var(--hud-text);
  font-size: .70em;
  font-style: normal;
  letter-spacing: .06em;
}
#elimination {
  position: absolute;
  top: 14.5%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: .55em;
  padding: .36em .74em;
  border-top: .13em solid var(--hud-cyan);
  background: rgba(8,15,25,.75);
  text-shadow: 0 1px 3px #0a0c10;
  color: var(--hud-text);
  white-space: nowrap;
}
#elimination small { font-size: .68em; font-weight: 850; letter-spacing: .09em; }
#elimination strong { font-style: italic; line-height: 1; font-variant-numeric: tabular-nums; }
#elimination.danger { background: rgba(113,28,30,.83); border-top-color: #ffb696; color: #fff7ec; }
#count {
  z-index: 2;
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translateX(-50%) skewX(-9deg);
  font-size: 6em;
  font-weight: 950;
  color: var(--paper);
  text-shadow: .05em .05em #6e2d38, .08em .08em #20192d;
}
.scrim { display: grid; place-items: center; background: rgba(8,16,29,.77); }
.menu {
  position: relative; min-width: 23em; padding: 1.28em 1.55em;
  background: linear-gradient(160deg, #192e40, var(--menu-ink) 57%);
  border: 1px solid var(--menu-edge); border-top: .14em solid var(--ice);
}
.menu::before { content: ""; position: absolute; top: -.14em; right: 0; width: 17%; height: .14em; background: var(--orange); }
h2 { font-size: 2.8em; line-height: 1.04; letter-spacing: -.06em; margin: .14em 0 .40em; }
.screen h2 { font-weight: 900; font-style: italic; }
.choices { display: grid; gap: .50em; }
#pause .menu { padding-top: 1.08em; padding-bottom: 1.08em; }
#pause .choices { gap: .34em; }
#pause .choices button { min-height: 2.26em; }
.settings-menu { width: min(47em, 88%); }
.settings-grid { display: grid; grid-template-columns: 1.22fr 1fr; gap: 1.35em; }
.choice-column h3 { margin: 0 0 .58em; color: var(--ice); font-size: .79em; letter-spacing: .12em; text-transform: uppercase; }
.settings-menu .choices { gap: .40em; }
.settings-menu .choices button { min-height: 2.24em; }
.settings-menu button span { white-space: nowrap; color: var(--ice); font-variant-numeric: tabular-nums; }
.settings-menu button.primary { margin-top: .86em; }
.settings-menu button.primary span { color: #301b26; }
.settings-menu button[aria-pressed="true"] span { color: #ffe2b7; }
.graphics-detail { margin: .78em 0 0; padding: .71em; border-left: .14em solid var(--ice); background: #142535; color: #c6d8e1; font-size: .79em; line-height: 1.45; }
.chapter-menu { width: min(51.5em, 92%); }
.chapter-menu .choices { grid-template-columns: 1fr 1fr; gap: .85em; }
.chapter-menu > .back-button { margin-top: .86em; width: 9em; }
[data-course="constanta"] { --course-art: url("assets/menu-waterfront.jpg"); }
[data-course="mamaia"] { --course-art: url("assets/menu-mamaia.jpg"); }
[data-course="tuzla"] { --course-art: url("assets/menu-tuzla.jpg"); }
[data-course="mangalia"] { --course-art: url("assets/menu-mangalia.jpg"); }
.chapter-menu .event-card {
  min-height: 9.05em; padding: .9em; align-items: flex-end;
  background-image: linear-gradient(0deg, #101b2a 2%, rgba(11,23,37,.9) 34%, transparent 77%), var(--course-art);
  background-size: cover; background-position: center;
}
.chapter-menu .event-name { font-size: 1.35em; font-style: italic; line-height: 1.02; }
.chapter-menu .event-detail { margin-top: .45em; font-style: normal; font-size: .56em; line-height: 1.25; }
.chapter-menu [aria-disabled="true"] { background-image: linear-gradient(0deg, #121b29 2%, rgba(20,30,43,.88) 45%, rgba(20,30,43,.42)), var(--course-art); }
.event-menu { width: min(51.5em, 92vw); }
.event-layout { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1fr); gap: 1.15em; }
.event-card { gap: .65em; min-height: 3.45em; padding: .5em .7em; }
.event-card .event-name { display: block; padding: 0; font-size: 1.02em; color: inherit; }
.event-card .event-detail { display: block; padding: 0; margin-top: .26em; font-size: .71em; line-height: 1.18; }
.event-card .event-record { white-space: nowrap; padding: .24em .44em; font-size: .72em; font-weight: 800; background: #122335; }
.event-preview { padding: 0 1em .74em; border: 1px solid var(--menu-edge); background: #142333; }
.event-hero {
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 8em; margin: 0 -1em; padding: .7em 1em;
  background-image: linear-gradient(0deg, #142333 4%, rgba(15,28,44,.76) 44%, transparent 100%), var(--course-art);
  background-position: center 54%; background-size: cover;
}
.event-type { color: var(--ice); text-transform: uppercase; font-weight: 850; font-size: .66em; letter-spacing: .10em; }
.event-preview h3, .garage-spec h3 { margin: 0; font-weight: 900; font-style: italic; letter-spacing: -.04em; }
.event-preview h3 { margin-top: .14em; font-size: 1.85em; line-height: 1; }
.event-preview p { margin: .42em 0 .7em; color: var(--muted); font-weight: 750; line-height: 1.42; font-size: .77em; white-space: pre-line; }
.goals { padding: 0; margin: 0; display: grid; gap: .40em; list-style: none; }
.goals li { display: grid; grid-template-columns: 3.2em minmax(0,1fr); align-items: baseline; gap: .5em; font-size: .76em; line-height: 1.25; }
.goals .goal-stars, .event-card .event-record, .rating { color: var(--cream); }
.goals .goal-stars { letter-spacing: .05em; }
.goals li.earned .goal-stars { color: #a4eff8; }
.selection-note { margin-top: .76em; color: var(--cream); font-size: .74em; font-weight: 750; line-height: 1.3; }
.selection-note:empty { display: none; }
.garage-screen {
  background: linear-gradient(90deg, #0d1726, rgba(13,23,38,.85) 29%, transparent 50%),
    linear-gradient(0deg, #0d1726, transparent 40%);
}
.garage-menu { position: absolute; top: 5.3%; left: 4.6%; width: 21em; }
.garage-menu .event-card { min-height: 2.75em; }
.garage-menu .event-card[aria-pressed="true"] { border-color: var(--orange); background: #293747; box-shadow: inset .19em 0 var(--orange); }
.garage-actions { margin-top: .85em; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); }
.garage-actions button { padding-left: .52em; padding-right: .52em; }
.garage-actions button span { padding-left: .30em; }
.paint-name { display: block; margin: .88em 0 .35em; font-size: .79em; }
.paint-choices { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: .42em; }
.paint-choices button {
  display: grid;
  place-items: center;
  justify-content: center;
  min-height: 2.10em;
  padding: 0;
  background: var(--paint-color);
  border: .13em solid #4d4651;
  color: #141221;
  text-shadow: 0 1px rgba(255,255,255,.7);
}
.paint-choices button[aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--paint-color);
  box-shadow: inset 0 0 0 .13em #1d1927;
}
.paint-choices button[aria-pressed="true"]::after { content: '✓'; color: #fff3e0; text-shadow: 0 0 .2em #151324, 1px 1px #151324; }
.paint-choices button[aria-disabled="true"] { color: var(--paper); opacity: .63; }
.garage-spec { position: absolute; bottom: 4%; right: 4.7%; width: 33em; }
.garage-spec h3 { margin: .12em 0 0; font-size: 3em; line-height: .96; text-shadow: 0 .05em .13em #161321; }
.garage-spec p { margin: .46em 0 .80em; color: var(--muted); font-size: .82em; }
.garage-stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .5em; margin: 0; }
.garage-stats div { padding: .44em .55em .47em; border-top: .13em solid var(--ice); background: #17293a; }
.garage-stats dt { color: var(--muted); font-size: .63em; font-weight: 800; text-transform: uppercase; }
.garage-stats dd { margin: .18em 0 0; font-size: .86em; font-weight: 800; letter-spacing: .03em; }
.rating { font-size: 1.2em; letter-spacing: .14em; }
.results { width: min(52em, 91%); max-height: 92%; overflow: auto; }
.result-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 1.4em; margin-top: .64em; }
.result-breakdown { padding: .8em; background: #142535; border-top: .13em solid var(--ice); }
.results h2 { margin-bottom: .08em; }
.result-time { color: var(--paper); font-size: 1.79em; font-weight: 850; }
.results .best { margin-top: .25em; }
.result-car { display: flex; align-items: center; gap: .4em; margin-top: .48em; color: var(--paper); font-size: .83em; font-weight: 750; }
.result-car i { display: inline-block; width: .75em; height: .75em; transform: skewX(-14deg); }
.result-stats { white-space: pre-line; font-size: .77em; line-height: 1.45; color: var(--muted); margin-top: .66em; letter-spacing: .045em; }
.result-breakdown .result-stats { border-top: 1px solid var(--menu-edge); padding-top: .6em; }
.result-actions { margin-top: 1em; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
#finish-perf { margin-top: .75em; border-top: 1px solid #544151; padding-top: .55em; white-space: pre-line; font-size: .72em; line-height: 1.24; color: var(--muted); }
#problem .menu { max-width: 75%; }
@media (prefers-reduced-motion: no-preference) {
  .loading-bar::before { animation: loading-sweep 1.3s ease-in-out infinite alternate; }
  @keyframes loading-sweep {
    to { transform: translateX(186%); }
  }
  .scrim .menu, .garage-menu, .garage-spec { animation: screen-entry .17s ease-out both; }
  @keyframes screen-entry {
    from { opacity: 0; transform: translateY(.35em); }
    to { opacity: 1; transform: translateY(0); }
  }
}
