:root {
  --hud-bg: rgba(9, 14, 28, 0.62);
  --hud-border: rgba(150, 178, 235, 0.26);
  --hud-fg: #e7eefc;
  --hud-dim: #97a6c4;
  --hud-accent: #ffc879;
  --hud-focus: #8fc3ff;
  color-scheme: dark;
}

html.light-scheme {
  --hud-bg: rgba(246, 248, 253, 0.78);
  --hud-border: rgba(38, 54, 90, 0.22);
  --hud-fg: #16203a;
  --hud-dim: #4a5a7a;
  --hud-accent: #a4501a;
  --hud-focus: #1d5fd0;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05070f;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--hud-fg);
}

html.light-scheme body { background: #cfd8e8; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.fallback {
  position: fixed;
  inset: auto 0 50% 0;
  margin: 0;
  padding: 1rem;
  text-align: center;
  font-size: 1rem;
  color: #dbe4f7;
}

/* ------------------------------------------------------------------ HUD */
.hud {
  position: fixed;
  top: max(0.85rem, env(safe-area-inset-top));
  right: max(0.85rem, env(safe-area-inset-right));
  z-index: 5;
  min-width: 13.5rem;
  padding: 0.7rem 0.85rem 0.75rem;
  border: 1px solid var(--hud-border);
  border-radius: 0.75rem;
  background: var(--hud-bg);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.36);
  font-size: 0.82rem;
  line-height: 1.35;
}

.hud-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.85rem;
  margin: 0;
}

.hud-grid dt {
  color: var(--hud-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.66rem;
  align-self: center;
}

.hud-grid dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.hud-grid dd#hud-route { color: var(--hud-accent); }

.paused {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--hud-accent);
}

.hud-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.65rem;
}

.hud-buttons button {
  flex: 1 1 auto;
  padding: 0.32rem 0.5rem;
  font: inherit;
  font-size: 0.72rem;
  color: var(--hud-fg);
  background: rgba(125, 155, 210, 0.14);
  border: 1px solid var(--hud-border);
  border-radius: 0.45rem;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.hud-buttons button:hover { background: rgba(140, 175, 235, 0.26); }

.hud-buttons button[aria-pressed="true"] {
  background: rgba(255, 200, 121, 0.24);
  border-color: var(--hud-accent);
}

.hud-buttons button:focus-visible,
.hud-buttons button:focus {
  outline: 2px solid var(--hud-focus);
  outline-offset: 2px;
}

.hud-buttons kbd {
  font: inherit;
  font-size: 0.62rem;
  opacity: 0.72;
  padding: 0 0.15rem;
  border: 1px solid currentColor;
  border-radius: 0.2rem;
}

/* ----------------------------------------------------------------- hint */
.hint {
  position: fixed;
  left: max(0.9rem, env(safe-area-inset-left));
  bottom: max(0.9rem, env(safe-area-inset-bottom));
  z-index: 5;
  margin: 0;
  padding: 0.45rem 0.7rem;
  max-width: min(30rem, calc(100vw - 2rem));
  border: 1px solid var(--hud-border);
  border-radius: 0.5rem;
  background: var(--hud-bg);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  font-size: 0.74rem;
  color: var(--hud-dim);
  transition: opacity 700ms ease;
}

.hint.is-faded { opacity: 0; }

@media (max-width: 560px) {
  .hud { min-width: 0; font-size: 0.75rem; }
  .hud-buttons button { font-size: 0.66rem; }
  .hint { font-size: 0.68rem; }
}

/* Reduced motion: no UI transitions, and the app itself slows its camera
   banking, drops the shake and thins the particles. */
html.reduced-motion .hint { transition: none; }
html.reduced-motion .hud-buttons button { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .hint { transition: none; }
  .hud-buttons button { transition: none; }
}
