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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #eee;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

#secret-toggle {
  display: inline-block;
  transition: transform 0.2s ease;
  cursor: default;
  user-select: none;
}

#status {
  font-size: 0.9rem;
  color: #888;
  font-weight: 400;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Video Container */
#video-container {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4/3;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#distance-display {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2.5rem;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  color: #666;
  text-shadow: 0 0 20px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.3);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

/* Hero Button */
.hero-button {
  width: 100%;
  padding: 1.25rem 2rem;
  font-size: 1.25rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  color: #fff;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 64px;
  position: relative;
  overflow: hidden;
}

.hero-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.hero-button:hover:not(:disabled)::before {
  left: 100%;
}

.hero-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 212, 255, 0.4);
}

.hero-button:active:not(:disabled) {
  transform: translateY(0);
}

.hero-button:disabled {
  background: linear-gradient(135deg, #2a2a3e 0%, #1a1a2e 100%);
  color: #666;
  cursor: not-allowed;
  box-shadow: none;
}

.hero-button.active {
  background: linear-gradient(135deg, #ff4757 0%, #cc3344 100%);
  box-shadow: 0 4px 16px rgba(255, 71, 87, 0.3);
}

.hero-button.active:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(255, 71, 87, 0.4);
}

.button-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.button-text {
  line-height: 1;
}

/* Collapsible Sections */
.collapsible-section {
  background: rgba(22, 33, 62, 0.6);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.3s;
}

.collapsible-section:hover {
  background: rgba(22, 33, 62, 0.8);
}

.section-toggle {
  width: 100%;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: #eee;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s;
  text-align: left;
}

.section-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.toggle-icon {
  font-size: 0.875rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: #00d4ff;
  font-weight: bold;
}

.section-toggle.expanded .toggle-icon {
  transform: rotate(90deg);
}

.toggle-text {
  flex: 1;
}

.badge {
  background: #00d4ff;
  color: #1a1a2e;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 1.25rem;
}

.section-content.expanded {
  max-height: 800px;
  padding: 0 1.25rem 1.25rem;
}

/* Button Styles */
.button-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

button:not(.hero-button):not(.section-toggle) {
  flex: 1;
  padding: 0.875rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  background: rgba(15, 52, 96, 0.8);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

button:not(.hero-button):not(.section-toggle):hover:not(:disabled) {
  background: rgba(26, 74, 122, 0.9);
  transform: translateY(-1px);
}

button:not(.hero-button):not(.section-toggle):active:not(:disabled) {
  transform: translateY(0);
}

button:not(.hero-button):not(.section-toggle):disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.danger {
  background: rgba(92, 42, 42, 0.8);
}

button.danger:hover:not(:disabled) {
  background: rgba(122, 58, 58, 0.9);
}

.hint {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* Reference Thumbnails */
#reference-thumbs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  min-height: 70px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

#reference-thumbs:empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

#reference-thumbs:empty::after {
  content: 'No reference photos yet';
  color: #666;
  font-size: 0.85rem;
}

#reference-thumbs img {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #00d4ff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

#reference-thumbs img:hover {
  transform: scale(1.05);
}

/* Threshold slider */
#threshold-control {
  margin-top: 0.5rem;
}

#threshold-control label {
  display: block;
  font-size: 0.95rem;
  color: #ccc;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

#threshold-control input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  margin-top: 0.5rem;
}

#threshold-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00d4ff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.4);
  transition: all 0.2s;
}

#threshold-control input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.6);
}

#threshold-control input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00d4ff;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.4);
  transition: all 0.2s;
}

#threshold-control input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.6);
}

#threshold-value {
  font-family: 'Courier New', monospace;
  color: #00d4ff;
  font-weight: 700;
  font-size: 1.05rem;
}

/* Responsive improvements */
@media (max-width: 600px) {
  #app {
    padding: 0.75rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .hero-button {
    font-size: 1.125rem;
    padding: 1.125rem 1.5rem;
  }

  #distance-display {
    font-size: 2rem;
    padding: 0.375rem 0.75rem;
  }
}

@media (min-width: 601px) {
  #app {
    padding: 2rem 1rem;
  }

  main {
    gap: 1.5rem;
  }

  .hero-button {
    font-size: 1.375rem;
    padding: 1.5rem 2.5rem;
  }
}

/* Smooth transitions */
* {
  -webkit-tap-highlight-color: transparent;
}

button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
