/* Hill Dash styles.
   Mobile-first: the phone viewport is the shape everything is designed around,
   desktop is the widening. Plain CSS, no build step, no external fonts. */

:root {
  --ink: #eef2f7;
  --ink-dim: #a9b4c4;
  --bg: #0f131b;
  --bg-2: #151b26;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #ffd76a;
  --accent-ink: #2a2103;
  --fuel: #7fe3a1;
  --danger: #ff6b6b;
  --radius: 14px;
  --pad: clamp(10px, 2.4vw, 18px);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
}

.shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad) max(var(--pad), env(safe-area-inset-bottom));
  gap: 8px;
}

/* ---------------------------------------------------------------- skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  font-weight: 700;
}
.skip-link:focus {
  left: 0;
}

/* ------------------------------------------------------------------- hud */
.hud {
  display: grid;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  z-index: 3;
}

.hud__row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hud__row--main {
  gap: 12px;
}

.hud__row--sub {
  gap: 12px;
  font-size: 12px;
  color: var(--ink-dim);
}

.hud__row--courses {
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-dim);
  gap: 8px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* The distance bar takes the slack on the main row; everything else is fixed. */
.stat--distance {
  flex: 1 1 auto;
}

.stat--coins,
.stat--speed,
.stat--fuel {
  flex: 0 0 auto;
}

.hud__buttons {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

.stat__label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.stat__value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.bar {
  position: relative;
  flex: 1 1 60px;
  min-width: 40px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.bar__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 120ms linear;
}

.bar--fuel {
  flex: 1 1 54px;
}

.bar--fuel .bar__fill {
  background: var(--fuel);
}

.bar.is-low .bar__fill {
  background: var(--danger);
}

/* ------------------------------------------------------------------ stage */
.stage {
  position: relative;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #1b2333;
  box-shadow: var(--shadow);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#game:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- pedals */
.pedals {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: 10px;
  padding: 10px;
  pointer-events: none;
}

.pedal {
  pointer-events: auto;
  flex: 1 1 0;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(15, 19, 27, 0.72);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  transition: transform 80ms ease, background 80ms ease;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.pedal svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pedal--gas {
  background: rgba(255, 215, 106, 0.16);
  border-color: rgba(255, 215, 106, 0.45);
}

.pedal--brake {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.4);
}

.pedal[aria-pressed='true'],
.pedal.is-held,
.pedal:active {
  transform: translateY(2px) scale(0.985);
  background: rgba(255, 215, 106, 0.32);
}

.pedal--brake[aria-pressed='true'],
.pedal--brake.is-held {
  background: rgba(255, 107, 107, 0.3);
}

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

/* --------------------------------------------------------------- overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(8, 11, 16, 0.72);
  backdrop-filter: blur(3px);
  z-index: 4;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: min(460px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(16px, 4vw, 26px);
  text-align: center;
  box-shadow: var(--shadow);
}

.panel__eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.panel__title {
  margin: 0 0 8px;
  font-size: clamp(26px, 8vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.panel__lead {
  margin: 0 0 16px;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.5;
}

.panel__stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0 0 16px;
}

.panel__stats[hidden] {
  display: none;
}

.panel__stats > div {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}

.panel__stats span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.panel__stats strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.panel__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.panel__hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.6;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 80ms ease, background 120ms ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn:active {
  transform: translateY(1px);
}

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

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover {
  background: #ffe28f;
}

.btn--ghost {
  background: transparent;
  padding: 6px 10px;
  min-height: 32px;
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn[hidden] {
  display: none;
}

/* ------------------------------------------------------------- level list */
.levels {
  display: flex;
  gap: 5px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.level button {
  appearance: none;
  position: relative;
  width: 34px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.level button:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

.level__stars {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  font-size: 7px;
  letter-spacing: 0;
  color: var(--accent);
}

.best {
  margin: 0;
  white-space: nowrap;
}

.live {
  position: absolute;
  left: 10px;
  bottom: 10px;
  margin: 0;
  font-size: 12px;
  color: var(--ink);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  max-width: 60%;
}

/* ---------------------------------------------------------------- footer */
.foot {
  text-align: center;
  font-size: 11px;
  color: var(--ink-dim);
}

.foot p {
  margin: 0;
}

/* ----------------------------------------------------- plain error pages */
body.plain {
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
}

.plain__card {
  max-width: 520px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.plain__card h1 {
  margin-top: 0;
  font-size: 26px;
}

.plain__card a {
  color: var(--accent);
}

.plain__foot {
  margin-bottom: 0;
  font-size: 12px;
  color: var(--ink-dim);
}

/* --------------------------------------------------------------- wider */
@media (min-width: 720px) {
  .shell {
    max-width: 1100px;
    margin: 0 auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .pedals {
    inset: auto 0 0 auto;
    width: min(420px, 46%);
  }

  .live {
    bottom: 16px;
    left: 16px;
    max-width: 40%;
  }

  .panel__stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (hover: hover) and (pointer: fine) {
  .pedals {
    opacity: 0.72;
  }
  .pedals:hover {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Keyboard hint hidden on touch-first devices: pedals are the affordance. */
@media (pointer: coarse) {
  .panel__hint kbd {
    display: none;
  }
}
