.garage-card {
  grid-area: garage;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #0a111c;
  --rim: linear-gradient(138deg, #9cf8f0b0, #98d7e130 34%, #dc79b64d 78%, #ed95c085);
}
:is(#staff-content, #member-content):has(> #panel > .garage-page) {
  padding: 0;
}
#panel:has(> .garage-page) {
  height: 100%;
  padding: 0;
}
.garage-page {
  height: 100%;
}
.garage-page .garage-scene {
  background: #0a111c url("./race/garage/branded-garage.webp") 54% 38% / cover no-repeat;
}
.garage-page .garage-vehicle {
  /* The images share a physical scale and tyre line, including space for the wet floor reflection. */
  inset: auto auto 8% 53%;
  /* Leave the upper controls clear even above the truck's flag in landscape. */
  width: min(104cqw, calc(157cqh - 84px));
  height: auto;
  aspect-ratio: 1600 / 980;
  transform: translateX(-50%);
}
@container garage (max-aspect-ratio: 1/1) {
  .garage-page .garage-scene {
    background-image: url("./race/garage/empty-garage-portrait.webp");
    background-position: center;
  }
  .garage-page .garage-vehicle {
    left: 50%;
    bottom: 16%;
    width: 112cqw;
  }
}
.garage-bay {
  container: garage / size;
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  overflow: hidden;
  color: #f7fbff;
  background: #09131f;
  --mint: #8dece5;
  --garage-gutter: clamp(12px, 3.6cqw, 32px);
}
.garage-scene, .garage-wall, .garage-floor { position: absolute; inset: 0; pointer-events: none; }
.garage-scene {
  overflow: hidden;
  background:
    radial-gradient(ellipse at 13% 38%, #235258 0%, transparent 44%),
    radial-gradient(ellipse at 95% 48%, #512b48 0%, transparent 46%),
    linear-gradient(174deg, #090f1b 6%, #162938 62%, #121624);
}
.garage-wall {
  bottom: 31%;
  background:
    linear-gradient(180deg, #05081570, transparent 54%, #08121b80),
    repeating-linear-gradient(96deg, transparent 0 calc(23% - 2px), #0c152664 23%, #a3cbdd12 calc(23% + 1px));
}
.garage-wall::before, .garage-wall::after {
  content: ""; position: absolute; top: 29%; width: 27%; height: 2px;
  transform: rotate(9deg); background: #b3fff0; box-shadow: 0 0 5px #83f8df, 0 4px 18px 2px #76e6de94;
}
.garage-wall::before { left: -6%; }
.garage-wall::after {
  right: -4%; top: 25%; width: 23%; transform: rotate(-9deg);
  background: #fbb1db; box-shadow: 0 0 5px #ff85cc, 0 4px 18px 2px #ee60b575;
}
.garage-floor {
  inset: 65% -15% -35%;
  transform: perspective(200px) rotateX(43deg);
  transform-origin: center top;
  border-top: 1px solid #a2dfee38;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(14% - 1px), #b5e4f420 14%),
    repeating-linear-gradient(0deg, transparent 0 calc(25% - 1px), #b5e4f419 25%),
    linear-gradient(105deg, #152b36, #1c293a 55%, #342434);
}
.garage-turntable {
  position: absolute; left: 50%; top: 60%; width: min(91cqw, 148cqh); height: 18%;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 1px solid #b5daea7a;
  background: radial-gradient(ellipse, #354752 15%, #233340 57%, #506272 69%, #1b2a3a 72%);
  box-shadow: 0 3px 0 #172a37, 0 4px 0 #92bbcc75, 0 8px 0 #0c1722, 0 12px 14px #020912c2;
}
.garage-turntable::before {
  content: ""; position: absolute; inset: 0 -1px -3px;
  border-radius: inherit;
  border-bottom: 2px solid transparent;
  border-left: 2px solid #8bf1ea;
  border-right: 2px solid #ec8fc2;
}
.garage-turntable::after {
  content: ""; position: absolute; inset: 3% 12% 10%;
  border-radius: inherit;
  background: radial-gradient(ellipse, #050912d9 0 35%, #060b137a 60%, transparent 75%);
}
.garage-vehicle {
  position: absolute; inset: 0;
  width: 100%; height: 100%; pointer-events: none;
}
.garage-slide { position: absolute; inset: 0; }
.garage-slide img { display: block; width: 100%; height: 100%; object-fit: contain; }
.garage-slide.incoming { animation: garage-arrive .42s var(--ease) both; }
.garage-slide.outgoing { animation: garage-depart .18s ease-out both; }
.garage-slide.outgoing + .incoming { animation-delay: .12s; }
@keyframes garage-arrive {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes garage-depart {
  from { opacity: 1; }
  to { opacity: 0; }
}
.garage-unavailable { position: absolute; inset: 0; display: grid; place-items: center; }
.garage-identifier, .garage-detail {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; line-height: 1.2; letter-spacing: .13em; text-transform: uppercase;
}
.garage-identifier { position: absolute; top: 16px; left: var(--garage-gutter); pointer-events: none; }
.garage-identifier svg { width: 17px; height: 17px; color: var(--mint); stroke-width: 1.7; }
.garage-bay button, :where(.garage-showroom) .garage-controls button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  color: #f5fbff; transition: color var(--micro), background var(--micro);
}
.garage-bay .garage-expand {
  position: absolute; inset: 0 0 22%; display: flex; align-items: flex-start; justify-content: flex-end;
  width: auto; height: auto; padding: 8px var(--garage-gutter); outline: none;
}
.garage-expand span {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px;
  color: #edf5f7; background: #101b28db; border: 1px solid #99bece7a; border-radius: 6px;
  font-size: 12px; font-weight: 700; line-height: 1.35;
}
.garage-expand svg { width: 13px; height: 13px; }
.garage-bay .garage-expand:focus-visible { outline: none; }
.garage-expand:focus-visible span { outline: 2px solid var(--mint); outline-offset: 2px; }
.garage-console {
  position: absolute; inset: auto 0 0; min-height: 21%;
  display: flex; justify-content: space-between; align-items: end; gap: 8px;
  padding: 12px var(--garage-gutter) clamp(8px, 3.2cqh, 18px);
  background: linear-gradient(0deg, #080f1bf7 18%, #0a1120d6 72%, transparent);
}
.garage-caption { min-width: 0; }
.garage-caption-enter { animation: garage-caption-in .2s ease-out .12s both; }
@keyframes garage-caption-in { from { opacity: 0; } to { opacity: 1; } }
.garage-caption h2, .garage-showroom .garage-caption h3 {
  color: #f5f9fb; margin: 4px 0 0; font: 400 clamp(20px, 5.2cqw, 43px)/1.12 var(--display);
  letter-spacing: .012em; text-transform: uppercase; text-wrap: balance;
}
.garage-detail { gap: 8px; color: #c5d0dd; font-size: clamp(11px, 1.9cqw, 12px); letter-spacing: .075em; }
.garage-index { color: var(--mint); font-variant-numeric: tabular-nums; white-space: nowrap; border-left: 1px solid #bbd5dd63; padding-left: 8px; }
.garage-controls { display: inline-flex; flex: none; border: 1px solid #a5c5d456; border-radius: 10px; overflow: hidden; background: #0b1323da; }
.garage-controls .garage-auto {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 61px; gap: 5px;
  font-size: 11px; font-weight: 700;
}
.garage-auto[aria-pressed="true"] { color: var(--mint); background: #234047a1; }
.garage-timer {
  position: absolute; inset: auto 0 0; height: 2px; background: var(--mint); pointer-events: none;
  transform-origin: left; animation: garage-countdown linear both;
}
@keyframes garage-countdown { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.garage-controls button + button { border-left: 1px solid #a5c5d42b; }
.garage-controls svg { width: 18px; height: 18px; }
.garage-controls button:nth-child(2) svg { width: 14px; height: 14px; fill: currentColor; stroke-width: 1.4; }
@media (hover: hover) {
  .garage-controls button:hover, .garage-expand:hover span { color: var(--mint); background: #263d49; }
}
.garage-bay button:focus-visible, .garage-showroom .garage-controls button:focus-visible, .garage-lineup button:focus-visible { outline: 2px solid #a0f8ed; outline-offset: -3px; }

.garage-dialog {
  width: min(58rem, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; overflow: auto; overscroll-behavior: contain;
  color: #f2f6fa; background: #0c1422; border: 1px solid #93b7c267;
}
.garage-dialog .paneltitle { margin: 0; padding: 8px clamp(14px, 3vw, 28px); border-bottom: 1px solid #a5c5d430; }
.garage-dialog .paneltitle h2 { font: 400 clamp(18px, 2.7vw, 28px)/1.2 var(--display); text-transform: uppercase; }
.garage-dialog .paneltitle .link { color: #e2ecf7; min-height: 44px; padding: 0 8px; }
.garage-showroom {
  --mint: #8dece5;
  --garage-gutter: clamp(12px, 3vw, 30px);
  position: relative;
  overflow: hidden;
  background: #0a1220;
}
.garage-model-view {
  position: relative;
  isolation: isolate;
  container-type: size;
  height: clamp(190px, min(42dvh, 37vw), 340px);
  overflow: hidden;
}
.garage-model-view .garage-wall { bottom: 30%; }
.garage-model-view .garage-floor { top: 70%; }
.garage-model-view::after {
  content: ""; position: absolute; inset: auto 0 0; height: 15%; pointer-events: none;
  background: linear-gradient(transparent, #0a1220);
}
.garage-showroom-poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
}
.garage-model-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.garage-model-canvas:active { cursor: grabbing; }
.garage-model-canvas:focus-visible { outline: 2px solid #8dece5; outline-offset: -3px; }
.garage-model-view[data-state="fallback"] .garage-model-canvas { visibility: hidden; }
/* Between cars the old one drives off, the next drives in, and the bay streaks past behind them. */
.garage-streaks {
  position: absolute; inset: 14% 0 30%; pointer-events: none; opacity: 0;
  transition: opacity 420ms ease-out;
  background:
    linear-gradient(90deg, transparent 0 52%, #8dece5a0 82%, transparent) 0 8% / 240px 1px repeat-x,
    linear-gradient(90deg, transparent 0 60%, #ee91c290 85%, transparent) 70px 27% / 380px 2px repeat-x,
    linear-gradient(90deg, transparent 0 45%, #ffffff5c 80%, transparent) 140px 44% / 190px 1px repeat-x,
    linear-gradient(90deg, transparent 0 58%, #8dece580 85%, transparent) 30px 63% / 460px 2px repeat-x,
    linear-gradient(90deg, transparent 0 50%, #ee91c270 82%, transparent) 210px 81% / 280px 1px repeat-x,
    linear-gradient(90deg, transparent 0 62%, #ffffff4d 86%, transparent) 90px 97% / 520px 1px repeat-x;
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  /* Paused rather than removed, so the streaks fade out where they are. */
  animation: garage-streaks 460ms linear infinite paused;
}
.garage-model-view:is([data-phase="leaving"], [data-phase="waiting"], [data-phase="arriving"]) .garage-streaks {
  opacity: 1; transition-duration: 120ms; animation-play-state: running;
}
.garage-model-view[data-direction="back"] .garage-streaks { animation-direction: reverse; }
@keyframes garage-streaks {
  to { background-position: -240px 8%, -310px 27%, -50px 44%, -430px 63%, -70px 81%, -430px 97%; }
}
.garage-loading {
  position: absolute; left: 50%; top: 44%; z-index: 2; translate: -50% -50%;
  display: grid; justify-items: center; gap: 9px; width: min(230px, 62%);
  color: #d4dee8; font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase;
  text-shadow: 0 1px 6px #060b19; pointer-events: none;
  opacity: 0; visibility: hidden;
}
/* Shown only when a car takes longer than the slide, so quick switches never flash it. */
.garage-model-view[data-phase="waiting"] .garage-loading {
  opacity: 1; visibility: visible; transition: opacity 200ms ease-out 200ms, visibility 0s 200ms;
}
.garage-loading-track {
  position: relative; width: 100%; height: 3px; overflow: hidden;
  border-radius: 3px; background: #ffffff26; box-shadow: 0 0 0 1px #ffffff12;
}
.garage-loading-track > span {
  position: absolute; inset: 0; transform-origin: left;
  background: linear-gradient(90deg, var(--mint), #ee91c2); box-shadow: 0 0 10px #8dece580;
  transition: transform 220ms ease-out;
}
.garage-loading-track::after {
  content: ""; position: absolute; inset: 0; width: 35%;
  background: linear-gradient(90deg, transparent, #ffffff8c, transparent);
  animation: garage-shimmer 1s linear infinite;
}
@keyframes garage-shimmer { from { translate: -100% 0; } to { translate: 290% 0; } }
.garage-model-view[data-phase="waiting"] .garage-model-status { opacity: 0; }
.garage-model-status {
  position: absolute; top: 12px; right: var(--garage-gutter); z-index: 1; pointer-events: none;
  display: inline-flex; align-items: center; gap: 5px;
  color: #d4dee8; font-size: 12px; font-weight: 600; text-shadow: 0 1px 5px #060b19;
}
.garage-model-status svg { width: 16px; height: 16px; color: var(--mint); }
.garage-showroom .garage-console {
  position: relative; inset: auto; align-items: center; min-height: 64px; gap: 8px 16px;
  padding: 4px var(--garage-gutter) 14px;
  background: #0a1220;
}
.garage-showroom .garage-caption h3 { font-size: clamp(20px, 3vw, 32px); }
/* Credit for a licensed model, under its name. */
.garage-credit { margin: 2px 0 0; color: #aebdcc; font-size: 12px; line-height: 1.35; }
.garage-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.garage-credit a:hover { color: #f5f9fb; }
.garage-credit a:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 2px; }

.garage-picker { padding: 12px clamp(12px, 2.4vw, 24px) 16px; border-top: 1px solid #91afc140; }
.garage-lineup-label {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;
  color: #bfccda; font-size: 11px; font-weight: 700; line-height: 1.25; letter-spacing: .09em; text-transform: uppercase;
}
.garage-lineup-label span:last-child { color: #8dece5; font-variant-numeric: tabular-nums; }
.garage-lineup {
  position: relative; display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain;
  padding-block: 3px 7px; scrollbar-width: thin; scrollbar-color: #586c80 #111b2b;
}
.garage-lineup button {
  position: relative; display: grid; place-items: center; flex: 1 0 60px;
  min-width: 0; height: clamp(46px, 5.3vw, 62px); overflow: hidden; padding: 0; color: #e7edf2;
  border: 1px solid #354455; border-radius: 7px; background: #172333;
}
.garage-lineup img { width: 100%; height: 100%; display: block; object-fit: contain; }
.garage-lineup button:hover { border-color: #92b2c0; }
.garage-lineup button[aria-pressed="true"] { border: 2px solid #8dece5; background: #233c46; }
.garage-applied {
  position: absolute; right: 2px; top: 2px; width: 14px; height: 14px; padding: 1px;
  color: #082428; background: #8dece5; border-radius: 50%; stroke-width: 3;
}
.garage-select {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 44px; border: 1px solid #ff86be; border-radius: 8px; padding: 8px 18px;
  color: #fff; background: #a71760; font-weight: 700;
}
.garage-picker-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 12px; }
.garage-lineup button[data-locked="true"] img { opacity: .62; }
.garage-lock { position: absolute; bottom: 2px; right: 3px; width: 16px; height: 16px; padding: 2px; color: white; background: #172333; border-radius: 4px; }
.garage-ratings p { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0; font-size: .88rem; }
.garage-ratings small { display: block; margin-top: 3px; color: var(--muted); }
.garage-select:hover:enabled { background: #be206e; }
.garage-select:disabled { color: #bcddd8; background: #192d35; border-color: #46646d; opacity: 1; }
.garage-select svg { width: 17px; height: 17px; }
@container garage (max-height: 220px) {
  .garage-identifier { top: 12px; }
  .garage-bay .garage-expand { padding-block: 5px; }
  .garage-console { padding-top: 3px; padding-bottom: 6px; }
  .garage-caption h2 { font-size: clamp(18px, 4.6cqw, 24px); }
}
@container garage (max-height: 157px) {
  .garage-vehicle { inset: 0 54% 0 0; width: 46%; }
  .garage-turntable { left: 24%; width: min(47cqw, 148cqh); }
  .garage-identifier { display: none; }
  .garage-console { inset: 0 0 0 46%; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 0 4px; background: none; }
  .garage-bay .garage-expand { inset: 0 54% 0 0; justify-content: flex-start; padding: 4px 6px; }
  .garage-expand span { padding: 2px 6px; font-size: 11px; }
  .garage-detail { font-size: 10px; }
  .garage-controls .garage-auto { width: 53px; }
  .garage-caption h2 { margin: 2px 0; font-size: clamp(15px, 4.3cqw, 22px); }
}
@media (max-width: 500px) {
  .garage-dialog { width: calc(100vw - 16px); }
  .garage-showroom .garage-console { flex-wrap: wrap; padding-block: 4px 10px; }
  .garage-showroom .garage-controls { margin-inline-start: auto; }
  .garage-model-status { font-size: 11px; }
  .garage-model-status svg { width: 15px; height: 15px; }
  .garage-picker-actions { flex-direction: column; align-items: stretch; }
  .garage-lineup { mask-image: linear-gradient(to right, transparent, black 6px, black calc(100% - 6px), transparent); }
  .garage-select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .garage-slide.incoming, .garage-slide.outgoing, .garage-slide.incoming img, .garage-caption-enter, .garage-timer { animation: none; }
  .garage-slide.outgoing { opacity: 0; }
  .garage-streaks { display: none; }
  .garage-loading-track::after { animation: none; }
}

.garage-cart-link { display:inline-flex; align-items:center; gap:6px; color:var(--mint); font-weight:700; white-space:nowrap; }
.garage-shop { width:min(100%,760px); min-width:0; margin-inline:auto; }
.garage-shop h1 { margin:.6em 0 .25em; }
.garage-shop-item, .garage-price-row, .garage-shop-footer { display:flex; align-items:center; gap:12px; padding:10px 0; border-top:1px solid var(--line); }
.garage-shop-item b, .garage-shop-footer button { margin-left:auto; white-space:nowrap; }
.garage-shop-item img { object-fit:contain; }
.garage-shop-item small, .garage-price-row small { display:block; color:var(--muted); }
.garage-price-row label { display:grid; flex:1; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:2px 8px; }
.garage-price-row label span { grid-area:1 / 2 / span 2; }
.garage-price-row input { width:6em; }
.garage-shop-total { font-weight:700; text-align:right; }
@media (max-width:450px) {
  .garage-shop-item { gap:7px; }
  .garage-shop-item img { width:52px; }
}
