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

html,
body {
  width: 100%;
  height: 100%;
  background: #08080c;
  color: #e8e8f0;
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.vga-stage {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: radial-gradient(circle at center, #141422 0%, #050508 100%);
}

#gameCanvas {
  width: min(100vw - 16px, calc((100vh - 16px) * 1.3333));
  height: min(100vh - 16px, calc((100vw - 16px) / 1.3333));
  aspect-ratio: 640 / 480;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 2px solid #2b2b3d;
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.9), 0 0 8px rgba(80, 140, 255, 0.15);
  background: #000;
  display: block;
}

.touch-controls {
  display: none;
  width: min(100vw - 16px, 520px);
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  touch-action: none;
}

.touch-group {
  display: flex;
  gap: 8px;
}

.vga-btn {
  min-width: 54px;
  height: 40px;
  padding: 0 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  font-weight: bold;
  color: #e2e8f0;
  background: #1e293b;
  border: 2px solid #475569;
  box-shadow: inset 1px 1px 0 #64748b, inset -1px -1px 0 #0f172a;
  cursor: pointer;
  touch-action: none;
}

.vga-btn:active,
.vga-btn.active {
  background: #334155;
  border-color: #38bdf8;
  color: #fde047;
}

.vga-btn-brake {
  border-color: #b91c1c;
  color: #fecaca;
}

.vga-btn-turbo {
  border-color: #0284c7;
  color: #bae6fd;
}

@media (hover: none) and (pointer: coarse), (max-width: 768px) {
  .touch-controls {
    display: flex;
  }

  #gameCanvas {
    width: min(100vw - 16px, calc((100vh - 72px) * 1.3333));
    height: min(100vh - 72px, calc((100vw - 16px) / 1.3333));
  }
}
