:root {
  --bg: #0b1220;
  --panel: rgba(15, 23, 42, 0.92);
  --panel-2: rgba(30, 41, 59, 0.88);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --line: rgba(148, 163, 184, 0.25);
  --accent: #22c55e;
  --accent-2: #16a34a;
  --fog: rgba(2, 6, 23, 0.78);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.98), rgba(2, 6, 23, 0.88));
  border-bottom: 1px solid var(--line);
}

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

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid transparent;
}

.badge.idle {
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.24);
}

.badge.tracking {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.28);
}

.badge.paused {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.28);
}

#mapShell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #0f172a;
}

#map {
  position: absolute;
  inset: 0;
}

.permission-hint {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 30;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: #fef3c7;
  box-shadow: var(--shadow);
}

.panel {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.94));
  border-top: 1px solid var(--line);
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-row-single {
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}

.field-select-wrap select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

.fixed-config-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fixed-card,
.stat-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.fixed-card strong,
.stat-card strong {
  display: block;
  color: var(--text);
}

.fixed-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
}

.button-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 10px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: rgba(34, 197, 94, 0.35);
  color: #052e16;
}

.btn-ghost {
  padding: 10px 12px;
}

.stats {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.message {
  margin: 12px 0 0;
  min-height: 20px;
  font-size: 13px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.map-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.fog-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.accuracy-circle {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.85);
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.08) inset;
}

.current-dot {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: #2563eb;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  z-index: 5;
}

@media (max-width: 560px) {
  .button-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
