:root {
  --sky: #0b1c3d;
  --clapboard: #efe8d6;
  --asphalt: #2c2c32;
  --gold: #efc14a;
  --lobster: #e31c33;
  --magenta: #ff3db4;
  --cap: #ffd000;
  --wood: #4a311c;
  --ink: #140c08;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #1a120c;
  color: var(--clapboard);
  font-family: Silkscreen, ui-monospace, monospace;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 12px;
  background:
    repeating-linear-gradient(
      90deg,
      #c9b89a 0 2px,
      #d8c9ab 2px 6px,
      #bba888 6px 7px
    );
}

.cabinet {
  width: min(960px, 100%);
  background: var(--wood);
  border: 6px solid #2a1a0e;
  box-shadow:
    0 0 0 4px #6b4a2a,
    0 18px 0 #140c08;
  padding: 0 0 8px;
}

.marquee {
  background: var(--sky);
  color: var(--gold);
  text-align: center;
  padding: 10px 12px 8px;
  border-bottom: 4px solid var(--lobster);
}

.marquee-town,
.marquee-tag {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--clapboard);
}

.marquee h1 {
  font-family: Bungee, Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(22px, 6vw, 42px);
  margin: 2px 0 4px;
  letter-spacing: 0.04em;
  color: #fff6d8;
  text-shadow: 3px 3px 0 var(--lobster);
}

.flag-bar {
  height: 10px;
  background: linear-gradient(
    90deg,
    #e40303 0 14.2%,
    #ff8c00 14.2% 28.4%,
    #ffed00 28.4% 42.6%,
    #008026 42.6% 56.8%,
    #24408e 56.8% 71%,
    #732982 71% 85.2%,
    #e31c33 85.2% 100%
  );
}

.crt {
  position: relative;
  margin: 8px 8px 0;
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 4px solid #0a0704;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgb(0 0 0 / 0) 0 3px,
    rgb(8 20 40 / 0.16) 3px 4px
  );
}

.hud-block[hidden],
.overlay[hidden],
.five-prompt[hidden] {
  display: none !important;
}

.hud {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

.hud-block {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: #fff6d8;
}

.hud-label {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.hud-combo {
  color: var(--magenta);
}

.hud-fives {
  color: var(--magenta);
}

.hud-zone {
  font-size: 7px;
  letter-spacing: 0.06em;
  color: rgb(255 246 216 / 0.45);
  margin-top: 1px;
}

.hud-lives {
  color: var(--cap);
}

.speed-track {
  width: 56px;
  height: 8px;
  background: #111;
  border: 1px solid #fff6d8;
  margin-top: 2px;
}

#speed-fill {
  height: 100%;
  width: 40%;
  background: var(--gold);
}

.five-prompt {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  font-family: Bungee, sans-serif;
  font-size: clamp(14px, 3.5vw, 22px);
  color: var(--magenta);
  text-shadow: 2px 2px 0 #000;
  animation: blink 0.28s steps(2) infinite;
  pointer-events: none;
}

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

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgb(11 28 61 / 0.72);
  display: grid;
  place-items: center;
  padding: 12px;
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  width: fit-content;
  max-width: min(440px, 94%);
  background: var(--clapboard);
  color: var(--ink);
  border: 4px solid var(--lobster);
  padding: 14px 20px 12px;
  text-align: center;
}

.overlay-kicker {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--lobster);
}

.overlay-card h2 {
  font-family: Bungee, sans-serif;
  font-weight: 400;
  font-size: clamp(13px, 2.6vw, 20px);
  line-height: 1.25;
  margin: 4px 0 8px;
  color: var(--sky);
}

.overlay-card h2 .title-line {
  display: block;
  white-space: nowrap;
}

.overlay-body {
  margin: 0 0 10px;
  font-size: 11px;
  line-height: 1.45;
}

.overlay-keys {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 10px;
}

.overlay-keys li {
  margin: 3px 0;
}

kbd {
  display: inline-block;
  background: var(--sky);
  color: var(--gold);
  padding: 1px 5px;
  margin: 0 2px;
  font-family: Silkscreen, monospace;
  font-size: 10px;
}

.overlay-go,
.arcade-btn {
  font-family: Bungee, sans-serif;
  cursor: pointer;
  border: 3px solid #140c08;
  image-rendering: pixelated;
}

.overlay-go {
  background: var(--lobster);
  color: #fff6d8;
  font-size: 16px;
  padding: 8px 22px;
}

.overlay-go:focus-visible {
  outline: 3px solid var(--magenta);
  outline-offset: 2px;
}

.overlay-best {
  margin: 8px 0 0;
  font-size: 10px;
}

.overlay-touch-hint {
  display: none;
  margin: 0 0 10px;
  font-size: 10px;
  line-height: 1.45;
}

.mobile-controls {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.mobile-btn {
  pointer-events: auto;
  font-family: Bungee, sans-serif;
  border: 3px solid #140c08;
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  image-rendering: pixelated;
  box-shadow: 0 4px 0 #140c08;
}

.mobile-btn.is-down {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #140c08;
}

.mobile-btn-steer {
  justify-self: stretch;
  min-height: 64px;
  background: var(--sky);
  color: var(--gold);
  font-size: 28px;
  line-height: 1;
}

.mobile-btn-steer[data-hold="left"] {
  justify-self: start;
  max-width: 140px;
}

.mobile-btn-steer[data-hold="right"] {
  justify-self: end;
  max-width: 140px;
}

.mobile-btn-five {
  width: 84px;
  height: 84px;
  background: var(--magenta);
  color: #fff6d8;
  font-size: 15px;
  letter-spacing: 0.04em;
  line-height: 1.1;
  padding: 8px 6px;
}

@media (hover: none) and (pointer: coarse) {
  body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-controls {
    display: grid;
  }

  .overlay-keys-desktop {
    display: none;
  }

  .overlay-touch-hint {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .five-prompt {
    animation: none;
  }
}
