:root {
  --bg: #14110f;
  --fg: #f7f3ee;
  --accent: #e8a33d;
  --accent-fg: #14110f;
  --font: system-ui, sans-serif;
  --panel: color-mix(in srgb, var(--fg) 8%, var(--bg));
  --line: color-mix(in srgb, var(--fg) 18%, transparent);
  --muted: color-mix(in srgb, var(--fg) 65%, transparent);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
input, textarea, select { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: fixed; inset: 0; }
.bg-image { position: fixed; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  z-index: 1;
}
.screen.active { display: flex; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 32px;
  border: 0;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 700;
  background: var(--panel);
  color: var(--fg);
  transition: transform .12s ease, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.small { min-height: 48px; font-size: 18px; padding: 0 22px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn:focus-visible, .tile:focus-visible, .chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- start ---------- */
#screen-start { gap: 28px; text-align: center; }
#slideshow { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
#slideshow img, #slideshow video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 1.2s ease; filter: brightness(.45);
}
#slideshow .on { opacity: 1; }
/* Start-screen video as an advert: no title over it, start buttons at the bottom. */
#screen-start.ad-only { justify-content: flex-end; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
#screen-start.ad-only .logo, #screen-start.ad-only .start-title, #screen-start.ad-only .start-sub { display: none; }
.logo { max-width: min(320px, 60vw); max-height: 22vh; object-fit: contain; }
.start-title { font-size: clamp(40px, 7vw, 88px); line-height: 1.02; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
.start-sub { font-size: clamp(20px, 2.6vw, 28px); margin: 0; color: var(--muted); }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; max-width: 980px; }
.tile {
  width: 200px; min-height: 170px; padding: 20px 16px;
  border-radius: var(--radius); border: 2px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.tile .ico { font-size: 48px; line-height: 1; }
.tile b { font-size: 22px; }
.tile small { color: var(--muted); font-size: 14px; line-height: 1.3; }
.tile.single { width: auto; min-height: 0; padding: 22px 48px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); border: 0; }
.tile.single .ico { font-size: 32px; }
.tile.single small { display: none; }

/* ---------- capture ---------- */
#screen-capture { padding: 0; background: #000; }
#stage { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
.stage-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: min(40vh, 320px); font-weight: 800; color: #fff; text-shadow: 0 6px 40px rgba(0,0,0,.6);
  pointer-events: none;
}
#countdown span { animation: pop .9s ease-out both; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(.9); opacity: .9; } }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#flash.go { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }
.hud-top { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; justify-content: center; gap: 12px; pointer-events: none; }
.pill { background: rgba(0,0,0,.55); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 20px; font-weight: 700; }
.pill.rec::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #ff3b30; margin-right: 8px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.capture-bottom {
  position: absolute; left: 0; right: 0; bottom: max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 16px;
}
.pickers { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.chips { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; padding: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 2px solid transparent; background: rgba(0,0,0,.55); color: #fff;
  border-radius: 14px; padding: 10px 16px; font-size: 17px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.chip.on { border-color: var(--accent); background: rgba(0,0,0,.75); }
.capture-actions { display: flex; gap: 14px; }
#guestbook-prompt { position: absolute; top: 80px; left: 24px; right: 24px; text-align: center; font-size: clamp(22px, 3vw, 34px); font-weight: 700; color: #fff; text-shadow: 0 2px 16px rgba(0,0,0,.7); pointer-events: none; }
#attendant-video { position: absolute; right: 20px; top: 80px; width: min(28vw, 260px); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.5); z-index: 5; }
.thumbs { position: absolute; left: 16px; bottom: 120px; display: flex; flex-direction: column; gap: 8px; }
.thumbs img { width: 96px; border-radius: 8px; border: 3px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.4); animation: slidein .4s ease-out; }
@keyframes slidein { from { transform: translateX(-120%); } to { transform: none; } }

.pill.warn { background: #d93025; }
#snap-preview {
  position: absolute; right: 24px; top: 80px; width: min(30vw, 320px); max-height: 60vh; object-fit: contain;
  border-radius: 14px; border: 4px solid #fff; box-shadow: 0 16px 50px rgba(0,0,0,.5); animation: slidein .3s ease-out;
}

/* ---------- self photo: pick photos ---------- */
#screen-select { flex-direction: row; align-items: stretch; gap: 28px; padding: 28px; }
.select-shots { flex: 1.4; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.select-shots h2 { margin: 0; font-size: 30px; }
.shot-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; padding: 4px; }
.shot-grid button { position: relative; padding: 0; border: 4px solid transparent; border-radius: 12px; background: #000; overflow: hidden; aspect-ratio: 2 / 3; }
.shot-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-grid button.on { border-color: var(--accent); }
.shot-grid b {
  position: absolute; top: 6px; left: 6px; min-width: 34px; height: 34px; border-radius: 99px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-fg); font-size: 18px;
}
.select-side { flex: 1; max-width: 520px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 0; }
#select-preview { max-width: 100%; max-height: 62vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); background: #fff; }

/* ---------- processing / review / share ---------- */
#screen-processing { gap: 22px; }
#render-preview { max-width: min(80vw, 520px); max-height: 60vh; border-radius: var(--radius); background: #000; }
.progress { width: min(420px, 80vw); height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.spinner { width: 56px; height: 56px; border-radius: 50%; border: 6px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-media { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4); background: #000; display: block; }
#screen-review { gap: 24px; }
#screen-review .media-box { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

#screen-share { flex-direction: row; gap: 36px; padding: 32px; }
#screen-share .media-box { flex: 1.3; height: 100%; display: flex; align-items: center; justify-content: center; min-width: 0; }
#screen-share .side { flex: 1; max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
.qr-card { background: #fff; color: #111; border-radius: var(--radius); padding: 18px; display: flex; gap: 16px; align-items: center; }
.qr-card svg { width: 168px; height: 168px; flex: none; }
.qr-wait { width: 168px; height: 168px; flex: none; display: flex; align-items: center; justify-content: center; }
.qr-card b { font-size: 22px; display: block; margin-bottom: 6px; }
.qr-card p { margin: 0; font-size: 16px; color: #444; line-height: 1.4; }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.share-actions .btn { width: 100%; font-size: 19px; padding: 0 16px; }
.share-actions .btn.wide { grid-column: 1 / -1; }
.copies { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 20px; font-weight: 700; }
.copies button { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--panel); font-size: 26px; }
.sent-list { font-size: 15px; color: var(--muted); min-height: 20px; }

/* ---------- forms (disclaimer, survey, keypad) ---------- */
.card {
  width: min(640px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border-radius: 24px; padding: 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.card h2 { margin: 0 0 16px; font-size: 32px; }
.card p { font-size: 20px; line-height: 1.5; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.field label { font-size: 19px; font-weight: 600; }
.field input[type=text], .field input[type=email], .field input[type=tel], .field textarea {
  font: inherit; font-size: 22px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--bg); color: var(--fg); width: 100%;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.options { display: flex; flex-wrap: wrap; gap: 10px; }
.options button { min-height: 52px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--line); background: transparent; font-size: 18px; }
.options button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.check { display: flex; gap: 14px; align-items: center; font-size: 20px; margin: 20px 0; }
.check input { width: 30px; height: 30px; accent-color: var(--accent); }
.err { color: #ff6b5b; font-size: 17px; min-height: 22px; }

.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden] { display: none; }

.keypad { display: grid; grid-template-columns: repeat(3, 80px); gap: 12px; justify-content: center; margin-top: 16px; }
.keypad button { height: 72px; border-radius: 16px; border: 0; background: var(--bg); font-size: 28px; font-weight: 700; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--fg); }
.pin-dots i.on { background: var(--fg); }

.op-grid { display: grid; gap: 14px; }
.op-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
.op-grid select, .op-grid input[type=text], .op-grid input[type=number] {
  font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.op-grid input[type=range] { width: 100%; accent-color: var(--accent); }
.op-grid .inline { flex-direction: row; align-items: center; gap: 10px; color: var(--fg); font-size: 17px; }
.op-preview { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 16/9; object-fit: contain; }

#admin-hotspot { position: fixed; top: 0; left: 0; width: 80px; height: 80px; z-index: 40; }
#sync-dot { position: fixed; right: 12px; bottom: 12px; z-index: 40; font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(0,0,0,.5); color: #fff; pointer-events: none; }
#sync-dot[hidden] { display: none; }

/* ---------- decorate ---------- */
#screen-decorate { padding: 16px; gap: 14px; }
.deco-stage { position: relative; flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.deco-stage canvas { max-width: 100%; max-height: 100%; touch-action: none; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.deco-tray { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; padding: 6px; }
.deco-tray button { flex: none; width: 64px; height: 64px; border-radius: 14px; border: 0; background: var(--panel); font-size: 36px; display: flex; align-items: center; justify-content: center; }
.deco-tray button img { width: 52px; height: 52px; object-fit: contain; }
.deco-tray button.on { outline: 3px solid var(--accent); }
.deco-tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--line); }
.swatch.on { border-color: var(--fg); }

#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 30px); z-index: 100;
  background: rgba(0,0,0,.85); color: #fff; padding: 14px 22px; border-radius: 14px; font-size: 18px;
  opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#screen-setup .card { text-align: left; }
.event-list { display: grid; gap: 10px; margin-top: 16px; }
.event-list button { text-align: left; padding: 16px 18px; border-radius: 14px; border: 2px solid var(--line); background: transparent; font-size: 19px; }
.event-list small { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }

@media (max-width: 820px), (orientation: portrait) {
  #screen-share { flex-direction: column; gap: 16px; padding: 16px; overflow-y: auto; justify-content: flex-start; }
  #screen-share .media-box { flex: none; height: 46vh; width: 100%; }
  #screen-share .side { max-width: none; width: 100%; }
  .qr-card svg { width: 128px; height: 128px; }
  .tile { width: 160px; min-height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- output switcher (share screen) ---------- */
#share-media { flex-direction: column; gap: 14px; }
.output-main { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.output-thumbs { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; padding: 4px; flex: none; }
.output-thumbs button {
  flex: none; width: 96px; padding: 5px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--panel); font-size: 13px; font-weight: 600;
}
.output-thumbs button.on { border-color: var(--accent); }
.output-thumbs img, .output-thumbs video { width: 100%; height: 92px; object-fit: contain; display: block; border-radius: 8px; }
.shots-count { flex: none; width: 110px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 12px; background: var(--panel); font-size: 13px; text-align: center; padding: 8px; }
.shots-count b { font-size: 30px; }
.output-thumbs .shots-count span { white-space: normal; margin: 0; }
.output-thumbs span { display: block; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#screen-start.ad-only .tile { width: auto; min-height: 0; padding: 14px 22px; flex-direction: row; gap: 10px; border-radius: 999px; }
#screen-start.ad-only .tile .ico { font-size: 28px; }
#screen-start.ad-only .tile small { display: none; }
