:root {
  color-scheme: dark;
  --bg: #152521;
  --panel: #20352f;
  --ink: #f2efde;
  --muted: #bdc7bc;
  --lime: #dbe993;
  --line: #40544a;
  font:
    13px / 1.5 system-ui,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: var(--ink);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--lime);
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 3px;
  padding: 8px 10px;
}
button:hover {
  border-color: var(--lime);
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
[hidden] {
  display: none !important;
}
main {
  --game-size: min(600px, 100svh - 80px, 100vw - 368px);
  display: grid;
  grid-template-columns: var(--game-size) 292px;
  align-items: center;
  align-content: center;
  gap: 28px;
  width: fit-content;
  min-height: 100svh;
  margin: auto;
  padding: 16px 24px;
}
.play,
aside {
  min-width: 0;
}
.stage {
  position: relative;
  aspect-ratio: 1;
  background: #0b1512;
  overflow: hidden;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  object-fit: contain;
  outline: none;
  touch-action: none;
}
canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--lime);
}
#start-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent, #0b1512e8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#start-overlay > button,
.download {
  background: var(--lime);
  color: var(--bg);
  border: 0;
  border-radius: 3px;
  font-weight: 600;
  padding: 10px 14px;
}
#load-status {
  max-width: 85%;
  text-align: center;
}
h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
}
#input-label {
  text-transform: capitalize;
}
p {
  margin: 0;
}
.controls,
.device-controls,
ol {
  color: var(--muted);
}
.save-status {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}
.install {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 20px;
}
.download {
  display: inline-block;
  text-decoration: none;
}
.download:hover {
  color: var(--bg);
  background: #e8f2b9;
}
ol {
  margin: 12px 0;
  padding-left: 19px;
}
li {
  padding-left: 2px;
}
strong {
  font-weight: 600;
  color: var(--ink);
}
.device-controls {
  font-size: 12px;
}
#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#touch button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  min-width: 46px;
  min-height: 46px;
  font-size: 11px;
  background: #152521d9;
  border-color: #e2ead285;
  color: var(--ink);
}
#touch button.pressed {
  background: var(--lime);
  color: var(--bg);
}
.steering {
  position: absolute;
  bottom: 24px;
  left: 8px;
  display: flex;
  gap: 6px;
}
.pedals {
  position: absolute;
  bottom: 24px;
  right: 8px;
  display: flex;
  gap: 6px;
}
.touch-pause {
  position: absolute;
  top: 38px;
  right: 8px;
}
.stage:fullscreen {
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  margin: auto;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
}
.stage:fullscreen::backdrop {
  background: #0b1512;
}

@media (max-width: 700px) and (orientation: portrait), (max-width: 640px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 454px);
    gap: 8px;
    padding: 8px;
  }
  .play {
    width: min(100%, max(280px, 100svh - 390px));
    justify-self: center;
  }
  h2 {
    margin-bottom: 4px;
  }
  .save-status {
    margin-top: 4px;
  }
  .install {
    margin-top: 8px;
    padding-top: 8px;
  }
  ol {
    margin: 8px 0;
  }
}
@media (min-width: 641px) and (max-height: 500px) and (orientation: landscape) {
  main {
    --game-size: min(100svh - 68px, 100vw - 336px);
    grid-template-columns: var(--game-size) minmax(0, min(368px, 100vw - var(--game-size) - 44px));
    gap: 16px;
    padding: 8px 14px;
  }
  .install {
    margin-top: 10px;
    padding-top: 10px;
  }
  h2 {
    margin-bottom: 4px;
  }
  ol {
    margin: 8px 0;
  }
}
@media (max-width: 480px), (max-height: 500px) {
  .pedals {
    gap: 4px;
    right: 5px;
  }
  .steering {
    gap: 4px;
    left: 5px;
  }
  #touch button {
    min-width: 44px;
    padding: 8px;
  }
}

.instructions-heading,
.links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.instructions-heading {
  justify-content: space-between;
  margin-bottom: 8px;
}
.instructions-heading h2 {
  margin: 0;
}
.icon-button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  padding: 7px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  border-radius: 3px;
}
.icon-button:hover {
  background: var(--panel);
}
.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-off,
[aria-pressed='true'] .sound-on {
  display: none;
}
[aria-pressed='true'] .sound-off {
  display: block;
}
.controls:has(.binding) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  font-size: 12px;
}
.binding {
  display: flex;
  align-items: center;
  gap: 6px;
}
.key-group {
  display: inline-flex;
  gap: 2px;
}
kbd {
  font:
    11px system-ui,
    sans-serif;
  display: inline-block;
  min-width: 19px;
  text-align: center;
  padding: 1px 3px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--ink);
}
.driving-tip {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.save-status:empty {
  display: none;
}
.sr-only,
.assistive-controls:not(:focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.assistive-controls:focus-within {
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--line);
}
.assistive-controls button {
  margin: 3px;
}
@media (pointer: coarse) {
  .icon-button {
    width: 44px;
    height: 44px;
  }
}

.no-script {
  max-width: 85%;
  text-align: center;
}
:root:has(.no-script) #play,
:root:has(.no-script) #load-status {
  display: none;
}

#variant-left,
#variant-right {
  position: absolute;
  bottom: 52px;
}
#variant-left {
  left: 0;
}
#variant-right {
  left: 50px;
}
