:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ink: #f8f8fa;
  --muted: #c3c5ce;
  --red: #ef4051;
  --edge: #ffffff29;
  --gap: clamp(12px, 2vw, 28px);
  background: #13151a;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p, ol, ul, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3, strong { overflow-wrap: anywhere; }
h1 { font-size: clamp(23px, 3vw, 40px); line-height: 1.04; }
h2 { font-size: clamp(18px, 2vw, 28px); line-height: 1.12; }
h3 { font-size: 1rem; line-height: 1.2; }
p { line-height: 1.35; }
small, .muted { color: var(--muted); }
button, input, summary { font: inherit; }
button, input:not([type=checkbox]):not([type=radio]) {
  min-height: 44px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--edge);
  color: var(--ink);
}
button {
  background: linear-gradient(#2d3036,#17191e);
  font-weight: 730;
  cursor: pointer;
  line-height: 1.15;
}
button:hover:not(:disabled) { border-color: #ffffff80; background-color: #2d3036; }
button.primary, button[aria-pressed=true] {
  border-color: #ee546364;
  background: linear-gradient(175deg,#c91b2e 0%,#a00717 66%,#7a0811);
  box-shadow: inset 0 1px 0 #ffffff1f,0 3px 12px #0004;
}
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, summary:focus-visible, .number-grid label:focus-within {
  outline: 2px solid #ff6774;
  outline-offset: 2px;
}
input:not([type=checkbox]):not([type=radio]) {
  background: #101216;
  width: 100%;
}
input[type=checkbox] { accent-color: #c91b2e; width: 17px; height: 17px; margin: 0; }
label { display: grid; gap: 5px; font-size: .84rem; }
summary { cursor: pointer; color: var(--muted); font-size: .84rem; }
details input { margin-top: 6px; }
.icon { display: inline-block; flex: 0 0 auto; width: 21px; height: 21px; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.stage {
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
  background-color: #171c26;
  --scene: url('/art/winter.webp');
  --focus-x: 50%;
  --focus-y: 55%;
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}
.stage::before {
  background: var(--scene) var(--focus-x) var(--focus-y) / cover no-repeat;
}
.stage::after {
  background: linear-gradient(180deg,#0b101866,transparent 26%,transparent 68%,#080a0ddb);
}
.stage[data-scene=opponent] { --scene: url('/art/opponent.webp'); }
.stage[data-scene=lobby] { --scene: url('/art/lobby.webp'); }
.stage[data-scene=bucket] { --scene: url('/art/bucket.webp'); }
.stage[data-scene=crash] { --scene: url('/art/crash.webp'); }
.stage[data-scene=premium] { --scene: url('/art/premium.webp'); }
.stage[data-scene=select] { --scene: url('/art/select.webp'); }
.stage[data-scene=retro] { --scene: url('/art/retro.webp'); }
.stage[data-scene=sell] { --scene: url('/art/sell.webp'); }
.stage[data-scene=repair] { --scene: url('/art/repair.webp'); }
.stage[data-scene=parts] { --scene: url('/art/parts.webp'); }
.stage[data-scene=detail] { --scene: url('/art/detail.webp'); }
.stage[data-scene=rent] { --scene: url('/art/rent.webp'); }
.stage[data-scene=diagnose] { --scene: url('/art/diagnose.webp'); }
.stage[data-scene=luck] { --scene: url('/art/luck.webp'); }
.stage[data-scene=museum] { --scene: url('/art/museum.webp'); }
.stage[data-scene=taxi] { --scene: url('/art/taxi.webp'); }
.stage[data-scene=race] { --scene: url('/art/race.webp'); }
.stage[data-scene=finish] { --scene: url('/art/finish.webp'); }
.stage[data-scene=spring] { --scene: url('/art/spring.webp'); }
.stage[data-scene=summer] { --scene: url('/art/summer.webp'); }
.stage[data-scene=autumn] { --scene: url('/art/autumn.webp'); }

.entry-stage { --focus-x: 69%; }
.entry-stage::after { background: linear-gradient(90deg,#090d15e8 0%,#090d15a0 34%,#090d1522 67%,transparent); }
.lobby-stage::after { background: #09101c68; }
.entry-layout {
  min-height: 100dvh;
  display: grid;
  align-items: safe center;
  padding-block: max(12px,env(safe-area-inset-top),min(3dvh,28px)) max(12px,env(safe-area-inset-bottom),min(3dvh,28px));
  padding-inline: max(16px,env(safe-area-inset-left),min(6vw,100px)) max(16px,env(safe-area-inset-right),min(6vw,100px));
}
.entry-content { width: min(100%,420px); min-width: 0; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .38em;
  line-height: 1;
  font-style: italic;
  font-size: clamp(17px,2.7vw,35px);
  font-weight: 900;
  letter-spacing: -.055em;
  white-space: nowrap;
  text-shadow: 0 2px 5px #0009;
}
.brand::before {
  content: "";
  display: inline-block;
  width: .36em;
  height: .88em;
  transform: skewX(-19deg);
  background: linear-gradient(90deg,#f63347 58%,#9a1224 59%);
}
.brand-large { flex-direction: column; align-items: flex-start; gap: 0; font-size: clamp(32px,min(9.1vw,11dvh),68px); }
.brand-large::before { display: none; }
.brand-large svg { width: 94%; height: auto; margin-bottom: -.09em; }
.entry-tagline { text-transform: uppercase; letter-spacing: .17em; font-size: .73rem; font-weight: 700; margin: 6px 0 14px; }
.entry-panel { position: relative; width: 100%; padding: 14px; }
.stack { display: grid; gap: 9px; }
.lobby-stage { padding: clamp(14px,3vw,44px); display: grid; grid-template-rows: auto 1fr; }
.lobby-head { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.lobby-head h1 { font-size: clamp(18px,2.2vw,28px); border-left: 1px solid #fff5; padding-left: 18px; }
.lobby-layout { align-self: center; width: min(100%,970px); margin: 0 auto; display: grid; gap: 20px; grid-template-columns: 1fr 1fr; align-items: start; }
.lobby-map { padding: 18px; }
.lobby-track { position: relative; }
.lobby-track svg { width: 100%; max-height: 215px; display: block; }
.lobby-track > div { position: absolute; inset: 30% 0; display: grid; place-content: center; text-align: center; }
.lobby-track strong { font-size: 2rem; line-height: 1; }
.lobby-players { display: grid; gap: 12px; }
.status-box { background: #14161bcc; border: 1px solid var(--edge); border-radius: 9px; padding: 12px; }

.game-stage { height: 100dvh; min-height: 270px; }
.game-stage { padding-inline: max(env(safe-area-inset-left),env(safe-area-inset-right)); }
.lobby-stage { padding-inline: max(var(--gap),env(safe-area-inset-left)) max(var(--gap),env(safe-area-inset-right)); }
.game-stage::after { content: none; }
.hud {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: clamp(8px,2vw,26px);
  padding: 5px var(--gap);
  padding-top: max(5px,env(safe-area-inset-top));
  background: #101219ed;
  border-bottom: 1px solid #ffffff1d;
}
.hud .brand { font-size: clamp(19px,2.65vw,31px); }
.hud-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .84rem; white-space: nowrap; }
.hud-meta strong { color: var(--ink); }
.hud-players { margin-left: auto; flex: 0 0 auto; }
.balance { white-space: nowrap; display: flex; gap: 7px; align-items: center; font-size: clamp(15px,2vw,22px); }
.balance .icon { color: #d4d5db; }
.play-area { --mini-map-width: clamp(82px,12vw,155px); min-height: 0; position: relative; }
.turn-flag, .mini-map { position: absolute; top: var(--gap); border: 1px solid var(--edge); border-radius: 10px; background: #11151adc; }
.turn-flag { left: var(--gap); max-width: calc(100% - var(--mini-map-width) - 3 * var(--gap)); padding: 12px 19px; }
.turn-flag p { margin-top: 5px; color: #dddde5; }
.mini-map { right: var(--gap); width: var(--mini-map-width); padding: 5px 9px 7px; font-size: .78rem; }
.mini-map span { display: block; overflow-wrap: anywhere; }
.mini-map svg { width: 100%; max-height: 48px; display: block; }
.overlay { position: absolute; inset: var(--gap); display: flex; gap: var(--gap); align-items: center; justify-content: flex-end; pointer-events: none; }
.overlay > .panel { pointer-events: auto; width: clamp(290px,31vw,415px); max-height: 100%; }
.overlay > [data-side=left] { margin-right: auto; }
.panel-footer { flex: 0 0 auto; display: grid; gap: 6px; padding: 9px 14px 12px; border-top: 1px solid #ffffff19; }
.mobile-end-turn,
.panel-footer:has(> .mobile-end-turn:only-child) { display: none; }
.panel-footer > .money-row { border-top: 0; padding-top: 0; }
.overlay > .center-panel { margin-inline: auto; }
.overlay:has(.center-panel) { justify-content: center; }
.final-area .overlay { inset: 10px var(--gap); }
.panel {
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg,#1a1d23f8,#111317fa 65%);
  border: 1px solid #dfe5ff3d;
  border-radius: 12px;
  box-shadow: 0 12px 32px #0005, inset 0 1px 0 #ffffff0f;
  min-width: 0;
}
.panel-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 13px 15px 9px; border-bottom: 1px solid #ffffff19; }
.panel-head h2 { margin-right: auto; }
.panel-body { grid-auto-rows: max-content; padding: 11px 14px 14px; overflow: auto; min-height: 0; display: grid; align-content: start; gap: 9px; scrollbar-color: #66646d #1b1e23; }
.center-panel { text-align: center; }
.center-panel .panel-head h2 { margin-inline: auto; }
.centered { min-height: 100dvh; display: grid; place-items: center; padding: var(--gap); }
.centered .panel { width: min(100%,395px); }
.icon-button.close { min-height: 37px; width: 37px; flex: 0 0 auto; padding: 5px; border-color: transparent; background: transparent; }
.tag, .timer { font-size: .77rem; color: #e5e5ea; white-space: nowrap; }
.timer { color: #ff8291; font-variant-numeric: tabular-nums; font-weight: 750; }
.tag { border: 1px solid var(--edge); padding: 3px 6px; border-radius: 5px; background: #ffffff09; }
.bottom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 6px var(--gap) max(var(--gap),env(safe-area-inset-bottom));
}
.bottom-bar nav, .move-controls { display: flex; gap: 7px; align-items: stretch; min-width: 0; }
.bottom-bar nav button { white-space: nowrap; }
.bottom-bar button, .category-list button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.bottom-bar nav button { background: #14171bed; }
.bottom-bar nav button[aria-pressed=true] { background: linear-gradient(#bd1426,#840915); }
.move-controls { margin-inline-start: auto; }
.move { min-width: 120px; text-align: left; }
.move > span { display: grid; gap: 3px; }
.move > small { margin-left: 5px; white-space: nowrap; }
.move small { font-size: .74em; color: #fff; }
.end-turn { white-space: nowrap; }
.card {
  display: grid;
  background: #0e1014b0;
  border: 1px solid var(--edge);
  border-radius: 8px;
  overflow: hidden;
}
.card-content { padding: 9px; display: grid; gap: 6px; min-width: 0; }
.car-title { display: flex; gap: 7px; align-items: center; justify-content: space-between; }
.car-photo { width: 100%; height: auto; aspect-ratio: 2.14; object-fit: cover; object-position: center 57%; display: block; }
.thumb { flex: 0 0 auto; width: 63px; height: 32px; overflow: hidden; object-fit: cover; border-radius: 4px; display: block; }
.money-row { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 5px 0; border-top: 1px solid #ffffff17; font-size: .83rem; }
.money-row strong { text-align: right; font-size: 1.08em; white-space: nowrap; }
.buttons { display: flex; gap: 7px; }
.buttons > * { flex: 1 1 0; min-width: 0; }
.category-list, .sale-list, .scan-list, .garage-list, .race-list { display: grid; gap: 6px; }
.category-list button { justify-content: start; text-align: left; }
.category-list button small { display: block; margin-top: 3px; }
.category-list button > span:not(.thumb) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.garage-list .card { grid-template-columns: minmax(75px,31%) 1fr; }
.garage-list .car-photo { align-self: start; height: auto; aspect-ratio: 1.6; }
.player-list { display: grid; gap: 4px; }
.player, .race-row, .sale-option {
  display: flex; align-items: center; gap: 7px; padding: 7px;
  border: 1px solid #ffffff16; border-radius: 6px; background: #ffffff0b;
}
.player > span, .race-row > span, .sale-option > .option-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.player strong, .sale-option strong { font-size: .83rem; text-align: right; white-space: nowrap; }
.player.active .icon { color: var(--red); }
.race-row.mine, .sale-option:has(:checked) { border-color: #e2374d87; background: linear-gradient(90deg,#a31125a0,#31151cbb); }
.die { min-width: 25px; min-height: 25px; display: inline-grid; place-items: center; border-radius: 4px; color: #121318; background: #eeeef0; }
.bid-stepper { display: grid; grid-template-columns: 40px minmax(0,1fr) 40px; gap: 3px; }
.bid-stepper input { text-align: center; }
.bid-stepper button { padding: 4px; font-size: 1.3rem; }
.number-group { border: 0; padding: 0; }
.number-group legend { color: var(--muted); font-size: .82rem; }
.number-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 4px; margin-top: 4px; }
.number-grid label { position: relative; }
.number-grid input { position: absolute; opacity: 0; margin: 0; width: 100%; height: 100%; }
.number-grid span { border: 1px solid var(--edge); display: grid; place-items: center; min-height: 38px; border-radius: 5px; background: #272930; }
.number-grid input:checked + span { background: #b71b2b; }
.scan-cover, .empty, .victory { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 16px 8px; }
.scan-cover .icon, .empty .icon, .victory .icon { width: 58px; height: 58px; color: #a9adb8; }
.victory .icon { color: #ffe1b0; }
.victory span { padding: 8px 14px; width: 100%; font-weight: 850; font-size: clamp(20px,3vw,36px); background: linear-gradient(90deg,transparent,#991629,transparent); }
.route-hero { text-align: center; }
.route-hero svg { width: 100%; max-height: 108px; }
.location-dot { display: inline-block; vertical-align: middle; width: 9px; height: 9px; background: var(--red); border-radius: 50%; }
.route-list { display: grid; gap: 3px; }
.route-list li { display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 5px; font-size: .84rem; border-radius: 5px; padding: 4px; }
.route-list li.here { background: #a8112566; }
.route-list small { display: block; }
.route-index { color: var(--muted); font-variant-numeric: tabular-nums; }
.route-list button { min-height: 39px; min-width: 108px; padding: 4px 7px; display: grid; justify-items: center; }
.journal-list { display: grid; gap: 4px; }
.journal-list li { background: #ffffff0d; border-radius: 4px; padding: 7px; font-size: .85rem; line-height: 1.3; }
#notice {
  position: fixed; z-index: 3; inset: auto 12px max(12px,env(safe-area-inset-bottom));
  margin: auto; width: fit-content; max-width: min(470px,calc(100% - 24px));
  background: #22252b; color: #fff; padding: 10px 15px; border: 1px solid #ff627490; border-radius: 8px; box-shadow: 0 6px 25px #0008;
}
@media (orientation: landscape) and (max-height: 540px) {
  :root { --gap: 9px; font-size: 14px; }
  .hud { min-height: 42px; }
  .hud button { min-height: 34px; }
  .overlay { inset: 6px var(--gap); }
  .overlay > .panel { width: clamp(255px,36vw,380px); }
  .panel-head { padding: 8px 10px 6px; }
  .panel-body { padding: 7px 9px 9px; gap: 6px; }
  .car-photo { aspect-ratio: 2.45; max-height: 100px; }
  .panel-footer { padding: 6px 9px; }
  .panel-footer button { min-height: 40px; }
  .overlay > .panel[data-panel=auction] .card { grid-template-columns: 31% minmax(0,1fr); }
  .overlay > .panel[data-panel=auction] .car-photo { height: 100%; aspect-ratio: 1; }
  .overlay > .panel[data-panel=auction] .money-row { display: grid; gap: 2px; }
  .overlay > .panel[data-panel=auction] .money-row strong { text-align: left; }
  .bottom-bar { gap: 6px; }
  .bottom-bar button { min-height: 39px; padding: 5px 7px; }
  .bottom-bar .icon { width: 16px; height: 16px; }
  .move { min-width: 0; }
}
@media (orientation: landscape) and (max-width: 750px) {
  .bottom-bar nav { gap: 4px; }
  .bottom-bar nav button { padding-inline: 5px; }
}
@media (orientation: portrait) {
  .entry-stage::before, .lobby-stage::before { inset: 0 0 23%; }
  .entry-stage::after { background: linear-gradient(0deg,#0a0d14 13%,#0a0d1490 55%,transparent 82%); }
  .lobby-stage::after { background: linear-gradient(0deg,#0a0d14d9,#0a0d144d); }
  .entry-layout { align-items: safe end; }
  .entry-content { margin-inline: auto; }
  .lobby-layout { grid-template-columns: 1fr; max-width: 450px; }
  .lobby-track svg { max-height: 138px; }
  .hud { gap: 7px; }
  .hud-meta span { display: none; }
  .hud-players { min-height: 36px; padding: 5px 7px; }
  .balance { gap: 3px; }
  .balance .icon { display: none; }
  .overlay { align-items: end; justify-content: center; }
  .overlay > .panel { width: 100%; margin-inline: auto; }
  .final-area .overlay { align-items: center; }
  .bottom-bar { flex-wrap: wrap; gap: 7px; }
  .bottom-bar nav, .move-controls { width: 100%; }
  .bottom-bar nav button, .move-controls button { flex: 1 1 auto; min-width: 0; padding-inline: 5px; }
  .bottom-bar nav .icon { display: none; }
  .bottom-bar button { font-size: .81rem; }
  .move { flex-wrap: wrap; }
  .move > small { margin-left: 0; }
  .end-turn { width: 100%; }
}
@media (orientation: landscape) and (max-width: 950px) and (max-height: 500px) {
  .overlay > .panel { width: 100%; margin-inline: auto; }
}
@media (orientation: portrait), (orientation: landscape) and (max-width: 950px) and (max-height: 500px) {
  .play-area { --mini-map-width: clamp(118px,32vw,148px); }
  .mini-map { padding-inline: 10px; }
  .action-overlay { inset-block: 6px; }
  .action-overlay > .panel { height: 100%; }
  .action-overlay .panel-body { flex: 1 1 auto; }
  .action-overlay .mobile-end-turn { display: block; }
  .action-overlay .panel-footer:has(> .mobile-end-turn:only-child) { display: grid; }
  .action-toolbar .end-turn { display: none; }
}
@media (max-width: 350px) and (orientation: portrait) {
  .hud .brand { font-size: 16px; }
  .hud-meta { font-size: .7rem; }
  .turn-flag { padding: 9px; }
}

.service-picker { display: flex; gap: 6px; overflow-x: auto; }
.service-picker button { flex: 0 0 auto; min-height: 34px; padding: 5px 8px; }
.service-picker button[aria-pressed=true] { border-color: #e2374d87; background: #921a2a; }
[data-panel=luck] .card { grid-template-columns: minmax(64px,26%) minmax(0,1fr); align-items: start; }
[data-panel=luck] .car-photo { aspect-ratio: 1.38; }
.sale-option input { flex: 0 0 auto; }
.sale-option { min-height: 46px; }

@media (orientation: landscape) and (max-width: 630px) {
  .bottom-bar nav .icon { display: none; }
  .bottom-bar nav button { font-size: .82rem; }
}
@media (orientation: portrait) and (max-width: 380px) {
  .thumb { width: 49px; }
  .hud-players .icon { width: 15px; }
  .hud-meta { font-size: .75rem; }
}

[data-panel=map] .route-list li { padding: 5px 7px; border: 1px solid #ffffff12; background-color: #ffffff05; }
[data-panel=map] .route-list li.here { border-color: #ec3d55a0; background-color: #9a172b42; }
[data-panel=map] .route-list .move small { color: #e9e9ef; }
[data-panel=map] .route-hero p { font-size: .85rem; }
@media (orientation: landscape) and (max-height: 430px) {
  .lobby-head { margin-bottom: 8px; }
  .lobby-map { padding: 10px; }
  .lobby-track svg { max-height: 130px; }
  .lobby-layout { gap: 12px; }
}

@media (orientation: landscape) and (max-width: 580px) {
  .bottom-bar nav, .move-controls { gap: 4px; }
  .bottom-bar button { padding-inline: 5px; font-size: .77rem; }
  .move > small { margin-left: 0; }
}
@media (orientation: portrait) {
  .bottom-bar nav { flex-wrap: wrap; }
  .bottom-bar nav button { min-height: 41px; }
}

.player-color {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 0 0 2px #ffffff25;
  margin-inline: 5px;
}
.vehicle-photo {
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 62%,#505968,#171c23 76%);
}
.vehicle-profile { display:block; width: 89%; height: 94%; object-fit: contain; }
.thumb .vehicle-profile { width: 94%; height: 100%; min-height: 0; }
.thumb.vehicle-photo { grid-template-rows: minmax(0,1fr); }
[data-scene=track] { --scene: url('/art/track.webp'); }
.game-stage > .screen {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  position: relative;
  z-index: 1;
}
.entry-stage > .screen, .lobby-stage > .screen { display: contents; }
.game-stage { overflow: clip; }
.game-stage:has(.motion-view) :is(.play-area,.bottom-bar) { visibility: hidden; }
.game-stage:has(.motion-view) .hud { z-index: 1; }
.motion-view {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
  justify-items: center;
  padding: clamp(53px,13dvh,82px) var(--gap) max(12px,env(safe-area-inset-bottom));
  overflow: hidden;
}
.motion-skip { z-index: 1; justify-self: end; }
.drive-view { position: relative; width: min(100%,680px); text-align: center; }
.drive-route {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: #121722ed;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 8px 12px;
}
.drive-route .icon { color: #ff697a; }
.drive-view p { margin-top: 6px; text-shadow: 0 2px 4px #000; font-weight: 700; }
.drive-view p small { display: block; }
.drive-progress { position: absolute; bottom: 1%; left: 16%; right: 16%; height: 3px; background: #ffffff4d; border-radius: 5px; overflow: hidden; }
.drive-progress span { display: block; height: 100%; background: #fb405c; transform-origin: left; animation: progress var(--motion-time) linear both; animation-delay: var(--elapsed); }
@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.race-track {
  width: min(100%,735px);
  align-self: center;
  max-height: 100%;
  overflow: auto;
  padding: 9px;
  background: #121722eb;
  border: 1px solid var(--edge);
  border-radius: 12px;
}
.sprint-row { display: grid; grid-template-columns: minmax(65px,23%) minmax(0,1fr); gap: 7px; align-items: center; }
.sprint-name { display: flex; gap: 4px; justify-content: space-between; min-width: 0; font-size: .82rem; }
.sprint-name span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sprint-lane { position: relative; height: clamp(22px,5dvh,34px); background: #ffffff0d; border-bottom: 1px dashed #b3c2d160; }
.sprint-lane::after { position: absolute; content: ''; width: 7px; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(#eee 0 4px,#212735 4px 8px); }
.sprint-car {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(37px,7vw,60px);
  display: grid;
  place-items: center;
  animation: sprint var(--finish-time) cubic-bezier(.4,.02,.4,1) both;
  animation-delay: var(--elapsed);
}
.sprint-photo { width: 100%; max-height: 100%; object-fit: contain; }
@keyframes sprint { from { left: 0; } to { left: calc(100% - clamp(37px,7vw,60px)); } }
.sprint-result { margin-top: 5px; color: #ffe2c0; text-align: center; font-size: .87rem; animation: reveal 200ms calc(1120ms + var(--elapsed)) both; }
@keyframes reveal { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .motion-view * { animation-duration: 0s !important; animation-delay: 0s !important; }
}
@media (max-height: 410px) { .sprint-lane { height: 19px; } }

@media (max-height: 410px) {
  .lobby-layout { align-self: start; }
  .lobby-players .player-list { max-height: 34dvh; overflow: auto; }
}

.party-button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.party-button .icon { width: 16px; height: 16px; }
@media (max-width: 650px) {
  .party-button { padding-inline: 8px; min-height: 36px; }
  .party-button span { display: none; }
}
@media (max-width: 390px) and (orientation: portrait) {
  .hud .brand { font-size: 17px; }
  .hud { gap: 5px; }
  .hud-players { padding-inline: 5px; }
  .hud-meta strong { font-size: .68rem; }
  .balance { font-size: .78rem; }
  .balance .player-color { width: 8px; height: 8px; flex-basis: 8px; margin-inline: 1px; }
}

.street-scenery, .street-world, .street-weather { position: absolute; inset: 0; pointer-events: none; }
.street-scenery { overflow: hidden; z-index: -1; }
.street-world { width: 100%; height: 100%; display: block; }
.stage[data-scene=street]::before { z-index: -2; background: #434b5c; }
.street-weather i {
  position: absolute;
  left: var(--x);
  animation-delay: var(--delay);
  animation-duration: var(--time);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.street-weather.snow i {
  top: -8%;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #f1f6ff;
  opacity: .72;
  box-shadow: 0 0 4px #fff6;
  animation-name: snowfall;
}
@keyframes snowfall { to { transform: translate(14vw,111dvh); } }
.street-weather.rain i {
  top: -12%;
  width: 1px;
  height: calc(var(--size) * 4);
  background: linear-gradient(transparent,#bccbea8c);
  animation-name: rainfall;
  animation-duration: calc(var(--time) * .33);
}
@keyframes rainfall { from { transform: rotate(13deg); } to { transform: translate(-11vw,117dvh) rotate(13deg); } }
.street-weather.leaves i {
  top: -8%;
  width: calc(var(--size) * 2);
  height: var(--size);
  border-radius: 80% 10% 85% 15%;
  background: #d99738;
  box-shadow: 1px 0 2px #44250f80;
  animation-name: leaf-fall;
}
.street-weather.leaves i:nth-child(even) { background: #a64f1b; }
@keyframes leaf-fall {
  38% { transform: translate(4vw,33dvh) rotate(175deg); }
  70% { transform: translate(-2vw,69dvh) rotate(350deg); }
  100% { transform: translate(7vw,112dvh) rotate(520deg); }
}
.street-weather.clouds i {
  top: var(--y);
  left: -24%;
  width: 32%;
  height: 8%;
  border-radius: 50%;
  background: radial-gradient(ellipse,#f4f6fa45,transparent 70%);
  animation-name: cloud-drift;
}
@keyframes cloud-drift { to { transform: translateX(125vw); } }
@media (prefers-reduced-motion: reduce) {
  .street-weather i { animation: none; }
  .street-weather.snow i, .street-weather.rain i, .street-weather.leaves i { display: none; }
}


.dice-panel {
  align-self: center;
  width: min(100%, 310px);
  max-height: 100%;
  overflow: auto;
  padding: 16px 18px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: #141820f5;
  box-shadow: 0 12px 40px #0006;
  text-align: center;
}
.dice-panel[data-group=true] {
  width: min(100%, 600px);
}
.dice-rolls {
  --die-size: 62px;
  display: grid;
  gap: 14px;
  margin-top: 12px;
  list-style: none;
}
.dice-panel[data-group=true] .dice-rolls {
  --die-size: 42px;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
}
.dice-roll {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
  min-width: 0;
  perspective: 400px;
}
.dice-player {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: .84rem;
  color: var(--muted);
}
.dice-cube {
  width: var(--die-size);
  height: var(--die-size);
  position: relative;
  margin-block: 6px;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt)) rotateY(var(--turn));
  animation: dice-tumble 600ms cubic-bezier(.2,.6,.35,1) both;
  animation-delay: var(--elapsed);
}
.dice-face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(3,1fr) / repeat(3,1fr);
  place-items: center;
  padding: 14%;
  background: #f9f4ed;
  border: 1px solid #e6dad0;
  border-radius: 12%;
  backface-visibility: hidden;
  transform: var(--face-turn, rotateY(0deg)) translateZ(calc(var(--die-size) / 2));
}
.dice-top { --face-turn: rotateX(90deg); }
.dice-right { --face-turn: rotateY(90deg); }
.dice-left { --face-turn: rotateY(-90deg); }
.dice-bottom { --face-turn: rotateX(-90deg); }
.dice-back { --face-turn: rotateY(180deg); }
.dice-face i {
  width: 61%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #971529;
}
@keyframes dice-tumble {
  from { transform: translateY(-8px) rotateX(-35deg) rotateY(-45deg); }
  to {
    transform: translateY(0) rotateX(calc(var(--tilt) + 720deg)) rotateY(calc(var(--turn) + 720deg));
  }
}
.dice-caption {
  display: grid;
  gap: 2px;
  animation: reveal 125ms both;
  animation-delay: calc(560ms + var(--elapsed));
}
.dice-caption span {
  font-size: .78rem;
  color: var(--muted);
}
.motion-dice[data-static=true] :is(.dice-cube,.dice-caption) {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .motion-dice :is(.dice-cube,.dice-caption) { animation: none !important; }
}
@media (max-height: 430px) {
  .dice-panel { padding-block: 9px; }
  .dice-rolls { --die-size: 42px; margin-top: 7px; }
  .dice-panel[data-group=true] .dice-rolls { --die-size: 30px; }
  .dice-roll { gap: 5px; }
  .dice-cube { margin-block: 4px; }
}


.vehicle-portrait { display: block; object-fit: cover; object-position: center; }
.card .car-photo.vehicle-portrait { width: 100%; }

.invite-controls, .rejoin-controls, .rejoin-link { display: grid; gap: 8px; }
.entry-panel .invite-controls {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--edge);
}
.entry-panel input { min-width: 0; }
.entry-panel .invite-buttons { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.entry-panel .invite-buttons [data-scan-qr] { grid-column: 1 / -1; }
.entry-panel .invite-buttons button { padding-inline: 8px; font-size: .85rem; }
.entry-panel .invite-qr img { display: block; width: 100%; }
@media (min-width: 760px) and (min-height: 521px) and (orientation: landscape) {
  .entry-panel .invite-qr {
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    transform: translateY(-50%);
    width: clamp(144px,23dvh,200px);
    padding: 8px;
    border: 1px solid var(--edge);
    border-radius: 11px;
    background: #15171c;
  }
}
@media (max-width: 759px), (max-height: 520px), (orientation: portrait) {
  .entry-panel { padding: 10px; }
  .entry-panel .stack { gap: 6px; }
  .entry-panel label { gap: 3px; }
  .entry-panel .invite-controls:has(.invite-qr:not([hidden])) {
    grid-template-columns: minmax(0,1fr) clamp(92px,18dvh,120px);
    align-items: center;
  }
  .entry-panel .invite-controls > label { grid-column: 1 / -1; }
  .entry-panel .invite-controls:has(.invite-qr:not([hidden])) .invite-buttons { grid-template-columns: minmax(0,1fr); }
  .entry-panel .invite-controls:has(.invite-qr:not([hidden])) .invite-buttons button {
    line-height: 1.1;
    padding-block: 5px;
  }
  .entry-panel .invite-qr { padding: 0; }
}
@media (min-width: 540px) and (max-height: 520px) {
  .entry-layout { padding-inline: max(12px,env(safe-area-inset-left)) max(12px,env(safe-area-inset-right)); }
  .entry-content { width: min(100%,720px); margin-inline: auto; }
  .entry-content .brand-large { font-size: clamp(28px,9dvh,48px); }
  .entry-tagline { margin: 3px 0 8px; }
  .entry-panel {
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
    gap: 12px;
    align-items: start;
  }
  .entry-panel .invite-controls {
    margin: 0;
    padding: 0 0 0 12px;
    border-top: 0;
    border-left: 1px solid var(--edge);
  }
}
@media (min-width: 300px) and (max-height: 570px) {
  .entry-panel .stack { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .entry-panel .stack > :is(button, details) { grid-column: 1 / -1; }
  .entry-panel .stack input { text-overflow: ellipsis; }
  .entry-panel details[open] {
    position: relative;
    display: grid;
    align-content: center;
    min-height: 44px;
    padding-right: calc(46% + 8px);
  }
  .entry-panel details[open] input {
    position: absolute;
    top: 0;
    right: 0;
    width: 46%;
    margin: 0;
  }
}
.invite-qr { padding: 4px 0; text-align: center; }
.invite-qr img { display: inline-block; width: min(100%, 192px); aspect-ratio: 1; border-radius: 6px; }
.qr-scanner {
  color: var(--ink);
  width: min(440px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  margin: auto;
  box-shadow: 0 12px 40px #0009;
}
.qr-scanner:not([open]) { display: none; }
.qr-scanner::backdrop { background: #080a10cc; }
.qr-scanner .panel-head { align-items: center; }
.qr-scanner .panel-head button { min-width: 44px; }
.qr-scanner video {
  display: block;
  width: 100%;
  height: min(44dvh,300px);
  border-radius: 8px;
  object-fit: contain;
  background: #0b0d12;
}
.qr-scanner .scanner-file input { padding: 8px; min-width: 0; }
.qr-scanner input::file-selector-button { margin-inline-end: 8px; }
.chat-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: min(42dvh, 280px); overflow-y: auto; }
.chat-log li { display: grid; gap: 2px; padding: 8px 10px; background: #ffffff0a; border-radius: 7px; overflow-wrap: anywhere; }
.chat-log strong { font-size: .85em; }
.chat-log li span { white-space: pre-wrap; }
#chat input { flex: 1 1 auto; }
#chat button { flex: 0 0 auto; }
