* { box-sizing: border-box; }

body {
  color: white;
  font-family: sans-serif;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100dvh; /* Changed back to dvh to fix mobile browser bar hiding the UI */
  overflow: hidden; 
  background-color: #000;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* --- UI OVERLAYS --- */
#status-indicator {
  font-family: "Gochi Hand", cursive;
  letter-spacing: 5px;
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 15px;
  border-radius: 6px;
  font-size: 32px;
  z-index: 1000;
  pointer-events: none;
}

#intro-overlay {
  font-family: "Gochi Hand", cursive;
  letter-spacing: 10px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  text-align: center;
  font-size: 4vw;
  font-weight: bold;
  z-index: 1000;
  pointer-events: none; 
}

/* --- FLOATING LEFT TOOLBAR & ACCORDIONS --- */
#side-toolbar {
  position: absolute;
  padding-top: 20px;
  left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
  /* NEW: Enables scrolling and adds breathing room */
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding-bottom: 20px;
}

/* NEW: Hides the default scrollbar for a cleaner look */
#side-toolbar::-webkit-scrollbar {
  display: none;
}

.accordion-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.circle-btn {
  background-image: url('imgs/circle-btn.svg');
  border: 2px solid #000;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.2);
  transition: transform 0.1s;
}

.circle-btn:active { transform: translateY(2px); }
.circle-btn.active { border-color: #FFE100; }
.btn-icon { width: 22px; height: 22px; margin: 0; display: block; }

.circle-btn:hover{
  transform: translate(0px, -5px);
  transition: transform ease 0.2s;
}
.hidden { display: none !important; }

.color-btn {
  background-image: none !important;
}

/* --- DRAGGABLE FACE WIDGET --- */
#face-widget {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 9999; /* Fixed z-index so it doesn't trap the window */
}
.face-toggle-btn { width: 50px; height: 50px; }

#face-diagram{
  width: 150px;
  aspect-ratio: 3/4;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20000; /* Ensures the button is above the window */
}

#face-widget-window {
  position: absolute;
  bottom: 80px; /* Positions perfectly above the bottom-right button */
  right: 20px;
  top: auto;
  left: auto;
  z-index: 90; /* Must be higher than the widget to remain visible */
  width: 200px;
  display: flex;
  flex-direction: column;
}

.custom-window-bg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1; 
  pointer-events: none;
}

.fake-window-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 10px 0 0;
  cursor: grab; 
  min-height: 40px; 
}
.fake-window-header:active { cursor: grabbing; }

.close-btn { 
  background: none; border: none; cursor: pointer; pointer-events: auto; 
  display: flex; justify-content: center; align-items: center;
}
.popup-body { padding: 15px; display: flex; justify-content: center; pointer-events: none; }

/* --- FACE DIAGRAM STYLING --- */
.face-diagram-container { 
  width: 150px; 
  height: 200px; /* Force explicit height to stop flexbox collapse */
  display: flex; 
  justify-content: center; 
  align-items: center; 
  position: relative; 
  z-index: 10;        
}

.face-outline {
  position: absolute; /* Pin it so it doesn't get crushed */
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;
  border: none; 
  background-color: transparent;
  background-image: url('imgs/potatoface.svg');
  background-size: contain; 
  background-position: center; 
  background-repeat: no-repeat;
}
.face-point { 
  position: absolute; 
  cursor: pointer; 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  background-color: transparent; 
  border: none; 
  pointer-events: auto; 
}

.left-eye { top: 27%; left: 17%; width: 30%; height: 22%; }
.right-eye { top: 27%; right: 15%; width: 30%; height: 22%; }
.nose { top: 55%; left: 53%; transform: translate(-50%, -50%); width: 25%; height: 26%; }
.mouth { bottom: 17%; left: 54%; transform: translateX(-50%); width: 50%; height: 18%; }
.red-dot { width: 8px; height: 8px; background-color: red; border-radius: 50%; display: none; box-shadow: 0 0 5px red; }
.face-point.active .red-dot { display: block; }

/* --- CANVAS --- */
/* --- CANVAS & VIDEO --- */
#canvas-container { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100vw; 
  height: 100dvh; /* Use dynamic viewport height */
  z-index: 1; 
}

#video-wrapper { 
  position: relative; 
  width: 100%; 
  height: 100%; 
}

/* 1. Put the camera feed in the back */
#video-wrapper video { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100% !important; 
  height: 100% !important; 
  object-fit: cover; 
  z-index: 1; 
  transform: scaleX(-1); /* <-- THIS MIRRORS THE CAMERA VISUALLY */
}

/* style.css - Update these lines */
#video-wrapper canvas { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100% !important; 
  height: 100% !important; 
  object-fit: cover; 
  z-index: 2; 
  pointer-events: auto; /* Changed from none to auto */
}

/* --- ADD THIS TO FIX THE LAYERING --- */
#video-wrapper video {
  z-index: 1; /* Pushes the camera feed to the back */
}

#video-wrapper canvas {
  z-index: 2; /* Pulls the drawing layer to the front */
  pointer-events: none; /* Lets clicks pass through to UI if needed */
}
/* ------------------------------------ */


.mobile-only { display: none !important; }
.desktop-only { display: inline-block; }

@media screen and (max-width: 1024px) {
  .mobile-only { display: inline-block !important; } 
  .desktop-only { display: none !important; }
  
  #intro-overlay { 
    font-size: 6vw; 
    width: 60%;
    line-height: 1.2;
  }

  #status-indicator {
    top: 10px;
    right: 10px;
    font-size: 24px;
  }

  #side-toolbar {
    left: 10px;
    gap: 8px;
  }
}