:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --warn: #ffcc00;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 58px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: var(--bg-primary);
  border-bottom: 1px solid #22222e;
}
.app-title {
  font-size: 18px; font-weight: 700; letter-spacing: 3px;
  color: var(--text-primary);
}
.gps-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-secondary);
}
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-muted); display: inline-block;
}
.dot.ok   { background: var(--accent-secondary); box-shadow: 0 0 10px var(--accent-secondary); animation: pulse 1.6s ease-in-out infinite; }
.dot.demo { background: var(--accent);           box-shadow: 0 0 10px var(--accent);           animation: pulse 1.6s ease-in-out infinite; }
.dot.warn { background: var(--warn);             box-shadow: 0 0 10px var(--warn); }
.dot.bad  { background: var(--danger);           box-shadow: 0 0 10px var(--danger); }
.dot.muted{ background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ---------- Gauge ---------- */
.gauge-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.gauge { position: relative; width: 384px; height: 384px; }
.gauge svg { width: 100%; height: 100%; display: block; }

.g-track {
  fill: none; stroke: var(--bg-tertiary); stroke-width: 22;
  stroke-linecap: round; stroke-dasharray: 801 1068;
}
.g-fill {
  fill: none; stroke: currentColor; color: var(--accent); stroke-width: 22;
  stroke-linecap: round; stroke-dasharray: 801 1068; stroke-dashoffset: 801;
  filter: drop-shadow(0 0 6px currentColor);
}

.readout {
  position: absolute; left: 50%; top: 43%;
  transform: translate(-50%, -50%); text-align: center;
}
.speed-value {
  font-size: 104px; font-weight: 700; line-height: 1;
  letter-spacing: -3px; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px var(--focus-glow);
}
.speed-unit {
  font-size: 24px; color: var(--text-secondary);
  margin-top: 8px; letter-spacing: 2px; text-transform: uppercase;
}

.mini-stats {
  position: absolute; left: 50%; bottom: 19%;
  transform: translateX(-50%);
  display: flex; gap: 44px;
}
.mini-stats > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mini-label { font-size: 13px; color: var(--text-muted); letter-spacing: 1px; }
.mini-val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.scale {
  position: absolute; bottom: 4%;
  font-size: 14px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.scale-min { left: 17%; }
.scale-max { right: 17%; }

/* ---------- Nav bar ---------- */
.navbar {
  flex: 0 0 auto;
  display: flex; gap: 12px;
  padding: 16px 18px 22px;
  background: var(--bg-primary);
  border-top: 1px solid #22222e;
}
.navbtn {
  flex: 1; height: 88px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 18px; font-weight: 600;
}

/* ---------- Trip stats ---------- */
.stats-list {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  gap: 10px; padding: 18px 26px;
}
.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 14px 20px; min-height: 54px;
}
.stat-label { font-size: 17px; color: var(--text-secondary); }
.stat-num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Settings ---------- */
.settings-list {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  gap: 18px; padding: 22px 26px;
}
.group-label {
  font-size: 14px; color: var(--text-muted); letter-spacing: 1px;
  margin-bottom: 10px; text-transform: uppercase;
}
.unit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.unitbtn {
  height: 72px; border-radius: var(--radius-md);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 18px; font-weight: 600;
}
.unitbtn.selected { background: var(--bg-tertiary); color: var(--accent); }
.unitbtn.selected::after { content: ' \2713'; color: var(--accent); }

.rowbtn {
  min-height: 64px; width: 100%;
  border-radius: var(--radius-md);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 17px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 18px;
}
