* {
  box-sizing: border-box;
  user-select: none;
  -webkit-touch-callout: none;
}

body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.camera-body {
  width: 100%;
  /* Dynamic viewport height handles iOS Safari address bar correctly */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background: radial-gradient(circle at center, #2e2b26 0%, #161513 100%);
  padding: env(safe-area-inset-top, 16px) 20px calc(env(safe-area-inset-bottom, 16px) + 12px) 20px;
}

/* Viewfinder Area */
.viewfinder-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0; /* Critical for iOS Safari to allow flex container shrinking */
  padding: 12px 0;
}

.viewfinder-frame {
  position: relative;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  aspect-ratio: 3 / 4;
  border: 7px solid #2a2a2a;
  border-radius: 16px;
  box-shadow: inset 0 0 10px #000, 0 8px 24px rgba(0,0,0,0.6);
  overflow: hidden;
  background: #000;
}

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

.viewfinder-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  pointer-events: none;
}

/* Controls Area (Pinned to bottom) */
.camera-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  flex-shrink: 0; /* Ensures button is never compressed or pushed out of view */
  z-index: 10;
}

.status-indicator {
  font-size: 13px;
  color: #bbb;
  min-height: 18px;
  text-align: center;
}

#shutter-btn {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #bf211e;
  border: 4px solid #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  touch-action: manipulation;
  transition: transform 0.08s ease;
}

#shutter-btn:active {
  transform: scale(0.92);
}

.shutter-inner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #961916;
  pointer-events: none;
}

/* Mechanical Shutter Blackout Overlay */
#flash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.12s ease-out; /* Smooth reveal */
}

#flash-overlay.active {
  opacity: 1;
  transition: none; /* Instant snap to black */
}

#flash-overlay.active {
  opacity: 0.95;
  transition: none;
}

#install-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin-bottom: 6px;
}
#install-btn:active {
  background: rgba(255, 255, 255, 0.3);
}