/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Lobster&display=swap');

body {
  margin: 0;
  text-align: center;
  background: linear-gradient(180deg, #fffaf7 0%, #fff4ef 100%);
  color: #222;
  font-family: sans-serif;
}

.hidden {
  display: none !important;
}

/* Welcome screen */
#welcome-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 216, 184, 0.95), transparent 26%),
    radial-gradient(circle at 80% 18%, rgba(214, 214, 255, 0.9), transparent 24%),
    radial-gradient(circle at 50% 90%, rgba(255, 206, 230, 0.9), transparent 28%),
    linear-gradient(135deg, rgba(255, 240, 247, 0.96), rgba(236, 232, 255, 0.94), rgba(255, 247, 221, 0.96));
  overflow: hidden;
}

#welcome-screen::before,
#welcome-screen::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.72;
  animation: floatBlob 16s ease-in-out infinite alternate;
}

#welcome-screen::before {
  width: 360px;
  height: 360px;
  left: 10%;
  top: 10%;
  background: rgba(255, 179, 198, 0.32);
}

#welcome-screen::after {
  width: 300px;
  height: 300px;
  right: 12%;
  bottom: 12%;
  background: rgba(172, 191, 255, 0.32);
  animation-delay: 1s;
}

.welcome-pills {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.welcome-pills span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.58rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(109, 82, 91, 0.12);
  box-shadow: 0 10px 30px rgba(132, 94, 150, 0.08);
  color: #553f60;
  font-size: 0.82rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

#welcome-screen h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: 'Lobster', cursive;
  font-size: clamp(42px, 10vw, 72px);
  font-weight: bold;
  letter-spacing: 0.06em;
  color: #2d1d39;
  text-shadow: 0 10px 32px rgba(255, 255, 255, 0.7);
  animation: fadeUp 0.9s ease both;
}

#welcome-screen p {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: 'Lobster', cursive;
  font-size: clamp(22px, 4vw, 30px);
  color: rgba(40, 26, 58, 0.82);
  text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.4);
  animation: fadeUp 1.05s ease both;
}

#welcome-screen button {
  position: relative;
  z-index: 1;
  padding: 1rem 2.6rem;
  font-size: 1.12rem;
  background: linear-gradient(135deg, #ff7aa1, #c38dff 52%, #ffd87b);
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  margin-top: 0.5rem;
  touch-action: manipulation;
  font-family: 'Lobster', cursive;
  font-weight: bold;
  box-shadow: 0 18px 40px rgba(160, 132, 215, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  animation: pulseButton 2.6s ease-in-out infinite;
}

#welcome-screen button:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.04);
  box-shadow: 0 22px 44px rgba(160, 132, 215, 0.42);
}

@keyframes floatBlob {
  0%   { transform: translate3d(0, 0, 0) scale(0.96); }
  100% { transform: translate3d(22px, -18px, 0) scale(1.08); }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseButton {
  0%, 100% { box-shadow: 0 18px 40px rgba(160, 132, 215, 0.35); }
  50% { box-shadow: 0 18px 40px rgba(160, 132, 215, 0.5), 0 0 0 12px rgba(196, 138, 255, 0.12); }
}

/* Video + countdown */
#video-wrap {
  position: relative;
  display: inline-block;
}

#camera {
  max-width: 90vw;
  max-height: 70vh;
  width: auto;
  height: auto;
  border: 4px solid white;
  border-radius: 8px;
  margin-top: 20px;
  transform: scaleX(-1); /* mirror preview like a real mirror */
}

#countdown {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 20px);
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 10px black;
  pointer-events: none;
}

/* Strip button */
#strip-btn {
  padding: 12px 30px;
  font-size: 18px;
  background: #555;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  touch-action: manipulation;
}

#strip-btn:hover {
  background: #777;
}

/* Result strip image */
#result img.strip {
  width: 220px;
  border-radius: 4px;
  margin-top: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transition: transform 0.3s;
}

#result img.strip:hover {
  transform: scale(1.5);
}

/* Print button */
#print-btn {
  padding: 12px 30px;
  font-size: 18px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  touch-action: manipulation;
  font-family: 'Lobster', cursive;
  font-weight: bold;
  text-shadow: 2px 2px 0px #333;
}

#print-btn:hover {
  background: #45a049;
}

/* ===== Template screen ===== */
#template-screen {
  margin: 40px auto 0;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 40px rgba(180, 80, 0, 0.25);
  padding: 30px;
  border-radius: 16px;
}

#template-screen h1 {
  font-family: 'Lobster', cursive;
  font-size: 44px;
  text-shadow: 3px 3px 0px #ddd;
  margin-top: 0;
}

#template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin: 20px 0;
}

.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 4px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  touch-action: manipulation;
  transition: transform 0.2s, border-color 0.2s;
}

.template-card:hover {
  transform: translateY(-4px);
}

.template-card.selected {
  border-color: #ff6b81;
  background: #fff0f2;
}

.template-preview {
  width: 120px;
  height: 360px;
  object-fit: contain;
  background: #eee;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.template-plain {
  border: 1px solid #ccc;
}

#template-confirm {
  padding: 12px 30px;
  font-size: 20px;
  background: #ff6b81;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  font-family: 'Lobster', cursive;
  font-weight: bold;
  text-shadow: 2px 2px 0px #333;
}

#template-confirm:hover:not(:disabled) {
  background: #ff4f68;
}

#template-confirm:disabled {
  background: #ccc;
  cursor: not-allowed;
  text-shadow: none;
}

#template-label {
  margin: 0;
  color: #555;
}

/* Change template button */
#change-template-btn {
  padding: 12px 30px;
  font-size: 18px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  touch-action: manipulation;
}

#change-template-btn:hover:not(:disabled) {
  background: #2563eb;
}

#strip-btn:disabled,
#change-template-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Flash effect ===== */
#flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 20px);
  margin-top: 20px;
  background: white;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
}

#flash.flash-on {
  animation: flash 0.4s ease-out;
}

@keyframes flash {
  0%   { opacity: 0.95; }
  100% { opacity: 0; }
}

/* ===== Download button ===== */
#download-btn {
  padding: 12px 30px;
  font-size: 18px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  touch-action: manipulation;
  font-family: 'Lobster', cursive;
  font-weight: bold;
  text-shadow: 2px 2px 0px #333;
}

#download-btn:hover {
  background: #2563eb;
}

/* ===== Edit screen ===== */
#edit-screen {
  margin: 20px auto 0;
  max-width: 900px;
  background: white;
  padding: 20px;
  border-radius: 12px;
}

#edit-screen h1 {
  font-family: 'Lobster', cursive;
  font-size: 40px;
  text-shadow: 3px 3px 0px #ddd;
  margin: 0 0 6px;
}

.edit-hint {
  margin: 0 0 12px;
  color: #666;
  font-size: 14px;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.edit-actions button {
  padding: 10px 22px;
  font-size: 17px;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

#edit-reset-btn    { background: #888; }
#edit-retake-btn   { background: #555; }
#edit-finalize-btn { background: #4CAF50; font-weight: bold; }
.edit-actions button:hover:not(:disabled) { filter: brightness(1.1); }
.edit-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

#edit-wrap {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  background: #ddd;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

#edit-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 600px;
  height: 1800px;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
}

.edit-slot {
  position: absolute;
  overflow: hidden;
  z-index: 1;
  cursor: grab;
  touch-action: none;
}

.edit-slot.dragging { cursor: grabbing; }

.edit-slot img {
  position: absolute;
  max-width: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.edit-template {
  position: absolute;
  top: 0;
  left: 0;
  width: 600px;
  height: 1800px;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.edit-frame {
  position: absolute;
  box-sizing: border-box;
  border: var(--bw, 3px) dashed #ff6b81;
  z-index: 3;
  pointer-events: none;
}

.edit-handle {
  position: absolute;
  box-sizing: border-box;
  width: var(--hs, 30px);
  height: var(--hs, 30px);
  background: white;
  border: var(--bw, 3px) solid #ff6b81;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  z-index: 4;
  touch-action: none;
}

.edit-handle.nw, .edit-handle.se { cursor: nwse-resize; }
.edit-handle.ne, .edit-handle.sw { cursor: nesw-resize; }

/* Edit Again button */
#edit-again-btn {
  padding: 12px 30px;
  font-size: 18px;
  background: #f59e0b;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  touch-action: manipulation;
}

#edit-again-btn:hover {
  background: #d98a06;
}

/* ===== Animated home background ===== */
#bg-anim {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(135deg, #ff9a56 0%, #ffb27a 30%, #ffcfa6 62%, #ffe6d2 100%);
  background-size: 220% 220%;
  animation: bgShift 24s ease-in-out infinite alternate;
  opacity: 1;
  transition: opacity 0.6s ease, visibility 0s;
}

#bg-anim.off {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s 0.6s;
}

#bg-anim.off * {
  animation-play-state: paused !important;
}

@keyframes bgShift {
  0%   { background-position: 0% 0%; }
  100% { background-position: 100% 100%; }
}

/* Soft light flares */
.bg-flare {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,240,200,0.35) 38%, rgba(255,255,255,0) 68%);
  mix-blend-mode: screen;
  opacity: 0.3;
  will-change: transform, opacity;
  animation: flareDrift 22s ease-in-out infinite alternate, flarePulse 9s ease-in-out infinite;
}

.bg-flare.f1 { width: 55vmax; height: 55vmax; left: -15vmax; top: -18vmax; animation-duration: 26s, 11s; }
.bg-flare.f2 { width: 42vmax; height: 42vmax; right: -12vmax; top: 10vh;    animation-duration: 21s, 8s;  animation-delay: -6s, -3s; }
.bg-flare.f3 { width: 48vmax; height: 48vmax; left: 20vw;    bottom: -24vmax; animation-duration: 29s, 13s; animation-delay: -12s, -6s; }
.bg-flare.f4 { width: 30vmax; height: 30vmax; right: 18vw;   top: -10vmax;  animation-duration: 18s, 7s;  animation-delay: -4s, -2s; }

@keyframes flareDrift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6vw, 5vh) scale(1.18); }
}

@keyframes flarePulse {
  0%, 100% { opacity: 0.18; }
  50%      { opacity: 0.55; }
}

/* Roaming icons: outer wrapper drifts on X, inner on Y (different speeds = organic path) */
.roam-x, .roam-y {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.roam-x {
  animation: roamX var(--dx, 36s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}

.roam-y {
  animation: roamY var(--dy, 30s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}

@keyframes roamX {
  from { transform: translateX(var(--x0)); }
  to   { transform: translateX(var(--x1)); }
}

@keyframes roamY {
  from { transform: translateY(var(--y0)); }
  to   { transform: translateY(var(--y1)); }
}

.roam-icon {
  display: block;
  width: var(--size, 140px);
  height: auto;
  filter: drop-shadow(0 12px 20px rgba(150, 60, 0, 0.28));
  animation: bob 6s ease-in-out infinite alternate;
  user-select: none;
  -webkit-user-drag: none;
}

.roam-icon.hero {
  animation-duration: 7s;
}

@keyframes bob {
  0%   { transform: rotate(-5deg) scale(1); }
  100% { transform: rotate(5deg)  scale(1.05); }
}

/* Sparkles (generated by script.js) */
#bg-sparkles {
  position: absolute;
  inset: 0;
}

.sparkle {
  position: absolute;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='white' d='M50 0C54 36 64 46 100 50C64 54 54 64 50 100C46 64 36 54 0 50C36 46 46 36 50 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.95));
  opacity: 0;
  will-change: transform, opacity;
  animation: twinkle 4s ease-in-out infinite;
}

.sparkle.gold {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='%23fff1a8' d='M50 0C54 36 64 46 100 50C64 54 54 64 50 100C46 64 36 54 0 50C36 46 46 36 50 0Z'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 6px rgba(255, 220, 120, 0.95));
}

@keyframes twinkle {
  0%   { opacity: 0;   transform: scale(0)   rotate(0deg); }
  50%  { opacity: 0.95; transform: scale(1)   rotate(90deg); }
  100% { opacity: 0;   transform: scale(0)   rotate(180deg); }
}

/* Respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
  #bg-anim,
  .bg-flare,
  .roam-x,
  .roam-y,
  .roam-icon {
    animation: none !important;
  }
  .roam-x { transform: translateX(var(--x0)); }
  .roam-y { transform: translateY(var(--y0)); }
  .sparkle { animation: none !important; opacity: 0.6; transform: scale(0.8); }
}

/* Hide the extra icons on small phones to keep the home screen clean */
@media (max-width: 600px) {
  .roam-x.extra { display: none; }
}

.template-error {
  color: #b00020;
  max-width: 420px;
  line-height: 1.5;
}

/* =====================================================
   WELCOME: Admin button (top-right)
   ===================================================== */
#admin-link {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 5;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #7a3a00;
  text-decoration: none;
  font-size: 15px;
  box-shadow: 0 2px 10px rgba(150, 60, 0, 0.2);
}
#admin-link:hover { background: #fff; }

/* Camera screen: gallery button */
#gallery-btn {
  padding: 12px 30px;
  font-size: 18px;
  background: #8b5cf6;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  touch-action: manipulation;
}
#gallery-btn:hover:not(:disabled) { background: #7c3aed; }
#gallery-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =====================================================
   EDITING SCREEN: filters + stickers
   ===================================================== */
#edit-screen { max-width: 1000px; }

.edit-layout {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.edit-panel {
  flex: 0 1 300px;
  min-width: 250px;
  background: #fafafa;
  border-radius: 12px;
  padding: 14px;
  text-align: left;
}
.edit-panel h3 { margin: 6px 0 8px; font-size: 16px; }
.edit-panel .edit-hint { margin: 0 0 8px; }

#filter-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 3px;
  border: 3px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  touch-action: manipulation;
}
.chip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #ddd;
}
.chip.active { border-color: #ff6b81; }

#sticker-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.stk-btn {
  aspect-ratio: 1;
  font-size: 26px;
  line-height: 1;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.stk-btn:hover { background: #fff0f2; }
.stk-btn img { width: 100%; height: 100%; object-fit: contain; }

/* stickers on the strip */
.edit-sticker {
  position: absolute;
  max-width: none;
  object-fit: contain;
  z-index: 5;
  cursor: move;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center;
}
.stk-ctl {
  position: absolute;
  box-sizing: border-box;
  border: var(--bw, 3px) dashed #ff6b81;
  z-index: 6;
  pointer-events: none;
  transform-origin: center;
}
.stk-del,
.stk-handle {
  position: absolute;
  box-sizing: border-box;
  width: var(--hs, 30px);
  height: var(--hs, 30px);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.stk-del {
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  background: #ff3b6b;
  color: #fff;
  font-size: calc(var(--hs, 30px) * 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.stk-handle {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
  background: #fff;
  border: var(--bw, 3px) solid #ff6b81;
  cursor: nwse-resize;
}
/* while a sticker is selected, hide the photo frame handles */
.sticker-mode .edit-frame,
.sticker-mode .edit-handle { display: none; }

/* =====================================================
   RESULT SCREEN + GALLERY
   ===================================================== */
#result-screen {
  margin: 20px auto;
  max-width: 900px;
  background: white;
  padding: 20px;
  border-radius: 12px;
}
#result-screen h1 {
  font-family: 'Lobster', cursive;
  font-size: 40px;
  text-shadow: 3px 3px 0px #ddd;
  margin: 0 0 10px;
}
#result-preview { min-height: 80px; }
#final-strip {
  width: min(260px, 70vw);
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
.muted { color: #777; }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 14px 0;
}
#result-screen .result-actions button {
  margin-top: 0;
  padding: 12px 22px;
  font-size: 17px;
  font-family: inherit;
  font-weight: normal;
  text-shadow: none;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
#share-btn { background: #8b5cf6; }
#share-btn:hover:not(:disabled) { background: #7c3aed; }
#new-strip-btn { background: #ff6b81; }
#new-strip-btn:hover { background: #ff4f68; }
#home-btn { background: #777; }
#home-btn:hover { background: #666; }
#result-screen .result-actions button:disabled { opacity: 0.4; cursor: not-allowed; }

.gallery-title { margin: 26px 0 12px; font-size: 20px; }
#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.g-card {
  background: #f7f7f7;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.g-card img {
  height: 200px;
  max-width: 100%;
  object-fit: contain;
  cursor: pointer;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.g-meta { font-size: 11px; color: #666; line-height: 1.3; }
.g-del {
  border: none;
  background: #fde5e5;
  color: #a11;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}

/* Small message popup */
#app-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #2b2118;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 90vw;
  z-index: 1000;
}
#app-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== AR face filters ===== */
#ar-canvas {
  position: absolute;
  left: 4px;
  top: 24px;
  width: calc(100% - 8px);
  height: calc(100% - 28px);
  transform: scaleX(-1);          /* mirrored like the video */
  pointer-events: none;
}
#ar-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin: 12px auto 0; max-width: 90vw;
}
.ar-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 64px; padding: 6px 8px; font-size: 11px;
  background: rgba(255,255,255,.12); color: #fff;
  border: 2px solid transparent; border-radius: 10px; cursor: pointer;
}
.ar-chip .ar-ico { font-size: 24px; line-height: 1; }
.ar-chip.active { border-color: #fff; background: rgba(255,255,255,.28); }
#ar-status { min-height: 1.2em; margin: 6px 0 0; }


/* ===== Online / offline / cloud badge ===== */
#net-badge {
  position: fixed; top: 10px; right: 12px; z-index: 50;
  padding: 4px 10px; font-size: 12px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: #fff; pointer-events: none;
}
#net-badge.net-online  { color: #8dffb0; }
#net-badge.net-offline { color: #ffd37a; }
#net-badge.net-error   { color: #ff9d9d; }


/* ===== Print settings ===== */
#print-settings {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 18px;
  margin: 8px auto 14px; max-width: 560px; font-size: 14px;
}
#print-settings label { display: flex; align-items: center; gap: 6px; }
#print-settings select, #print-settings input[type=number] {
  padding: 5px 8px; border-radius: 6px; border: 1px solid #ccc; font: inherit;
}
#print-settings input[type=number] { width: 60px; }
#print-settings .edit-hint { flex-basis: 100%; margin: 0; text-align: center; }

/* =====================================================
   Visibility + motion upgrade: filter chips and camera buttons
   ===================================================== */

/* ---- Filter bar: bright cards with dark text, easy to read on any background ---- */
#ar-bar {
  gap: 10px;
  margin: 16px auto 4px;
  padding: 12px 14px;
  max-width: min(94vw, 760px);
  background: rgba(255, 255, 255, .55);
  border-radius: 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ar-chip {
  min-width: 74px;
  padding: 8px 10px 7px;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  color: #3a2a1a;
  background: #fff;
  border: 3px solid transparent;
  border-radius: 14px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15);
  transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), box-shadow .18s, background .18s, border-color .18s, color .18s;
  animation: chipIn .45s cubic-bezier(.3, 1.5, .5, 1) backwards;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ar-chip:nth-child(1)  { animation-delay: .00s; } .ar-chip:nth-child(2)  { animation-delay: .04s; }
.ar-chip:nth-child(3)  { animation-delay: .08s; } .ar-chip:nth-child(4)  { animation-delay: .12s; }
.ar-chip:nth-child(5)  { animation-delay: .16s; } .ar-chip:nth-child(6)  { animation-delay: .20s; }
.ar-chip:nth-child(7)  { animation-delay: .24s; } .ar-chip:nth-child(8)  { animation-delay: .28s; }
.ar-chip:nth-child(9)  { animation-delay: .32s; } .ar-chip:nth-child(10) { animation-delay: .36s; }
.ar-chip:nth-child(11) { animation-delay: .40s; } .ar-chip:nth-child(12) { animation-delay: .44s; }
.ar-chip .ar-ico { font-size: 32px; transition: transform .25s cubic-bezier(.3, 1.8, .5, 1); }
.ar-chip:hover { transform: translateY(-4px) scale(1.06); box-shadow: 0 8px 16px rgba(0, 0, 0, .22); }
.ar-chip:hover .ar-ico { transform: scale(1.18) rotate(-8deg); }
.ar-chip:active { transform: scale(.94); }
.ar-chip.active {
  color: #fff;
  background: linear-gradient(135deg, #ff6b81, #ff9a56);
  border-color: #fff;
  box-shadow: 0 0 0 3px #ff6b81, 0 8px 18px rgba(255, 107, 129, .55);
  transform: translateY(-3px) scale(1.08);
  animation: chipPop .4s cubic-bezier(.3, 1.8, .5, 1);
}
#ar-status { color: #5a4636; font-weight: 600; }

@keyframes chipIn  { from { opacity: 0; transform: translateY(14px) scale(.8); } }
@keyframes chipPop { 0% { transform: scale(.9); } 60% { transform: translateY(-5px) scale(1.16); } 100% { transform: translateY(-3px) scale(1.08); } }

/* ---- Green-screen backdrops ---- */
.camera-addons {
  width: min(94vw, 560px);
  margin: 14px auto 8px;
  padding: 13px 16px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 20px;
  background: rgba(255,255,255,.62);
  box-shadow: 0 8px 24px rgba(120,60,90,.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.backdrop-control {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: #704858;
  font-size: 14px;
  font-weight: 800;
}
#backdrop-select {
  max-width: min(100%, 260px);
  padding: 8px 14px;
  border: 1px solid #efccdc;
  border-radius: 999px;
  background: #fff;
  color: #604454;
  font: inherit;
  font-size: 13px;
}
.camera-addons .edit-hint { margin: 8px 0 0; font-size: 12px; }
.capture-output-note { margin: 8px auto 0; color: #846b79; font-size: 12px; }

/* ---- Camera buttons: gradients, lift on hover, press on click, shine sweep ---- */
#strip-btn, #change-template-btn, #gallery-btn {
  position: relative;
  overflow: hidden;
  padding: 13px 28px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 14px;
  color: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .28), 0 10px 20px rgba(0, 0, 0, .18);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
#strip-btn          { background: linear-gradient(135deg, #ff6b81, #ff4f68); }
#change-template-btn { background: linear-gradient(135deg, #3b82f6, #2563eb); }
#gallery-btn        { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
#strip-btn:hover:not(:disabled), #change-template-btn:hover:not(:disabled), #gallery-btn:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 9px 0 rgba(0, 0, 0, .25), 0 16px 26px rgba(0, 0, 0, .22);
  filter: brightness(1.08);
}
#strip-btn:active:not(:disabled), #change-template-btn:active:not(:disabled), #gallery-btn:active:not(:disabled) {
  transform: translateY(3px) scale(.97);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 3px 8px rgba(0, 0, 0, .2);
}
#strip-btn::after, #change-template-btn::after, #gallery-btn::after {
  content: '';
  position: absolute; top: 0; left: -80%;
  width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
}
#strip-btn:hover:not(:disabled)::after, #change-template-btn:hover:not(:disabled)::after, #gallery-btn:hover:not(:disabled)::after {
  animation: shine .7s ease;
}
@keyframes shine { to { left: 130%; } }

/* The main capture button gently pulses so it draws the eye */
#strip-btn:not(:disabled) { animation: capPulse 2.2s ease-in-out infinite; }
@keyframes capPulse {
  0%, 100% { box-shadow: 0 5px 0 rgba(0, 0, 0, .28), 0 10px 20px rgba(0, 0, 0, .18), 0 0 0 0 rgba(255, 107, 129, .6); }
  50%      { box-shadow: 0 5px 0 rgba(0, 0, 0, .28), 0 10px 20px rgba(0, 0, 0, .18), 0 0 0 12px rgba(255, 107, 129, 0); }
}

#strip-btn:disabled, #change-template-btn:disabled, #gallery-btn:disabled {
  filter: grayscale(.5); opacity: .55; box-shadow: 0 3px 0 rgba(0, 0, 0, .2);
}

@media (prefers-reduced-motion: reduce) {
  .ar-chip, .ar-chip.active, #strip-btn { animation: none !important; }
  .ar-chip, .ar-chip .ar-ico, #strip-btn, #change-template-btn, #gallery-btn,
  #result-screen .result-actions button, .output-panel, #final-strip, #final-gif {
    transition: none;
    animation: none !important;
  }
}

/* =====================================================
   AESTHETIC RESULT SCREEN + GALLERY (pastel, polaroid, soft motion)
   ===================================================== */
:root {
  --rs-ink: #4a3b34;
  --rs-pink: #ff8fab;
  --rs-peach: #ffc9a8;
  --rs-lilac: #c8b6ff;
  --rs-mint: #b8f2e6;
}

#result-screen {
  position: relative;
  max-width: 880px;
  margin: 24px auto 40px;
  padding: 28px 22px 34px;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 201, 168, .55), transparent 40%),
    radial-gradient(circle at 90% 12%, rgba(200, 182, 255, .45), transparent 42%),
    radial-gradient(circle at 80% 95%, rgba(184, 242, 230, .5), transparent 40%),
    #fffaf6;
  border: 2px dashed rgba(255, 143, 171, .55);
  border-radius: 32px;
  box-shadow: 0 18px 50px rgba(120, 70, 50, .16);
  color: var(--rs-ink);
  animation: rsIn .6s cubic-bezier(.2, 1.2, .4, 1) both;
}
@keyframes rsIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }

#result-screen h1 {
  display: inline-block;
  margin: 0 0 14px;
  font-size: 46px;
  text-shadow: none;
  background: linear-gradient(90deg, #ff6b81, #ff9a56, #c084fc);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
#result-screen h1::before, #result-screen h1::after {
  content: '✦'; display: inline-block; margin: 0 10px; font-size: 22px;
  -webkit-text-fill-color: #ffb3c6; color: #ffb3c6;
  animation: twinkleStar 2.4s ease-in-out infinite;
}
#result-screen h1::after { animation-delay: 1.2s; }
@keyframes twinkleStar { 0%, 100% { opacity: .35; transform: scale(.8) rotate(0); } 50% { opacity: 1; transform: scale(1.3) rotate(25deg); } }

/* ---- the strip: polaroid frame, washi tape, gentle float ---- */
#result-preview {
  position: relative;
  display: inline-block;
  min-height: 80px;
  margin: 8px 0 4px;
  padding-top: 14px;
}
#result-preview::before {            /* washi tape */
  content: '';
  position: absolute; top: 0; left: 50%;
  width: 96px; height: 28px;
  transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(255, 179, 198, .85) 0 8px, rgba(255, 224, 232, .85) 8px 16px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  z-index: 2; opacity: .95;
}
#result-preview.dual-output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 22px;
  width: 100%;
  box-sizing: border-box;
  padding: 30px 8px 10px;
}
#result-preview.dual-output-grid::before { display: none; }
.output-panel {
  position: relative;
  min-width: 0;
  min-height: 200px;
  padding: 20px 14px 14px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 24px;
  background: linear-gradient(150deg, rgba(255,255,255,.78), rgba(255,241,247,.72));
  box-shadow: 0 9px 24px rgba(120,70,50,.1), inset 0 1px 0 #fff;
  animation: cardIn .55s cubic-bezier(.3,1.4,.5,1) both;
}
.output-panel:nth-of-type(2) { animation-delay: .1s; }
.output-panel::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  width: 72px;
  height: 21px;
  transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(255,179,198,.9) 0 7px, rgba(255,224,232,.9) 7px 14px);
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.output-panel:nth-of-type(2)::before {
  background: repeating-linear-gradient(45deg, rgba(200,182,255,.9) 0 7px, rgba(232,222,255,.9) 7px 14px);
  transform: translateX(-50%) rotate(3deg);
}
.output-panel h2 {
  margin: 0 0 10px;
  color: #704858;
  font-family: 'Lobster', cursive;
  font-size: 22px;
  font-weight: 400;
}
.output-panel .edit-hint {
  min-height: 36px;
  margin: 0 0 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.output-panel .result-actions { margin: 10px 0 0; }
.output-panel .result-actions button { padding: 10px 16px; font-size: 14px; }
#gif-download-btn { background: linear-gradient(135deg, #c084fc, #8b5cf6); }
#gif-share-btn { background: linear-gradient(135deg, #fb7185, #ec4899); }
#result-empty { grid-column: 1 / -1; }
#final-strip, #final-gif {
  box-sizing: border-box;
  width: min(260px, 100%, 20vh);
  max-width: 100%;
  height: auto;
  padding: 10px 10px 30px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 14px 34px rgba(90, 50, 30, .28), 0 2px 6px rgba(0, 0, 0, .12);
}
#final-strip {
  transform: rotate(-1.5deg);
  animation: floaty 5s ease-in-out infinite;
  transition: transform .4s cubic-bezier(.3, 1.5, .5, 1);
}
#final-strip:hover { transform: rotate(0) scale(1.04); animation-play-state: paused; }
#final-gif {
  display: block;
  margin: 0 auto;
  object-fit: contain;
  transform: rotate(1.5deg);
  animation: floaty 5s ease-in-out infinite reverse;
}
@keyframes floaty { 0%, 100% { transform: rotate(-1.5deg) translateY(0); } 50% { transform: rotate(-1deg) translateY(-8px); } }

/* ---- action buttons: pastel gradient pills ---- */
.result-actions { gap: 12px; margin: 18px 0 10px; }
#result-screen .result-actions button {
  position: relative; overflow: hidden;
  padding: 13px 26px;
  font-size: 17px; font-weight: 700; letter-spacing: .2px;
  font-family: inherit; text-shadow: none;
  color: #fff; border: none; border-radius: 999px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .16), 0 10px 20px rgba(0, 0, 0, .12);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
#print-btn      { background: linear-gradient(135deg, #34d399, #10b981); }
#download-btn   { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
#share-btn      { background: linear-gradient(135deg, #c084fc, #8b5cf6); }
#edit-again-btn { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
#new-strip-btn  { background: linear-gradient(135deg, #ff8fab, #ff5d7a); }
#home-btn       { background: linear-gradient(135deg, #9ca3af, #6b7280); }
#result-screen .result-actions button:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 9px 0 rgba(0, 0, 0, .14), 0 16px 26px rgba(0, 0, 0, .16);
  filter: brightness(1.07);
}
#result-screen .result-actions button:active:not(:disabled) {
  transform: translateY(3px) scale(.97);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 3px 8px rgba(0, 0, 0, .14);
}
#result-screen .result-actions button::after {
  content: ''; position: absolute; top: 0; left: -80%; width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .5), transparent);
  transform: skewX(-20deg); pointer-events: none;
}
#result-screen .result-actions button:hover:not(:disabled)::after { animation: shine .7s ease; }
#result-screen .result-actions button:disabled { opacity: .45; filter: grayscale(.4); }

/* ---- print settings: soft glass panel ---- */
#print-settings {
  max-width: 540px; margin: 14px auto 18px; padding: 14px 20px;
  gap: 10px 20px; font-size: 14px; font-weight: 600; color: var(--rs-ink);
  background: rgba(255, 255, 255, .7);
  border: 1.5px solid rgba(255, 143, 171, .35);
  border-radius: 20px;
  box-shadow: 0 6px 18px rgba(120, 70, 50, .08);
}
#print-settings select, #print-settings input[type=number] {
  padding: 7px 12px; border: 1.5px solid #f3cfd9; border-radius: 999px;
  background: #fff; color: var(--rs-ink); font: inherit; font-weight: 500;
  transition: border-color .2s, box-shadow .2s;
}
#print-settings select:focus, #print-settings input[type=number]:focus {
  outline: none; border-color: var(--rs-pink); box-shadow: 0 0 0 4px rgba(255, 143, 171, .25);
}
#print-settings input[type=checkbox] { width: 18px; height: 18px; accent-color: #ff6b81; cursor: pointer; }
#print-settings .print-check { cursor: pointer; }
#print-settings .edit-hint { font-size: 12px; font-weight: 400; font-style: italic; color: #8a7468; line-height: 1.5; }
#print-settings code { background: #ffe9ef; color: #c2415f; padding: 1px 6px; border-radius: 6px; font-style: normal; }

/* ---- gallery: polaroids pinned with tape ---- */
.gallery-title {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  margin: 34px 0 20px; font-family: 'Lobster', cursive; font-size: 30px; font-weight: 400; color: var(--rs-ink);
}
.gallery-title::before, .gallery-title::after {
  content: ''; flex: 1; max-width: 120px; height: 2px;
  background: repeating-linear-gradient(90deg, #ffb3c6 0 6px, transparent 6px 12px);
}
#gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; padding: 4px 6px; }
.g-card {
  position: relative;
  padding: 16px 10px 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(90, 50, 30, .16);
  transform: rotate(var(--tilt, -2deg));
  transition: transform .3s cubic-bezier(.3, 1.5, .5, 1), box-shadow .3s;
  animation: cardIn .5s cubic-bezier(.3, 1.4, .5, 1) backwards;
}
.g-card:nth-child(odd)  { --tilt: -2.2deg; }
.g-card:nth-child(even) { --tilt: 2deg; }
.g-card:nth-child(3n)   { --tilt: -.8deg; }
.g-card:nth-child(1) { animation-delay: .05s; } .g-card:nth-child(2) { animation-delay: .12s; }
.g-card:nth-child(3) { animation-delay: .19s; } .g-card:nth-child(4) { animation-delay: .26s; }
.g-card:nth-child(5) { animation-delay: .33s; } .g-card:nth-child(6) { animation-delay: .40s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) rotate(0) scale(.9); } }
.g-card::before {                    /* tape */
  content: ''; position: absolute; top: -9px; left: 50%;
  width: 54px; height: 18px; transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, rgba(200, 182, 255, .85) 0 6px, rgba(232, 222, 255, .85) 6px 12px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.g-card:nth-child(even)::before { background: repeating-linear-gradient(45deg, rgba(184, 242, 230, .9) 0 6px, rgba(226, 250, 245, .9) 6px 12px); transform: translateX(-50%) rotate(4deg); }
.g-card:hover { transform: rotate(0) translateY(-8px) scale(1.05); box-shadow: 0 18px 34px rgba(90, 50, 30, .26); z-index: 2; }
.g-card img { border-radius: 3px; box-shadow: 0 3px 10px rgba(0, 0, 0, .22); transition: transform .25s; }
.g-card img:hover { transform: scale(1.03); }
.g-meta { font-size: 11px; color: #8a7468; }
.g-del {
  padding: 5px 14px; border-radius: 999px; font-weight: 600;
  background: #ffe9ef; color: #c2415f;
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), background .15s, color .15s;
}
.g-del:hover { background: #ff5d7a; color: #fff; transform: scale(1.08); }
.g-del:active { transform: scale(.94); }

@media (max-width: 520px) {
  #result-screen { padding: 22px 12px 28px; border-radius: 24px; }
  #result-screen h1 { font-size: 38px; }
  #result-screen .result-actions button { padding: 12px 20px; font-size: 16px; }
  #result-preview.dual-output-grid { grid-template-columns: 1fr; gap: 18px; padding: 26px 2px 6px; }
  .output-panel { min-height: 0; padding: 20px 10px 12px; }
  .output-panel .result-actions { gap: 8px; }
  .output-panel .result-actions button { padding: 10px 14px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  #result-screen, #final-strip, #final-gif, .g-card, .output-panel, #result-screen h1::before, #result-screen h1::after { animation: none !important; }
  #result-screen .result-actions button, .g-card, #final-strip, #final-gif, .output-panel { transition: none; }
}

/* =====================================================
   LIVELY CAMERA + EDIT SCREENS (pastel, glow, soft motion)
   ===================================================== */
body:has(#booth-screen:not(.hidden)), body:has(#edit-screen:not(.hidden)) {
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 201, 168, .65), transparent 38%),
    radial-gradient(circle at 92% 14%, rgba(200, 182, 255, .55), transparent 40%),
    radial-gradient(circle at 80% 92%, rgba(184, 242, 230, .6), transparent 40%),
    radial-gradient(circle at 12% 88%, rgba(255, 179, 198, .5), transparent 38%),
    #fff7ee;
  background-attachment: fixed;
}

/* ---------- Camera screen ---------- */
#booth-screen h1 {
  display: block; width: fit-content; margin: 18px auto 6px;
  background: linear-gradient(90deg, #ff6b81, #ff9a56, #c084fc);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  animation: lifeUp .6s cubic-bezier(.3, 1.4, .5, 1) both;
}
#booth-screen h1::before, #booth-screen h1::after {
  content: '✦'; margin: 0 10px; font-size: .5em; -webkit-text-fill-color: #ffb3c6; color: #ffb3c6;
  display: inline-block; animation: twinkleStar 2.4s ease-in-out infinite;
}
#booth-screen h1::after { animation-delay: 1.2s; }
#template-label {
  display: block; width: fit-content; margin: 0 auto 4px; padding: 5px 16px; font-size: 14px; font-weight: 600; color: #7a4b5c;
  background: rgba(255, 255, 255, .8); border: 1.5px dashed #ffb3c6; border-radius: 999px;
  animation: lifeUp .6s .08s cubic-bezier(.3, 1.4, .5, 1) both;
}
#video-wrap { animation: lifeUp .7s .14s cubic-bezier(.3, 1.4, .5, 1) both; }
#camera {
  border: 4px solid #fff; border-radius: 26px; margin-top: 20px;
  box-shadow: 0 0 0 3px #fff, 0 0 0 7px rgba(255, 143, 171, .55), 0 18px 44px rgba(120, 60, 60, .3);
  animation: camGlow 3.2s ease-in-out infinite;
}
@keyframes camGlow {
  0%, 100% { box-shadow: 0 0 0 3px #fff, 0 0 0 7px rgba(255, 143, 171, .55), 0 18px 44px rgba(120, 60, 60, .3); }
  50%      { box-shadow: 0 0 0 3px #fff, 0 0 0 12px rgba(200, 182, 255, .5), 0 22px 54px rgba(160, 80, 120, .38); }
}
#video-wrap::before {                         /* pulsing LIVE badge */
  content: '● LIVE'; position: absolute; top: 28px; left: 16px; z-index: 5;
  padding: 4px 12px; font-size: 12px; font-weight: 800; letter-spacing: 1px; color: #fff;
  background: rgba(230, 40, 70, .88); border-radius: 999px; box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
  animation: livePulseB 1.6s ease-in-out infinite; pointer-events: none;
}
@keyframes livePulseB { 50% { opacity: .55; transform: scale(.94); } }
#ar-bar { animation: lifeUp .7s .22s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes lifeUp { from { opacity: 0; transform: translateY(22px) scale(.96); } }
/* entrance once, then (capture only) a steady pulse - two separate animations so they never loop together */
#booth-screen #strip-btn:not(:disabled) { animation: lifeUp .6s .3s cubic-bezier(.3, 1.4, .5, 1) backwards, capPulse 2.2s 1s ease-in-out infinite; }
#booth-screen #strip-btn:disabled { animation: none; }
#booth-screen #change-template-btn { animation: lifeUp .6s .38s cubic-bezier(.3, 1.4, .5, 1) backwards; }
#booth-screen #gallery-btn { animation: lifeUp .6s .46s cubic-bezier(.3, 1.4, .5, 1) backwards; }

/* countdown + flash while taking the strip */
#countdown { font-family: 'Lobster', cursive; font-size: clamp(48px, 13vw, 110px); color: #fff; text-align: center;
  text-shadow: 0 0 18px #ff6b81, 0 0 36px #c084fc, 0 4px 12px rgba(0, 0, 0, .45); }
#countdown.tick { animation: countPop .85s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes countPop { 0% { transform: scale(.2) rotate(-12deg); opacity: 0; } 35% { transform: scale(1.3) rotate(4deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
#flash { border-radius: 22px; }

/* ---------- Edit screen ---------- */
#edit-screen {
  position: relative; max-width: 1020px; margin: 22px auto 40px; padding: 26px 20px 30px;
  background:
    radial-gradient(circle at 10% 5%, rgba(255, 201, 168, .5), transparent 40%),
    radial-gradient(circle at 95% 10%, rgba(200, 182, 255, .45), transparent 42%), #fffaf6;
  border: 2px dashed rgba(255, 143, 171, .55); border-radius: 32px;
  box-shadow: 0 18px 50px rgba(120, 70, 50, .16);
  animation: rsIn .6s cubic-bezier(.2, 1.2, .4, 1) both;
}
#edit-screen h1 {
  display: inline-block; margin: 0 0 14px;
  background: linear-gradient(90deg, #ff6b81, #ff9a56, #c084fc);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; text-shadow: none;
}
.edit-actions { gap: 10px; }
.edit-actions button {
  position: relative; overflow: hidden; padding: 11px 22px; font-weight: 700; color: #fff; border: 0; border-radius: 999px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .15), 0 10px 18px rgba(0, 0, 0, .1);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s, filter .15s;
}
#edit-reset-btn    { background: linear-gradient(135deg, #a8a29e, #78716c); }
#edit-autocrop-btn { background: linear-gradient(135deg, #c084fc, #8b5cf6); }
#edit-retake-btn   { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
#edit-finalize-btn { background: linear-gradient(135deg, #34d399, #10b981); }
.edit-actions button:hover:not(:disabled) { transform: translateY(-4px) scale(1.05); box-shadow: 0 9px 0 rgba(0, 0, 0, .13), 0 16px 24px rgba(0, 0, 0, .14); }
.edit-actions button:active:not(:disabled) { transform: translateY(3px) scale(.97); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.edit-actions button::after {
  content: ''; position: absolute; top: 0; left: -80%; width: 50%; height: 100%; transform: skewX(-20deg); pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .5), transparent);
}
.edit-actions button:hover:not(:disabled)::after { animation: shine .7s ease; }
#edit-finalize-btn:not(:disabled) { animation: finPulse 2.2s ease-in-out infinite; }
@keyframes finPulse { 50% { box-shadow: 0 5px 0 rgba(0, 0, 0, .15), 0 0 0 10px rgba(16, 185, 129, 0); } 0% { box-shadow: 0 5px 0 rgba(0, 0, 0, .15), 0 0 0 0 rgba(16, 185, 129, .5); } }
.edit-actions button:disabled { opacity: .5; filter: grayscale(.4); }

.edit-hint { display: inline-block; padding: 5px 14px; font-size: 13px; color: #7a5a66; background: rgba(255, 255, 255, .75); border-radius: 999px; }
#edit-wrap { border-radius: 10px; box-shadow: 0 0 0 6px #fff, 0 16px 38px rgba(90, 50, 30, .3); }

.edit-panel {
  padding: 16px 14px; background: rgba(255, 255, 255, .8); border: 1.5px solid rgba(255, 143, 171, .3);
  border-radius: 24px; box-shadow: 0 8px 22px rgba(120, 70, 50, .1);
  animation: lifeUp .6s .15s cubic-bezier(.3, 1.4, .5, 1) both;
}
.edit-panel h3 { font-size: 17px; color: #5a3b4a; }
.chip {
  border-radius: 14px; transition: transform .2s cubic-bezier(.3, 1.8, .5, 1), box-shadow .2s, border-color .2s;
  animation: chipIn .45s cubic-bezier(.3, 1.5, .5, 1) backwards;
}
.chip:nth-child(2) { animation-delay: .04s; } .chip:nth-child(3) { animation-delay: .08s; } .chip:nth-child(4) { animation-delay: .12s; }
.chip:nth-child(5) { animation-delay: .16s; } .chip:nth-child(6) { animation-delay: .20s; } .chip:nth-child(7) { animation-delay: .24s; }
.chip:hover { transform: translateY(-4px) scale(1.06); box-shadow: 0 8px 16px rgba(0, 0, 0, .18); }
.chip.active { border-color: #ff6b81; box-shadow: 0 0 0 3px rgba(255, 107, 129, .35), 0 8px 16px rgba(255, 107, 129, .35); animation: chipPop .4s cubic-bezier(.3, 1.8, .5, 1); }
.stk-btn { border-radius: 14px; transition: transform .2s cubic-bezier(.3, 1.8, .5, 1), background .2s, box-shadow .2s; }
.stk-btn:hover { background: #fff0f4; transform: translateY(-3px) scale(1.14) rotate(-6deg); box-shadow: 0 8px 14px rgba(255, 107, 129, .3); z-index: 2; }
.stk-btn:active { transform: scale(.88) rotate(8deg); }
#sticker-list { scrollbar-width: thin; scrollbar-color: #ff9ab0 #ffeef2; }
#sticker-list::-webkit-scrollbar { width: 8px; }
#sticker-list::-webkit-scrollbar-track { background: #ffeef2; border-radius: 8px; }
#sticker-list::-webkit-scrollbar-thumb { background: linear-gradient(#ff9ab0, #c9a7ff); border-radius: 8px; }

@media (max-width: 600px) {
  #edit-screen { margin: 10px 8px 30px; padding: 20px 10px 24px; border-radius: 24px; }
  #video-wrap::before { top: 22px; left: 10px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  #camera, #video-wrap::before, #booth-screen h1, #booth-screen h1::before, #booth-screen h1::after, #template-label, #video-wrap,
  #ar-bar, #edit-screen, .edit-panel, .chip, #edit-finalize-btn, #booth-screen #strip-btn, #booth-screen #change-template-btn, #booth-screen #gallery-btn, #countdown.tick { animation: none !important; }
}

/* =====================================================
   LIVELY TEMPLATE PICKER (pastel card, polaroid templates, glowing pick)
   ===================================================== */
#template-screen {
  position: relative; max-width: 920px; margin: 34px auto 40px; padding: 28px 22px 32px;
  background:
    radial-gradient(circle at 10% 6%, rgba(255, 201, 168, .55), transparent 40%),
    radial-gradient(circle at 94% 10%, rgba(200, 182, 255, .45), transparent 42%),
    radial-gradient(circle at 85% 96%, rgba(184, 242, 230, .5), transparent 40%), rgba(255, 250, 246, .94);
  border: 2px dashed rgba(255, 143, 171, .55); border-radius: 32px;
  box-shadow: 0 18px 50px rgba(120, 70, 50, .2);
  animation: rsIn .6s cubic-bezier(.2, 1.2, .4, 1) both;
}
#template-screen h1 {
  display: block; width: fit-content; margin: 0 auto 4px; text-shadow: none;
  background: linear-gradient(90deg, #ff6b81, #ff9a56, #c084fc);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
#template-screen h1::before, #template-screen h1::after {
  content: '✦'; display: inline-block; margin: 0 12px; font-size: .45em; -webkit-text-fill-color: #ffb3c6; color: #ffb3c6;
  animation: twinkleStar 2.4s ease-in-out infinite;
}
#template-screen h1::after { animation-delay: 1.2s; }
#template-screen h1 + p, #template-screen .template-error { font-size: 14px; }

#template-list { gap: 26px 22px; margin: 26px 0 22px; padding-top: 10px; }

.template-card {
  position: relative; padding: 18px 14px 12px; gap: 10px;
  background: #fff; border: 0; border-radius: 10px; font-family: inherit; font-size: 15px; font-weight: 700; color: #5a3b4a;
  box-shadow: 0 8px 22px rgba(90, 50, 30, .2);
  transform: rotate(var(--tilt, -2deg));
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), box-shadow .3s;
  animation: cardIn .55s cubic-bezier(.3, 1.4, .5, 1) backwards;
  -webkit-tap-highlight-color: transparent;
}
.template-card:nth-child(odd)  { --tilt: -2.2deg; }
.template-card:nth-child(even) { --tilt: 2deg; }
.template-card:nth-child(3n)   { --tilt: -.8deg; }
.template-card:nth-child(1) { animation-delay: .08s; } .template-card:nth-child(2) { animation-delay: .16s; }
.template-card:nth-child(3) { animation-delay: .24s; } .template-card:nth-child(4) { animation-delay: .32s; }
.template-card:nth-child(5) { animation-delay: .40s; } .template-card:nth-child(6) { animation-delay: .48s; }
.template-card::before {                      /* washi tape */
  content: ''; position: absolute; top: -10px; left: 50%; width: 62px; height: 20px; transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, rgba(255, 179, 198, .9) 0 6px, rgba(255, 224, 232, .9) 6px 12px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.template-card:nth-child(even)::before {
  background: repeating-linear-gradient(45deg, rgba(200, 182, 255, .9) 0 6px, rgba(232, 222, 255, .9) 6px 12px); transform: translateX(-50%) rotate(4deg);
}
.template-card:hover { transform: rotate(0) translateY(-8px) scale(1.05); box-shadow: 0 18px 34px rgba(90, 50, 30, .28); }
.template-card:active { transform: scale(.97); }
.template-preview { width: 130px; height: 390px; border-radius: 4px; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); transition: transform .3s; }
.template-card:hover .template-preview { transform: scale(1.02); }

.template-card.selected {
  background: linear-gradient(180deg, #fff, #ffeef3);
  box-shadow: 0 0 0 4px #ff6b81, 0 0 0 9px rgba(255, 107, 129, .25), 0 18px 34px rgba(255, 107, 129, .4);
  transform: rotate(0) translateY(-6px) scale(1.04);
  animation: tplPick .45s cubic-bezier(.3, 1.8, .5, 1);
  color: #d63a5a;
}
.template-card.selected::after {              /* check badge */
  content: '✓'; position: absolute; top: -12px; right: -12px; width: 34px; height: 34px; display: grid; place-items: center;
  font-size: 19px; font-weight: 800; color: #fff; border-radius: 50%;
  background: linear-gradient(135deg, #ff8fab, #ff5d7a); box-shadow: 0 4px 10px rgba(255, 93, 122, .5), 0 0 0 3px #fff;
  animation: badgePop .5s cubic-bezier(.3, 2, .5, 1);
}
@keyframes tplPick { 0% { transform: rotate(var(--tilt, 0)) scale(.95); } 55% { transform: rotate(0) translateY(-12px) scale(1.1); } 100% { transform: rotate(0) translateY(-6px) scale(1.04); } }
@keyframes badgePop { from { transform: scale(0) rotate(-90deg); } }

#template-confirm {
  position: relative; overflow: hidden; padding: 14px 40px; font-size: 22px; border-radius: 999px; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  background: linear-gradient(135deg, #ff8fab, #ff5d7a);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .16), 0 12px 22px rgba(255, 93, 122, .4);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s, filter .15s;
}
#template-confirm::after {
  content: ''; position: absolute; top: 0; left: -80%; width: 50%; height: 100%; transform: skewX(-20deg); pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
}
#template-confirm:hover:not(:disabled) { background: linear-gradient(135deg, #ff8fab, #ff5d7a); transform: translateY(-4px) scale(1.05); filter: brightness(1.07); }
#template-confirm:hover:not(:disabled)::after { animation: shine .7s ease; }
#template-confirm:active:not(:disabled) { transform: translateY(3px) scale(.97); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
#template-confirm:not(:disabled) { animation: capPulse 2.2s ease-in-out infinite; }
#template-confirm:disabled { background: linear-gradient(135deg, #d6d3d1, #a8a29e); box-shadow: 0 3px 0 rgba(0, 0, 0, .12); opacity: .75; text-shadow: none; }

@media (max-width: 600px) {
  #template-screen { margin: 14px 8px 30px; padding: 22px 10px 26px; border-radius: 24px; }
  #template-list { gap: 22px 14px; }
  .template-preview { width: 108px; height: 324px; }
}
@media (prefers-reduced-motion: reduce) {
  #template-screen, #template-screen h1::before, #template-screen h1::after, .template-card, .template-card.selected,
  .template-card.selected::after, #template-confirm:not(:disabled) { animation: none !important; }
  .template-card, .template-preview { transition: none; }
}

/* =====================================================
   TEMPLATE SCREEN: shifting gradient, floating hearts + balloons, glass card, glow on hover
   ===================================================== */
/* 1) peach -> pink -> lavender gradient that slowly drifts */
#bg-anim {
  background: linear-gradient(120deg, #ffc9a3, #ffb3c6 22%, #e3c8ff 44%, #ffb3c6 66%, #ffd1b0 88%, #ffc9a3);
  background-size: 320% 320%;
  animation: bgShift 22s ease-in-out infinite alternate;
}

/* 2) slow floating hearts, balloons and sparkles */
.floater {
  position: absolute; bottom: -80px; left: 0; line-height: 1; opacity: 0; user-select: none; will-change: transform, opacity;
  filter: drop-shadow(0 4px 8px rgba(160, 60, 100, .25));
  animation: floatUp var(--dur, 20s) linear var(--delay, 0s) infinite;
}
.floater > i { display: block; font-style: normal; animation: sway var(--sway, 5s) ease-in-out infinite alternate; }
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(var(--r0, -8deg)); opacity: 0; }
  8%   { opacity: .85; }
  92%  { opacity: .75; }
  100% { transform: translateY(-118vh) rotate(var(--r1, 10deg)); opacity: 0; }
}
@keyframes sway { from { transform: translateX(-16px); } to { transform: translateX(16px); } }

/* 3) frosted-glass card */
#template-screen {
  background:
    radial-gradient(circle at 10% 6%, rgba(255, 255, 255, .55), transparent 42%),
    radial-gradient(circle at 92% 94%, rgba(255, 255, 255, .35), transparent 45%),
    rgba(255, 255, 255, .34);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
  border: 1.5px solid rgba(255, 255, 255, .75);
  box-shadow: 0 18px 50px rgba(150, 60, 100, .22), inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(255, 255, 255, .3);
  border-radius: 34px;
}

/* 4) soft glow on hover (cards keep their shadow, gain a glowing border) */
.template-card:hover:not(.selected) {
  box-shadow: 0 0 0 3px rgba(255, 143, 171, .75), 0 0 30px 6px rgba(255, 143, 171, .5), 0 18px 34px rgba(90, 50, 30, .28);
  animation: glowPulse 1.8s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 143, 171, .75), 0 0 26px 4px rgba(255, 143, 171, .45), 0 18px 34px rgba(90, 50, 30, .28); }
  50%      { box-shadow: 0 0 0 3px rgba(200, 160, 255, .85), 0 0 38px 10px rgba(200, 160, 255, .55), 0 18px 34px rgba(90, 50, 30, .28); }
}
.template-card.selected { box-shadow: 0 0 0 4px #ff6b81, 0 0 36px 8px rgba(255, 107, 129, .5), 0 18px 34px rgba(255, 107, 129, .4); }

@media (max-width: 600px) { .floater { font-size: 80% !important; } }
@media (prefers-reduced-motion: reduce) {
  .floater, .floater > i, .template-card:hover:not(.selected) { animation: none !important; }
  .floater { display: none; }
}

/* =====================================================
   SHARED LIVELY BACKGROUND (welcome, template picker AND camera) + camera-screen glass
   ===================================================== */
/* gradient drift on its own layer: transform only, so it stays smooth next to the live camera */
#bg-anim { animation: none; background: #ffc9b3; }
#bg-anim::before {
  content: ''; position: absolute; inset: -55%; will-change: transform;
  background: conic-gradient(from 0deg, #ffc9a3, #ffb3c6, #e3c8ff, #ffb3c6, #ffd1b0, #ffc9a3);
  animation: washSpin 46s linear infinite;
}
/* keep the heavy blend effects off while the camera is running */
body:has(#booth-screen:not(.hidden)) .bg-flare,
body:has(#booth-screen:not(.hidden)) .sparkle,
body:has(#booth-screen:not(.hidden)) .roam-x { display: none; }

/* title: camera icon on the left */
#booth-screen h1.brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand-ico {
  height: clamp(36px, 7vw, 54px); width: auto; flex: 0 0 auto;
  filter: drop-shadow(0 4px 8px rgba(160, 60, 100, .35));
  animation: brandBob 3.4s ease-in-out infinite; -webkit-text-fill-color: initial;
}
@keyframes brandBob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-5px) rotate(5deg); } }
#booth-screen h1.brand::before { margin: 0 2px 0 0; }
#booth-screen h1.brand::after { margin: 0 0 0 2px; }

/* frosted glass filter panel */
#ar-bar {
  background: rgba(255, 255, 255, .36); border: 1.5px solid rgba(255, 255, 255, .75); border-radius: 26px;
  -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: 0 14px 36px rgba(150, 60, 100, .2), inset 0 1px 0 rgba(255, 255, 255, .9);
}
#template-label { background: rgba(255, 255, 255, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

/* glow on hover for the filter cards and camera buttons */
.ar-chip:hover:not(.active) {
  box-shadow: 0 0 0 3px rgba(255, 143, 171, .75), 0 0 26px 5px rgba(255, 143, 171, .5), 0 8px 16px rgba(0, 0, 0, .18);
  animation: glowPulseS 1.8s ease-in-out infinite;
}
@keyframes glowPulseS {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 143, 171, .75), 0 0 22px 4px rgba(255, 143, 171, .45), 0 8px 16px rgba(0, 0, 0, .18); }
  50%      { box-shadow: 0 0 0 3px rgba(200, 160, 255, .85), 0 0 32px 8px rgba(200, 160, 255, .55), 0 8px 16px rgba(0, 0, 0, .18); }
}

/* Paid-save badge and cashier/voucher dialog */
.pay-free-badge {
  width: fit-content; max-width: 100%; margin: 8px auto 14px; padding: 8px 16px;
  border: 1px solid rgba(255, 122, 162, .32); border-radius: 999px;
  background: rgba(255, 255, 255, .78); color: #a5365b; font-weight: 800;
  box-shadow: 0 6px 18px rgba(160, 70, 110, .12);
}
.pay-free-badge.is-free { color: #2d795d; border-color: rgba(65, 170, 125, .28); }
.pay-free-badge.is-error { color: #a33; border-color: rgba(180, 50, 50, .3); }
.pay-dialog {
  width: min(440px, calc(100vw - 28px)); padding: 24px; border: 1px solid rgba(255,255,255,.8);
  border-radius: 24px; color: #42323d; background: linear-gradient(145deg, #fffaf7, #fff0f5);
  box-shadow: 0 24px 80px rgba(65, 32, 50, .3);
}
.pay-dialog::backdrop { background: rgba(42, 25, 40, .52); backdrop-filter: blur(5px); }
.pay-dialog h3 { margin: 0 0 8px; font-size: 22px; }
.pay-dialog > p { line-height: 1.5; }
.pay-dialog label { display: grid; gap: 6px; margin: 12px 0; font-size: 13px; font-weight: 700; }
.pay-dialog input, .pay-dialog select {
  width: 100%; padding: 11px 12px; border: 1px solid #ecd3df; border-radius: 12px;
  background: #fff; color: inherit; font: inherit;
}
.pay-dialog-price { font-weight: 800; color: #a5365b; }
.pay-qr-guest { display: grid; justify-items: center; gap: 8px; margin: 14px 0; padding: 14px; border: 1px solid rgba(255, 122, 162, .24); border-radius: 18px; background: rgba(255,255,255,.75); text-align: center; }
.pay-qr-guest img { display: block; width: min(220px, 62vw); max-height: 270px; object-fit: contain; border-radius: 10px; background: white; }
.pay-qr-label { margin: 0; color: #684658; font-weight: 800; }
.pay-qr-guest a { color: #a5365b; font-weight: 800; }
.pay-qr-note { margin: 0; color: #796673; font-size: 12px; }
.pay-or { text-align: center; color: #87717d; font-size: 13px; }
.pay-dialog-message { min-height: 20px; color: #a5365b; font-size: 13px; }
.pay-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.pay-dialog-actions button { padding: 10px 16px; border: 0; border-radius: 999px; font: inherit; font-weight: 800; cursor: pointer; }
.pay-qr-payment { margin: 16px 0; padding: 14px; border: 1px solid rgba(240, 211, 192, .85); border-radius: 16px; background: #fffaf7; text-align: center; }
.pay-qr-payment h4 { margin: 0 0 10px; }
.pay-qr-payment img { display: block; width: min(240px, 70vw); max-height: 300px; margin: 0 auto; object-fit: contain; }
.pay-qr-payment p { margin: 10px 0 0; font-size: 12px; line-height: 1.5; }
#pay-dialog-cancel { color: #674a5a; background: #f2e4eb; }
#pay-dialog-confirm { color: #674a5a; background: #f2e4eb; }
#pay-gcash-checkout, #pay-finish-save { color: #fff; background: linear-gradient(135deg, #15a86d, #087c51); }
#pay-dialog-confirm:disabled { opacity: .55; cursor: wait; }
#booth-screen #change-template-btn:hover:not(:disabled), #booth-screen #gallery-btn:hover:not(:disabled) {
  box-shadow: 0 9px 0 rgba(0, 0, 0, .22), 0 0 28px 6px rgba(255, 255, 255, .6), 0 16px 26px rgba(0, 0, 0, .22);
}
@media (prefers-reduced-motion: reduce) {
  #bg-anim::before, .brand-ico, .ar-chip:hover:not(.active) { animation: none !important; }
}
@keyframes washSpin { to { transform: rotate(360deg); } }

/* ===== Template categories ===== */
#category-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin: 16px auto 4px; max-width: 100%;
}
#category-bar:empty { display: none; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 40px;
  font: inherit; font-size: 14px; font-weight: 600; color: #6a4a40; cursor: pointer;
  background: #fff; border: 2px solid #ffd9e2; border-radius: 999px;
  box-shadow: 0 3px 8px rgba(150, 70, 50, .12);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1), background .2s, border-color .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.cat-chip .cat-ico { font-size: 18px; line-height: 1; }
.cat-chip .cat-n { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: #ffe9ef; color: #c2415f; }
.cat-chip:hover { transform: translateY(-2px) scale(1.04); border-color: #ff8fab; }
.cat-chip.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, #ff8fab, #ff9a56); }
.cat-chip.active .cat-n { background: rgba(255, 255, 255, .3); color: #fff; }
.cat-empty { grid-column: 1 / -1; width: 100%; text-align: center; opacity: .7; font-size: 14px; }
@media (max-width: 600px) {
  #category-bar { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scroll-snap-type: x proximity;
    padding: 4px 6px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  #category-bar::-webkit-scrollbar { display: none; }
  .cat-chip { flex: 0 0 auto; scroll-snap-align: center; }
}
@media (prefers-reduced-motion: reduce) { .cat-chip { transition: none; } }

/* ---------- Camera controls and live photo rail ---------- */
.camera-workspace {
  display: flex; align-items: stretch; justify-content: center; gap: 20px;
  width: fit-content; max-width: calc(100vw - 28px); margin: 0 auto;
}
#video-wrap { flex: 0 1 auto; min-width: 0; }
#camera { max-width: min(70vw, 820px); max-height: 66vh; }
#camera.is-unmirrored, #ar-canvas.is-unmirrored { transform: none; }
.camera-tools {
  position: absolute; z-index: 6; top: 30px; right: 16px;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px;
  max-width: calc(100% - 32px);
}
.camera-tool {
  min-height: 36px; padding: 7px 11px; border: 1px solid rgba(255,255,255,.8); border-radius: 999px;
  color: #624550; background: rgba(255,255,255,.82); box-shadow: 0 4px 14px rgba(50,20,40,.18);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.camera-tool:hover { transform: translateY(-2px); }
.camera-tool.is-on { color: #fff; background: linear-gradient(135deg, #ff7190, #b276df); }
#camera-rail {
  box-sizing: border-box; flex: 0 0 174px; align-self: center; padding: 15px 13px;
  border: 1px solid rgba(255,255,255,.85); border-radius: 24px;
  background: linear-gradient(155deg, rgba(255,255,255,.9), rgba(255,245,249,.78) 52%, rgba(246,239,255,.88));
  box-shadow: 0 12px 32px rgba(120,60,90,.16), inset 0 1px 0 #fff;
  text-align: left; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: lifeUp .65s .2s cubic-bezier(.3,1.4,.5,1) both;
}
.camera-rail-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.camera-rail-heading h2 { margin: 0; color: #704858; font-size: 15px; }
.camera-rail-count { padding: 3px 8px; border-radius: 999px; color: #a34e78; background: #ffe5ed; font-size: 12px; }
.camera-shot-meter {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(215, 183, 205, .35);
}
.camera-shot-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8fab, #a879e8);
  transition: width .35s ease;
}
.camera-rail-note { min-height: 30px; margin: 7px 0 10px; color: #846b79; font-size: 11px; line-height: 1.4; }
#camera-shots { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.camera-shot {
  position: relative; display: grid; grid-template-columns: 64px 1fr; grid-template-rows: 1fr 1fr;
  align-items: center; column-gap: 9px; min-height: 56px; padding: 5px;
  border: 1px solid rgba(228,194,210,.7); border-radius: 13px; background: rgba(255,255,255,.58);
  color: #896e7b; transition: transform .22s ease, border-color .22s ease, background .22s ease, box-shadow .22s ease;
}
.camera-shot-thumb {
  position: relative; grid-row: 1 / 3; display: grid; place-items: center; width: 64px; height: 48px;
  overflow: hidden; border-radius: 9px; background: linear-gradient(135deg, #ffe2eb, #eee4ff);
}
.camera-shot.captured .camera-shot-thumb::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 50%;
  color: #fff;
  background: #55a780;
  font-size: 10px;
  font-weight: 900;
}
.camera-shot-placeholder { color: #bd8ba8; font-size: 19px; }
.camera-shot-thumb img { width: 100%; height: 100%; object-fit: cover; filter: brightness(1.16) contrast(1.06) saturate(1.08); }
.camera-shot-number { align-self: end; color: #715064; font-size: 11px; font-weight: 800; }
.camera-shot-status { align-self: start; color: #a28b97; font-size: 10px; }
.camera-shot.active { transform: translateX(-3px); border-color: #e99ab8; background: #fff4f8; box-shadow: 0 0 0 2px rgba(233,154,184,.15); }
.camera-shot.active .camera-shot-status { color: #b94c77; font-weight: 700; }
.camera-shot.captured { border-color: #e8c2d4; background: #fff; }
.camera-shot.captured .camera-shot-status { color: #539879; font-weight: 700; }
.camera-shot.latest { animation: shotPop .48s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes shotPop { 45% { transform: scale(1.07) rotate(-1deg); } }

@media (max-width: 760px) {
  .camera-workspace { flex-direction: column; align-items: center; gap: 12px; max-width: calc(100vw - 20px); }
  #camera { max-width: calc(100vw - 36px); max-height: 52vh; }
  #camera-rail { width: min(100%, 520px); flex-basis: auto; padding: 12px 14px; }
  #camera-rail .camera-rail-note { min-height: 0; }
  #camera-shots { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .camera-shot { grid-template-columns: 52px 1fr; min-height: 48px; column-gap: 7px; padding: 4px; }
  .camera-shot-thumb { width: 52px; height: 42px; }
  .camera-tools { top: 28px; right: 10px; gap: 5px; }
  .camera-tool { min-height: 32px; padding: 5px 8px; font-size: 11px; }
  .camera-addons {
    box-sizing: border-box;
    width: min(94vw, 560px);
    max-width: calc(100vw - 20px);
    padding: 11px 12px;
  }
  .backdrop-control { font-size: 13px; }
}
@media (max-width: 480px) {
  .camera-rail-heading h2 { font-size: 14px; white-space: nowrap; }
  #camera-rail .camera-rail-note { margin: 6px 0 9px; }
  #camera-shots {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 84px;
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 7px;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(190, 125, 164, .45) transparent;
    -webkit-overflow-scrolling: touch;
  }
  .camera-shot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    box-sizing: border-box;
    flex: 0 0 84px;
    width: 84px;
    min-height: 0;
    padding: 6px;
    scroll-snap-align: start;
  }
  .camera-shot-thumb { width: 100%; height: 54px; }
  .camera-shot-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
  .camera-shot-number, .camera-shot-status { font-size: 9px; white-space: nowrap; }
  .camera-shot.active { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  #camera-rail, .camera-shot.latest { animation: none; }
  .camera-tool, .camera-shot, .camera-shot-meter span { transition: none; }
}