  :root {
    --fg: #ffecff;
    --glow: rgba(255, 140, 255, .45);
    --car-size: clamp(130px, 13vw, 250px);
    --car-cycle-duration: 14s;
    --car-sway-distance: clamp(24px, 5.5vw, 80px);
    --road-horizon-bottom: 17svh;
    --road-depth: 14svh;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; }

  html.js.preload #title-wrap,
  html.js.preload #play-audio,
  html.js.preload footer,
  html.js.preload #car-layer {
    visibility: hidden;
  }

  body {
    margin: 0;
    min-height: 100svh;
    background: #0b0215 url("bg.jpg") center / cover no-repeat fixed;
    overflow: hidden;
    font-family: "Press Start 2P", monospace;
  }

  @supports (-webkit-touch-callout:none) {
    body { background-attachment: scroll; }
  }

  #title-wrap {
    position: fixed;
    bottom: 18svh;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 4;
    width: 100%;
    padding: 0 4vw;
  }

  h1 {
    margin: 0;
    white-space: nowrap;
    font-family: "Press Start 2P", system-ui, monospace;
    font-size: clamp(10px, 4.4vw, 36px);
    letter-spacing: .06em;
    color: var(--fg);
    text-shadow:
      0 0 6px var(--glow),
      0 0 24px var(--glow),
      0 0 48px rgba(255, 80, 255, .25);
    pointer-events: none;
    user-select: none;
  }

  .cursor {
    display: inline-block;
    width: .6ch;
    margin-left: .05ch;
    border-left: .6ch solid var(--fg);
    filter: drop-shadow(0 0 8px var(--glow));
    animation: blink 1s steps(1) infinite;
  }

  @keyframes blink {
    50% { opacity: 0; }
  }

  .dracones {
    transition: color .05s, text-shadow .05s, filter .05s;
  }

  .dracones.flash {
    color: #fff;
    text-shadow:
      0 0 6px #fff,
      0 0 22px #fff,
      0 0 42px rgba(255, 200, 255, .8),
      0 0 64px rgba(255, 140, 255, .6);
    animation: strobe 0.12s steps(1) 0s 3;
    filter: brightness(1.2);
  }

  @keyframes strobe {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
  }

  #car-layer {
    position: fixed;
    left: 50%;
    bottom: var(--road-horizon-bottom);
    width: var(--car-size);
    transform: translate3d(-50%, calc(var(--road-depth) * 1.04), 0) scale(1.04);
    transform-origin: center bottom;
    pointer-events: none;
    z-index: 1;
    will-change: transform;
  }

  body.drive-started #car-layer {
    animation: drive-to-sunset var(--car-cycle-duration) linear both;
  }

  #car-layer .car-sway {
    width: 100%;
    will-change: transform;
  }

  body.drive-started #car-layer .car-sway {
    animation: car-sway var(--car-cycle-duration) linear both;
  }

  body.random-sway #car-layer .car-sway,
  body.straight-drive #car-layer .car-sway {
    animation: none;
  }

  #car-layer img {
    display: block;
    width: 100%;
    height: auto;
    /* Smooth sampling avoids visible pixel jumps as the car becomes small. */
    image-rendering: auto;
    opacity: 0;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45));
    will-change: opacity;
    user-select: none;
    -webkit-user-drag: none;
  }

  body.drive-started #car-layer img {
    animation: car-visibility var(--car-cycle-duration) linear both;
  }

  #drive-fog {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: .12;
    background:
      radial-gradient(ellipse at 50% 88%, rgba(255, 222, 236, 0) 0 14%, rgba(255, 222, 236, .04) 28%, rgba(255, 222, 236, .10) 46%, rgba(255, 222, 236, .16) 62%, rgba(255, 222, 236, .22) 78%, rgba(255, 222, 236, .28) 100%),
      linear-gradient(to top, rgba(255, 206, 229, .14) 0%, rgba(255, 196, 223, .06) 20%, rgba(255, 184, 218, .02) 36%, rgba(255, 184, 218, 0) 52%);
    mix-blend-mode: screen;
  }

  #noise {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    mix-blend-mode: screen;
    image-rendering: pixelated;
    transition: opacity .06s linear;
  }

  footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 4px;
    text-align: center;
    font: 10px/1.4 monospace;
    color: #bbb;
    z-index: 5;
    padding: 0 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  }

  footer a {
    color: #aaa;
    text-decoration: none;
  }

  footer a:hover {
    text-decoration: underline;
  }

  #play-audio {
    position: fixed;
    bottom: 8svh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    display: none;
    opacity: 0;
    cursor: pointer;
    user-select: none;
    font-family: "Press Start 2P", monospace;
    font-size: 14px;
    letter-spacing: .08em;
    line-height: 1;
    padding: 14px 22px;
    color: #fff;
    background: #1a0f1f;
    image-rendering: pixelated;
    text-transform: uppercase;
    text-shadow:
      0 0 6px rgba(255, 120, 255, .8),
      0 0 18px rgba(255, 120, 255, .4);
    box-shadow:
      0 0 0 3px #ffffff,
      0 0 0 3px #8a3da1,
      0 3px 0 3px #3b123f,
      0 5px 0 0 rgba(0, 0, 0, .6);
    border: none;
    -webkit-tap-highlight-color: transparent;
  }

  #play-audio::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, .14) 0 2px,
      rgba(0, 0, 0, 0) 2px 4px
    );
    opacity: .28;
    pointer-events: none;
  }

  #play-audio::before {
    content: "";
    position: absolute;
    inset: -14px;
    background: radial-gradient(ellipse at center, rgba(255, 120, 255, .35), transparent 60%);
    animation: pulse 2.6s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
  }

  @keyframes pulse {
    0%, 100% { opacity: .35; }
    50% { opacity: .7; }
  }

  #play-audio:hover {
    background: #311038;
    box-shadow:
      0 0 0 3px #fff,
      0 0 0 6px #b067c8,
      0 3px 0 6px #4a174f,
      0 3px 3px 3px rgba(0, 0, 0, .65);
  }

  #play-audio:active {
    transform: translate(-50%, 6px);
    box-shadow:
      0 0 0 3px #fff,
      0 0 0 6px #8a3da1,
      0 2px 0 6px #3b123f,
      0 4px 6px 6px rgba(0, 0, 0, .55);
  }

  #play-audio.show {
    display: inline-block;
    animation: crt-in 900ms steps(10) forwards;
  }

  #play-audio[hidden] {
    display: none;
  }

  #play-audio:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 8px;
  }

  @keyframes crt-in {
    0% { opacity: 0; filter: contrast(250%) brightness(60%); }
    15% { opacity: .4; }
    25% { opacity: .1; }
    40% { opacity: .7; }
    55% { opacity: .2; }
    70% { opacity: .9; }
    100% { opacity: 1; filter: none; }
  }

  /* One easing curve keeps the car's size and road position in sync. */
  @keyframes drive-to-sunset {
    0% {
      transform: translate3d(-50%, calc(var(--road-depth) * 1.04), 0) scale(1.04);
      animation-timing-function: cubic-bezier(.38, .70, .68, .92);
    }
    84% {
      transform: translate3d(-50%, calc(var(--road-depth) * .025), 0) scale(.025);
    }
    84.01%, 100% {
      transform: translate3d(-50%, calc(var(--road-depth) * 1.04), 0) scale(1.04);
    }
  }

  @keyframes car-visibility {
    0% { opacity: 0; }
    4%, 69% { opacity: 1; }
    79% { opacity: .65; }
    84%, 100% { opacity: 0; }
  }

  /* Quarter-wave curves match speed at each line crossing and pause at turns. */
  @keyframes car-sway {
    0% {
      transform: translate3d(0, 0, 0);
      animation-timing-function: cubic-bezier(.333, .524, .667, 1);
    }
    10.5% {
      transform: translate3d(var(--car-sway-distance), 0, 0);
      animation-timing-function: cubic-bezier(.333, 0, .667, .476);
    }
    21% {
      transform: translate3d(0, 0, 0);
      animation-timing-function: cubic-bezier(.333, .524, .667, 1);
    }
    31.5% {
      transform: translate3d(calc(var(--car-sway-distance) * -1), 0, 0);
      animation-timing-function: cubic-bezier(.333, 0, .667, .476);
    }
    42% {
      transform: translate3d(0, 0, 0);
      animation-timing-function: cubic-bezier(.333, .524, .667, 1);
    }
    52.5% {
      transform: translate3d(var(--car-sway-distance), 0, 0);
      animation-timing-function: cubic-bezier(.333, 0, .667, .476);
    }
    63% {
      transform: translate3d(0, 0, 0);
      animation-timing-function: cubic-bezier(.333, .524, .667, 1);
    }
    73.5% {
      transform: translate3d(calc(var(--car-sway-distance) * -1), 0, 0);
      animation-timing-function: cubic-bezier(.333, 0, .667, .476);
    }
    84%, 100% {
      transform: translate3d(0, 0, 0);
    }
  }

  @media (max-width: 600px) {
    :root {
      --car-size: clamp(102px, 31vw, 155px);
      --car-sway-distance: clamp(18px, 5.5vw, 30px);
      --road-horizon-bottom: 18svh;
      --road-depth: 15svh;
    }

    footer { font-size: 9px; }
  }

  @media (max-height: 500px) {
    :root { --car-size: clamp(80px, 16svh, 130px); }
    #title-wrap { bottom: 24svh; }
  }

  @media (prefers-reduced-motion: reduce) {
    #car-layer, body.drive-started #car-layer {
      animation: none;
      transform: translate3d(-50%, calc(var(--road-depth) * .82), 0) scale(.82);
    }

    #car-layer img, body.drive-started #car-layer img {
      animation: none;
      opacity: 1;
    }
    #car-layer .car-sway, body.drive-started #car-layer .car-sway {
      animation: none;
    }

    #noise { display: none; }
    .cursor, .dracones.flash, #play-audio::before, #play-audio.show {
      animation: none;
    }

    #play-audio.show { opacity: 1; }
  }
