:root {
  color-scheme: dark;
  --bg: #111319;
  --panel: #1b1f27;
  --road: #2f343b;
  --line: #d9d3be;
  --accent: #36d7a2;
  --danger: #ff5f57;
  --text: #f4f2ea;
  --muted: #a8b0bc;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 15%, rgba(54, 215, 162, 0.14), transparent 24rem),
    linear-gradient(135deg, #0f1117 0%, #171a20 50%, #20242a 100%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  touch-action: manipulation;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 540px) minmax(260px, 360px);
  gap: 28px;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

.game-panel {
  width: 100%;
}

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

.hud > div {
  min-height: 64px;
  padding: 10px 14px;
  background: rgba(27, 31, 39, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

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

.hud strong {
  display: block;
  margin-top: 3px;
  font-size: 24px;
  line-height: 1;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  max-height: calc(100vh - 150px);
  background: var(--road);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.touch-controls button,
.start-button {
  min-height: 48px;
  border-radius: 8px;
  background: #2b3038;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 800;
  font-size: 14px;
}

#jumpBtn {
  color: #101820;
  background: #f0c15d;
}

.start-button {
  width: 100%;
  margin-top: 22px;
  color: #09120f;
  background: var(--accent);
}

.side-panel {
  padding: 26px;
  background: rgba(27, 31, 39, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.side-panel h1 {
  margin: 0 0 12px;
  font-size: 44px;
  line-height: 0.95;
}

.side-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.key-grid {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px 12px;
  align-items: center;
  margin-top: 24px;
}

.key-grid span {
  min-height: 34px;
  display: grid;
  place-items: center;
  background: #252a32;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  font-weight: 800;
}

.car-style-panel {
  margin-top: 22px;
}

.car-style-panel > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.car-style-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.car-style-buttons button {
  min-height: 40px;
  border-radius: 8px;
  background: #252a32;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
}

.car-style-buttons button.active {
  color: #09120f;
  background: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 860px) {
  body {
    min-height: 100dvh;
  }

  .shell {
    width: min(560px, calc(100vw - 20px));
    min-height: 100dvh;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 0 12px;
  }

  .side-panel {
    order: -1;
    padding: 12px;
  }

  .side-panel h1 {
    font-size: 28px;
    margin-bottom: 6px;
  }

  .side-panel p {
    font-size: 14px;
    line-height: 1.35;
  }

  .hud > div {
    min-height: 50px;
    padding: 8px 10px;
  }

  .hud strong {
    font-size: 20px;
  }

  .key-grid {
    display: none;
  }

  .car-style-panel {
    margin-top: 12px;
  }

  .car-style-buttons button {
    min-height: 38px;
  }

  canvas {
    width: auto;
    height: min(calc((100vw - 20px) * 1.5), calc(100dvh - 352px));
    max-width: 100%;
    margin: 0 auto;
  }

  .touch-controls {
    position: sticky;
    bottom: 8px;
    z-index: 4;
    gap: 6px;
  }

  .touch-controls button {
    min-height: 56px;
    padding: 0 4px;
    font-size: 12px;
  }
}
