body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
  /* Background Image */
  background-image: url('https://omniakashica.com/wp-content/uploads/2024/11/Designer-11.jpeg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed; /* Optional: keeps the background fixed while scrolling */
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Modal Styles */
.modal {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
  justify-content: center;
  align-items: center;
  z-index: 1000; /* Ensure it's on top of everything */
  /* Optional: Add animation */
  animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 500px;
  width: 90%;
  /* Ensure content doesn't get too wide on small screens, but can expand on larger ones */
  box-sizing: border-box; /* Include padding in the width calculation */
}

/* Optional: Fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

header {
  background-color: rgba(51, 51, 51, 0.1);
  color: #fff;
  text-align: center;
  padding: 0.25em 0; /* Reduced padding by 50% */
  width: 100%;
}

main {
  padding: 20px;
  max-width: 800px; /* Limit main content width */
  width: 100%;
  box-sizing: border-box; /* Include padding in the width calculation */
}

section {
  margin-bottom: 20px;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  text-align: center; /* Center content within sections */
  box-sizing: border-box; /* Include padding in the width calculation */
}

button {
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  margin: 5px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em; /* Ensure button text scales */
  white-space: nowrap; /* Prevent button text from wrapping unnaturally */
}

button:hover {
  background-color: #3e8e41;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hidden {
  display: none;
}

#captured-photo-display {
  border: 1px solid #ccc;
  margin-bottom: 10px;
  max-width: 100%; /* Make image responsive */
  height: auto; /* Maintain aspect ratio */
  display: block; /* Remove extra space below image */
}

#camera-stream {
  border: 1px solid #ccc;
  margin-bottom: 10px;
  max-width: 100%; /* Make video stream responsive */
  height: auto; /* Maintain aspect ratio */
  display: block; /* Remove extra space below video */
}

/* Updated to apply responsive styling to both camera-stream and the canvas */
#camera-stream,
#hand-input canvas {
  border: 1px solid #ccc;
  margin-bottom: 10px;
  max-width: 100%; /* Make responsive */
  height: auto; /* Maintain aspect ratio */
  display: block; /* Remove extra space below */
}

#hand-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.8); /* Set background to 70% transparency */
  width: fit-content; /* Adjust the width to fit its content */
  margin: 0 auto; /* Center the section horizontally */
  padding: 20px; /* Add padding for content inside the section */
  box-sizing: border-box; /* Include padding in width calculation */
  max-width: 90%; /* Prevent it from becoming too wide on very large screens */
}

/* Make the instruction text inside #hand-input white */
#hand-input p {
  color: white; /* Changed to white */
}

.controls {
  margin-top: 10px;
  text-align: center;
  display: flex; /* Added to make buttons inline */
  justify-content: center; /* Added to center buttons */
  gap: 10px; /* Added to provide space between buttons */
  flex-wrap: wrap; /* Allow buttons to wrap to the next line on smaller screens */
  margin-bottom: 15px; /* Added space for loading indicator */
}

/* New: Loading Indicator Styles */
#loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 10px;
  font-weight: bold;
  color: #ffffff; /* Changed to white */
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #4CAF50;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Style for the Results Modal */
#results-modal {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
  justify-content: center;
  align-items: center;
  z-index: 1001; /* Higher than other modals */
}

#results-modal .modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 500px;
  width: 90%;
  position: relative; /* For close button positioning */
  box-sizing: border-box;
}

/* Style for the Close Button */
#close-results {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 1.2em; /* Size of the house icon */
  color: #333; /* Ensure the color contrasts with the background */
}

#results-modal.show {
  display: flex; /* Show the modal */
}

/* New: Floating Home Button */
#floating-menu {
  position: fixed;
  bottom: 20px;
  left: 20px; /* Changed from right: 20px; */
  z-index: 999; /* Below modals which are 1000/1001 */
  display: flex; /* Use flexbox to arrange multiple buttons */
  flex-direction: column; /* Stack buttons vertically */
  gap: 10px; /* Space between buttons */
}

#floating-menu a {
  display: flex; /* Use flexbox to center content */
  justify-content: center;
  align-items: center;
  background-color: rgba(76, 175, 80, 0.1); /* Changed to 10% transparency */
  color: white;
  width: 60px; /* Fixed width for circular button */
  height: 60px; /* Fixed height for circular button */
  border-radius: 50%; /* Make it circular */
  text-decoration: none;
  font-size: 2em; /* Size of the house icon */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: background-color 0.3s ease, transform 0.2s ease; /* Add transform for subtle effects */
}

#floating-menu a:hover {
  background-color: #3e8e41;
  transform: scale(1.05); /* Slightly enlarge on hover */
}

#floating-menu a:active {
  transform: scale(0.95); /* Slightly shrink on click */
}

/* Media Queries for Responsiveness */
@media (max-width: 768px) {
  body {
    padding: 10px; /* Reduce padding on smaller screens */
  }

  main {
    padding: 10px;
  }

  section {
    padding: 15px; /* Adjust section padding */
  }

  .modal-content {
    width: 95%; /* Make modal content wider on small screens */
    padding: 15px;
  }

  button {
    padding: 8px 15px; /* Smaller padding for buttons */
    font-size: 0.9em; /* Slightly smaller font for buttons */
  }

  #hand-input p {
    font-size: 0.9em; /* Smaller text for instructions */
  }

  #floating-menu {
    bottom: 10px;
    right: 10px;
    gap: 8px; /* Slightly less space between buttons */
  }

  #floating-menu a {
    width: 50px; /* Smaller floating buttons */
    height: 50px;
    font-size: 1.8em; /* Adjust icon size */
  }
}

@media (max-width: 480px) {
  body {
    justify-content: flex-start; /* Align content to top on very small screens if needed */
  }

  header {
    padding: 0.5em 0; /* Adjust header padding */
  }

  .modal-content {
    padding: 10px;
  }

  #hand-input {
    padding: 15px;
  }

  .controls {
    flex-direction: column; /* Stack buttons vertically on very small screens */
    gap: 5px;
    align-items: stretch; /* Make buttons take full width of container */
  }

  button {
    width: auto; /* Allow buttons to adjust width */
    margin: 5px 0; /* Adjust vertical margin for stacked buttons */
  }

  #floating-menu {
    flex-direction: row; /* Arrange floating buttons horizontally at the bottom */
    width: 100%;
    justify-content: flex-start; /* Aligned buttons to the start (left) */
    align-items: center;
    bottom: 0;
    left: 0;
    padding: 5px 0;
    padding-left: 10px; /* Added padding to align buttons from the left edge */
    background-color: rgba(51, 51, 51, 0.8); /* Add background to floating menu */
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }

  #floating-menu a {
    width: 45px;
    height: 45px;
    font-size: 1.5em;
    box-shadow: none; /* Remove individual button shadow when grouped */
  }
}