:root {
  --bg: #0a0e1a;
  --bg-card: #131825;
  --bg-card-2: #1a2030;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #fbbf24;
  --success: #22c55e;
  --warning: #fb923c;
  --error: #ef4444;
  --border: rgba(255, 255, 255, 0.08);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 4px;
}

header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.status {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-card);
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.status.ok { color: var(--success); border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.05); }
.status.error { color: var(--error); border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.05); }
.status.warn { color: var(--warning); border-color: rgba(251, 146, 60, 0.3); background: rgba(251, 146, 60, 0.05); }

.screen { display: flex; flex-direction: column; gap: 14px; }
.screen.hidden { display: none; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.welcome p { margin-bottom: 12px; color: var(--text-muted); }
.welcome ul { padding-left: 4px; line-height: 1.9; list-style: none; margin-bottom: 16px; }
.welcome .muted { font-size: 0.875rem; }
.welcome .small { font-size: 0.75rem; margin-top: 12px; text-align: center; }

.card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Compass */
.compass {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 16px;
}

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

#rose {
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#target-group {
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#current-line, #target-line {
  transition: x2 0.3s ease-out, y2 0.3s ease-out, stroke 0.2s;
}

.compass-card.aligned #target-group circle {
  filter: drop-shadow(0 0 8px var(--success));
}

.compass-card.aligned #target-group circle:first-child {
  r: 11;
}

/* Efficiency display */
.efficiency-display {
  text-align: center;
  margin: 4px auto 18px;
  max-width: 280px;
}
.eff-pct {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text-muted);
  transition: color 0.2s;
}
.eff-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  margin: 10px 0 6px;
  overflow: hidden;
}
.eff-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #fb923c 35%, #fbbf24 60%, #22c55e 90%);
  border-radius: 3px;
  width: 0%;
  transition: width 0.2s;
}
.eff-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Tilt visual */
.tilt-visual {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 16px;
}

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

.tilt-card.aligned #current-line {
  stroke: var(--success);
  filter: drop-shadow(0 0 6px var(--success));
}

/* Readings */
.readings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reading {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
}

.reading .value {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.reading .label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
  font-weight: 600;
}

.reading.sep {
  flex: 0;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.aligned .reading .value { color: var(--success); }

/* Info grid */
.info-grid {
  display: grid;
  gap: 0;
}

.info-grid > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.info-grid > div:last-child { border-bottom: none; }

.info-grid .label { color: var(--text-muted); font-weight: 500; }
.info-grid span:not(.label) { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Mode toggle */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 12px 8px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn:active { transform: scale(0.97); }

.mode-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.mode-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin-top: 4px;
}

/* Buttons */
.btn-primary, .btn-secondary {
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}

.btn-primary { background: var(--accent); color: var(--bg); }
.btn-secondary { background: var(--bg-card-2); color: var(--text); border: 1px solid var(--border); }

.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }

.btn-primary:disabled { opacity: 0.5; cursor: wait; }

.actions-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.actions-card button { margin-top: 0; }

.muted { color: var(--text-muted); }

.version-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.55;
  padding: 12px 0 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
