:root {
  --ink: #17213b;
  --ink-soft: #34415f;
  --cream: #fff8e7;
  --paper: rgba(255, 249, 235, 0.88);
  --panel: rgba(244, 251, 247, 0.82);
  --panel-line: rgba(255, 255, 255, 0.52);
  --coral: #ff6c72;
  --sun: #ffd66f;
  --sea: #21c9bd;
  --sky: #80dff0;
  --violet: #8e74ff;
  --shadow: 0 20px 70px rgba(37, 47, 76, 0.2);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #8eddeb;
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(33, 201, 189, 0.7);
  outline-offset: 3px;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 44%, transparent 54%, rgba(19, 28, 50, 0.16) 100%),
    linear-gradient(180deg, rgba(255, 181, 126, 0.08), transparent 30%, rgba(17, 30, 51, 0.1));
  z-index: 2;
}

#cinemaBars span {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  background: #0d172b;
  z-index: 4;
  transition: height 0.8s cubic-bezier(.2,.72,.16,1);
}

#cinemaBars span:first-child { top: 0; }
#cinemaBars span:last-child { bottom: 0; }

body.in-race #cinemaBars span {
  height: 10px;
}

#speedFx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  background: repeating-conic-gradient(from 0deg at 50% 55%, transparent 0deg 10deg, rgba(255,255,255,.22) 11deg, transparent 12deg 20deg);
  mask-image: radial-gradient(circle at 50% 55%, transparent 0 35%, #000 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 55%, transparent 0 35%, #000 72%);
}

body.boosting #speedFx {
  opacity: 0.62;
  animation: speed-fx 0.25s linear infinite;
}

@keyframes speed-fx {
  from { transform: scale(1.08) rotate(0deg); }
  to { transform: scale(1.23) rotate(1.8deg); }
}

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.glass-panel {
  border: 1px solid var(--panel-line);
  background:
    linear-gradient(135deg, rgba(255,255,255,.74), rgba(245,250,246,.5)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.eyebrow {
  display: block;
  color: #61708b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.start-screen {
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px clamp(24px, 5vw, 72px);
  scrollbar-width: none;
}

.start-screen::-webkit-scrollbar {
  display: none;
}

.menu-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(215, 245, 242, 0.84) 0%, rgba(232, 248, 242, 0.52) 43%, transparent 69%),
    linear-gradient(0deg, rgba(24, 41, 68, 0.26), transparent 34%);
  pointer-events: none;
}

body[data-level="3"] .menu-wash {
  background:
    linear-gradient(90deg, rgba(255, 222, 188, .8) 0%, rgba(239, 205, 184, .48) 44%, transparent 72%),
    linear-gradient(0deg, rgba(78, 42, 50, .32), transparent 37%);
}

body[data-level="4"] .menu-wash {
  background:
    linear-gradient(90deg, rgba(229, 238, 247, .86) 0%, rgba(223, 233, 247, .56) 44%, transparent 73%),
    linear-gradient(0deg, rgba(55, 74, 112, .22), transparent 38%);
}

body[data-level="5"] .menu-wash {
  background:
    linear-gradient(90deg, rgba(18, 30, 51, .9) 0%, rgba(27, 38, 64, .62) 44%, transparent 74%),
    linear-gradient(0deg, rgba(8, 16, 34, .58), transparent 38%);
}

body[data-level="5"] .hero-copy h1 {
  color: #fff4df;
}

body[data-level="5"] .hero-copy h1 span {
  color: #ff688d;
}

body[data-level="5"] .lead,
body[data-level="5"] .kicker,
body[data-level="5"] .brand-mark,
body[data-level="5"] .edition-tag {
  color: #dce6ef;
}

body[data-level="5"] .edition-tag,
body[data-level="5"] .feature-pills span {
  border-color: rgba(255,255,255,.2);
  background: rgba(255,255,255,.12);
}

.start-layout {
  position: relative;
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: minmax(480px, 1.1fr) minmax(390px, 0.72fr);
  align-items: center;
  gap: clamp(32px, 6vw, 92px);
}

.hero-copy {
  max-width: 710px;
  padding-bottom: 4vh;
  animation: hero-in 0.8s cubic-bezier(.16,.84,.28,1) both;
}

@keyframes hero-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: clamp(36px, 7vh, 82px);
}

.brand-mark {
  display: inline-block;
  font-size: 12px;
  line-height: 0.95;
  font-weight: 1000;
  font-style: italic;
  letter-spacing: 0.11em;
  color: var(--ink);
  transform: skew(-7deg);
}

.edition-tag {
  padding: 8px 13px;
  border: 1px solid rgba(23, 33, 59, 0.18);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.34);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.kicker {
  margin: 0 0 10px;
  color: #3b6076;
  font-size: clamp(10px, 1.1vw, 13px);
  font-weight: 900;
  letter-spacing: 0.2em;
}

.hero-copy h1 {
  max-width: 700px;
  margin: 0;
  font-family: "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: clamp(70px, 9vw, 136px);
  line-height: 0.82;
  letter-spacing: -0.07em;
  color: var(--ink);
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.35);
  transform: skew(-4deg);
}

.hero-copy h1 span {
  display: block;
  color: var(--coral);
  margin-left: clamp(8px, 3vw, 54px);
  letter-spacing: -0.08em;
  text-shadow: 0 5px 0 rgba(255,255,255,.38), 0 14px 30px rgba(255,108,114,.13);
}

.lead {
  margin: 26px 0 24px;
  max-width: 540px;
  color: #38506a;
  font-size: clamp(14px, 1.25vw, 18px);
  line-height: 1.75;
  font-weight: 550;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feature-pills span {
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.66);
  color: #3e526e;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}

.garage-card {
  width: 100%;
  max-width: 492px;
  justify-self: end;
  padding: clamp(22px, 2.2vw, 32px);
  border-radius: 31px;
  animation: garage-in 0.8s 0.12s cubic-bezier(.16,.84,.28,1) both;
}

@keyframes garage-in {
  from { opacity: 0; transform: translateX(28px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.garage-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.garage-heading h2 {
  margin: 5px 0 0;
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 900;
}

.garage-count {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.1em;
  color: #68748a;
}

.campaign-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #758399;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .08em;
}

.campaign-head b {
  color: #9aa5b4;
  font-size: 7px;
  font-weight: 750;
  letter-spacing: .02em;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 11px;
}

.stage-chip {
  position: relative;
  min-width: 0;
  height: 51px;
  padding: 7px 4px 6px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 59, .09);
  border-radius: 11px;
  background: rgba(255, 255, 255, .36);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.stage-chip:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(255,255,255,.62);
}

.stage-chip.is-selected {
  border-color: rgba(255, 108, 114, .72);
  background: rgba(255,255,255,.82);
  box-shadow: 0 6px 14px rgba(255,108,114,.11);
}

.stage-chip.is-locked {
  cursor: not-allowed;
  opacity: .43;
  filter: grayscale(.5);
}

.stage-chip.is-complete::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 5px;
  color: var(--sea);
  font-size: 8px;
  font-weight: 1000;
}

.stage-chip span {
  display: block;
  color: var(--coral);
  font-family: "Arial Black", sans-serif;
  font-size: 13px;
  font-style: italic;
  line-height: 1;
}

.stage-chip b {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: #55647a;
  font-size: 8px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.car-grid {
  display: grid;
  gap: 8px;
}

.car-card {
  position: relative;
  min-height: 62px;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 10px 15px 10px 10px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 7px 17px rgba(33, 53, 79, 0.05);
  transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.car-card:hover {
  transform: translateX(3px);
  background: rgba(255,255,255,.64);
}

.car-card.is-selected {
  border-color: rgba(255, 108, 114, 0.64);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 26px rgba(255, 108, 114, 0.13);
}

.car-card.is-selected::after {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 4px;
  border-radius: 0 8px 8px 0;
  background: var(--coral);
}

.car-swatch {
  position: relative;
  width: 54px;
  height: 42px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, #ffabbb, #7b5df5);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}

.car-swatch::before {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  top: 14px;
  height: 17px;
  border-radius: 50% 50% 34% 34%;
  background: rgba(255, 255, 255, 0.74);
  transform: skew(-10deg);
}

.car-swatch::after {
  content: "";
  position: absolute;
  left: 17px;
  right: 17px;
  top: 21px;
  height: 7px;
  border-radius: 5px;
  background: rgba(23, 33, 59, 0.75);
}

.car-swatch.tide { background: linear-gradient(145deg, #8cf7e9, #1c9f9b); }
.car-swatch.flame { background: linear-gradient(145deg, #ffc063, #f04f59); }

.car-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 14px;
  font-weight: 850;
}

.car-name small {
  margin-top: 4px;
  color: #748198;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .14em;
}

.car-number {
  font-family: "Arial Black", sans-serif;
  font-size: 17px;
  font-style: italic;
  color: rgba(23,33,59,.55);
}

.car-stats {
  position: absolute;
  right: 13px;
  bottom: 8px;
  width: 70px;
  display: flex;
  gap: 3px;
}

.car-stats i {
  display: block;
  flex: 1;
  height: 2px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--coral) var(--v), rgba(23,33,59,.12) var(--v));
}

.identity-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(23,33,59,.08);
}

.identity-field,
.color-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.identity-field > span,
.color-field > span {
  color: #8491a3;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .07em;
}

.identity-field input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(23,33,59,.11);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: rgba(255,255,255,.55);
  font: 800 12px/1 "Segoe UI", "Microsoft YaHei", sans-serif;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.identity-field input:focus {
  border-color: rgba(33,201,189,.66);
  box-shadow: 0 0 0 3px rgba(33,201,189,.1);
}

.number-field input {
  text-align: center;
  font-family: "Arial Black", sans-serif;
  font-size: 16px;
  font-style: italic;
}

.color-field {
  grid-column: 1 / -1;
}

.color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.color-picker button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 3px solid rgba(255,255,255,.78);
  border-radius: 50%;
  cursor: pointer;
  background: var(--swatch);
  box-shadow: 0 2px 7px rgba(23,33,59,.15), 0 0 0 1px rgba(23,33,59,.08);
  transition: transform .18s ease, box-shadow .18s ease;
}

.color-picker button:nth-child(1) { --swatch: #8f72ff; }
.color-picker button:nth-child(2) { --swatch: #22c9bb; }
.color-picker button:nth-child(3) { --swatch: #ff7952; }
.color-picker button:nth-child(4) { --swatch: #e94d70; }
.color-picker button:nth-child(5) { --swatch: #42a7ff; }
.color-picker button:nth-child(6) { --swatch: #8edb54; }

.color-picker button:hover {
  transform: scale(1.12);
}

.color-picker button.is-selected {
  box-shadow: 0 0 0 2px var(--ink), 0 4px 12px rgba(23,33,59,.18);
}

.garage-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
  padding: 11px 0;
  border-top: 1px solid rgba(23, 33, 59, 0.08);
  border-bottom: 1px solid rgba(23, 33, 59, 0.08);
}

.garage-meta div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: center;
}

.garage-meta span {
  color: #8190a4;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .1em;
}

.garage-meta b {
  font-size: 11px;
  font-weight: 800;
}

.start-button {
  position: relative;
  width: 100%;
  height: 59px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: center;
  gap: 1px 16px;
  padding: 0 22px;
  overflow: hidden;
  border: none;
  border-radius: 18px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 15px 34px rgba(23, 33, 59, 0.22);
  cursor: pointer;
  text-align: left;
  transition: transform .2s ease, box-shadow .2s ease;
}

.start-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,.19) 45%, transparent 65%);
  transform: translateX(-110%);
  transition: transform .6s ease;
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(23, 33, 59, 0.27);
}

.start-button:hover::before {
  transform: translateX(110%);
}

.start-button span {
  font-size: 17px;
  font-weight: 850;
}

.start-button b {
  align-self: center;
  color: rgba(255,255,255,.52);
  font-size: 8px;
  letter-spacing: .15em;
}

.start-button i {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  font-style: normal;
  font-size: 23px;
}

.menu-help {
  margin: 11px 0 0;
  text-align: center;
  color: #7b8699;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
}

.race-hud {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  transition: opacity .35s ease;
}

.race-cluster {
  position: absolute;
  top: 26px;
  left: 28px;
  width: 238px;
  padding: 17px 18px;
  border-radius: 19px;
}

.session-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(23,33,59,.08);
  color: #6c7e92;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .05em;
}

.session-line b {
  max-width: 95px;
  overflow: hidden;
  color: var(--coral);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lap-line,
.timer-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.lap-line strong {
  font-size: 29px;
  line-height: 1;
  font-weight: 1000;
}

.lap-line small {
  color: #8994a6;
  font-size: 13px;
}

.timer-line strong {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  letter-spacing: -.03em;
}

.timer-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(23,33,59,.09);
}

.split-row {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: #8090a3;
  font-size: 8px;
  font-weight: 700;
}

.split-row b {
  color: #4b5a70;
  font-variant-numeric: tabular-nums;
  font-size: 9px;
}

.position-badge {
  position: absolute;
  top: 25px;
  right: 30px;
  min-width: 128px;
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 21px;
}

.position-badge > span {
  font-family: "Arial Black", sans-serif;
  font-size: 48px;
  line-height: 1;
  color: var(--coral);
  font-style: italic;
}

.position-badge div {
  display: flex;
  flex-direction: column;
}

.position-badge small {
  color: #7e8898;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .1em;
}

.position-badge b {
  color: #8a95a6;
  font-size: 12px;
}

.map-shell {
  position: absolute;
  left: 28px;
  bottom: 27px;
  width: 206px;
  padding: 13px;
  border-radius: 18px;
}

.map-topline {
  display: flex;
  justify-content: space-between;
  color: #526279;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .1em;
}

.map-topline span:last-child {
  color: #8994a6;
}

#minimap {
  display: block;
  width: 100%;
  height: 112px;
  margin-top: 5px;
}

.speed-shell {
  position: absolute;
  right: 30px;
  bottom: 28px;
  width: 174px;
  padding: 12px 15px 10px;
  border-radius: 23px;
}

.speed-ring {
  --speed-pct: 0deg;
  width: 126px;
  height: 126px;
  margin: -31px auto 1px;
  padding: 10px;
  border-radius: 50%;
  background: conic-gradient(from 220deg, var(--coral) var(--speed-pct), rgba(255,255,255,.36) 0 280deg, transparent 0);
  box-shadow: 0 10px 30px rgba(36, 48, 78, .13);
  transform: rotate(0deg);
}

.speed-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(248, 252, 247, .93);
  border: 5px solid rgba(255,255,255,.5);
}

.speed-inner strong {
  font-size: 39px;
  line-height: .9;
  font-weight: 1000;
  font-style: italic;
  font-variant-numeric: tabular-nums;
}

.speed-inner span {
  margin-top: 7px;
  color: #7e899a;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .16em;
}

.gear-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  color: #8994a5;
  font-size: 8px;
  font-weight: 800;
}

.gear-row b {
  color: var(--ink);
  font-size: 17px;
}

.boost-shell {
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: min(340px, 34vw);
  padding: 13px 17px 11px;
  border-radius: 17px;
  transform: translateX(-50%);
}

.boost-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 900;
}

.boost-title b {
  color: var(--sea);
  font-size: 8px;
  letter-spacing: .13em;
}

.boost-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(23, 33, 59, .11);
  box-shadow: inset 0 1px 2px rgba(23,33,59,.13);
}

.boost-track i {
  display: block;
  width: 64%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sea), #9dfbd9);
  box-shadow: 0 0 12px rgba(33,201,189,.48);
  transition: width .12s linear;
}

body.boosting .boost-track i {
  background: linear-gradient(90deg, #ffcf54, var(--coral), #d994ff);
}

.drift-row {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: #8590a0;
  font-size: 8px;
  font-weight: 700;
}

.drift-row b {
  color: var(--coral);
}

.controls-ribbon {
  position: absolute;
  right: 31px;
  top: 126px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 13px;
  color: #69778b;
  font-size: 8px;
  font-weight: 700;
}

.controls-ribbon span {
  display: flex;
  gap: 7px;
  align-items: center;
}

kbd {
  min-width: 35px;
  padding: 2px 5px;
  border: 1px solid rgba(23,33,59,.15);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255,255,255,.48);
  color: #526279;
  font-family: inherit;
  font-size: 7px;
  text-align: center;
}

.icon-button {
  position: absolute;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
  background: rgba(248,252,248,.74);
  box-shadow: 0 7px 20px rgba(35,49,76,.13);
  color: #4f5f76;
  font-size: 14px;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.pause-button {
  top: 27px;
  left: 286px;
}

.sound-button {
  top: 71px;
  left: 286px;
}

.toast {
  position: absolute;
  left: 50%;
  top: 22%;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  background: rgba(23, 33, 59, .82);
  box-shadow: 0 11px 34px rgba(12, 21, 37, .24);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  opacity: 0;
  transform: translate(-50%, 10px) scale(.94);
  transition: opacity .2s ease, transform .2s ease;
  backdrop-filter: blur(12px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.toast.drift {
  background: rgba(255,108,114,.86);
}

.countdown {
  position: absolute;
  left: 50%;
  top: 42%;
  color: #fff;
  font-family: "Arial Black", sans-serif;
  font-size: clamp(80px, 14vw, 180px);
  line-height: 1;
  font-style: italic;
  letter-spacing: -.08em;
  text-shadow: 0 7px 0 rgba(23,33,59,.18), 0 24px 50px rgba(23,33,59,.28);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.6);
}

.countdown.show {
  animation: count-pop .82s cubic-bezier(.16,.8,.2,1) both;
}

@keyframes count-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.52) rotate(-5deg); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.05) rotate(0); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.18); }
}

.pause-screen,
.result-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(19, 31, 50, 0.26);
  backdrop-filter: blur(8px);
}

.modal-card,
.result-card {
  width: min(510px, 100%);
  padding: 32px;
  border-radius: 29px;
  animation: modal-in .35s cubic-bezier(.16,.84,.28,1) both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.modal-card h2,
.result-card h2 {
  margin: 8px 0 10px;
  font-size: 32px;
  letter-spacing: -.055em;
}

.modal-card p {
  margin: 0 0 23px;
  color: #67758a;
  line-height: 1.7;
  font-size: 13px;
}

.modal-actions {
  display: grid;
  gap: 9px;
}

.modal-actions.horizontal {
  grid-template-columns: 1.15fr .82fr .82fr auto;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 13px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.primary-button {
  border: none;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(23,33,59,.18);
}

.primary-button:disabled {
  cursor: default;
  opacity: .46;
  box-shadow: none;
}

.secondary-button {
  border: 1px solid rgba(23,33,59,.13);
  color: var(--ink);
  background: rgba(255,255,255,.5);
}

.text-button {
  border: none;
  color: #65748a;
  background: transparent;
}

.result-sound {
  min-width: 78px;
  padding: 0 10px;
  border: 1px solid rgba(23,33,59,.1);
  border-radius: 11px;
  color: #65748a;
  background: rgba(255,255,255,.38);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.result-card {
  width: min(660px, 100%);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  right: -150px;
  top: -180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,108,114,.23), transparent 68%);
}

.result-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(23,33,59,.09);
}

.result-copy {
  display: flex;
  flex-direction: column;
}

.result-driver {
  margin: -4px 0 0;
  color: #77869b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
}

.result-hero h2 {
  font-size: 48px;
  line-height: 1;
}

.result-rank {
  display: flex;
  align-items: center;
  gap: 2px;
  font-style: italic;
}

.result-rank span {
  color: var(--coral);
  font-size: 25px;
  font-weight: 1000;
}

.result-rank strong {
  color: var(--coral);
  font-family: "Arial Black", sans-serif;
  font-size: 90px;
  line-height: .8;
  letter-spacing: -.08em;
}

.result-times {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 17px 0;
}

.result-times div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.result-times span {
  color: #77869a;
  font-size: 9px;
  font-weight: 750;
}

.result-times b {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.standings {
  display: grid;
  gap: 5px;
  margin-bottom: 18px;
}

.standing-row {
  display: grid;
  grid-template-columns: 30px 12px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 10px;
  color: #5f6e83;
  font-size: 11px;
  font-weight: 700;
}

.standing-row.is-player {
  color: var(--ink);
  background: rgba(255,255,255,.56);
}

.standing-row > b {
  font-size: 12px;
}

.standing-row .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.standing-row time {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.touch-controls {
  position: absolute;
  inset: auto 0 24px;
  z-index: 8;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
}

.touch-controls button {
  pointer-events: auto;
  width: 60px;
  height: 60px;
  border: 1px solid rgba(255,255,255,.58);
  border-radius: 19px;
  color: #35445c;
  background: rgba(255,255,255,.62);
  backdrop-filter: blur(12px);
  box-shadow: 0 9px 25px rgba(23,33,59,.17);
  font-size: 21px;
  font-weight: 900;
  touch-action: none;
}

.touch-steer,
.touch-actions {
  display: flex;
  gap: 9px;
}

.touch-actions button {
  width: 56px;
  height: 56px;
  font-size: 12px;
}

.touch-actions .touch-gas {
  width: 70px;
  height: 70px;
  background: rgba(255, 214, 111, .8);
}

.touch-actions .touch-boost {
  background: rgba(140, 247, 233, .75);
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #fff;
  background: #1b2c45;
  transition: opacity .6s ease, visibility .6s ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-mark {
  font-family: "Arial Black", sans-serif;
  font-size: 37px;
  line-height: .86;
  font-style: italic;
  letter-spacing: -.06em;
}

.loading-mark span {
  display: block;
  color: var(--coral);
  margin-left: 30px;
}

.loading-track {
  width: 190px;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255,255,255,.15);
}

.loading-track i {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--sun);
  animation: loading 1.1s ease-in-out infinite alternate;
}

.loading-screen p {
  margin: 0;
  color: rgba(255,255,255,.55);
  font-size: 10px;
  letter-spacing: .14em;
}

@keyframes loading {
  from { transform: translateX(-40%); }
  to { transform: translateX(170%); }
}

@media (max-width: 1100px) {
  .start-layout {
    grid-template-columns: 1fr 390px;
    gap: 28px;
  }

  .hero-copy h1 {
    font-size: clamp(66px, 8.5vw, 108px);
  }

  .controls-ribbon {
    display: none;
  }
}

@media (max-width: 860px) {
  .start-screen {
    align-items: flex-start;
    overflow-y: auto;
    padding: 22px;
  }

  .start-layout {
    display: block;
    width: min(560px, 100%);
  }

  .hero-copy {
    padding: 0 0 22px;
  }

  .brand-row {
    margin-bottom: 34px;
  }

  .hero-copy h1 {
    font-size: clamp(62px, 17vw, 102px);
  }

  .lead {
    margin: 18px 0;
    font-size: 13px;
  }

  .garage-card {
    max-width: none;
    margin-bottom: 24px;
  }

  .race-cluster {
    top: 16px;
    left: 14px;
    width: 186px;
    padding: 12px;
  }

  .timer-line strong {
    font-size: 15px;
  }

  .lap-line strong {
    font-size: 23px;
  }

  .split-row {
    display: none;
  }

  .position-badge {
    top: 15px;
    right: 14px;
    min-width: 95px;
    height: 68px;
  }

  .position-badge > span {
    font-size: 37px;
  }

  .pause-button {
    left: auto;
    right: 120px;
    top: 16px;
  }

  .sound-button {
    left: auto;
    right: 158px;
    top: 16px;
  }

  .map-shell {
    width: 148px;
    left: 14px;
    bottom: 14px;
    padding: 8px;
  }

  #minimap {
    height: 87px;
  }

  .speed-shell {
    width: 128px;
    right: 14px;
    bottom: 14px;
    padding: 8px;
  }

  .speed-ring {
    width: 96px;
    height: 96px;
    margin-top: -24px;
  }

  .speed-inner strong {
    font-size: 29px;
  }

  .boost-shell {
    width: 210px;
    bottom: 14px;
  }

  .controls-ribbon {
    display: none;
  }

  .result-times {
    gap: 7px;
  }

  .result-times b {
    font-size: 13px;
  }
}

@media (max-width: 620px) {
  .hero-copy h1 {
    font-size: 58px;
  }

  .hero-copy h1 span {
    margin-left: 15px;
  }

  .edition-tag,
  .feature-pills {
    display: none;
  }

  .lead {
    margin-bottom: 12px;
  }

  .garage-card {
    padding: 18px;
    border-radius: 24px;
  }

  .garage-meta {
    margin: 14px 0;
  }

  .map-shell,
  .controls-ribbon,
  .sound-button {
    display: none;
  }

  .boost-shell {
    left: 14px;
    bottom: 158px;
    width: calc(100% - 174px);
    transform: none;
  }

  .speed-shell {
    right: 14px;
    bottom: 158px;
  }

  .race-cluster {
    width: 160px;
  }

  .position-badge {
    min-width: 87px;
  }

  .pause-button {
    top: 92px;
    right: 15px;
  }

  .result-card,
  .modal-card {
    padding: 23px;
  }

  .result-hero h2 {
    font-size: 38px;
  }

  .result-rank strong {
    font-size: 67px;
  }

  .modal-actions.horizontal {
    grid-template-columns: 1fr;
  }
}

@media (hover: none), (pointer: coarse) {
  .touch-controls:not(.is-hidden) {
    display: flex;
  }

  .speed-shell,
  .boost-shell {
    bottom: 155px;
  }

  .controls-ribbon {
    display: none;
  }

  .touch-controls {
    bottom: 12px;
    padding: 0 12px;
    gap: 8px;
  }

  .touch-steer,
  .touch-actions {
    display: grid;
    gap: 6px;
  }

  .touch-steer {
    grid-template-columns: repeat(2, 58px);
  }

  .touch-actions {
    grid-template-columns: repeat(2, 58px);
  }

  .touch-controls button,
  .touch-actions button,
  .touch-actions .touch-gas {
    width: 58px;
    height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
