:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0e1116;
  color: #f7f8fb;
  --speedfx: 0;
  --speedfx-opacity: 0;
}

* {
  box-sizing: border-box;
}

html,
body,
#game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #111820;
}

#game::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(90deg, transparent 0%, rgb(255 255 255 / 4%) 48%, transparent 51%),
    radial-gradient(circle at 50% 42%, rgb(0 217 255 / 9%), transparent 34%),
    radial-gradient(circle at 50% 50%, transparent 46%, rgb(0 0 0 / 42%) 100%),
    linear-gradient(180deg, rgb(80 130 190 / 12%), transparent 30%, rgb(255 60 170 / 8%) 100%);
}

#game::before {
  content: "";
  position: fixed;
  inset: -12%;
  z-index: 1;
  pointer-events: none;
  opacity: var(--speedfx-opacity);
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgb(255 255 255 / 12%) 35px 36px, transparent 37px 70px);
  filter: blur(10px);
  transform: perspective(600px) rotateX(58deg) scaleY(1.8);
}

#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 3;
}

.brand,
.telemetry,
#garage,
.pause-box,
#mapPanel {
  background: rgb(10 14 20 / 78%);
  border: 1px solid rgb(255 255 255 / 12%);
  box-shadow: 0 16px 40px rgb(0 0 0 / 36%);
  backdrop-filter: blur(14px);
}

.brand {
  min-width: 172px;
  padding: 10px 12px;
  border-radius: 8px;
}

.brand strong {
  display: block;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #aeb7c4;
  font-size: 12px;
}

.telemetry {
  min-height: 48px;
  display: grid;
  grid-template-columns: repeat(6, minmax(54px, auto));
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
}

#mapPanel {
  position: fixed;
  left: 14px;
  bottom: 14px;
  width: 180px;
  height: 180px;
  border-radius: 8px;
  padding: 8px;
  z-index: 3;
  pointer-events: none;
}

#minimap {
  width: 100%;
  height: 100%;
  display: block;
}

.telemetry span {
  color: #c4ccd8;
  font-size: 12px;
  white-space: nowrap;
}

.telemetry b {
  color: #fff;
  display: block;
  font-size: 20px;
  line-height: 1.05;
}

#garage {
  position: fixed;
  top: 78px;
  right: 14px;
  width: min(320px, calc(100vw - 28px));
  border-radius: 8px;
  overflow: hidden;
  z-index: 3;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.tabs button,
.panel button,
.google {
  min-height: 36px;
  border: 0;
  color: #eef2f7;
  background: #26303d;
  cursor: pointer;
}

.tabs button {
  background: transparent;
  color: #aeb7c4;
}

.tabs button.active {
  background: #1d2734;
  color: #fff;
}

.panel {
  display: none;
  padding: 12px;
  gap: 10px;
}

.panel.active {
  display: grid;
}

label {
  display: grid;
  gap: 6px;
  color: #c4ccd8;
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 6px;
  padding: 6px 8px;
  color: #f8fafc;
  background: #151d27;
}

input[type="color"] {
  padding: 2px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel button,
.google {
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  display: grid;
  place-items: center;
}

#pauseMenu {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(4 8 13 / 42%);
  z-index: 5;
}

#pauseMenu.hidden {
  display: none;
}

.pause-box {
  width: min(360px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 18px;
}

.pause-box h1 {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.pause-actions {
  display: grid;
  gap: 10px;
}

.pause-actions button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: #f8fafc;
  background: #26303d;
  cursor: pointer;
}

#touch {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
  z-index: 3;
}

.stick,
.pedals button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.stick {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgb(18 25 34 / 72%);
  border: 1px solid rgb(255 255 255 / 16%);
  position: relative;
}

.stick span {
  position: absolute;
  width: 54px;
  height: 54px;
  left: 39px;
  top: 39px;
  border-radius: 50%;
  background: #d6dde7;
}

.pedals {
  display: flex;
  gap: 12px;
}

.pedals button {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 18%);
  color: #fff;
  background: rgb(37 46 58 / 82%);
}

#throttleTouch {
  background: rgb(36 111 74 / 86%);
}

#brakeTouch {
  background: rgb(148 43 47 / 86%);
}

@media (max-width: 780px) {
  #hud {
    display: grid;
  }

  .telemetry {
    justify-self: stretch;
    grid-template-columns: repeat(3, 1fr);
  }

  #garage {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 166px;
    width: auto;
    max-height: 38vh;
    overflow: auto;
  }

  #mapPanel {
    width: 128px;
    height: 128px;
    left: 10px;
    bottom: 166px;
  }
}

@media (pointer: fine) and (min-width: 900px) {
  #touch {
    opacity: 0;
  }
}
