.photobooth-preview {
  --booth-font-size: clamp(8px, 2.25vmin, 13px);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #030303;
  color: #fff;
}
html:has(.photobooth-preview[open]), body:has(.photobooth-preview[open]),
.photobooth-preview::backdrop { background: #030303; }
.photobooth-preview [hidden] { display: none; }
.photobooth-scene {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100vw, max(56.25dvh, 480px));
  aspect-ratio: 9 / 16;
  translate: -50% -50%;
  transform-origin: 50% 49%;
  opacity: 0;
}
.photobooth-scene > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Cut the blue aperture from each photo independently of the live monitor. */
.photobooth-dark, .photobooth-lit {
  clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0,
    25.8% 40.8%, 74.2% 40.8%, 74.2% 57.3%, 25.8% 57.3%, 25.8% 40.8%, 0 0);
}
.photobooth-lit { opacity: 0; }
.photobooth-enter .photobooth-scene { animation: booth-arrive var(--booth-entrance) cubic-bezier(.38,.12,.21,1) both; }
.photobooth-enter .photobooth-dark { animation: booth-wide-exit var(--booth-entrance) step-end both; }
.photobooth-enter .photobooth-lit { animation: booth-lights var(--booth-entrance) linear both, booth-keep-footer var(--booth-entrance) step-end both; }
@keyframes booth-wide-exit { to { visibility: hidden; } }
@keyframes booth-keep-footer { to { clip-path: inset(69% 0 0); } }
@keyframes booth-arrive {
  0% { opacity: 0; transform: scale(.96); }
  30% { opacity: .8; }
  50% { opacity: 1; transform: scale(1.09); }
  100% { opacity: 1; transform: scale(1.94); }
}
@keyframes booth-lights {
  0%, 25% { opacity: 0; }
  33% { opacity: .67; }
  38% { opacity: .23; }
  52%, 100% { opacity: 1; }
}
.photobooth-monitor {
  --booth-logo-height: 2.12em;
  position: absolute;
  inset: 40.5% 25.4% 42.35%;
  z-index: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  font-size: var(--booth-font-size);
}
.photobooth-enter .photobooth-monitor { animation: booth-monitor-on .34s 1.48s ease both; }
@keyframes booth-monitor-on {
  from { background: #000; }
  to { background: #050505; }
}
.photobooth-monitor video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.photobooth-content {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  align-content: center;
  justify-items: center;
  gap: .45em;
  padding: calc(var(--booth-logo-height) + 1.02em) 1.05em .62em;
  text-align: center;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.27;
}
.photobooth-monitor-logo {
  --logo-height: var(--booth-logo-height);
  position: absolute;
  z-index: 2;
  top: .48em;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.photobooth-content p { margin: 0; }
.photobooth-actions {
  position: absolute;
  top: 67%;
  left: 50%;
  width: 47%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .45em;
  font: 650 var(--booth-font-size)/1.2 system-ui, -apple-system, sans-serif;
}
.photobooth-actions:empty { display: none; }
.photobooth-actions button {
  border: 0;
  border-radius: 999px;
  min-height: 24px;
  padding: .35em 1.1em;
  background: #fff;
  color: #0e0e0d;
  font: inherit;
}
.photobooth-count { font-size: 3em; line-height: 1; text-shadow: 0 1px 8px #000; }
.photobooth-content small {
  background: #0e0e0dbb;
  border-radius: .5em;
  padding: .3em .6em;
}
.photobooth-close {
  position: absolute;
  right: calc(14px + max(env(safe-area-inset-right, 0px),
    calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px))));
  top: calc(14px + max(env(safe-area-inset-top, 0px),
    calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px))));
  z-index: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #0e0e0d24;
  color: #0e0e0d;
  background: #fff;
  font-size: 25px;
  line-height: 1;
}
@media (prefers-reduced-motion: reduce) {
  .photobooth-enter .photobooth-scene { animation: none; opacity: 1; transform: scale(1.94); }
  .photobooth-enter .photobooth-dark { animation: none; visibility: hidden; }
  .photobooth-enter .photobooth-lit { animation: none; opacity: 1; clip-path: inset(69% 0 0); }
  .photobooth-enter .photobooth-monitor { animation: none; background: #050505; }
}

/* Match the monitor in the supplied close-up to its position in the wide shot. */
.photobooth-scene > .photobooth-closeup {
  inset: 19.45% auto auto 23.33%;
  width: 53.45%;
  height: 53.43%;
  clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0,
    4.7% 40.1%, 95.3% 40.1%, 95.3% 70.45%, 4.7% 70.45%, 4.7% 40.1%, 0 0);
  -webkit-mask-image: linear-gradient(#000 94%, transparent);
  mask-image: linear-gradient(#000 94%, transparent);
  opacity: 0;
}
.photobooth-enter .photobooth-closeup { animation: booth-detail .34s 1.96s ease both; }
@keyframes booth-detail { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .photobooth-enter .photobooth-closeup { animation: none; opacity: 1; }
}

.photobooth-monitor {
  box-shadow: inset 0 0 .5em #000;
}
.photobooth-title {
  display: block;
  color: #f2f3f2;
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.16;
}
.photobooth-instructions {
  overflow: auto;
  align-content: safe center;
  gap: .38em;
  overscroll-behavior: contain;
}
.photobooth-copy {
  width: min(100%, 24em);
  display: grid;
  gap: .24em;
  font-size: .95em;
}
.photobooth-actions .photobooth-next {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
}
.photobooth-next::after {
  content: '';
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 1.4px 1.4px 0 0;
  transform: translateX(-1px) rotate(45deg);
}
.photobooth-copy strong { font-weight: 750; }
.photobooth-qr-message { color: #f4cbd8; }
.photobooth-capture {
  padding: .7em;
  font: 600 clamp(8px, 1.85vmin, 12px)/1.2 system-ui, sans-serif;
}
.photobooth-viewfinder {
  position: absolute;
  inset: 11%;
  pointer-events: none;
  background:
    linear-gradient(#f2f3f2,#f2f3f2) left top / .85em 1px,
    linear-gradient(#f2f3f2,#f2f3f2) left top / 1px .85em,
    linear-gradient(#f2f3f2,#f2f3f2) right top / .85em 1px,
    linear-gradient(#f2f3f2,#f2f3f2) right top / 1px .85em,
    linear-gradient(#f2f3f2,#f2f3f2) left bottom / .85em 1px,
    linear-gradient(#f2f3f2,#f2f3f2) left bottom / 1px .85em,
    linear-gradient(#f2f3f2,#f2f3f2) right bottom / .85em 1px,
    linear-gradient(#f2f3f2,#f2f3f2) right bottom / 1px .85em;
  background-repeat: no-repeat;
}
.photobooth-frame-number, .photobooth-count {
  position: absolute;
  bottom: .55em;
  background: #0e0e0de6;
  line-height: 1;
}
.photobooth-frame-number { left: .6em; padding: .45em .6em; border-radius: .2em; }
.photobooth-count {
  bottom: .25em;
  right: .25em;
  width: 1.42em;
  height: 1.42em;
  display: grid;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: #fff;
  font-size: 1.85em;
  font-variant-numeric: tabular-nums;
}
.photobooth-review { overflow: auto; }
.photobooth-flashing::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #fff;
  pointer-events: none;
}

.photobooth-loading {
  display: grid;
  justify-items: center;
  gap: .75em;
  width: min(70%, 14em);
}
.photobooth-loading-track {
  display: block;
  width: 100%;
  height: .8em;
  border: 1px solid #fff;
  border-radius: 999px;
  overflow: hidden;
}
.photobooth-loading-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: inherit;
  transform-origin: left;
  transform: scaleX(0);
}

.staff-photobooth [data-booth-qr] {
  display: block;
  width: min(100%, 230px);
  margin: 12px auto;
}
.staff-photobooth [data-booth-save] {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #046cf5;
  color: #fff;
  text-align: center;
  font-weight: 700;
  text-decoration: none;
}
.staff-photobooth [hidden] { display: none; }

.photobooth-monitor video.photobooth-rear-camera { transform: none; }
.photobooth-camera-choice p { font-size: 1.15em; }
.photobooth-qr-scan > p {
  position: absolute;
  z-index: 1;
  top: calc(var(--booth-logo-height) + .65em);
  left: 5%;
  right: 5%;
  justify-self: center;
  width: fit-content;
  padding: .34em .55em;
  background: #000c;
}
.photobooth-qr-frame {
  position: absolute;
  inset: 50% auto auto 50%;
  height: 53%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid #fff;
  box-shadow: 0 0 0 100vmax #0005;
  pointer-events: none;
}
