:root {
  --road: #4a4f57;
  --road-dark: #3c4148;
  --shoulder: #8a9099;
  --kerb: #b9bfc7;
  --mark: #e8e3d0;
  --bike-wrong: #d63a3a;
  --bike-ok: #2f9e5f;
  --car: #2f6fd0;
  --panel: #12161c;
  --text: #eef2f6;
  --muted: #9aa6b2;
  --focus: #ffcf4d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: #0d1117;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 8px 10px;
  gap: 8px;
}

/* --- HUD ------------------------------------------------------------------ */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex: 0 0 auto;
}

.hud-item {
  background: var(--panel);
  border: 1px solid #232a33;
  border-radius: 10px;
  padding: 5px 6px;
  text-align: center;
  min-width: 0;
}

.hud-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-value {
  display: block;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-value.pulse { animation: pulse 0.35s ease-out; }
@keyframes pulse {
  from { transform: scale(1.25); color: var(--focus); }
  to { transform: scale(1); }
}

#lives { color: var(--bike-wrong); letter-spacing: 0.08em; }

/* --- stage ---------------------------------------------------------------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--road-dark);
}

#road {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* --- overlay -------------------------------------------------------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(8, 11, 15, 0.86);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}

.overlay[hidden] { display: none; }

.panel {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid #2a323d;
  border-radius: 14px;
  padding: 18px 16px;
  text-align: left;
}

.panel h1 {
  font-size: 21px;
  margin: 0 0 8px;
}

.panel p {
  margin: 0 0 10px;
  color: #d5dde5;
}

.rules {
  margin: 0 0 12px;
  padding-left: 18px;
  color: #cbd5df;
  font-size: 15px;
}

.rules li { margin-bottom: 5px; }

.hint {
  font-size: 14px;
  color: var(--muted);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #3a444f;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #1c222a;
  font: inherit;
  font-size: 13px;
}

button {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--bike-ok);
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- footer --------------------------------------------------------------- */
.foot {
  flex: 0 0 auto;
  font-size: 13.5px;
  color: var(--muted);
}

.foot p { margin: 0 0 4px; }

.foot .meta { color: #7f8b97; }

button.link {
  display: inline;
  width: auto;
  margin: 0;
  padding: 0 2px;
  background: none;
  color: #7fc3ff;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
}

button.link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (max-height: 560px) {
  .foot { display: none; }
  .hud-value { font-size: 17px; }
}
