* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Arial", sans-serif;
  background-color: white;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
  text-align: center;
  width: 100%;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: 1.5rem;
  color: #2c3e50;
  padding: 0 10px;
}

h2 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  margin-bottom: 1rem;
  color: #34495e;
}

/* Main page options */
.options-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding: 0 10px;
}

.option-card {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 15px;
  padding: 1.5rem;
  width: 100%;
  max-width: 300px;
  min-width: 280px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.option-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.option-card p {
  margin-bottom: 1.5rem;
  color: #6c757d;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  min-height: 44px; /* Touch-friendly minimum size */
  min-width: 44px;
  touch-action: manipulation; /* Prevent zoom on double-tap */
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-secondary {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.btn-tertiary {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Touch devices - remove hover effects */
@media (hover: none) {
  .btn:hover {
    transform: none;
    box-shadow: none;
  }

  .option-card:hover {
    transform: none;
    box-shadow: none;
  }
}

/* Camera container */
.camera-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1rem auto;
  width: 100%;
  max-width: 500px;
}

/* Updated camera preview - bigger for all devices */
.camera-preview {
  width: 300px; /* Increased from 270px */
  height: 500px; /* Increased from 450px */
  max-height: 80vh; /* Limit height to 80% of viewport */
  border-radius: 150px; /* Adjusted for new size */
  border: 4px solid #2c3e50;
  object-fit: cover;
  background: #000;
  position: relative;
  overflow: hidden;
  transform: scaleX(-1); /* Mirror the camera like a selfie */
}

.camera-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
  transition: background-color 0.3s ease;
}

/* Countdown overlay inside camera */
.countdown-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  pointer-events: none;
}

.countdown-overlay .countdown {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: bold;
  color: #ffffff;
  border-radius: 50%;
  width: clamp(80px, 20vw, 120px);
  height: clamp(80px, 20vw, 120px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Move closer message overlay - positioned above progress bar */
.move-closer-overlay {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 101;
  pointer-events: none;
  width: 60%;
  max-width: 200px;
}

.move-closer-message {
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #17a2b8, #138496);
  padding: 6px 12px;
  border-radius: 12px;
  white-space: nowrap;
  text-align: center;
  margin-bottom: 8px;
}

/* Meter container overlay - positioned below move closer text */
.meter-overlay {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
  width: 60%;
  max-width: 200px;
  padding: 8px 12px;
  border-radius: 8px;
}

/* Status messages */
.status-container {
  margin: 1rem 0;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.status-message {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: bold;
  margin-bottom: 1rem;
  text-align: center;
  word-wrap: break-word;
}

.countdown {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: bold;
  color: #e74c3c;
}

/* Hide original countdown when using overlay */
.countdown.hidden-for-overlay {
  display: none !important;
}

.proximity-meter {
  width: 100%;
  height: 20px;
  border-radius: 10px;
  background: #ecf0f1;
  border: 1px solid #bdc3c7;
}

.proximity-meter::-webkit-meter-bar {
  background: #ecf0f1;
  border-radius: 10px;
  border: none;
}

.proximity-meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  border-radius: 10px;
}

.proximity-meter::-moz-meter-bar {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  border-radius: 10px;
}

.meter-label {
  font-size: clamp(0.7rem, 1.8vw, 0.8rem);
  color: #ffffff;
  margin-top: 4px;
  text-align: center;
  font-weight: 500;
}

/* Responsive adjustments for move closer and meter overlays */
@media (max-width: 768px) {
  .move-closer-overlay {
    top: 10%;
    width: 50%;
    max-width: 160px;
  }

  .move-closer-message {
    font-size: clamp(0.7rem, 2.2vw, 0.9rem);
    padding: 5px 10px;
  }

  .meter-overlay {
    top: 15%;
    width: 50%;
    max-width: 160px;
    padding: 6px 10px;
  }

  .proximity-meter {
    height: 16px;
  }

  .meter-label {
    font-size: 0.7rem;
    margin-top: 3px;
  }

  /* Tablet size camera - bigger than original */
  .camera-preview {
    width: 280px; /* Increased from 245px */
    height: 460px; /* Increased from 400px */
    border-radius: 140px; /* Adjusted for new size */
  }

  .camera-container {
    max-width: 320px;
  }
}

@media (max-width: 480px) {
  /* Mobile phones - much bigger camera */
  .camera-preview {
    width: 280px; /* Significantly increased from 220px */
    height: 460px; /* Significantly increased from 350px */
    border-width: 3px;
    border-radius: 140px; /* Adjusted for new size */
  }

  /* Adjust container to accommodate larger camera */
  .camera-container {
    max-width: 320px; /* Increased to fit larger camera */
  }

  /* Adjust overlay positions for larger camera */
  .move-closer-overlay {
    top: 8%; /* Adjusted position */
    width: 55%; /* Slightly larger for better visibility */
    max-width: 180px;
  }

  .move-closer-message {
    font-size: clamp(0.65rem, 2vw, 0.8rem);
    padding: 4px 8px;
  }

  .meter-overlay {
    top: 13%; /* Adjusted position */
    width: 55%; /* Slightly larger for better visibility */
    max-width: 180px;
    padding: 5px 8px;
  }

  .proximity-meter {
    height: 14px;
  }

  .meter-label {
    font-size: 0.65rem;
    margin-top: 2px;
  }
}

/* Very small phones - still keep camera reasonably large */
@media (max-width: 360px) {
  .camera-preview {
    width: 260px; /* Still larger than original */
    height: 420px; /* Still larger than original */
    border-radius: 130px;
  }

  .camera-container {
    max-width: 300px;
  }
}

/* Ultra-wide mobile screens */
@media (max-width: 480px) and (min-height: 700px) {
  .camera-preview {
    width: 300px; /* Even larger for tall screens */
    height: 480px; /* Even taller for tall screens */
    border-radius: 150px;
  }

  .camera-container {
    max-width: 340px;
  }
}

/* Controls */
.controls {
  margin: 1.5rem 0;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 10px;
}

.control-btn {
  padding: 12px 20px;
  border: 2px solid #3498db;
  background: white;
  color: #3498db;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

.control-btn:hover {
  background: #3498db;
  color: white;
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Label selection */
.label-selection {
  margin: 1.5rem 0;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 10px;
}

.label-btn {
  padding: 15px 30px;
  border: 3px solid transparent;
  border-radius: 10px;
  font-size: clamp(1rem, 2.8vw, 1.1rem);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 44px;
  min-width: 120px;
  touch-action: manipulation;
}

.label-btn.alive {
  background: #2ecc71;
  color: white;
}

.label-btn.spoof {
  background: #e74c3c;
  color: white;
}

.label-btn.selected {
  border-color: #2c3e50;
  transform: scale(1.05);
}

/* Results */
.result-container {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 15px;
  border: 2px solid #e9ecef;
  margin-left: 10px;
  margin-right: 10px;
}

.result-message {
  font-size: clamp(1.2rem, 3.5vw, 1.5rem);
  font-weight: bold;
  margin-bottom: 1rem;
}

.result-alive {
  color: #2ecc71;
}

.result-spoof {
  color: #e74c3c;
}

/* Navigation */
.nav-container {
  margin: 1rem 0;
  padding: 0 10px;
}

.nav-btn {
  background: #6c757d;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.3s ease;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  min-height: 44px;
  touch-action: manipulation;
}

.nav-btn:hover {
  background: #5a6268;
}

/* Responsive design adjustments for smaller elements */
@media (max-width: 480px) {
  .container {
    padding: 5px;
  }

  .options-container {
    gap: 0.5rem;
    margin-top: 1rem;
  }

  .option-card {
    padding: 1rem;
    min-width: 250px;
  }

  .controls {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .label-selection {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .label-btn {
    width: 100%;
    max-width: 200px;
  }

  .btn {
    width: 100%;
    max-width: 250px;
  }

  .result-container {
    margin-left: 5px;
    margin-right: 5px;
    padding: 1rem;
  }

  .move-closer-message {
    font-size: 0.9rem;
    padding: 6px 12px;
    white-space: normal;
    line-height: 1.2;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .camera-preview {
    width: 300px; /* Increased from 270px */
    height: 500px; /* Increased from 450px */
    border-radius: 150px;
  }

  .options-container {
    gap: 1.5rem;
  }
}

/* Large screens */
@media (min-width: 1025px) {
  .container {
    padding: 20px;
  }

  .camera-preview {
    width: 300px; /* Increased from 270px */
    height: 500px; /* Increased from 450px */
    border-radius: 150px;
  }
}

/* Landscape orientation on mobile - optimize for horizontal space */
@media (max-width: 768px) and (orientation: landscape) {
  .countdown-overlay .countdown {
    width: clamp(60px, 15vh, 100px);
    height: clamp(60px, 15vh, 100px);
    font-size: clamp(2rem, 6vh, 3rem);
  }

  h1 {
    font-size: clamp(1.5rem, 5vh, 2rem);
    margin-bottom: 1rem;
  }

  .status-message {
    font-size: clamp(1rem, 4vh, 1.3rem);
  }

  .camera-preview {
    width: 240px; /* Smaller width for landscape */
    height: 380px; /* Smaller height for landscape */
    border-radius: 120px;
  }

  .camera-container {
    max-width: 280px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .camera-preview {
    border-width: 2px;
  }

  .btn,
  .label-btn,
  .nav-btn {
    border-width: 1px;
  }
}

/* Hidden class */
.hidden {
  display: none !important;
}

/* Loading spinner */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: clamp(30px, 8vw, 40px);
  height: clamp(30px, 8vw, 40px);
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.btn:focus,
.label-btn:focus,
.nav-btn:focus,
.control-btn:focus {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}

/* Ensure text is readable on all backgrounds */
.status-message,
.result-message {
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

/* Label Selection Page Styles */
.helper-text {
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  color: #6c757d;
  margin-bottom: 2rem;
  text-align: center;
}

.label-selection-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 2rem 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.label-option-card {
  background: #f8f9fa;
  border: 3px solid #e9ecef;
  border-radius: 15px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  touch-action: manipulation;
}

.label-option-card:hover {
  border-color: #3498db;
  background: #f1f8ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

.label-option-card:focus {
  outline: none;
  border-color: #3498db;
  background: #f1f8ff;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.label-option-card.selected {
  border-color: #2ecc71;
  background: #f0fff4;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.2);
}

.label-option-card.selected:hover {
  border-color: #27ae60;
  background: #e8f8f0;
}

.label-option-content {
  flex: 1;
  text-align: left;
}

.label-option-content h3 {
  font-size: clamp(1.2rem, 3vw, 1.4rem);
  font-weight: bold;
  margin: 0 0 0.5rem 0;
  color: #2c3e50;
}

.label-option-content p {
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  color: #6c757d;
  margin: 0;
  line-height: 1.4;
}

.label-option-indicator {
  width: 24px;
  height: 24px;
  border: 2px solid #bdc3c7;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  margin-left: 1rem;
  transition: all 0.3s ease;
}

.label-option-card.selected .label-option-indicator {
  border-color: #2ecc71;
  background: #2ecc71;
}

.label-option-card.selected .label-option-indicator::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
}

.error-message {
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 1rem 0;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  text-align: center;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Touch devices - remove hover effects */
@media (hover: none) {
  .label-option-card:hover {
    transform: none;
    box-shadow: none;
    border-color: #e9ecef;
    background: #f8f9fa;
  }

  .label-option-card.selected:hover {
    border-color: #2ecc71;
    background: #f0fff4;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.2);
  }
}

/* Responsive design for label selection */
@media (min-width: 768px) {
  .label-selection-page {
    flex-direction: row;
    gap: 1.5rem;
  }

  .label-option-card {
    flex: 1;
    flex-direction: column;
    text-align: center;
    min-height: 120px;
    padding: 2rem 1.5rem;
  }

  .label-option-content {
    text-align: center;
  }

  .label-option-indicator {
    margin-left: 0;
    margin-top: 1rem;
  }
}

@media (max-width: 480px) {
  .label-option-card {
    padding: 1rem;
    min-height: 70px;
  }

  .label-option-content h3 {
    font-size: 1.1rem;
  }

  .label-option-content p {
    font-size: 0.9rem;
  }

  .label-option-indicator {
    width: 20px;
    height: 20px;
    margin-left: 0.5rem;
  }

  .label-option-card.selected .label-option-indicator::after {
    width: 6px;
    height: 6px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .label-option-card {
    border-width: 2px;
  }

  .label-option-card.selected {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .label-option-card {
    transition: none;
  }

  .label-option-indicator {
    transition: none;
  }
}
