.written-page .ride-open {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 17px;
  margin: 20px 0;
  padding: 5px 17px;
  border: 1px solid #efcdbb;
  border-radius: 2px;
  background: #f2d8c8;
  color: #482932;
  cursor: pointer;
  font: 700 0.875rem/1.4 var(--sans);
}

.written-page .ride-open:focus-visible,
.ride-dialog :is(button, a):focus-visible {
  outline: 2px solid #f4ceba;
  outline-offset: 4px;
}

.ride-dialog {
  --cabin-width: min(100vw, 295dvh);
  --cabin-height: calc(var(--cabin-width) / 1.5);
  --cabin-glow: 247 169 125;
  --cabin-secondary: 255 218 174;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #100d10;
  color: #fff2e6;
  overscroll-behavior: contain;
}

body:has(.ride-dialog[open]) { overflow: hidden; }
.ride-dialog::backdrop { background: #100d10; }
.ride-dialog[data-track="the-hills"] {
  --cabin-glow: 181 117 255;
  --cabin-secondary: 101 153 255;
}
.ride-dialog[data-track="blinding-lights"] {
  --cabin-glow: 255 75 101;
  --cabin-secondary: 255 167 92;
}

.ride-layout {
  position: relative;
  isolation: isolate;
  height: 100%;
  overflow: hidden;
}
.ride-layout::before,
.ride-layout::after {
  position: absolute;
  pointer-events: none;
  content: "";
}
.ride-layout::before {
  z-index: -1;
  inset: -32px;
  background:
    radial-gradient(ellipse at 50% 58%, rgb(var(--cabin-glow) / 0.22), transparent 68%),
    url("cabin.png") center / cover no-repeat;
  filter: blur(34px) brightness(0.48);
}
.ride-layout::after {
  z-index: 1;
  inset: 0;
  background: linear-gradient(180deg, #100c10cc, #100c1029 18%, transparent 36% 70%, #100c10bf);
}

.ride-header, .ride-footer {
  position: absolute;
  z-index: 2;
  inset-inline: 0;
  padding-inline: clamp(16px, 3.4vw, 76px);
}
.ride-header {
  top: max(env(safe-area-inset-top), clamp(12px, 3.5dvh, 46px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.ride-header h2 {
  color: #fff2e6;
  font: 400 clamp(1.55rem, 3.4vw, 3.55rem)/1.06 var(--serif);
  letter-spacing: -0.035em;
  text-shadow: 0 2px 12px #100c10;
}

.ride-back {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 5px clamp(8px, 1vw, 16px);
  border: 1px solid #f4ceba45;
  border-radius: 3px;
  background: #171117b8;
  color: #f4ceba;
  font: 700 0.82rem/1.3 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.ride-back .arrow { transform: rotate(180deg) scale(0.78); }

.ride-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  isolation: isolate;
  width: var(--cabin-width);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%);
  container-type: inline-size;
  overflow: hidden;
  background: #171114;
}

.ride-cabin, .ride-glass, .ride-screen { position: absolute; }
.ride-cabin { inset: 0; height: 100%; object-fit: cover; }

.ride-glass {
  top: calc(var(--glass-top) * 1%);
  left: calc(var(--glass-left) * 1%);
  isolation: isolate;
  overflow: hidden;
  background: #2f3c50;
  pointer-events: none;
}
.ride-flurry {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Every pane clips the same panorama from the stage origin. */
.ride-glass img {
  position: absolute;
  top: calc(-0.666667cqw * var(--glass-top));
  left: calc((-5 - var(--glass-left)) * 1cqw);
  width: 110cqw;
  height: 31cqw;
  object-fit: cover;
  object-position: center 78%;
  transform-origin: 49.6% 60.5%;
  filter: brightness(0.9) saturate(0.9);
}
.ride-glass::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(157deg, #263b5a25, transparent 54%, #17132128);
  box-shadow: inset 0 0 1.35cqw #16131b70;
  content: "";
}

.ride-glass--front {
  --glass-top: 16.6;
  --glass-left: 22.27;
  width: 55.99%;
  height: 20.51%;
  /* The second contour shows the street through the upper steering-wheel opening. */
  clip-path: polygon(evenodd,
    0% 10.95%, 1.05% 7.62%, 3.84% 4.76%, 9.65% 3.33%, 27.67% 1.43%,
    38.14% 1.9%, 58.14% 0.48%, 91.05% 3.33%, 95.47% 5.71%, 98.6% 10.95%,
    89.65% 12.86%, 87.56% 15.71%, 85.7% 21.9%, 84.19% 32.38%, 83.37% 39.52%,
    82.67% 50.95%, 82.09% 66.19%, 81.98% 86.19%, 82.44% 99.05%,
    33.83% 98.52%, 32.90% 97.85%, 32.32% 97.33%, 31.74% 96.85%, 30.57% 96.33%,
    29.99% 94.62%, 29.41% 92.71%, 28.83% 90.95%, 28.25% 89.38%, 27.67% 87.95%,
    27.09% 86.95%, 26.50% 85.67%, 25.92% 84.71%, 25.34% 83.95%, 24.76% 83.38%,
    24.18% 82.76%, 23.02% 82.14%, 21.85% 81.86%, 20.69% 82.09%, 19.53% 82.71%,
    18.36% 83.71%, 17.78% 84.38%, 17.43% 84.90%, 17.33% 76.19%, 17.09% 62.86%,
    16.63% 51.43%, 15.81% 40%, 15% 31.9%, 13.49% 22.38%, 11.86% 16.67%,
    9.65% 12.86%, 7.33% 11.9%, 0.58% 11.43%, 0% 10.95%, 17.56% 95.24%,
    18.02% 91.9%, 18.72% 89.52%, 20% 87.62%, 21.4% 87.38%, 22.79% 87.62%,
    24.19% 89.05%, 25.35% 90.95%, 26.4% 92.86%, 27.33% 94.29%, 28.14% 97.14%,
    27.21% 96.67%, 25.81% 95.24%, 24.19% 95%, 22.21% 95.24%, 20.23% 95.48%,
    18.72% 96.19%, 17.79% 96.67%, 17.56% 95.24%);
}

.ride-glass--left {
  --glass-top: 4.39;
  --glass-left: 0;
  width: 17.32%;
  height: 36.23%;
  clip-path: polygon(evenodd,
    0% 1.08%, 17.29% 7.28%, 30.08% 12.67%, 37.97% 21.83%, 40.98% 28.3%,
    40.6% 36.39%, 36.84% 43.94%, 33.83% 51.75%, 28.95% 60.38%, 24.44% 69.27%,
    19.92% 80.59%, 15.41% 90.3%, 11.28% 98.11%, 0% 99.46%, 0% 1.08%,
    84.59% 34.23%, 87.97% 36.93%, 92.86% 42.05%, 97.74% 47.44%, 93.61% 53.64%,
    89.85% 58.76%, 87.97% 66.04%, 86.47% 79.51%, 86.84% 89.22%, 89.85% 96.5%,
    58.65% 98.11%, 60.15% 90.57%, 62.03% 82.21%, 64.29% 73.58%, 68.42% 63.34%,
    72.18% 53.91%, 76.69% 45.55%, 80.45% 37.74%, 84.59% 34.23%);
}

.ride-glass--right {
  --glass-top: 4.39;
  --glass-left: 82.55;
  width: 17.45%;
  height: 36.23%;
  clip-path: polygon(evenodd,
    100% 1.08%, 84.33% 7.28%, 72.76% 13.21%, 62.31% 20.49%, 57.84% 27.49%,
    58.96% 35.58%, 62.31% 43.67%, 65.67% 51.21%, 69.78% 59.57%, 74.25% 70.08%,
    81.34% 82.48%, 85.82% 92.72%, 89.93% 98.38%, 100% 99.46%, 100% 1.08%,
    15.3% 34.23%, 20.9% 39.89%, 25.75% 47.17%, 29.48% 57.14%, 33.58% 67.39%,
    38.06% 78.17%, 40.67% 88.95%, 43.28% 98.11%, 9.33% 96.77%, 13.81% 90.3%,
    15.3% 80.59%, 13.06% 70.35%, 10.82% 60.38%, 7.46% 53.91%, 2.61% 47.71%,
    4.1% 42.86%, 8.21% 38.81%, 15.3% 34.23%);
}

:is(.ride-lighting, .ride-light-fill, .ride-light-accent) {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  pointer-events: none;
}
.ride-lighting {
  background:
    radial-gradient(ellipse 25% 14% at 0% 51%, rgb(var(--cabin-glow) / 0.59), transparent),
    radial-gradient(ellipse 25% 14% at 100% 51%, rgb(var(--cabin-glow) / 0.59), transparent),
    radial-gradient(ellipse 19% 12% at 50% 49%, rgb(var(--cabin-glow) / 0.49), transparent);
  opacity: 0.46;
  transition: opacity 110ms var(--ease-out);
}
.ride-light-fill {
  background:
    radial-gradient(ellipse 19% 23% at 4% 79%, rgb(var(--cabin-secondary) / 0.46), transparent),
    radial-gradient(ellipse 19% 23% at 96% 79%, rgb(var(--cabin-secondary) / 0.46), transparent),
    radial-gradient(ellipse 10% 22% at 41% 67%, rgb(var(--cabin-secondary) / 0.45), transparent),
    radial-gradient(ellipse 10% 22% at 59% 67%, rgb(var(--cabin-secondary) / 0.45), transparent),
    radial-gradient(ellipse 35% 14% at 50% 100%, rgb(var(--cabin-secondary) / 0.28), transparent);
  opacity: 0.37;
  transition: opacity 240ms var(--ease-out);
}
.ride-light-accent {
  background:
    radial-gradient(ellipse 12% 20% at 50% 75%, rgb(var(--cabin-secondary) / 0.39), transparent),
    radial-gradient(ellipse 19% 15% at 24% 64%, rgb(var(--cabin-glow) / 0.22), transparent),
    radial-gradient(ellipse 19% 15% at 77% 64%, rgb(var(--cabin-glow) / 0.22), transparent),
    radial-gradient(ellipse 25% 8% at 50% 13%, rgb(var(--cabin-secondary) / 0.2), transparent);
  opacity: 0.39;
  transition: opacity 175ms var(--ease-out);
}
.ride-strip {
  position: absolute;
  overflow: hidden;
  height: max(1px, 0.2cqw);
  border-radius: 50px;
  background: linear-gradient(90deg, rgb(var(--cabin-secondary)), rgb(var(--cabin-glow)) 82%);
  box-shadow: 0 0 0.75cqw 0.13cqw rgb(var(--cabin-glow) / 0.78);
}
.ride-strip::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 18%, #fff1dc 53%, transparent 86%);
  opacity: 0;
  content: "";
}
.door-left { left: 0; top: 48.17%; width: 7.76%; transform: rotate(-10.5deg); }
.door-right { right: 0; top: 48.17%; width: 7.5%; transform: rotate(10.5deg); }
.dash-left { left: 41.2%; top: 48.13%; width: 3.45%; }
.dash-right { left: 55.1%; top: 48.13%; width: 6.5%; }
.armrest-left { left: -1.7%; top: 70.2%; width: 10.15%; transform: rotate(-48deg); }
.armrest-right { right: -1.7%; top: 70.2%; width: 10.15%; transform: rotate(48deg); }
.ride-light-accent .ride-strip {
  height: max(1px, 0.14cqw);
  transform-origin: left center;
  box-shadow: 0 0 0.63cqw 0.09cqw rgb(var(--cabin-secondary) / 0.74);
}
.console-left { left: 42.38%; top: 70.7%; width: 8.1%; transform: rotate(97deg); }
.console-right { left: 57.56%; top: 70.7%; width: 8.1%; transform: rotate(83deg); }
.console-bridge { left: 43.1%; top: 76.46%; width: 13.8%; opacity: 0.7; }

.ride-screen {
  --screen-color: 189 143 255;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.85cqw, 17px);
  top: 45.35%;
  width: 19.95%;
  height: 17.6%;
  padding: 0.75cqw;
  border: 1px solid rgb(var(--screen-color) / 0.25);
  border-radius: 0.75cqw;
  background:
    radial-gradient(ellipse at 20% 85%, rgb(var(--screen-color) / 0.16), transparent 79%),
    #100e15;
  color: #fff5ea;
  cursor: pointer;
  text-align: left;
}
.ride-screen-left { left: 13.15%; }
.ride-screen-right { left: 67.45%; --screen-color: 255 125 143; }
.ride-screen[aria-pressed="true"] {
  background:
    radial-gradient(ellipse at 21% 71%, rgb(var(--screen-color) / 0.31), transparent 85%),
    #16111c;
  border-color: rgb(var(--screen-color) / 0.8);
  box-shadow: 0 0 0.95cqw rgb(var(--screen-color) / 0.42);
}
.ride-play-icon {
  display: grid;
  flex: 0 0 auto;
  width: clamp(11px, 3cqw, 65px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgb(var(--screen-color) / 0.65);
  border-radius: 50%;
  color: rgb(var(--screen-color));
}
.ride-play-icon::before {
  width: 0;
  height: 0;
  margin-left: 1px;
  border-block: clamp(2px, 0.45cqw, 10px) solid transparent;
  border-left: clamp(3px, 0.69cqw, 15px) solid;
  content: "";
}
.ride-screen[aria-pressed="true"] .ride-play-icon::before {
  width: clamp(4px, 0.84cqw, 18px);
  height: clamp(5px, 0.95cqw, 20px);
  margin-left: 0;
  border: none;
  border-inline: clamp(1px, 0.23cqw, 4px) solid;
}
.ride-screen-text { min-width: 0; }
.ride-artist {
  display: block;
  margin-bottom: 0.36cqw;
  font: 700 clamp(6px, 0.94cqw, 17px)/1.1 var(--sans);
  letter-spacing: 0.07em;
  color: rgb(var(--screen-color));
}
.ride-track-name {
  display: block;
  font: 700 clamp(9px, 2cqw, 42px)/1.04 var(--sans);
  letter-spacing: -0.025em;
}

.ride-footer {
  bottom: max(env(safe-area-inset-bottom), clamp(12px, 3dvh, 36px));
  text-align: center;
  font: 400 0.9rem/1.45 var(--sans);
  text-shadow: 0 1px 9px #100c10;
}
.ride-instruction, .ride-status { color: #f8ddd0; }
.ride-touch-hint { display: none; }

@media (hover: hover) and (pointer: fine) {
  .ride-screen:hover { border-color: rgb(var(--screen-color) / 0.85); }
  .ride-back:hover { border-color: #f4ceba99; color: #fff2e6; }
  .written-page .ride-open:hover { background: #fff0e7; }
}

@media (hover: none), (pointer: coarse) {
  .ride-hover-hint { display: none; }
  .ride-touch-hint { display: inline; }
  .ride-screen::after { position: absolute; inset: -4px; content: ""; }
}

@media (min-aspect-ratio: 3/2) {
  .ride-stage {
    top: clamp(calc(100% - var(--cabin-height)), calc(50% - var(--cabin-height) * 0.423), 0px);
    transform: translateX(-50%);
  }
}

@media (min-aspect-ratio: 3/2) and (max-aspect-ratio: 59/20) {
  .ride-layout::before { display: none; }
}

@media (max-aspect-ratio: 3/2) {
  .ride-dialog { --cabin-width: min(124vw, 150dvh); }
  .ride-stage { mask-image: linear-gradient(180deg, transparent, #000 9% 89%, transparent); }
}

@media (min-aspect-ratio: 59/20) {
  .ride-stage { mask-image: linear-gradient(90deg, transparent, #000 5% 95%, transparent); }
}

@media (prefers-reduced-motion: no-preference) {
  .ride-dialog[open] { animation: enter-ride 330ms var(--ease-out) both; }
  .ride-dialog[open] .ride-glass img { animation: street-advance 35s linear both; }
  .ride-dialog[open] .ride-strip::after { animation: light-welcome 1.25s var(--ease-out) both; }
  .ride-dialog[open] .ride-light-accent .ride-strip::after { animation-delay: 190ms; }
  @keyframes enter-ride {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @keyframes street-advance {
    from { transform: scale(1); }
    to { transform: scale(1.16); }
  }
  @keyframes light-welcome {
    0% { opacity: 0; transform: translateX(-100%); }
    26% { opacity: 0.88; }
    100% { opacity: 0; transform: translateX(100%); }
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(.ride-lighting, .ride-light-fill, .ride-light-accent) { transition: none; }
  .ride-flurry { display: none; }
}
