.photo-camera {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: none;
  object-fit: cover;
  transform: scaleX(-1);
  background: #08070e;
}

.stage > #avatarCanvas {
  position: relative;
  z-index: 1;
}

body.photo-preview .photo-camera,
body.photo-mode .photo-camera {
  display: block;
}

body.photo-preview {
  background: #08070e;
}

.photo-preview-badge {
  position: fixed;
  left: 50%;
  top: max(78px, env(safe-area-inset-top));
  z-index: 32;
  display: none;
  max-width: min(86vw, 720px);
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(9, 8, 16, .72);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
  backdrop-filter: blur(18px);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

body.photo-preview .photo-preview-badge {
  display: block;
}

.photo-countdown {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: none;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0 24%, rgba(0, 0, 0, .16) 78%);
}

.photo-countdown.visible {
  display: grid;
}

.photo-countdown-content {
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
  text-shadow: 0 8px 30px rgba(0, 0, 0, .58);
}

.photo-countdown-label {
  max-width: min(82vw, 620px);
  color: #fff;
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 800;
}

.photo-countdown-number {
  min-height: 1em;
  color: #fff;
  font-size: clamp(96px, 22vw, 240px);
  font-weight: 900;
  line-height: .86;
  letter-spacing: -.06em;
}

.photo-flash {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}

.photo-flash.fire {
  animation: photo-booth-flash .48s ease-out;
}

@keyframes photo-booth-flash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

.photo-result {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: rgba(8, 7, 14, .82);
  backdrop-filter: blur(24px);
}

.photo-result.visible {
  display: grid;
}

.photo-result-card {
  width: min(100%, 980px);
  max-height: calc(100dvh - 40px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(250px, .8fr);
  gap: 22px;
  padding: 22px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 28px;
  background: rgba(25, 21, 37, .95);
  box-shadow: 0 36px 110px rgba(0, 0, 0, .5);
  color: #fff;
}

.photo-result-image-wrap {
  min-height: 240px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 20px;
  background: #0a0911;
}

.photo-result-image {
  width: 100%;
  max-height: calc(100dvh - 84px);
  display: block;
  object-fit: contain;
}

.photo-result-side {
  display: grid;
  align-content: center;
  gap: 14px;
  text-align: center;
}

.photo-result-side h2 {
  margin: 0;
  color: #fff;
  font-size: 24px;
}

.photo-result-side p {
  margin: 0;
  color: rgba(255, 255, 255, .7);
  font-size: 14px;
  line-height: 1.55;
}

.photo-qr-wrap {
  width: min(100%, 260px);
  aspect-ratio: 1;
  margin: 4px auto;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 20px;
  background: #fff;
}

.photo-qr-wrap canvas {
  position: static;
  inset: auto;
  z-index: auto;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  display: block;
  opacity: 1;
  filter: none;
  transform: none;
  touch-action: auto;
}

.photo-result-actions {
  display: grid;
  gap: 10px;
}

.photo-download-link {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(90, 185, 255, .95), rgba(155, 110, 255, .82));
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.photo-result-close {
  min-height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.photo-error {
  color: #ffb4c0 !important;
}

body.photo-mode .topbar,
body.photo-mode .stage-conversation,
body.photo-mode .composer,
body.photo-mode .config,
body.photo-mode .panel,
body.photo-mode #captureBtn,
body.photo-mode .camera-panel,
body.photo-mode .health-panel,
body.photo-mode .loading-overlay,
body.photo-mode .install-guide {
  visibility: hidden;
  pointer-events: none;
}

.photo-booth-settings {
  display: grid;
  gap: 10px;
}

.photo-booth-settings .setting-status {
  min-height: 18px;
  margin: 0;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .photo-result-card {
    grid-template-columns: 1fr;
    width: min(100%, 620px);
  }

  .photo-result-image {
    max-height: 52dvh;
  }

  .photo-result-side {
    padding-bottom: 4px;
  }

  .photo-qr-wrap {
    width: min(58vw, 230px);
  }
}

@media (max-width: 520px) {
  .photo-result {
    padding: 12px;
  }

  .photo-result-card {
    max-height: calc(100dvh - 24px);
    padding: 14px;
    gap: 14px;
    border-radius: 22px;
  }

  .photo-result-side h2 {
    font-size: 20px;
  }

  .photo-qr-wrap {
    width: min(52vw, 190px);
    padding: 10px;
    border-radius: 16px;
  }
}
