:root {
  --bg: #05070d;
  --panel: rgba(13, 18, 30, 0.86);
  --panel-solid: #0d1220;
  --text: #e8ecf4;
  --dim: #9aa7bd;
  --accent: #8ab4ff;
  --amber: #ffd166;
  --line: rgba(255,255,255,0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#cam {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  background: #000;
}

#sky {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 1;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 16px;
  z-index: 5;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.hud-line { font-size: 13px; letter-spacing: 0.08em; text-shadow: 0 1px 4px rgba(0,0,0,0.9); }
.hud-line.dim { color: var(--dim); font-size: 11px; margin-top: 2px; }
.hud-label { color: var(--dim); margin-right: 4px; font-size: 11px; }
#hud-right { text-align: right; }

#btn-settings {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 5;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* ---------- Start overlay ---------- */
#start {
  position: fixed; inset: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(80,110,180,0.25), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, rgba(255,209,102,0.08), transparent 60%),
    var(--bg);
  padding: 24px;
}
.start-card {
  max-width: 380px; width: 100%;
  text-align: center;
}
.star-logo svg { width: 92px; height: 92px; filter: drop-shadow(0 4px 18px rgba(255,209,102,0.35)); }
.start-card h1 { margin-top: 14px; font-size: 30px; letter-spacing: 0.06em; }
.tagline { margin-top: 10px; color: var(--dim); font-size: 15px; line-height: 1.55; }
#btn-start {
  margin-top: 26px;
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  color: #10131c;
  background: linear-gradient(135deg, #ffd166, #ffb347);
  border: none;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(255,190,80,0.35);
  cursor: pointer;
}
.hint { margin-top: 16px; font-size: 12.5px; color: #c3cede; line-height: 1.5; }
.hint.dim { color: var(--dim); }
#sensor-note { color: var(--amber); }

/* ---------- Settings sheet ---------- */
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 15;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 72vh;
  overflow-y: auto;
  animation: slideup 0.22s ease;
}
@keyframes slideup { from { transform: translateY(40%); opacity: 0.4; } to { transform: none; opacity: 1; } }
.sheet-grab { width: 44px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.25); margin: 2px auto 12px; }
.sheet-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tg {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}
.tg input { accent-color: var(--accent); width: 15px; height: 15px; }
.tg:has(input:checked) { border-color: rgba(138,180,255,0.55); background: rgba(138,180,255,0.10); }

.ctrl { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.ctrl-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); }
.ctrl-row output { color: var(--text); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 26px; }

.loc-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 14px; }
#loc-label { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
}
#btn-sheet-close { width: 100%; margin-top: 6px; padding: 12px; font-weight: 600; }

.advanced details { margin-bottom: 10px; }
.advanced summary { font-size: 13px; color: var(--dim); cursor: pointer; margin-bottom: 8px; }
.advanced .toggles { margin: 8px 0; }

/* ---------- Info card ---------- */
#info {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  min-width: 240px; max-width: 86vw;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  pointer-events: none;
  text-align: center;
  animation: slideup 0.18s ease;
}
#info-name { font-size: 17px; font-weight: 700; color: var(--amber); }
#info-sub { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
#info-stats { margin-top: 8px; font-size: 12.5px; color: var(--text); line-height: 1.6; font-variant-numeric: tabular-nums; }

/* ---------- Loading / error ---------- */
#loading, #error {
  position: fixed; inset: 0;
  z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  color: var(--dim);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}
#error { color: #ff9d9d; }

@media (max-width: 480px) {
  .start-card h1 { font-size: 26px; }
  .tagline { font-size: 14px; }
}
