html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0b0b;
}

#c {
  width: 100vw;
  height: 100vh;
  display: block;
}

#webcam {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;     /* fill the screen like a background */
  transform: scaleX(-1); /* mirror like a selfie view (optional) */
  z-index: 0;
}

#c {
  position: fixed;
  inset: 0;
  z-index: 1;            /* canvas above video */
}

#ui {
  z-index: 2;            /* UI above both */
}


#ui {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 12px 12px;
  border-radius: 12px;
  color: #fff;
  background: rgba(0,0,0,0.60);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  width: min(520px, calc(100vw - 24px));
}

/* Finger cursor overlay */
#fingerCursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  transform: translate(-9999px, -9999px); /* hidden until first update */
  pointer-events: none;
  z-index: 3; /* above canvas + video + UI */
}

#fingerCursor svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

#fingerCursor .outer {
  fill: none;
  stroke: #2f6bff;
  stroke-width: 6;
  opacity: 0.95;
}

#fingerCursor .inner {
  fill: none;
  stroke: #2f6bff;
  stroke-width: 12;
  opacity: 0;              /* hidden until arming */
  stroke-linecap: round;

  /* dash animation setup (JS sets dasharray/dashoffset) */
  transition: stroke-dashoffset 200ms linear, opacity 80ms linear;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/* when arming, show the inner ring */
#fingerCursor.arming .inner {
  opacity: 0.95;
}


.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

button {
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
}

label { font-size: 14px; display: inline-flex; gap: 8px; align-items: center; }
.checkbox { opacity: 0.95; }

#status {
  margin-top: 4px;
  font-size: 14px;
  opacity: 0.95;
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.35;
}

/* Tuning panel */
#tuning {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.15);
}

#tuning summary {
  cursor: pointer;
  font-size: 14px;
  opacity: 0.95;
  user-select: none;
}

.tuningGrid {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.tuningSectionTitle {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.8;
}

.tuningGrid label {
  display: grid;
  grid-template-columns: 110px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.tuningGrid input[type="range"] {
  width: 100%;
}

.val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.95;
}
/* Bottom mode bar */
#modeBar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.modeBtn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
}

.modeBtn.active {
  outline: 2px solid rgba(255,255,255,0.35);
}

#modeHint {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.2;
  margin-left: auto;
  max-width: 520px;
}

/* Finger “mouse cursor” shown only over the UI bar area */
#mouseCursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  transform: translate(-9999px, -9999px);
  pointer-events: none;
  z-index: 25;
  display: none;
}

#mouseCursor svg {
  width: 100%;
  height: 100%;
}

#mouseCursor path {
  fill: rgba(255,255,255,0.95);
  stroke: rgba(0,0,0,0.55);
  stroke-width: 1.2;
}
