:root {
  --ink: #0b1020;
  --panel: rgba(12, 18, 38, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --hot: #ff3d5a;
  --gold: #ffc53d;
  --sky: #5ad1ff;
  --text: #f4f6ff;
  --muted: #a8b0cc;
  --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);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Screens */
.screen {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  z-index: 20;
}
.screen.show { display: flex; }
#loading { background: radial-gradient(ellipse at 50% 30%, #1d2a5c, var(--ink) 70%); z-index: 70; transition: opacity .6s ease; }
#loading.fading { opacity: 0; pointer-events: none; }
.load-inner { width: min(420px, 90vw); text-align: center; }
.load-bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; margin: 22px 0 12px; }
.load-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--hot), var(--gold)); transition: width .2s; }
#load-text { color: var(--muted); font-size: 14px; }

.logo {
  font-weight: 900; font-style: italic; letter-spacing: -1px; line-height: .9;
  font-size: clamp(38px, 8vw, 84px);
  background: linear-gradient(180deg, #fff 30%, #ffd9a0); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #b3122b) drop-shadow(0 10px 18px rgba(0,0,0,.5));
}
.logo span { background: linear-gradient(180deg, #fff27a, #ff9d1c); -webkit-background-clip: text; background-clip: text; }
.logo.small { font-size: 44px; }

#menu { flex-direction: column; justify-content: space-between; align-items: stretch; background: linear-gradient(180deg, rgba(8,12,30,.55), transparent 30%, transparent 55%, rgba(8,12,30,.7)); }
.menu-top { text-align: center; }
.tag { margin-top: 10px; color: #fff; opacity: .85; font-weight: 600; letter-spacing: .5px; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.menu-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  width: min(720px, 100%); margin: 0 auto; max-height: 100%; overflow: auto;
}
.menu-panel.narrow { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }
.menu-panel h2 { margin: 0 0 8px; font-style: italic; font-size: 28px; }
.menu-panel h3 { margin: 4px 0 8px; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.driver-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.driver {
  border: 2px solid transparent; border-radius: 12px; padding: 6px 4px 8px; background: rgba(255,255,255,.06);
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 700;
}
.driver .sw { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 -6px 0 rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.4); position: relative; }
.driver .sw::after { content: ""; position: absolute; left: 7px; right: 7px; top: 12px; height: 8px; border-radius: 4px; background: rgba(10,14,30,.8); }
.driver.on { border-color: var(--gold); background: rgba(255,197,61,.14); }
.driver-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 14px; margin: 10px 0 14px; font-size: 12px; color: var(--muted); }
.stat b { display: block; height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); margin-top: 3px; overflow: hidden; }
.stat b i { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), #8fffb0); }
.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); font-weight: 800; }
.seg button.on { background: var(--gold); color: #2a1a00; border-color: var(--gold); }
.big-btn {
  width: 100%; padding: 14px; border: 0; border-radius: 12px; font-size: 20px; font-weight: 900; font-style: italic; letter-spacing: .5px;
  background: linear-gradient(180deg, #ff5a6e, #d8163a); color: #fff; box-shadow: 0 5px 0 #8a0c24, 0 10px 24px rgba(216,22,58,.4);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #8a0c24; }
.btn { width: 100%; padding: 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.07); font-weight: 700; }
.menu-help { margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.6; text-align: center; }
.menu-help kbd { background: rgba(255,255,255,.12); border-radius: 4px; padding: 1px 5px; font-family: inherit; color: #fff; }
.toggle { display: flex; gap: 10px; align-items: center; font-weight: 600; padding: 4px 2px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--gold); }
body:not(.is-touch) .touch-only { display: none; }

#pause, #results { background: rgba(5, 8, 20, .55); }
#res-table { width: 100%; border-collapse: collapse; margin: 6px 0 16px; font-size: 15px; }
#res-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
#res-table tr.me td { color: var(--gold); font-weight: 800; }
#res-table td:first-child { width: 44px; font-weight: 900; font-style: italic; }
#res-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#res-table .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; }
.res-btns { display: flex; flex-direction: column; gap: 10px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 12px rgba(0,0,0,.35); }
.hud-tl { position: absolute; top: calc(12px + var(--safe-t)); left: calc(14px + var(--safe-l)); }
.lap { font-size: 34px; font-style: italic; }
.lap small { font-size: 16px; opacity: .85; }
.time { font-size: 20px; font-variant-numeric: tabular-nums; }
.laptimes { font-size: 13px; opacity: .8; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hud-tr { position: absolute; top: calc(12px + var(--safe-t)); right: calc(14px + var(--safe-r)); }
.item-slot {
  width: 86px; height: 86px; border-radius: 18px; position: relative;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.28), rgba(255,255,255,.06)); border: 3px solid rgba(255,255,255,.85);
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 0 18px rgba(255,255,255,.18);
}
.item-icon { position: absolute; inset: 8px; background-size: contain; background-position: center; background-repeat: no-repeat; }
.item-slot.rolling .item-icon { filter: blur(.6px); }
.item-count { position: absolute; right: -6px; bottom: -6px; font-size: 20px; font-style: italic; }
#minimap { position: absolute; left: calc(10px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); width: 170px; height: 170px; opacity: .95; }
.hud-br { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); text-align: right; }
.pos { font-size: 84px; font-style: italic; line-height: .95; letter-spacing: -2px;
  background: linear-gradient(180deg, #fff 20%, #ffd23d 55%, #ff8a00); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #7a2b00) drop-shadow(0 6px 10px rgba(0,0,0,.5)); text-shadow: none; }
.pos sup { font-size: 34px; letter-spacing: 0; }
.speed { font-size: 15px; opacity: .9; }
.speed b { font-size: 24px; font-variant-numeric: tabular-nums; }
.coins { font-size: 26px; display: inline-flex; align-items: center; gap: 6px; font-style: italic; }
.coin-ico { width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc400 45%, #c07a00); box-shadow: inset 0 0 0 3px rgba(150,90,0,.6); display: inline-block; }
.standings { margin-top: 10px; font-size: 13px; line-height: 1.55; }
.standings div { display: flex; align-items: center; gap: 6px; opacity: .92; }
.standings i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.standings .me { color: var(--gold); }
.banner {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(56px, 12vw, 140px); font-style: italic; font-weight: 900;
  opacity: 0; transform: scale(.6); transition: opacity .15s, transform .25s cubic-bezier(.2,1.6,.4,1);
  background: linear-gradient(180deg, #fff 25%, #ffd23d 60%, #ff6a00); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 5px 0 #7a1b00) drop-shadow(0 10px 20px rgba(0,0,0,.5)); text-shadow: none;
}
.banner.show { opacity: 1; transform: scale(1); }
.banner.warn { background: linear-gradient(180deg, #fff 20%, #ff5a6e 60%, #b3122b); -webkit-background-clip: text; background-clip: text; }
.sub-banner { position: absolute; left: 0; right: 0; top: 52%; text-align: center; font-size: 24px; opacity: 0; transition: opacity .2s; }
.sub-banner.show { opacity: 1; }
#speedlines {
  position: absolute; inset: -10%; opacity: 0; transition: opacity .25s;
  background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,.0) 0deg 3deg, rgba(255,255,255,.22) 3.3deg 3.6deg, rgba(255,255,255,0) 4deg 9deg);
  -webkit-mask-image: radial-gradient(ellipse at 50% 55%, transparent 32%, #000 70%); mask-image: radial-gradient(ellipse at 50% 55%, transparent 32%, #000 70%);
}
.icon-btn {
  position: absolute; pointer-events: auto; top: calc(12px + var(--safe-t)); right: calc(112px + var(--safe-r));
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10,14,30,.5); font-weight: 900; letter-spacing: -1px;
}

/* Touch controls */
#touch { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
#steer-zone { position: absolute; left: 0; top: 30%; bottom: 0; width: 45%; pointer-events: auto; }
.zone-hint { position: absolute; left: calc(40px + var(--safe-l)); bottom: calc(200px + var(--safe-b)); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; opacity: .35; font-weight: 800; }
#stick-base {
  position: absolute; width: 130px; height: 130px; border-radius: 50%; margin: -65px 0 0 -65px;
  left: calc(110px + var(--safe-l)); top: calc(100% - 110px - var(--safe-b));
  background: radial-gradient(circle, rgba(255,255,255,.08), rgba(255,255,255,.18)); border: 2px solid rgba(255,255,255,.35);
}
#stick-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
#touch-buttons { position: absolute; right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); width: 250px; height: 230px; pointer-events: none; }
.tbtn {
  position: absolute; pointer-events: auto; border-radius: 50%; border: 3px solid rgba(255,255,255,.7); font-weight: 900; font-size: 13px; letter-spacing: .5px;
  background: rgba(15,20,40,.45); color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.35); touch-action: none;
}
.tbtn.down { background: rgba(255,255,255,.45); transform: scale(.94); }
.t-drift { width: 104px; height: 104px; right: 0; bottom: 0; border-color: #7fd8ff; }
.t-item { width: 78px; height: 78px; right: 116px; bottom: 16px; border-color: var(--gold); }
.t-brake { width: 62px; height: 62px; right: 22px; bottom: 120px; border-color: #ff8a9a; font-size: 11px; }
.t-gas { width: 62px; height: 62px; right: 150px; bottom: 110px; border-color: #8fffb0; font-size: 12px; }
body.autogas .t-gas { display: none; }
/* on the starting grid the gas waits for the player, so the pedal shows */
body.autogas.on-grid .t-gas { display: block; width: 88px; height: 88px; right: 134px; bottom: 104px; font-size: 16px; }
body.autogas.on-grid .t-gas.down { animation: none; background: rgba(143,255,176,.55); }
@keyframes gas-pulse { 50% { box-shadow: 0 0 0 10px rgba(143,255,176,.25), 0 4px 14px rgba(0,0,0,.35); } }
.grid-hint { position: absolute; left: 50%; bottom: calc(22% + var(--safe-b)); transform: translateX(-50%); padding: 8px 16px; border-radius: 14px; background: rgba(10,14,30,.72); border: 1px solid rgba(143,255,176,.5); font-size: 16px; font-weight: 800; white-space: nowrap; opacity: 0; transition: opacity .3s; pointer-events: none; }
.grid-hint.show { opacity: 1; }
.grid-hint b { color: var(--gold); }
.grid-hint .gh-touch, body.is-touch .grid-hint .gh-keys { display: none; }
body.is-touch .grid-hint .gh-touch { display: inline; }
@media (max-height: 520px) { .grid-hint { font-size: 13px; bottom: calc(12px + var(--safe-b)); } }
body.is-touch #minimap { left: calc(8px + var(--safe-l)); top: calc(92px + var(--safe-t)); bottom: auto; width: 110px; height: 110px; }
body.is-touch .hud-br { bottom: auto; top: calc(8px + var(--safe-t)); right: calc(112px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; }
body.is-touch .hud-br .pos { order: -1; }
body.is-touch .pos { font-size: 54px; }
body.is-touch .pos sup { font-size: 22px; }
body.is-touch .coins { font-size: 20px; }
body.is-touch .coin-ico { width: 18px; height: 18px; }
body.is-touch .speed { font-size: 12px; }
body.is-touch .speed b { font-size: 18px; }
body.is-touch .standings { display: none; }
body.is-touch .icon-btn { right: auto; left: 50%; margin-left: -22px; opacity: .8; }
/* camera switch: touch only, beside the pause button */
.cam-btn { display: none; padding: 0; }
.cam-btn svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; vertical-align: middle; }
.cam-btn.on { background: rgba(255,197,61,.35); border-color: var(--gold); }
body.is-touch .cam-btn { display: block; margin-left: 30px; }
body.split .cam-btn { display: none; }

#rotate-hint {
  display: none; position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 30;
  background: rgba(10,14,30,.8); padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 700; white-space: nowrap; pointer-events: none;
}

@media (orientation: portrait) {
  body.is-touch .hud-br { top: calc(104px + var(--safe-t)); right: calc(14px + var(--safe-r)); }
}
@media (max-width: 720px) {
  .driver-grid { grid-template-columns: repeat(4, 1fr); }
  .driver-stats { grid-template-columns: repeat(2, 1fr); }
  .item-slot { width: 70px; height: 70px; border-radius: 14px; }
  .lap { font-size: 26px; }
  .time { font-size: 16px; }
}
@media (max-height: 480px) {
  .menu-panel { padding: 12px 14px; }
  .logo { font-size: 40px; }
  .tag { margin-top: 4px; font-size: 12px; }
  .driver-grid { grid-template-columns: repeat(8, 1fr); gap: 5px; }
  .driver { padding: 4px 2px 5px; font-size: 10px; }
  .driver .sw { width: 26px; height: 26px; }
  .driver .sw::after { left: 5px; right: 5px; top: 9px; height: 6px; }
  .driver-stats { margin: 6px 0 8px; grid-template-columns: repeat(4, 1fr); }
  .seg { margin-bottom: 10px; }
  .seg button { padding: 7px; }
  .big-btn { padding: 10px; font-size: 17px; }
  .menu-help { display: none; }
  #menu { flex-direction: row; align-items: center; gap: 16px; }
  .menu-top { flex: 0 0 32%; }
  .menu-panel { width: auto; flex: 1; }
  .item-slot { width: 62px; height: 62px; }
  .lap { font-size: 22px; }
  .time { font-size: 14px; }
  body.is-touch #minimap { top: calc(78px + var(--safe-t)); width: 96px; height: 96px; }
  body.is-touch .pos { font-size: 46px; }
  body.is-touch .hud-br { right: calc(92px + var(--safe-r)); }
}

/* ===================== AAA flow screens ===================== */
#fader { position: fixed; inset: 0; background: #000; opacity: 1; pointer-events: none; z-index: 60; transition: opacity .45s ease; }
#fader.clear { opacity: 0; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 59; transition: opacity .6s ease-out; }
.load-tip { margin-top: 26px; font-size: 13px; color: #cfd6f2; opacity: .75; min-height: 2.6em; line-height: 1.4; }

.logo.huge { font-size: clamp(54px, 11vw, 150px); letter-spacing: -2px; }
#title { flex-direction: column; justify-content: space-between; background: radial-gradient(ellipse at 50% 30%, rgba(0,0,0,0) 40%, rgba(5,8,20,.55)); }
.title-wrap { margin-top: 6vh; text-align: center; animation: titleIn 1.4s cubic-bezier(.2,1.2,.3,1) both; }
.title-sub { margin-top: 10px; font-weight: 900; letter-spacing: 10px; font-size: clamp(12px, 1.6vw, 18px); color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.press { font-weight: 900; font-style: italic; letter-spacing: 3px; font-size: clamp(18px, 2.4vw, 28px); text-transform: uppercase;
  color: #fff; text-shadow: 0 3px 0 #b3122b, 0 0 24px rgba(255,90,110,.6); animation: pulse 1.6s ease-in-out infinite; }
.title-foot { width: 100%; display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: #fff; opacity: .8; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.97); } }
@keyframes titleIn { from { opacity: 0; transform: scale(1.4) translateY(-20px); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }

#main-menu { justify-content: flex-start; align-items: stretch; flex-direction: column; background: linear-gradient(90deg, rgba(5,8,20,.82), rgba(5,8,20,.35) 45%, transparent 70%); }
.mm-brand { margin: 2vh 0 4vh 2vw; }
.mm-list { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); margin-left: 2vw; }
.mm-btn { text-align: left; padding: 14px 20px; border-radius: 14px; border: 1px solid rgba(255,255,255,.14); background: rgba(12,18,38,.62);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .15s, background .15s, border-color .15s; animation: slideIn .5s both; }
.mm-btn:nth-child(2) { animation-delay: .06s; } .mm-btn:nth-child(3) { animation-delay: .12s; } .mm-btn:nth-child(4) { animation-delay: .18s; }
.mm-btn b { display: block; font-size: 26px; font-style: italic; font-weight: 900; letter-spacing: -.5px; }
.mm-btn small { color: var(--muted); font-weight: 600; }
.mm-btn:hover, .mm-btn:focus-visible { transform: translateX(10px); background: linear-gradient(90deg, rgba(216,22,58,.85), rgba(216,22,58,.35)); border-color: #ff5a6e; outline: none; }
.mm-foot { margin: auto 0 0 2vw; font-size: 12px; color: #fff; opacity: .7; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }

#setup { justify-content: space-between; align-items: flex-end; background: linear-gradient(90deg, transparent 40%, rgba(5,8,20,.5)); }
.showcase { align-self: flex-end; margin: 0 0 3vh 2vw; text-shadow: 0 4px 20px rgba(0,0,0,.6); }
.sc-mode { font-weight: 900; letter-spacing: 6px; font-size: 13px; color: var(--gold); }
.sc-name { font-size: clamp(48px, 8vw, 110px); font-weight: 900; font-style: italic; line-height: .95; letter-spacing: -2px; }
.sc-num { font-size: 22px; font-weight: 900; opacity: .7; }
.setup-panel { width: min(520px, 100%); margin: 0; align-self: center; }
.setup-panel .driver-grid { grid-template-columns: repeat(4, 1fr); }
.row-btns { display: flex; gap: 10px; margin-top: 6px; }
.row-btns .btn { flex: 1; }
.row-btns .big-btn { flex: 2; }
.seg.small button { padding: 8px 4px; font-size: 13px; }
.menu-panel.wide { width: min(460px, 100%); }
.opt-note { font-size: 12px; color: var(--muted); margin: -8px 0 8px; }
.slider { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-weight: 600; padding: 4px 2px; }
.slider input { flex: 1; max-width: 240px; accent-color: var(--gold); }
.controls-body { font-size: 14px; line-height: 1.55; color: #dfe4f7; }
.controls-body table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.controls-body td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
.controls-body td:first-child { color: var(--muted); }
.controls-body kbd { background: rgba(255,255,255,.12); border-radius: 4px; padding: 1px 6px; font-family: inherit; color: #fff; }

.intro-card { position: fixed; left: calc(4vw + var(--safe-l)); bottom: 12vh; z-index: 15; pointer-events: none; opacity: 0; transform: translateX(-30px); transition: opacity .5s, transform .6s cubic-bezier(.2,1,.3,1); }
.intro-card.show { opacity: 1; transform: none; }
.ic-bar { width: 90px; height: 6px; background: linear-gradient(90deg, var(--hot), var(--gold)); border-radius: 3px; margin-bottom: 10px; }
.ic-title { font-size: clamp(34px, 6vw, 72px); font-weight: 900; font-style: italic; letter-spacing: -1px; line-height: 1; text-shadow: 0 4px 24px rgba(0,0,0,.6); }
.ic-sub { font-weight: 800; letter-spacing: 4px; margin-top: 6px; font-size: 15px; text-shadow: 0 2px 10px rgba(0,0,0,.7); }
.ic-skip { margin-top: 22px; font-size: 12px; opacity: .65; font-weight: 700; letter-spacing: 1px; }

.best { font-size: 13px; color: var(--gold); margin-top: 2px; font-variant-numeric: tabular-nums; }
.wg-hud { color: #ffb347; font-size: 12px; }
/* on phones the top left is taken by the minimap, so the record line sits under the pause button */
body.is-touch .wg-hud { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; font-weight: 800; text-shadow: 0 1px 3px rgba(0,0,0,.7); pointer-events: none; }
.pos.pulse { animation: posPulse .45s cubic-bezier(.2,1.8,.4,1); }
@keyframes posPulse { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
.item-slot.pop { animation: pop .35s cubic-bezier(.2,1.8,.4,1); }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.delta-good { color: #6dff9c; } .delta-bad { color: #ff7a8a; }

.results-wrap { display: flex; gap: 24px; align-items: flex-end; justify-content: center; width: 100%; }
.podium { display: flex; align-items: flex-end; gap: 8px; }
.pod { width: 110px; text-align: center; animation: rise .7s cubic-bezier(.2,1.3,.3,1) both; }
.pod .pn { font-weight: 900; font-style: italic; font-size: 18px; margin-bottom: 6px; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.pod .pb { border-radius: 10px 10px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; font-size: 44px; font-weight: 900; font-style: italic; color: rgba(0,0,0,.55); box-shadow: inset 0 -20px 30px rgba(0,0,0,.25); }
.pod.p1 .pb { height: 150px; background: linear-gradient(180deg, #ffe58a, #e0a91c); }
.pod.p2 .pb { height: 110px; background: linear-gradient(180deg, #f3f5f9, #aab2c0); }
.pod.p3 .pb { height: 80px; background: linear-gradient(180deg, #f2b98a, #b0683a); }
.pod.p1 { animation-delay: .35s; } .pod.p2 { animation-delay: .15s; } .pod.p3 { animation-delay: .5s; }
.pod .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
@keyframes rise { from { opacity: 0; transform: translateY(60px); } to { opacity: 1; transform: none; } }
.results-panel { width: min(460px, 100%); margin: 0; }
.res-note { color: var(--gold); font-weight: 800; margin: -4px 0 6px; min-height: 1em; }
.fps { position: fixed; left: 50%; bottom: calc(6px + var(--safe-b)); transform: translateX(-50%); z-index: 40; font: 700 11px ui-monospace, monospace; background: rgba(0,0,0,.5); padding: 2px 8px; border-radius: 6px; }

@media (max-width: 900px), (max-height: 520px) {
  .results-wrap { flex-direction: column; align-items: center; gap: 10px; }
  .podium { display: none; }
  #setup { flex-direction: column; justify-content: flex-end; align-items: stretch; }
  .showcase { display: none; }
  .setup-panel { align-self: stretch; width: auto; }
}
@media (max-height: 520px) {
  .setup-panel .driver-grid { grid-template-columns: repeat(8, 1fr); }
  .setup-panel h3 { margin: 2px 0 4px; }
  .setup-panel .seg { margin-bottom: 6px; }
  .mm-brand { margin: 0 0 2vh 2vw; }
  .mm-btn { padding: 8px 14px; }
  .mm-btn b { font-size: 20px; }
  .results-panel { padding: 10px 14px; }
  #res-table td { padding: 3px 6px; font-size: 13px; }
  .intro-card { bottom: 6vh; }
}

.track-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.track-card { text-align: left; border: 2px solid transparent; border-radius: 12px; padding: 0; overflow: hidden; background: rgba(255,255,255,.06); }
.track-card .tc-art { height: 46px; position: relative; }
.track-card .tc-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.35)); }
.track-card b { display: block; padding: 6px 8px 0; font-size: 13px; font-style: italic; font-weight: 900; }
.track-card small { display: block; padding: 0 8px 7px; font-size: 10px; color: var(--muted); line-height: 1.25; }
.track-card.on { border-color: var(--gold); background: rgba(255,197,61,.12); }
@media (max-height: 520px) { .track-card small { display: none; } .track-card .tc-art { height: 22px; } }

.driver .pt { width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.22), rgba(255,255,255,.04)); background-size: cover; }
.driver .pt img { width: 100%; height: 100%; display: block; }
.vehicle-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
.vehicle-card { border: 2px solid transparent; border-radius: 12px; background: rgba(255,255,255,.06); padding: 4px 4px 6px; text-align: center; }
.vehicle-card img { width: 100%; height: 52px; object-fit: contain; display: block; }
.vehicle-card b { display: block; font-size: 11px; font-weight: 900; font-style: italic; }
.vehicle-card small { display: block; font-size: 9.5px; color: var(--muted); line-height: 1.2; }
.vehicle-card.on { border-color: var(--gold); background: rgba(255,197,61,.12); }
.sc-vehicle { font-weight: 800; letter-spacing: 3px; font-size: 13px; opacity: .85; margin-top: 4px; text-transform: uppercase; }
.stat.off b i { background: linear-gradient(90deg, #ffb13d, #ffe27a); }
@media (max-height: 520px) { .vehicle-card img { height: 30px; } .vehicle-card small { display: none; } .driver .pt { width: 30px; height: 30px; } }

/* setup: two columns on wide screens */
.setup-panel { width: min(820px, 100%); }
.setup-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.setup-panel .track-grid { grid-template-columns: 1fr; gap: 6px; }
.setup-panel .track-card { display: grid; grid-template-columns: 54px 1fr; align-items: center; }
.setup-panel .track-card .tc-art { height: 100%; min-height: 44px; grid-row: span 2; }
.setup-panel .track-card b { padding: 6px 8px 0; }
.setup-panel .vehicle-grid { grid-template-columns: repeat(2, 1fr); }
.setup-panel .vehicle-card img { height: 58px; }
.setup-panel .driver-stats { grid-template-columns: repeat(3, 1fr); margin: 8px 0 10px; }
.setup-panel .seg { margin-bottom: 10px; }
.setup-panel .seg button { padding: 8px 4px; font-size: 13px; }
@media (max-width: 900px), (max-height: 520px) {
  .setup-cols { grid-template-columns: 1fr; gap: 0; }
  .setup-panel .track-grid { grid-template-columns: repeat(3, 1fr); }
  .setup-panel .track-card { display: block; }
  .setup-panel .vehicle-grid { grid-template-columns: repeat(4, 1fr); }
  .setup-panel .driver-stats { grid-template-columns: repeat(5, 1fr); }
}
@media (max-height: 520px) and (min-width: 700px) {
  .setup-cols { grid-template-columns: 1fr 1fr; gap: 12px; }
  .setup-panel { width: min(760px, 100%); max-height: 100%; }
  .setup-panel .vehicle-grid { grid-template-columns: repeat(2, 1fr); }
  .setup-panel .driver-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ===================== World Tour ===================== */
.mm-btn.mm-hero { background: linear-gradient(90deg, rgba(255,197,61,.28), rgba(12,18,38,.62)); border-color: rgba(255,197,61,.55); }
.mm-btn.mm-hero b { font-size: 30px; background: linear-gradient(180deg, #fff 30%, #ffd23d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mm-btn:nth-child(5) { animation-delay: .24s; }
#adventure { --wc: #4caf50; --wa: #b8f07a; align-items: stretch; justify-content: stretch; background: linear-gradient(180deg, rgba(5,8,20,.72), rgba(5,8,20,.35) 40%, rgba(5,8,20,.78)); }
.adv-wrap { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 1180px; margin: 0 auto; min-height: 0; }
.adv-top { display: flex; align-items: center; gap: 16px; }
.adv-top .logo.small { font-size: 36px; }
.adv-total { margin-left: auto; font-weight: 900; font-style: italic; font-size: 26px; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.adv-total small { font-size: 16px; color: var(--muted); }
.adv-back { width: auto; padding: 10px 18px; }
.adv-worlds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.adv-world { text-align: left; padding: 10px 14px; border-radius: 14px; border: 2px solid rgba(255,255,255,.12); background: linear-gradient(135deg, color-mix(in srgb, var(--wc) 55%, transparent), rgba(12,18,38,.7)); position: relative; overflow: hidden; transition: transform .15s, border-color .15s; }
.adv-world small { display: block; font-size: 10px; letter-spacing: 3px; font-weight: 900; opacity: .75; }
.adv-world b { display: block; font-size: 19px; font-style: italic; font-weight: 900; line-height: 1.1; }
.adv-world .ws { display: block; font-size: 13px; font-weight: 800; color: var(--gold); margin-top: 2px; }
.adv-world.on { border-color: var(--wa); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 0 0 3px color-mix(in srgb, var(--wa) 30%, transparent); }
.adv-world.locked { filter: grayscale(.8) brightness(.7); }
.adv-world.locked .ws { color: var(--muted); }
.adv-world.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.adv-body { display: grid; grid-template-columns: 1fr 360px; gap: 14px; min-height: 0; flex: 1; }
.adv-events { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: start; overflow: auto; }
.adv-event { text-align: left; border-radius: 14px; border: 2px solid rgba(255,255,255,.12); background: rgba(12,18,38,.72); padding: 0 0 10px; overflow: hidden; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .15s, border-color .15s; animation: slideIn .4s both; }
.adv-event:hover { transform: translateY(-3px); }
.adv-event.on { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,197,61,.25); }
.adv-event.boss { border-color: rgba(179,29,255,.6); }
.adv-event.boss.on { border-color: var(--gold); }
.ae-art { height: 54px; position: relative; }
.ae-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,.45)); }
.ae-num { position: absolute; left: 10px; bottom: 4px; z-index: 1; font-size: 30px; font-weight: 900; font-style: italic; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.adv-event .ae-type { display: block; padding: 8px 12px 0; font-size: 10px; letter-spacing: 2px; font-weight: 900; color: var(--wa); }
.adv-event b { display: block; padding: 0 12px; font-size: 17px; font-style: italic; font-weight: 900; }
.adv-event .ae-track { display: block; padding: 0 12px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.adv-event .stars { padding: 0 12px; }
.stars { display: inline-flex; gap: 2px; font-style: normal; }
.stars i { font-style: normal; color: rgba(255,255,255,.18); font-size: 18px; }
.stars i.on { color: var(--gold); text-shadow: 0 0 10px rgba(255,197,61,.6); }
.adv-detail { width: auto; margin: 0; display: flex; flex-direction: column; gap: 8px; align-self: start; }
.ad-head small { font-size: 11px; letter-spacing: 2px; font-weight: 900; color: var(--wa); }
.ad-head h2 { margin: 2px 0 0; font-size: 30px; line-height: 1.05; }
.ad-meta { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: capitalize; }
.ad-blurb { margin: 2px 0 4px; font-size: 15px; line-height: 1.45; }
.ad-goals { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.ad-goal { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.05); font-weight: 700; font-size: 14px; }
.ad-goal .stars { min-width: 60px; }
.ad-goal .stars i { color: rgba(255,255,255,.35); font-size: 16px; }
.ad-goal.done { background: rgba(255,197,61,.14); }
.ad-goal.done .stars i { color: var(--gold); }
.adv-story { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; padding: 0 16px calc(24px + var(--safe-b)); background: linear-gradient(180deg, transparent 40%, rgba(5,8,20,.8)); z-index: 25; }
.adv-story.show { display: flex; }
.as-card { width: min(720px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 22px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); animation: rise .45s cubic-bezier(.2,1.3,.3,1) both; }
.as-who { font-weight: 900; letter-spacing: 3px; font-size: 13px; text-transform: uppercase; color: var(--gold); }
.as-who.vex { color: #d77bff; }
.as-line { font-size: 20px; line-height: 1.4; font-weight: 700; margin: 6px 0 14px; }
.as-next { width: auto; padding: 10px 26px; font-size: 17px; float: right; }
#adv-results { background: rgba(5,8,20,.55); }
.ar-panel { width: min(480px, 100%); text-align: center; }
.ar-type { font-size: 11px; letter-spacing: 2px; font-weight: 900; color: var(--muted); }
.ar-panel h2 { font-size: 34px; margin: 2px 0 2px; }
.ar-line { font-weight: 800; font-size: 17px; }
.ar-stars { display: flex; justify-content: center; gap: 10px; margin: 10px 0 2px; }
.ar-stars i { font-style: normal; font-size: 64px; line-height: 1; color: rgba(255,255,255,.14); transform: scale(.8); transition: color .2s, transform .35s cubic-bezier(.2,1.8,.4,1); }
.ar-stars i.on { color: var(--gold); transform: scale(1.15); text-shadow: 0 0 24px rgba(255,197,61,.8); }
.ar-panel .ad-goal { text-align: left; }
.ar-unlocks .unlock { margin: 6px 0; padding: 10px; border-radius: 10px; background: linear-gradient(90deg, rgba(179,29,255,.35), rgba(61,255,176,.25)); font-weight: 900; animation: pop .5s cubic-bezier(.2,1.8,.4,1) both; animation-delay: 1.8s; }
.objective { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); text-align: center; padding: 6px 16px 7px; border-radius: 12px; background: rgba(10,14,30,.45); border: 1px solid rgba(255,255,255,.15); }
.objective b { display: block; font-size: 20px; font-style: italic; }
.objective small { display: block; font-size: 12px; color: var(--gold); letter-spacing: .5px; }
body.is-touch .objective { top: calc(60px + var(--safe-t)); padding: 3px 10px 4px; }
body.is-touch .objective b { font-size: 15px; }
.driver.locked, .vehicle-card.locked { opacity: .38; filter: grayscale(1); position: relative; }
.driver.locked::after, .vehicle-card.locked::after { content: "🔒"; position: absolute; top: 4px; right: 6px; font-size: 13px; filter: none; }
/* seven tracks, ten drivers, five vehicles */
.setup-panel .track-grid { grid-template-columns: 1fr 1fr; }
.setup-panel .track-card small { display: none; }
.setup-panel .track-card .tc-art { min-height: 34px; }
.setup-panel .driver-grid { grid-template-columns: repeat(5, 1fr); }
.setup-panel .vehicle-grid { grid-template-columns: repeat(3, 1fr); }
.setup-panel .vehicle-card img { height: 44px; }
.setup-panel .seg { flex-wrap: wrap; }
@media (max-width: 900px), (max-height: 520px) {
  .adv-body { grid-template-columns: 1fr; overflow: auto; }
  .adv-events { grid-template-columns: repeat(5, 1fr); overflow: visible; }
  .ae-art { height: 30px; }
  .ae-num { font-size: 20px; }
  .adv-event b { font-size: 13px; }
  .adv-event .ae-track { display: none; }
  .setup-panel .track-grid { grid-template-columns: repeat(4, 1fr); }
  .setup-panel .driver-grid { grid-template-columns: repeat(10, 1fr); }
  .setup-panel .vehicle-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-height: 520px) {
  .adv-top .logo.small { font-size: 26px; }
  .adv-total { font-size: 20px; }
  .adv-worlds { gap: 6px; }
  .adv-world { padding: 6px 10px; }
  .adv-world b { font-size: 14px; }
  .adv-world small { display: none; }
  .adv-detail { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; }
  .adv-detail .ad-head { flex: 1; order: 0; }
  .adv-detail .ad-head h2 { font-size: 22px; }
  .adv-detail .ad-meta, .adv-detail .ad-blurb { display: none; }
  .adv-detail .big-btn { flex: 0 0 170px; order: 1; padding: 9px; font-size: 17px; }
  .adv-detail .ad-goals { flex-direction: row; margin: 0; flex: 1 1 100%; order: 2; }
  .adv-detail .ad-goal { flex: 1; padding: 5px 8px; font-size: 12px; }
  .as-line { font-size: 16px; }
  .ar-stars i { font-size: 44px; }
  .ar-panel h2 { font-size: 26px; }
  .ar-panel .ad-goals { display: none; }
}
@media (max-height: 520px) {
  .mm-brand .logo.small { font-size: 30px; }
  .mm-brand { margin: 0 0 1.5vh 2vw; }
  .mm-list { gap: 6px; overflow: auto; min-height: 0; }
  /* seven buttons: two columns on short landscape phones so they all fit */
  .mm-list { display: grid; grid-template-columns: 1fr 1fr; width: min(640px, 100%); }
  .mm-list .mm-hero { grid-column: 1 / -1; }
  .mm-btn:hover, .mm-btn:focus-visible { transform: translateY(-2px); }
  .mm-btn { padding: 6px 14px; }
  .mm-btn b { font-size: 18px; }
  .mm-btn.mm-hero b { font-size: 22px; }
  .mm-btn small { font-size: 11px; }
  .mm-foot { display: none; }
}
/* keep Start in reach while the setup panel scrolls */
.setup-panel .row-btns { position: sticky; bottom: -18px; padding: 10px 0 12px; margin-bottom: -12px; background: linear-gradient(180deg, rgba(12,18,38,0), rgba(12,18,38,.96) 30%); z-index: 2; }
@media (max-width: 900px), (max-height: 520px) {
  .setup-panel .track-card .tc-art { height: 46px; min-height: 0; }
  .setup-panel .track-card b { font-size: 11px; padding: 4px 6px; }
}
@media (max-height: 520px) {
  .setup-panel .row-btns { bottom: -12px; }
  .setup-panel .track-card .tc-art { height: 34px; }
  .setup-panel .vehicle-card img { height: 30px; }
}

.banner.small { font-size: clamp(30px, 5.5vw, 64px); top: 20%; }

/* Grand Prix */
.cup-only { display: none; }
.tt-only { display: none; }
#setup.tt .tt-only { display: block; }
#setup.tt .seg.tt-only { display: flex; }
#setup.cup .cup-only { display: block; }
#setup.cup .cup-grid.cup-only { display: grid; }
#setup.cup .race-only, #setup.cup .track-grid { display: none; }
.cup-grid { grid-template-columns: 1fr; gap: 8px; margin-bottom: 10px; }
.cup-card { text-align: left; border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; box-shadow: inset 0 -30px 40px rgba(0,0,0,.35); }
.cup-card b { display: block; font-size: 18px; font-style: italic; font-weight: 900; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.cup-card small { display: block; font-size: 11px; font-weight: 700; opacity: .9; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.cup-card.on { border-color: #fff; box-shadow: inset 0 -30px 40px rgba(0,0,0,.35), 0 0 0 3px rgba(255,255,255,.35); }
.mm-btn:nth-child(6) { animation-delay: .3s; }
@media (max-height: 520px) { .cup-card { padding: 6px 10px; } .cup-card b { font-size: 15px; } .cup-card small { font-size: 10px; } }

.banner.small { white-space: nowrap; }

/* Mirror mode: the picture and the minimap flip, the HUD does not */
body.mirror canvas#game, body.mirror #minimap { transform: scaleX(-1); }
#setup.cup .mirror-h { display: block; }

.paint-row button[data-paint="carbon"] { background: linear-gradient(135deg, #2a2d34, #111317); }
.paint-row button[data-paint="chrome"] { background: linear-gradient(135deg, #f4f7fb, #9aa3b2); color: #1a1d24; }
.paint-row button[data-paint="gold"] { background: linear-gradient(135deg, #ffe27a, #c98a0c); color: #2a1a00; }
.paint-row button.on { outline: 3px solid var(--gold); outline-offset: 1px; }
.paint-row button.locked { opacity: .4; filter: grayscale(.7); }
.paint-row button.locked::after { content: " 🔒"; }

.random-card .tc-art { display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; font-style: italic; background: repeating-linear-gradient(135deg, #3a2a6a, #3a2a6a 10px, #2a1f52 10px, #2a1f52 20px); }
.random-card .rv-ic { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 900; font-style: italic; color: var(--gold); }
.setup-panel .vehicle-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px), (max-height: 520px) {
  .setup-panel .vehicle-grid { grid-template-columns: repeat(6, 1fr); }
  .random-card .rv-ic { height: 30px; font-size: 22px; }
}

/* with tilt steering the joystick is optional: dim it */
body.tilt #stick-base { opacity: .35; }
body.tilt .zone-hint::after { content: " or tilt"; }

.as-pic { float: left; width: 64px; height: 64px; margin: 0 14px 6px 0; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 900; font-style: italic; }
.as-pic img { width: 100%; height: 100%; display: block; }
.as-pic.coach { background: linear-gradient(135deg, #ffc53d, #ff7a1a); color: #2a1a00; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.as-pic.vex { background: radial-gradient(circle at 50% 40%, rgba(179,29,255,.5), rgba(20,8,31,.9)); box-shadow: 0 0 0 3px #b31dff, 0 0 20px rgba(179,29,255,.6); }
@media (max-height: 520px) { .as-pic { width: 46px; height: 46px; font-size: 22px; } }
/* no long-press callouts or magnifier inside the iOS app */
html, body, button, canvas { -webkit-touch-callout: none; }

.item-help { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 12px; }
.item-help div { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.item-help i { flex: 0 0 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.08) center / 80% no-repeat; }
.item-help b { display: block; color: #fff; font-size: 13.5px; }

/* keyboard and gamepad focus */
button:focus-visible, .track-card:focus-visible, .driver:focus-visible, .vehicle-card:focus-visible, .adv-event:focus-visible, .adv-world:focus-visible { outline: 3px solid #7fe8ff; outline-offset: 2px; }

.ic-vs { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.ic-vs:empty { display: none; }
.vs-card { width: 96px; text-align: center; font-weight: 900; font-style: italic; font-size: 18px; text-shadow: 0 2px 8px rgba(0,0,0,.7); animation: rise .6s cubic-bezier(.2,1.3,.3,1) both; }
.vs-card img { width: 96px; height: 96px; border-radius: 50%; display: block; background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.25), rgba(0,0,0,.4)); box-shadow: 0 0 0 4px var(--c), 0 0 26px var(--c); margin-bottom: 6px; }
.vs-card.them { animation-delay: .25s; }
.vs-x { font-size: 44px; font-style: italic; font-weight: 900; color: var(--gold); text-shadow: 0 3px 0 #b3122b, 0 0 20px rgba(255,197,61,.6); }
@media (max-height: 520px) { .vs-card, .vs-card img { width: 64px; } .vs-card img { height: 64px; } .vs-x { font-size: 30px; } }

.load-icon { width: 120px; height: 120px; border-radius: 28px; display: block; margin: 0 auto 18px; box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.12); animation: pulse 2.4s ease-in-out infinite; }
@media (max-height: 520px) { .load-icon { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 10px; } }

.adv-worlds { grid-template-columns: repeat(4, 1fr) 0.8fr; }
.adv-world.daily { background: linear-gradient(135deg, rgba(255,61,90,.55), rgba(255,197,61,.35)); }
@media (max-height: 520px) and (min-width: 700px) {
  .setup-panel .vehicle-grid { grid-template-columns: repeat(3, 1fr); }
  .setup-col { min-width: 0; }
  .setup-panel .seg button { min-width: 0; }
}
@media (max-height: 520px) and (min-width: 700px) {
  .setup-panel .driver-grid { grid-template-columns: repeat(5, 1fr); }
}
.setup-panel .row-btns .btn { background: #1b2244; }

/* ===================== split screen ===================== */
body.is-touch .desk-only { display: none !important; }
body.split #hud::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: linear-gradient(90deg, #ff3d5a, #ffc53d, #5ad1ff); box-shadow: 0 0 12px rgba(0,0,0,.6); }
body.split .hud-br { bottom: calc(50% + 10px); }
body.split .hud-br .pos { font-size: 56px; }
body.split #minimap, body.split .standings, body.split #objective, body.split .laptimes, body.split .best { display: none !important; }
body.split .hud-tl::before { content: "P1"; display: inline-block; font-weight: 900; font-style: italic; background: #ff3d5a; padding: 0 8px; border-radius: 6px; margin-right: 8px; font-size: 18px; vertical-align: 6px; }
body.split .banner { top: 18%; font-size: clamp(40px, 7vw, 90px); }
.hud2 { position: fixed; left: 0; right: 0; bottom: 0; height: 50%; pointer-events: none; z-index: 10; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.h2-tag { position: absolute; left: 14px; top: 14px; font-weight: 900; font-style: italic; background: #5ad1ff; color: #07203a; padding: 0 8px; border-radius: 6px; font-size: 18px; }
.h2-lap { position: absolute; left: 60px; top: 12px; font-size: 22px; font-style: italic; }
.h2-item { position: absolute; right: 14px; top: 14px; width: 70px; height: 70px; }
.h2-pos { position: absolute; right: 16px; bottom: 10px; font-size: 56px; }

.adv-worlds { grid-template-columns: repeat(5, 1fr) 0.85fr; }
@media (max-width: 900px), (max-height: 520px) { .adv-world b { font-size: 12.5px; } .adv-world .ws { font-size: 11px; } }

.photo-ui { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); z-index: 30; display: flex; gap: 14px; align-items: center; background: rgba(10,14,30,.6); border: 1px solid var(--line); border-radius: 99px; padding: 8px 10px 8px 18px; font-weight: 700; font-size: 13px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.photo-ui .btn { width: auto; padding: 8px 18px; border-radius: 99px; }

.coach { position: absolute; left: 50%; bottom: calc(22% + var(--safe-b)); transform: translate(-50%, 10px); max-width: min(560px, 80vw); text-align: center; padding: 10px 18px; border-radius: 14px; background: rgba(10,14,30,.72); border: 1px solid rgba(255,197,61,.55); font-size: 17px; font-weight: 800; opacity: 0; transition: opacity .3s, transform .3s; text-shadow: none; }
.coach.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-height: 520px) { .coach { font-size: 14px; bottom: 34%; } }

/* World leaderboard */
.lb-me { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lb-me b { color: var(--gold); }
.lb-small { width: auto; padding: 6px 12px; font-size: 13px; }
.lb-editor { display: flex; gap: 6px; flex-wrap: wrap; }
.lb-editor select { flex: 1 1 120px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: #141a33; color: inherit; font: inherit; font-weight: 700; }
.lb-editor .lb-save { background: var(--gold); color: #2a1a00; border-color: var(--gold); }
.lb-track { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lb-track b { font-size: 18px; text-align: center; flex: 1; }
.lb-arrow { width: 44px; padding: 6px 0; font-size: 22px; line-height: 1; }
.lb-status { font-size: 13px; color: var(--muted); min-height: 18px; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lb-table td:first-child { width: 34px; color: var(--muted); font-weight: 800; }
.lb-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.lb-table td.lb-n { overflow: hidden; text-overflow: ellipsis; max-width: 0; width: 100%; }
.lb-table tr.me td { color: var(--gold); }
.lb-table tr.lb-gap td { border-bottom: none; text-align: center; color: var(--muted); padding: 2px; }
.lb-table .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.lb-note { margin: 0; }
/* seven menu buttons on laptop-height screens */
@media (min-height: 521px) and (max-height: 860px) {
  .mm-btn { padding: 9px 20px; }
  .mm-btn b { font-size: 22px; }
  .mm-btn.mm-hero b { font-size: 26px; }
}
/* Ultra draws a blank world inside the iOS app, so the app hides it */
body.native-app #q-row [data-q="ultra"], body.native-app #q-row [data-q="max"], body.is-touch #q-row [data-q="max"] { display: none; }

/* Garage, coin lines and rival difficulty (gameplay package) */
.garage-panel { width: min(560px, 100%); }
.gr-top { display: flex; align-items: center; justify-content: space-between; }
.gr-top h2 { margin: 0; }
.gr-coins { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 22px; color: var(--gold); }
.gr-tabs { margin: 10px 0 12px; }
.gr-tabs button { padding: 8px 2px; font-size: 12.5px; }
.gr-part { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.gr-info b { display: block; font-size: 15px; }
.gr-info small { color: var(--muted); font-size: 12px; }
.gr-pips { display: flex; gap: 4px; grid-column: 1; }
.gr-pips i { width: 26px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.14); }
.gr-pips i.on { background: linear-gradient(90deg, var(--sky), #8fffb0); }
.gr-buy { grid-column: 2; grid-row: 1 / span 2; width: auto; min-width: 128px; background: var(--gold); color: #2a1a00; border-color: var(--gold); font-weight: 900; }
.gr-buy.poor { background: rgba(255,255,255,.07); color: var(--muted); border-color: var(--line); }
.gr-buy:disabled { opacity: .55; }
.gr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gr-card { border: 2px solid transparent; border-radius: 12px; padding: 8px 6px 10px; background: rgba(255,255,255,.06); display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.gr-card b { font-size: 13px; }
.gr-card small { color: var(--muted); font-size: 11.5px; }
.gr-card.on { border-color: var(--gold); background: rgba(255,197,61,.14); }
.gr-card.locked .gr-sw { filter: saturate(.7) brightness(.85); }
.gr-sw { width: 100%; height: 26px; border-radius: 8px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.2); }
.gr-status { margin-top: 12px; min-height: 34px; font-size: 13px; color: #dfe4f7; }
.gr-note2 { margin: 12px 0 0; }
.res-coins { color: var(--gold); font-weight: 900; margin: -4px 0 8px; }
.res-coins:empty { display: none; }
.ar-unlocks .unlock.coin { background: linear-gradient(90deg, rgba(255,197,61,.35), rgba(255,157,28,.2)); animation-delay: 1.2s; }
.ad-diff { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; }
.ad-diff small { color: var(--muted); font-weight: 800; letter-spacing: 1.5px; font-size: 11px; }
.ad-diff .seg { margin: 0; flex: 1; }
.ad-ease { font-size: 12.5px; color: #8fffb0; margin-bottom: 6px; }
.item-slot.guarding { box-shadow: 0 0 0 3px #7fe8ff, 0 0 16px rgba(127,232,255,.7); }
@media (max-height: 520px) {
  .adv-detail .ad-diff { order: 1; margin: 0; gap: 0; flex: 0 0 auto; }
  .adv-detail .ad-diff small { display: none; }
  .adv-detail .ad-diff .seg button { padding: 5px 6px; font-size: 11px; }
  .adv-detail .ad-diff { margin-left: 24px; }
  .adv-detail .ad-ease { display: none; }
}

/* ---- Loading screen: art backdrop, speed streaks, a kart that drives the bar ---- */
#loading { overflow: hidden; background: #070b1a; }
.ld-bg { position: absolute; inset: -12%; background: url(icons/icon-512.png) center / cover; filter: blur(26px) saturate(1.5) brightness(.72); transform: scale(1.15); animation: ld-drift 14s ease-in-out infinite alternate; will-change: transform; }
.ld-vig { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, rgba(7,11,26,0) 0%, rgba(7,11,26,.55) 60%, rgba(7,11,26,.92) 100%); }
.ld-streaks { position: absolute; inset: 0; pointer-events: none; }
.ld-streaks i { position: absolute; top: var(--y); left: 0; width: var(--l); height: 2px; border-radius: 2px; opacity: var(--o);
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.95)); transform: translateX(-30vw); animation: ld-streak var(--d) linear var(--dl) infinite; will-change: transform; }
.ld-road { position: absolute; left: -20%; right: -20%; bottom: -8%; height: 34%; opacity: .55;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.35) 0 6px, transparent 6px 80px), linear-gradient(180deg, rgba(255,90,110,0), rgba(255,90,110,.25));
  transform: perspective(300px) rotateX(62deg); transform-origin: 50% 100%; -webkit-mask-image: linear-gradient(180deg, transparent, #000 60%); mask-image: linear-gradient(180deg, transparent, #000 60%);
  animation: ld-road .9s linear infinite; }
#loading .load-inner { position: relative; z-index: 2; width: min(560px, 90vw); }
#loading .load-icon { animation: ld-float 3.2s ease-in-out infinite; box-shadow: 0 18px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.18), 0 0 46px rgba(255,90,110,.35); }
#loading .logo { position: relative; }
.ld-track { position: relative; margin: 44px 0 8px; }
#loading .load-bar { height: 10px; margin: 0; background: rgba(255,255,255,.12); box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }
#loading .load-bar i { position: relative; box-shadow: 0 0 14px rgba(255,170,60,.7); transition: width .35s cubic-bezier(.2,.8,.2,1); }
.ld-kart { position: absolute; bottom: 5px; left: 0; width: 60px; height: 32px; margin-left: -30px; z-index: 3; pointer-events: none; transform: translateX(0); transition: left .35s cubic-bezier(.2,.8,.2,1); animation: ld-bob .28s ease-in-out infinite alternate; }
.ld-kart svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); }
.ld-wheels circle:nth-child(2n+1) { transform-box: fill-box; transform-origin: center; }
.ld-sparks { position: absolute; right: 88%; bottom: 8px; width: 46px; height: 8px; border-radius: 6px;
  background: linear-gradient(270deg, rgba(255,200,70,.95), rgba(255,90,60,.4), transparent); filter: blur(1px); animation: ld-flame .18s ease-in-out infinite alternate; }
.ld-flag { position: absolute; right: -6px; top: -14px; width: 20px; height: 26px; border-left: 2px solid #cfd6f2;
  background: conic-gradient(#fff 25%, #111 0 50%, #fff 0 75%, #111 0) 0 0 / 8px 8px; transform-origin: left center; animation: ld-wave .6s ease-in-out infinite alternate; }
.ld-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; }
#loading #load-text { text-align: left; }
#load-pct { font-size: 30px; font-style: italic; font-weight: 900; letter-spacing: -1px; color: #fff; text-shadow: 0 3px 0 #b3122b, 0 0 20px rgba(255,90,110,.5); font-variant-numeric: tabular-nums; }
#loading .load-tip { margin-top: 16px; transition: opacity .45s; }
#loading .load-tip.swap { opacity: 0; }
#loading.done .ld-kart { left: 118% !important; transition: left .42s cubic-bezier(.6,0,1,.6); }
#loading.done .ld-streaks i { animation-duration: .35s; }
#loading.done #load-pct { color: var(--gold); }
@keyframes ld-drift { from { transform: scale(1.15) translate3d(-2%, -1%, 0); } to { transform: scale(1.3) translate3d(2%, 1.5%, 0); } }
@keyframes ld-streak { from { transform: translateX(-30vw); } to { transform: translateX(130vw); } }
@keyframes ld-road { from { background-position: 0 0, 0 0; } to { background-position: -80px 0, 0 0; } }
@keyframes ld-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes ld-bob { from { transform: translateY(0) rotate(-1deg); } to { transform: translateY(-2px) rotate(1deg); } }
@keyframes ld-flame { from { width: 34px; opacity: .8; } to { width: 54px; opacity: 1; } }
@keyframes ld-wave { from { transform: skewY(-6deg) scaleX(1); } to { transform: skewY(6deg) scaleX(.85); } }
@media (max-height: 520px) {
  #loading .load-icon { width: 64px; height: 64px; margin-bottom: 8px; }
  .ld-track { margin-top: 40px; }
  #load-pct { font-size: 24px; }
  #loading .load-tip { margin-top: 8px; min-height: 2.4em; }
}
@media (prefers-reduced-motion: reduce) {
  .ld-bg, .ld-streaks i, .ld-road, #loading .load-icon, .ld-kart, .ld-sparks, .ld-flag { animation: none !important; }
  .ld-streaks { display: none; }
}
