:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #1d242c;
  --panel-2: #26303a;
  --line: #405061;
  --text: #f7fbff;
  --muted: #aab8c5;
  --gold: #f7c94b;
  --green: #44d49a;
  --red: #ff5a65;
  --blue: #55a8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(85, 168, 255, 0.2), transparent 34rem),
    linear-gradient(180deg, #151b22 0%, var(--bg) 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.shell {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.hud-item {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(29, 36, 44, 0.94);
}

.hud-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.hud-item strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(17px, 3.4vw, 25px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
}

canvas {
  display: block;
  width: min(100%, 520px);
  height: auto;
  max-height: calc(100vh - 168px);
  aspect-ratio: 13 / 19;
  border: 2px solid #405366;
  border-radius: 8px;
  background: #232a31;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: stretch;
  gap: 12px;
  padding: 18px;
  background: rgba(8, 11, 15, 0.78);
  border-radius: 8px;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  max-width: 14ch;
  justify-self: center;
  text-align: center;
  font-size: clamp(28px, 6vw, 48px);
  line-height: 1;
}

.overlay p {
  max-width: 500px;
  margin: 0;
  justify-self: center;
  color: var(--muted);
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
}

.menu-panel {
  width: min(100%, 520px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(29, 36, 44, 0.95);
}

.menu-panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-choice {
  min-height: 42px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--car-color);
}

.color-choice.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(247, 201, 75, 0.28);
}

.weapon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.weapon-choice {
  min-height: 76px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: left;
}

.weapon-choice strong,
.weapon-choice span {
  display: block;
}

.weapon-choice strong {
  margin-bottom: 5px;
  font-size: 15px;
}

.weapon-choice span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.weapon-choice.active {
  border-color: var(--gold);
  background: #3a3221;
}

.weapon-choice.locked {
  color: #d7e0e8;
}

.status {
  min-height: 20px;
  margin-top: 8px;
  color: var(--gold);
  font-size: 13px;
}

.overlay > button {
  min-width: 150px;
  min-height: 48px;
  padding: 12px 20px;
  justify-self: center;
  border-radius: 8px;
  background: var(--gold);
  color: #201700;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 8px;
}

.control {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 700;
}

.control:active,
.control.active {
  background: var(--blue);
  color: #06111f;
}

.control.fire {
  background: var(--red);
}

@media (max-width: 640px) {
  .shell {
    padding: 8px;
    gap: 9px;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
  }

  canvas {
    max-height: calc(100vh - 220px);
  }

  .overlay {
    padding: 10px;
  }

  .weapon-grid {
    grid-template-columns: 1fr;
  }
}
