:root {
  --bg: #05080a;
  --neon: #39ff14;
  --neon-dim: rgba(57, 255, 20, 0.35);
  --cyan: #00e5ff;
  --amber: #ff9f1c;
  --panel: rgba(6, 14, 10, 0.55);
  --panel-brd: rgba(57, 255, 20, 0.28);
  --txt: #d6ffe0;
  --txt-dim: #6f8f7a;
  --danger: #ff3b3b;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: "Share Tech Mono", ui-monospace, monospace;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: block;
}

/* ---------- Camera + overlay ---------- */
#cam, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#cam {
  object-fit: cover;
  background: #000;
}
#overlay {
  pointer-events: none;
  z-index: 2;
}

/* ---------- Aesthetic FX ---------- */
.fx-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.16) 0px,
    rgba(0, 0, 0, 0.16) 1px,
    transparent 2px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}
.fx-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

/* ---------- Top HUD ---------- */
.hud-top {
  position: absolute;
  z-index: 5;
  top: 0; left: 0; right: 0;
  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, 4, 0.7), transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 18px;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.45);
}
.brand-mark { color: var(--neon); animation: pulse 2.2s infinite; }
.brand-name .thin { color: var(--neon); margin-left: 4px; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
  padding: 5px 10px;
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.pill-k { font-size: 9px; letter-spacing: 1.5px; color: var(--txt-dim); }
.pill-v { font-size: 16px; font-weight: 700; color: var(--neon); line-height: 1.1; }
#pillStatus.live {
  color: var(--neon);
  position: relative;
}
#pillStatus.live::after {
  content: "";
  position: absolute;
  right: -10px; top: 50%;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  transform: translateY(-50%);
  box-shadow: 0 0 8px var(--danger);
  animation: blink 1s steps(2) infinite;
}

/* ---------- Control dock ---------- */
.dock {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(680px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(57, 255, 20, 0.05);
}
.dock-row { display: flex; align-items: center; gap: 10px; }
.dock-buttons { flex-wrap: wrap; }

.btn {
  appearance: none;
  cursor: pointer;
  font-family: "Share Tech Mono", monospace;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--txt);
  background: rgba(10, 22, 16, 0.8);
  border: 1px solid var(--panel-brd);
  border-radius: 10px;
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.06s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--neon); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  flex: 1 1 150px;
  justify-content: center;
  font-weight: 700;
  color: #03130a;
  background: linear-gradient(180deg, #5dff3c, #2ad60f);
  border-color: transparent;
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.35);
}
.btn-primary .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #03130a;
}
.btn-primary[data-on="1"] {
  background: linear-gradient(180deg, #ff6a6a, #e02424);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 59, 59, 0.4);
}
.btn-primary[data-on="1"] .dot { background: #fff; animation: blink 1s steps(2) infinite; }

.btn-toggle[data-on="1"] {
  color: #03130a;
  background: linear-gradient(180deg, #6df0ff, #00cfe8);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.4);
}

/* tuning row */
.dock-tune { justify-content: space-between; flex-wrap: wrap; }
.slider-wrap { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; }
.slider-label { font-size: 11px; letter-spacing: 1px; color: var(--txt-dim); }
.slider-label b { color: var(--neon); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--neon), rgba(57, 255, 20, 0.15));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #eafff0;
  border: 3px solid var(--neon);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.6);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #eafff0;
  border: 3px solid var(--neon);
  cursor: pointer;
}

.toggles { display: flex; gap: 14px; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--txt-dim); cursor: pointer; }
.chk input { accent-color: var(--neon); width: 16px; height: 16px; }
.chk span { letter-spacing: 1px; }

/* ---------- Boot overlay ---------- */
.boot {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(8, 20, 14, 0.7), rgba(2, 5, 4, 0.92));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
}
.boot.hidden { opacity: 0; pointer-events: none; }
.boot-card {
  text-align: center;
  padding: 28px 26px;
  border: 1px solid var(--panel-brd);
  border-radius: 16px;
  background: var(--panel);
  max-width: 360px;
  width: calc(100% - 48px);
}
.boot-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 22px;
  color: var(--neon);
  text-shadow: 0 0 16px rgba(57, 255, 20, 0.5);
  margin-bottom: 8px;
}
.boot-msg { font-size: 13px; color: var(--txt); margin-bottom: 14px; line-height: 1.5; }
.boot.error .boot-msg { color: #ffb4b4; }
.boot-start {
  width: 100%;
  justify-content: center;
  margin: 2px 0 14px;
  font-size: 15px;
  padding: 14px 16px;
}
.boot-start .cam-ico { font-size: 16px; line-height: 1; }
.boot-foot { font-size: 10px; letter-spacing: 1px; color: var(--txt-dim); }
.spinner {
  width: 42px; height: 42px;
  margin: 0 auto 16px;
  border: 3px solid rgba(57, 255, 20, 0.2);
  border-top-color: var(--neon);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0.15; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .brand-name { font-size: 15px; }
  .pill { min-width: 50px; padding: 4px 7px; }
  .pill-v { font-size: 14px; }
  .dock { width: calc(100% - 16px); border-radius: 14px; }
  .btn { font-size: 13px; padding: 12px; }
  .btn-toggle { flex: 1 1 100%; justify-content: center; }
}

@media (min-width: 561px) and (max-width: 900px) {
  .btn-toggle { flex: 1 1 auto; }
}
