:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #111827;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  display: flex;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  overscroll-behavior: none;
}

main {
  width: min(500px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back {
  align-self: flex-start;
  margin-bottom: 12px;
  color: #d1d5db;
  font-weight: 700;
  text-decoration: none;
}

.back:hover {
  color: #c084fc;
}

h1 {
  margin: 0 0 16px;
  color: #c084fc;
  font-size: clamp(1.7rem, 6vw, 2.25rem);
  line-height: 1.15;
  text-align: center;
}

.stage {
  position: relative;
  width: 100%;
  border: 4px solid #a855f7;
  border-radius: 8px;
  overflow: hidden;
  background: #2d5016;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.75);
  text-align: center;
}

.overlay.is-off {
  display: none;
}

.card {
  max-width: 360px;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 6vw, 1.9rem);
}

h2.crash {
  color: #ef4444;
}

#overlay-copy {
  margin: 0 0 16px;
  color: #d1d5db;
  line-height: 1.45;
}

.points {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
}

.best {
  margin: 0 0 18px;
  color: #facc15;
  font-size: 1.25rem;
  font-weight: 700;
}

.note {
  margin: -8px 0 16px;
  color: #fde68a;
  font-weight: 700;
}

#race-btn {
  border: 0;
  border-radius: 999px;
  background: #9333ea;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 12px 32px;
  cursor: pointer;
}

#race-btn:hover,
#race-btn:focus-visible {
  background: #7e22ce;
}

.steer {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
}

.steer button {
  flex: 1;
  min-height: 72px;
  border: 3px solid #7e22ce;
  border-radius: 16px;
  background: #9333ea;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.steer button.is-held,
.steer button:active {
  background: #6b21a8;
  transform: translateY(2px);
}

.hint {
  margin: 12px 0 0;
  color: #9ca3af;
  font-size: 0.875rem;
  line-height: 1.4;
  text-align: center;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 3px solid #facc15;
  outline-offset: 3px;
}

@media (max-width: 420px) {
  body {
    padding: 12px;
  }

  .steer button {
    min-height: 64px;
  }
}
