:root {
  --bg-primary: #000000; /* pure black = transparent on additive display, real world shows through */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

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

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

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

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 600; flex: 1; }
.header-meta { font-size: 14px; color: var(--text-secondary); }
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}
.status-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(255, 170, 0, 0.18);
  color: var(--warning);
}
.status-pill.ok { background: rgba(0, 255, 136, 0.18); color: var(--success); }
.status-pill.bad { background: rgba(255, 68, 102, 0.18); color: var(--danger); }

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Focus States (critical for EMG/D-pad) --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Navigation Bar --- */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.danger { background: rgba(255, 68, 102, 0.22); color: var(--danger); }

/* ==================== SPEED SCREEN ==================== */
.speed-content {
  align-items: center;
  justify-content: center;
  gap: 22px;
}

/* Circular speed gauge — conic-gradient fill, GPU-friendly */
.gauge {
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent-primary) 0deg, var(--bg-tertiary) 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease;
}
.gauge-inner {
  width: 264px;
  height: 264px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.speed-value {
  font-size: 110px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.speed-unit {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-primary);
  margin-top: 6px;
  letter-spacing: 1px;
}

.stat-row { display: flex; gap: 10px; width: 100%; }
.stat {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
}
.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.stat-val {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-secondary);
}

/* ==================== COMPASS SCREEN ==================== */
/* Reuses the big speed-gauge layout. Bright colors — dark grays are ~invisible
   on the additive display. */
.compass-gauge {
  background: none;
  border: 8px solid rgba(255, 255, 255, 0.6);
  position: relative;
}
.compass-gauge .speed-value { font-size: 96px; color: var(--accent-primary); }
.compass-gauge .speed-unit { font-size: 40px; font-weight: 800; color: var(--text-primary); }
/* The rose rotates so N sits at the real bearing as you turn your head */
.compass-rose {
  position: absolute;
  inset: 0;
  transition: transform 0.12s linear;
}
.rose-mark {
  position: absolute;
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  transform: translate(-50%, -50%);
}
.rose-n { top: 16px; left: 50%; color: var(--danger); }
.rose-s { bottom: 16px; left: 50%; transform: translate(-50%, 50%); }
.rose-e { right: 14px; top: 50%; transform: translate(50%, -50%); }
.rose-w { left: 14px; top: 50%; }
.compass-debug {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ==================== TRIP / DETAILS ==================== */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.card-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.card-value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-primary);
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 15px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

.hidden { display: none !important; }
