/* Lane Rush — mobile-first stylesheet. */

:root {
  --bg: #0b1015;
  --fg: #f1f5f9;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-hot: #16a34a;
  --road: #1a1d24;
  --grass: #0f3a1f;
  --card: rgba(15, 23, 42, 0.92);
  --card-border: rgba(148, 163, 184, 0.25);
  --tap-min: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  /* Lock the viewport — no scroll, no rubber-banding while playing. */
  overflow: hidden;
}

a { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: calc(0.5rem + var(--safe-top)) 0.75rem 0.5rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0));
  z-index: 2;
}

.title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.hud {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.4rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}
.hud-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.hud-value { font-weight: 700; font-size: 1.1rem; }
.hud-divider { color: var(--muted); }

.mute-btn {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(0,0,0,0.4);
  color: var(--fg);
  font-size: 0.85rem;
}
.mute-btn[aria-pressed="true"] { color: var(--muted); }

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--grass);
  /* Disable iOS callout/selection on long press. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
#game:focus { outline: none; }
#game:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 21, 0.55);
  backdrop-filter: blur(2px);
  padding: 1rem;
  z-index: 3;
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.4rem 1.3rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.overlay-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.lead {
  margin: 0 0 1rem;
  color: var(--muted);
}

.hints {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
  text-align: left;
  color: var(--fg);
}
.hints li { padding: 0.2rem 0; }
.hints strong { color: var(--accent); margin-right: 0.4rem; }

.record {
  margin: 0 0 0.6rem;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.04em;
}

.result {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  column-gap: 1rem;
  row-gap: 0.2rem;
  margin: 0 0 1.2rem;
}
.result dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.result dd { margin: 0; font-weight: 700; font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.primary-btn {
  display: inline-block;
  width: 100%;
  min-height: 52px;
  padding: 0.9rem 1.2rem;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #062b14;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 0.05s ease, background 0.15s ease;
}
.primary-btn:hover { background: var(--accent-hot); }
.primary-btn:active { transform: translateY(1px); }

/* ---------- Footer ---------- */
.footnote {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.4rem 0.75rem calc(0.4rem + var(--safe-bottom));
  background: rgba(0,0,0,0.4);
}
.footnote p { margin: 0; }

/* ---------- Larger screens ---------- */
@media (min-width: 768px) {
  .topbar { padding: calc(0.75rem + var(--safe-top)) 1.5rem 0.75rem; }
  .title { font-size: 1.2rem; }
  .hud { font-size: 1rem; }
  .overlay-card { padding: 1.8rem 1.6rem; }
  .overlay-card h2 { font-size: 1.9rem; }
}

@media (min-width: 1100px) {
  /* Center the play stage on wide screens — racing games feel weird stretched ultra-wide. */
  .stage {
    display: flex;
    justify-content: center;
  }
  #game {
    position: relative;
    inset: auto;
    width: min(540px, 100%);
    height: 100%;
    box-shadow: 0 0 0 1px var(--card-border), 0 20px 60px rgba(0,0,0,0.5);
  }
  .overlay {
    inset: 0;
    /* Keep overlay covering whole stage so the dim/blur looks intentional. */
  }
}

/* Reduced motion: dampen the running road on menu/gameover. */
@media (prefers-reduced-motion: reduce) {
  .overlay-card { transition: none; }
}
