* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background: #050505; font-family: 'Segoe UI', Arial, sans-serif; }

/* =====================
   WEBCAM WRAP
   ===================== */
#webcam-wrap {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 20;
}
#webcam {
  width: 200px;
  height: 150px;
  border: 2px solid rgba(0,255,180,0.5);
  border-radius: 10px;
  transform: scaleX(-1);
  background: #111;
  display: block;
}
#landmark-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 200px;
  height: 150px;
  border-radius: 10px;
  pointer-events: none;
}
#cam-label {
  text-align: center;
  color: rgba(0,255,180,0.7);
  font-size: 0.7rem;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* =====================
   GESTURE GUIDE
   ===================== */
#guide {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
}
.g-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 6px 12px;
  transition: all 0.25s ease;
  backdrop-filter: blur(6px);
}
.g-item.active {
  border-color: rgba(0,255,180,0.65);
  background: rgba(0,255,180,0.09);
  box-shadow: 0 0 14px rgba(0,255,180,0.3);
}
.g-icon { font-size: 1.2rem; width: 22px; text-align: center; }
.g-text { font-size: 0.7rem; color: rgba(255,255,255,0.5); line-height: 1.4; }
.g-text b { color: rgba(255,255,255,0.85); font-weight: 600; display: block; }
.g-item.active .g-text { color: rgba(255,255,255,0.85); }

/* =====================
   CONFIDENCE BAR
   ===================== */
#conf-wrap {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
#conf-label {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.3);
  letter-spacing: 1px;
}
#conf-bar-bg {
  width: 110px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}
#conf-bar {
  height: 4px;
  background: linear-gradient(90deg,#00ffb4,#00cfff);
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s ease;
}

/* =====================
   LOCK RING
   ===================== */
#lock-ring {
  position: absolute;
  bottom: 178px;
  left: 30px;
  z-index: 20;
  pointer-events: none;
}

/* =====================
   ERROR MESSAGE
   ===================== */
#error-msg {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  color: #ff4444;
  background: rgba(0,0,0,0.85);
  padding: 24px 32px;
  border-radius: 12px;
  font-size: 15px;
  display: none;
  text-align: center;
  z-index: 100;
  border: 1px solid rgba(255,68,68,0.3);
  max-width: 90vw;
}

/* =====================
   BACK BUTTON
   ===================== */
#back-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
  letter-spacing: 0.5px;
}
#back-btn:hover {
  background: rgba(0,255,180,0.1);
  border-color: rgba(0,255,180,0.5);
  color: #00ffb4;
}

/* =====================
   GUIDE TOGGLE BUTTON (mobile/tablet)
   ===================== */
#guide-toggle {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  padding: 7px 14px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
}
#guide-toggle:hover, #guide-toggle.active {
  background: rgba(0,255,180,0.1);
  border-color: rgba(0,255,180,0.5);
  color: #00ffb4;
}

/* =====================
   TABLET (≤ 768px)
   ===================== */
@media (max-width: 768px) {

  /* Webcam — pindah ke bawah tengah agar tangan lebih mudah diarahkan */
  #webcam-wrap {
    bottom: 70px;
    top: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  #webcam {
    width: 180px;
    height: 135px;
  }
  #landmark-canvas {
    width: 180px;
    height: 135px;
  }

  /* Lock ring tepat di atas webcam wrap */
  #lock-ring {
    bottom: 213px;
    left: 50%;
    top: auto;
    transform: translateX(-50%);
  }

  /* Guide — tersembunyi by default, tampil saat toggle */
  #guide-toggle { display: block; }

  #guide {
    top: 0; right: 0;
    transform: none;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(12px);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 80px 24px 24px;
    display: none;
    pointer-events: all;
  }
  #guide.open {
    display: flex;
  }
  .g-item {
    width: 100%;
    max-width: 340px;
    padding: 10px 16px;
    pointer-events: all;
  }
  .g-icon { font-size: 1.4rem; }
  .g-text { font-size: 0.78rem; }

  /* Confidence bar — di atas webcam wrap, tengah */
  #conf-wrap {
    bottom: 218px;
    right: 50%;
    transform: translateX(50%);
    align-items: center;
  }
  #conf-bar-bg { width: 150px; }
}

/* =====================
   MOBILE (≤ 480px)
   ===================== */
@media (max-width: 480px) {

  #webcam-wrap {
    bottom: 60px;
  }
  #webcam {
    width: 140px;
    height: 105px;
  }
  #landmark-canvas {
    width: 140px;
    height: 105px;
  }

  /* Lock ring */
  #lock-ring {
    bottom: 173px;
  }

  /* Confidence bar */
  #conf-wrap {
    bottom: 178px;
  }
  #conf-bar-bg { width: 120px; }

  .g-item { max-width: 290px; }
  .g-icon { font-size: 1.2rem; }
  .g-text { font-size: 0.72rem; }

  #back-btn { font-size: 0.72rem; padding: 6px 11px; }
  #guide-toggle { font-size: 0.72rem; padding: 6px 11px; }
}
