:root {
  --bg: #08111d;
  --panel: rgba(10, 22, 42, 0.7);
  --panel-strong: rgba(10, 22, 42, 0.86);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #f6f8fb;
  --muted: #bfd0e4;
  --accent: #22c55e;
  --accent-2: #f59e0b;
  --accent-3: #38bdf8;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.14), transparent 30%),
    linear-gradient(180deg, #0b1930 0%, #06111f 100%);
  overflow: hidden;
}

#sceneMount,
.scene-fx {
  position: fixed;
  inset: 0;
}

#sceneMount {
  z-index: 0;
}

.scene-fx {
  z-index: 1;
  pointer-events: none;
}

canvas {
  display: block;
}

.speed-lines,
.vignette {
  position: absolute;
  inset: 0;
}

.speed-lines {
  opacity: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) 54px,
      rgba(255, 255, 255, 0.12) 56px,
      rgba(255, 255, 255, 0) 60px
    );
  mix-blend-mode: screen;
  transform: perspective(900px) rotateX(70deg) scale(1.2);
  transform-origin: center bottom;
  transition: opacity 160ms ease;
}

.vignette {
  background:
    radial-gradient(circle at center, rgba(0, 0, 0, 0) 56%, rgba(0, 0, 0, 0.28) 100%),
    linear-gradient(180deg, rgba(5, 10, 22, 0.38), transparent 24%, transparent 78%, rgba(5, 10, 22, 0.46));
}

.hud-shell {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2;
  pointer-events: none;
  padding: 16px;
}

.topbar,
.dashboard,
.bottom-overlay {
  pointer-events: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  background: linear-gradient(180deg, rgba(8, 20, 39, 0.92), rgba(8, 20, 39, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  padding: 18px 20px;
  backdrop-filter: blur(16px);
}

.topbar h1,
.fact-header h2 {
  margin: 6px 0;
}

.topbar p,
.controls-panel p,
.fact-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(56, 189, 248, 0.14);
  color: #d8efff;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-card,
.fact-panel,
.controls-panel {
  background: linear-gradient(180deg, rgba(10, 22, 42, 0.86), rgba(10, 22, 42, 0.66));
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(14px);
}

.stat-card {
  padding: 14px 16px;
  min-height: 106px;
}

.label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-size: 1.32rem;
  margin-top: 6px;
}

.speedometer {
  margin-top: 8px;
  width: 100%;
  max-width: 180px;
}

.speedometer-svg {
  display: block;
  width: 100%;
  height: auto;
}

.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 14;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 20 10;
  opacity: 0.95;
}

.gauge-needle {
  transform-origin: 110px 110px;
  transition: transform 120ms ease-out;
}

.gauge-needle line {
  stroke: #f97316;
  stroke-width: 6;
  stroke-linecap: round;
}

.gauge-center {
  fill: #f8fafc;
}

.gauge-mark {
  fill: #bfd0e4;
  font-size: 15px;
  font-weight: 700;
}

.sub {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.boost-track {
  margin-top: 10px;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.boost-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #22c55e, #f59e0b);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.5);
}

.boost-card strong {
  font-size: 1.1rem;
}

.bottom-overlay {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(330px, 0.9fr);
  gap: 14px;
  align-items: end;
}

.fact-panel,
.controls-panel {
  padding: 18px;
}

.fact-panel {
  box-shadow: 0 18px 45px rgba(5, 10, 22, 0.28);
}

.fact-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 8px;
}

.primary-btn {
  min-width: 132px;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: #04100a;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.26);
}

.quiz-wrap {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-btn,
.touch-btn {
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-weight: 800;
}

.option-btn {
  padding: 0 14px;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.touch-btn {
  cursor: pointer;
  font-size: 1.05rem;
  min-height: 56px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.touch-btn.accent {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.42);
}

.swipe-hint {
  color: #d3e7ff;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.14);
}

body.speed-fast .speed-lines {
  opacity: 0.2;
}

body.speed-boost .speed-lines {
  opacity: 0.42;
}

body.speed-boost .touch-btn.accent {
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
}

@media (max-width: 1200px) {
  .dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .dashboard,
  .bottom-overlay {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .hud-shell,
  .bottom-overlay {
    padding: 10px;
  }

  .topbar,
  .stat-card,
  .fact-panel,
  .controls-panel {
    border-radius: 18px;
  }

  .topbar h1 {
    font-size: 1.6rem;
  }

  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .touch-btn {
    min-height: 62px;
  }
}
