/* Fuel Run — canyon interceptor. */

:root {
  --fr-bg: #041a28;
  --fr-deep: #02121d;
  --fr-sky: #0e7490;
  --fr-cyan: #38bdf8;
  --fr-cyan-soft: rgba(56, 189, 248, 0.16);
  --fr-amber: #fbbf24;
  --fr-amber-soft: rgba(251, 191, 36, 0.16);
  --fr-red: #f87171;
  --fr-green: #4ade80;
  --fr-text: #e0f2fe;
  --fr-muted: #93b8cc;
  --fr-line: rgba(125, 211, 252, 0.18);
  --fr-line-strong: rgba(125, 211, 252, 0.36);
  --fr-panel: rgba(6, 31, 46, 0.82);
  --fr-radius: 18px;
  --fr-font: "Trebuchet MS", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.fr-page {
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  background:
    radial-gradient(900px 520px at 50% -12%, rgba(14, 165, 233, 0.22), transparent 62%),
    radial-gradient(700px 420px at 110% 110%, rgba(248, 113, 113, 0.1), transparent 60%),
    linear-gradient(180deg, #062c3f, var(--fr-bg) 60%, var(--fr-deep));
  color: var(--fr-text);
  font-family: var(--fr-font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.fr-wrap {
  width: 100%;
  max-width: 560px;
  height: calc(100dvh - var(--app-header-h, 64px) - 8px);
  margin: 0 auto;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ---------- Top bar ---------- */

.fr-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
}

.fr-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.fr-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--fr-line-strong);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}

.fr-brand-copy {
  min-width: 0;
}

.fr-title {
  margin: 0;
  font-size: clamp(1.15rem, 5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
  background: linear-gradient(90deg, #7dd3fc 10%, #fbbf24 60%, #f87171 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.fr-subtitle {
  margin: 3px 0 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fr-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fr-topbar-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.fr-icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--fr-line);
  border-radius: 999px;
  background: rgba(6, 31, 46, 0.72);
  color: var(--fr-text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 150ms ease, transform 120ms ease;
}

.fr-icon-btn:hover {
  border-color: var(--fr-cyan);
}

.fr-icon-btn:active {
  transform: scale(0.94);
}

.fr-icon-btn.is-muted {
  color: var(--fr-muted);
}

.fr-pause-glyph {
  display: block;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 8px 0 0 currentColor;
  margin-right: 8px;
}

/* ---------- HUD ---------- */

.fr-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.25fr;
  gap: 6px;
}

.fr-chip {
  min-width: 0;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--fr-line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(30, 58, 76, 0.55), rgba(4, 24, 36, 0.8));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 18px rgba(0, 0, 0, 0.3);
}

.fr-chip .k {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #7dd3fc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fr-chip .v {
  font-size: 1.02rem;
  font-weight: 800;
  color: #f0f9ff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(14, 165, 233, 0.45);
}

.fr-fuel .v {
  color: var(--fr-amber);
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.55);
}

.fr-sector .fr-bar i {
  background: linear-gradient(90deg, var(--fr-cyan), #a5f3fc 70%, var(--fr-amber));
}

.fr-dist {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fr-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.fr-bar {
  display: block;
  height: 5px;
  margin-top: 2px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.fr-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--fr-red), var(--fr-amber) 45%, var(--fr-green));
  transition: width 120ms linear;
}

.fr-bar i.is-low {
  background: var(--fr-red);
  animation: fr-low 700ms ease-in-out infinite;
}

/* ---------- Stage ---------- */

.fr-stage {
  position: relative;
  flex: 1;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(14, 165, 233, 0.38);
  border-radius: var(--fr-radius);
  background:
    radial-gradient(90% 70% at 50% 30%, rgba(14, 116, 144, 0.25), transparent 70%),
    #02121d;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 18px 40px -18px rgba(0, 0, 0, 0.8),
    inset 0 0 50px rgba(2, 18, 29, 0.9);
}

.fr-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 3px),
    radial-gradient(120% 85% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  opacity: 0.45;
}

#canvas {
  display: block;
  width: 420px;
  height: 620px;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
}

/* ---------- Touch controls ---------- */

.fr-pads {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr;
  gap: 8px;
}

.fr-pad {
  min-height: 50px;
  padding: 8px;
  border: 1px solid rgba(14, 165, 233, 0.45);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 42, 60, 0.94), rgba(3, 18, 29, 0.94));
  color: #7dd3fc;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 4px 0 rgba(14, 165, 233, 0.28);
  transition: transform 90ms ease, box-shadow 90ms ease, background 120ms ease;
}

.fr-pad:active,
.fr-pad.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(14, 165, 233, 0.28);
}

.fr-pad.fr-fire {
  color: #082f49;
  background: linear-gradient(135deg, var(--fr-amber), #f97316);
  border-color: rgba(251, 191, 36, 0.6);
  box-shadow: 0 4px 0 rgba(251, 191, 36, 0.3);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.fr-hint {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.35;
  text-align: center;
  color: var(--fr-muted);
}

/* ---------- Overlays ---------- */

.fr-overlay {
  position: fixed;
  inset: var(--app-header-h, 64px) 0 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  background:
    radial-gradient(560px 320px at 50% 38%, rgba(14, 165, 233, 0.2), transparent 70%),
    linear-gradient(180deg, rgba(2, 18, 29, 0.9), rgba(1, 9, 15, 0.97));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.fr-card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: clamp(18px, 5vw, 26px);
  border: 1px solid var(--fr-line-strong);
  border-radius: 22px;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(251, 191, 36, 0.09), transparent 62%),
    linear-gradient(160deg, rgba(10, 42, 60, 0.98), rgba(2, 18, 29, 0.99));
  box-shadow: 0 26px 60px -22px rgba(0, 0, 0, 0.9);
  text-align: center;
  animation: fr-rise 260ms cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

.fr-card-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  text-align: left;
}

.fr-card-brand img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--fr-line-strong);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.fr-eyebrow {
  margin: 0 0 4px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fr-amber);
}

.fr-card h2 {
  margin: 0;
  font-size: clamp(1.6rem, 7vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f0f9ff;
}

.fr-card-brand h2 {
  font-size: clamp(1.35rem, 5vw, 1.7rem);
}

.fr-lead {
  margin: 0 0 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #bae6fd;
}

.fr-goal {
  display: grid;
  gap: 2px;
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.04));
  text-align: left;
}

.fr-goal span {
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--fr-amber);
}

.fr-goal strong {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  color: #fef3c7;
}

.fr-rules {
  margin: 0 0 16px;
  padding: 12px 0 0;
  border-top: 1px solid var(--fr-line);
  list-style: none;
  display: grid;
  gap: 7px;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--fr-muted);
}

.fr-rules li {
  position: relative;
  padding-left: 17px;
}

.fr-rules li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fr-cyan);
  box-shadow: 0 0 0 3px var(--fr-cyan-soft);
}

.fr-btn {
  width: 100%;
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #38bdf8, #a78bfa 55%, #f87171);
  color: #04121c;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 12px 28px -12px rgba(56, 189, 248, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 130ms ease, filter 150ms ease;
}

.fr-btn:hover {
  filter: brightness(1.05);
}

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

.fr-controls {
  margin: 12px 0 0;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--fr-muted);
}

.fr-score-final {
  margin: 10px 0 2px;
  font-size: clamp(2rem, 10vw, 2.8rem);
  font-weight: 800;
  color: var(--fr-amber);
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.45);
  font-variant-numeric: tabular-nums;
}

.fr-muted {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--fr-muted);
}

.fr-card-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.fr-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--fr-line);
  border-radius: 12px;
  color: var(--fr-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms ease, border-color 150ms ease;
}

.fr-link:hover {
  color: var(--fr-text);
  border-color: var(--fr-line-strong);
}

.fr-hide {
  display: none !important;
}

/* ---------- Motion ---------- */

@keyframes fr-rise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fr-low {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .fr-wrap {
    padding-inline: 9px;
    gap: 6px;
  }

  .fr-hud {
    gap: 4px;
  }

  .fr-chip {
    padding: 5px 6px;
  }

  .fr-chip .k {
    font-size: 0.46rem;
    letter-spacing: 0.08em;
  }

  .fr-chip .v {
    font-size: 0.9rem;
  }

  .fr-pad {
    min-height: 46px;
  }

  .fr-title {
    letter-spacing: 0.1em;
  }
}

@media (max-height: 720px) {
  .fr-hint {
    display: none;
  }
}

@media (max-height: 600px) {
  .fr-subtitle {
    display: none;
  }

  .fr-wrap {
    gap: 5px;
    padding-top: 6px;
  }

  .fr-pad {
    min-height: 44px;
  }
}

@media (min-width: 900px) {
  .fr-wrap {
    max-width: 380px;
    padding-top: 16px;
  }

  .fr-stage {
    border-radius: 22px;
  }
}
