:root {
  color-scheme: light;
  --ink: #1c2926;
  --paper: #f9efa2;
  --edge: #203326;
  --yellow: #f4d84b;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Courier New", monospace;
}
button,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #009ddd;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
canvas {
  image-rendering: pixelated;
}
.site-header {
  height: 48px;
  padding: 0 4vw;
  border-bottom: 2px solid #5f8236;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 10px;
  letter-spacing: 1px;
}
.site-header a {
  color: inherit;
  text-decoration: none;
}
.site-header button {
  background: #e7eab2;
  border: 1px solid #4a6135;
  padding: 8px;
  font-size: 10px;
}
main {
  max-width: 1280px;
  margin: auto;
  padding: 24px 4vw;
}
.menu {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 4%;
  align-items: center;
  padding: 22px 0;
}
.eyebrow {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
}
.intro h1,
#announcement,
.race-top > div {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  margin: 0;
}
.title-art {
  width: 100%;
  display: block;
  margin: 24px 0;
}
.subtitle {
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  margin: 14px 0;
}
.subtitle span {
  color: #c12d13;
}
.track-card {
  display: flex;
  align-items: center;
  background: #78d243;
  border: 3px solid #294d25;
  margin-top: 20px;
  padding: 10px;
  gap: 12px;
}
.track-card canvas {
  width: 140px;
  height: 100px;
  border: 2px solid #265b1c;
}
.track-card b {
  font-size: 14px;
}
.track-card p {
  font-size: 10px;
  line-height: 1.8;
}
.reference {
  text-align: center;
  font-size: 10px;
  line-height: 1.8;
  margin-top: 20px;
}
.garage {
  position: relative;
  background: #46533c;
  border: 4px solid #252d25;
  box-shadow: 7px 7px 0 #25312a;
  padding: 24px;
  margin-top: 15px;
}
.garage::before {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: -16px;
  height: 12px;
  background: repeating-conic-gradient(#fffce5 0 25%, #19251b 0 50%) 0/12px 12px;
  border: 2px solid #25312a;
}
.garage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #f5c750;
  background: #101910;
  border: 3px solid #748361;
  padding: 12px;
  margin-bottom: 18px;
}
#selected-name {
  font-size: 11px;
  color: #fff38a;
  font-weight: bold;
}
.roster {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}
.pilot {
  border: 3px solid var(--edge);
  background: #5c7850;
  padding: 0;
  box-shadow: 2px 2px 0 #80946b;
}
.pilot canvas {
  display: block;
  width: 100%;
  height: auto;
  background: repeating-linear-gradient(
    135deg,
    #80d3e4 0 18px,
    #a5e9ed 18px 21px,
    #80d3e4 21px 38px
  );
  border-bottom: 2px solid #34532b;
}
.pilot span {
  display: block;
  font-size: 10px;
  font-weight: bold;
  color: #fcf6c8;
  padding: 7px 1px;
}
.pilot[aria-pressed="true"] {
  background: #fff455;
  border-color: #fff38a;
  box-shadow: 3px 3px 0 #182c1b;
}
.pilot[aria-pressed="true"] span {
  color: #26331e;
}
.pilot:hover {
  transform: translateY(-2px);
}
.setup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: #fff5b3;
  font-size: 11px;
}
.setup select {
  background: #eef0b6;
  color: #243129;
  border: 2px solid #253927;
  padding: 10px;
}
.setup > span {
  width: 100%;
  color: #d0debd;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--yellow);
  color: #243129;
  border: 3px solid #1c2e20;
  padding: 17px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 1px;
  box-shadow: 3px 3px 0 #91a35e;
}
.primary:hover {
  background: #fff38a;
}
.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.controls-summary {
  text-align: center;
  font-size: 10px;
  line-height: 1.9;
  color: #d6e3c5;
  margin: 22px 0 0;
}
.audio-settings {
  grid-column: 1/-1;
  font-size: 11px;
  margin-top: 2px;
}
.audio-settings summary {
  cursor: pointer;
}
.audio-settings label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 15px 0 0;
}
.audio-settings button {
  padding: 8px;
  background: transparent;
  border: 1px solid var(--ink);
}
footer {
  display: flex;
  justify-content: space-between;
  border-top: 2px solid #748b43;
  margin: 0 4vw;
  padding: 20px 0;
  font-size: 9px;
  letter-spacing: 1px;
}
#race {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(700px, calc((100dvh - 215px) * 1.142857));
  margin: auto;
}
.screen {
  position: relative;
  order: 1;
  background: #14251b;
  border: 3px solid #15221c;
  box-shadow: 5px 5px 0 #334332;
}
#game {
  display: block;
  width: 100%;
  aspect-ratio: 256/224;
}
.race-top {
  order: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: #293826;
  color: #fff;
  padding: 5px 8px;
  min-height: 35px;
  border: 2px solid #161f19;
  border-top: 0;
}
.race-top::before {
  content: "CIRCUITO 1 · 5 VOLTAS";
  font-size: 10px;
  color: #edeea7;
  margin-right: auto;
}
.race-top small {
  display: none;
}
.race-top button {
  border: 1px solid #6c845b;
  background: #435436;
  color: #fff9cb;
  padding: 5px 8px;
  min-height: 25px;
  min-width: 44px;
}
#item-name {
  font-size: 10px;
}
.race-top #pause {
  font-size: 14px;
}
.race-top button:disabled {
  opacity: 0.6;
}
.race-bottom {
  order: 3;
  display: flex;
  justify-content: space-between;
  background: #d7dc81;
  border: 2px solid #1a2b1d;
  border-top: 0;
  padding: 8px;
  font-size: 10px;
  font-weight: bold;
  gap: 10px;
}
.race-bottom #hint {
  text-align: center;
  font-size: 9px;
}
.touch-controls {
  order: 4;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.touch-controls > div {
  display: flex;
  gap: 8px;
}
.touch-controls button {
  touch-action: none;
  user-select: none;
  background: #dde1a0;
  border: 2px solid #2b492b;
  height: 48px;
  min-width: 55px;
  padding: 8px;
  font-size: 11px;
  font-weight: bold;
}
.touch-controls .gas {
  background: #f4d84b;
}
.touch-controls button.held {
  background: #273f28;
  color: #fff;
}
.dialog {
  background: #f6ecad;
  padding: 25px;
  border: 3px solid #2c432e;
  box-shadow: 6px 6px 0 #0005;
  max-width: 460px;
  width: 100%;
  text-align: center;
}
.dialog h2 {
  font-size: 30px;
  margin: 12px 0;
}
.dialog p {
  font-size: 12px;
  line-height: 1.7;
}
.dialog > button:not(.primary) {
  margin: 15px 6px 0;
  background: transparent;
  border: 0;
  text-decoration: underline;
  padding: 8px;
  font-size: 12px;
}
#overlay {
  position: absolute;
  inset: 0;
  background: #172532bd;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 15px;
}
#results {
  font-size: 12px;
  line-height: 1.8;
  margin: 12px 0;
}
#results canvas {
  display: block;
  width: 100%;
  max-height: 110px;
  object-fit: contain;
  margin-bottom: 10px;
}
.result-ranking {
  max-height: 105px;
  overflow: auto;
  padding: 6px 0;
  color: #24321f;
}
#orientation {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 10;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 25px;
}
#orientation b {
  font-size: 80px;
  color: #467c2c;
}
#orientation h2 {
  font-size: 26px;
}
#orientation p {
  font-size: 13px;
  line-height: 1.8;
}
@media (max-height: 600px) {
  .site-header {
    height: 32px;
  }
  main {
    padding: 8px 3vw;
  }
  .menu {
    padding: 8px 0;
    grid-template-columns: 0.9fr 1.2fr;
    gap: 3%;
  }
  .garage {
    padding: 12px;
    margin-top: 12px;
  }
  .garage-heading {
    padding: 7px;
    margin-bottom: 10px;
  }
  .garage-heading .eyebrow {
    font-size: 8px;
  }
  .roster {
    gap: 8px;
  }
  .pilot canvas {
    height: 51px;
    object-fit: contain;
  }
  .pilot span {
    font-size: 8px;
    padding: 4px 0;
  }
  .setup {
    margin: 10px 0;
  }
  .setup select {
    padding: 5px;
    font-size: 10px;
  }
  .setup > span,
  .controls-summary,
  .reference,
  footer {
    display: none;
  }
  .primary {
    padding: 9px;
    font-size: 12px;
  }
  .title-art {
    margin: 18px 0;
  }
  .intro .eyebrow {
    font-size: 8px;
  }
  .subtitle {
    font-size: 10px;
    letter-spacing: 1px;
  }
  .intro .track-card {
    display: none;
  }
  #race {
    max-width: calc((100dvh - 130px) * 1.142857);
  }
  .race-top {
    padding: 4px 6px;
    min-height: 31px;
  }
  .race-top::before {
    font-size: 8px;
  }
  .race-top button {
    font-size: 9px;
    min-height: 24px;
    padding: 3px 6px;
  }
  .race-bottom {
    padding: 5px;
    font-size: 9px;
  }
  #hint {
    display: none;
  }
  .touch-controls {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: 6px;
  }
  .touch-controls button {
    height: 42px;
    min-width: 48px;
    font-size: 10px;
  }
  .dialog {
    padding: 12px;
    max-width: 380px;
  }
  .dialog h2 {
    font-size: 20px;
  }
  .dialog p {
    font-size: 10px;
    margin: 6px 0;
  }
  #results canvas {
    display: none;
  }
  .result-ranking {
    max-height: 65px;
  }
  .dialog > button:not(.primary) {
    margin-top: 8px;
  }
  .audio-settings {
    margin: 0;
  }
}
@media (max-width: 650px) and (orientation: landscape) {
  .intro .eyebrow,
  .subtitle {
    display: none;
  }
  .garage-heading .eyebrow {
    letter-spacing: 0;
  }
  .roster {
    gap: 4px;
  }
  .pilot canvas {
    height: 42px;
  }
  .garage {
    padding: 8px;
  }
  .garage-heading {
    padding: 5px;
  }
  .setup select {
    max-width: 145px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pilot:hover {
    transform: none;
  }
}
body.play-mode {
  --play-toolbar: 44px;
  --play-extra: 0px;
  background: #000;
  overflow: hidden;
}
.play-mode .site-header,
.play-mode footer,
.play-mode .race-bottom {
  display: none;
}
.play-mode main {
  position: fixed;
  inset: 0;
  max-width: none;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #000;
}
.play-mode #race {
  height: 100%;
  width: 100%;
  max-width: none;
  margin: 0;
  align-items: center;
  justify-content: center;
}
.play-mode .screen {
  flex: none;
  width: min(
    calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)),
    calc(
      (
          100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) -
            var(--play-toolbar) - var(--play-extra)
        ) *
        1.142857
    )
  );
  border: 0;
  box-shadow: none;
}
.play-mode .race-top {
  flex: none;
  width: min(
    calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)),
    calc(
      (
          100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) -
            var(--play-toolbar) - var(--play-extra)
        ) *
        1.142857
    )
  );
  height: var(--play-toolbar);
  min-height: var(--play-toolbar);
  padding: 0 5px;
  border: 0;
  gap: 6px;
}
.play-mode .race-top::before {
  content: none;
}
.play-mode .race-top #speed {
  margin-right: auto;
  color: #fff2b3;
  font-size: 11px;
}
.play-mode .race-top button {
  min-height: 40px;
  font-size: 10px;
  padding: 4px 8px;
}
.play-mode .touch-controls {
  display: none;
}
.play-mode.touch-enabled .touch-controls {
  display: flex;
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  margin: 0;
  pointer-events: none;
}
.play-mode.touch-enabled .touch-controls button {
  pointer-events: auto;
  height: 48px;
  min-width: 44px;
}
.play-mode.touch-enabled .touch-controls > div:last-child {
  display: grid;
  grid-template-columns: 84px 84px;
  gap: 6px;
}
.play-mode.touch-enabled .touch-controls .gas {
  grid-column: 1/-1;
}
@media (min-width: 701px) {
  .play-mode.touch-enabled .screen,
  .play-mode.touch-enabled .race-top {
    max-width: calc(
      100vw - 376px - env(safe-area-inset-left) - env(safe-area-inset-right)
    );
  }
}
@media (max-width: 700px) {
  body.play-mode.touch-enabled {
    --play-extra: 54px;
  }
  .play-mode.touch-enabled .touch-controls {
    position: static;
    width: 100%;
    flex: none;
    height: 54px;
    padding: 3px max(4px, env(safe-area-inset-right)) 3px
      max(4px, env(safe-area-inset-left));
    gap: 4px;
  }
  .play-mode.touch-enabled .touch-controls > div {
    gap: 4px;
  }
  .play-mode.touch-enabled .touch-controls > div:last-child {
    display: flex;
    gap: 4px;
  }
  .play-mode.touch-enabled .touch-controls button {
    font-size: 9px;
    padding: 5px;
    min-width: 42px;
  }
  .play-mode .race-top {
    gap: 3px;
  }
  .play-mode .race-top button {
    font-size: 9px;
    padding: 3px 5px;
  }
  .play-mode .race-top #speed {
    font-size: 9px;
  }
}
