/* ============================================================
   Xmas 2026 AI Video Booth — design system
   Ink canvas · coral/violet/mint · gold for the holiday
   One stylesheet for booth, TV wall and admin.
   ============================================================ */

:root {
  --ink: #07080d;
  --ink-2: #0b0d15;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f6f7fb;
  --muted: #9aa1b6;
  --dim: #6a7185;

  --coral: #f4263c;        /* Xmas red */
  --red: #f4263c;
  --red-deep: #7d0d1a;
  --pine: #12a06a;         /* Xmas green */
  --pine-deep: #063a29;
  --violet: #8b5cf6;
  --mint: #2fe6a8;
  --amber: #ffb44d;
  --ice: #7dd3fc;
  --gold: #f5c97a;
  --snow: #eaf2ff;

  /* ── Xmas props · inline SVG so every tile has a real tree / gift / star ── */
  --svg-tree: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 130'%3E%3Crect x='45' y='104' width='10' height='16' rx='1' fill='%235a3a20'/%3E%3Cpath d='M50 30 74 68H26z' fill='%230b5c3a'/%3E%3Cpath d='M50 52 82 98H18z' fill='%230f7a4d'/%3E%3Cpath d='M50 8 68 44H32z' fill='%2312a06a'/%3E%3Cpath d='M50 0l2.7 6.4 6.9.6-5.2 4.5 1.6 6.7-6-3.6-6 3.6 1.6-6.7L40.4 7l6.9-.6z' fill='%23f5c97a'/%3E%3Cg fill='%23f4263c'%3E%3Ccircle cx='38' cy='62' r='4'/%3E%3Ccircle cx='62' cy='84' r='4'/%3E%3Ccircle cx='46' cy='94' r='3.4'/%3E%3C/g%3E%3Cg fill='%23f5c97a'%3E%3Ccircle cx='59' cy='56' r='3.2'/%3E%3Ccircle cx='34' cy='86' r='3.2'/%3E%3C/g%3E%3C/svg%3E");
  --svg-gift: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 80'%3E%3Crect x='10' y='34' width='50' height='42' rx='3' fill='%23f4263c'/%3E%3Crect x='30' y='34' width='10' height='42' fill='%23f5c97a'/%3E%3Crect x='10' y='50' width='50' height='9' fill='%23f5c97a'/%3E%3Crect x='6' y='26' width='58' height='11' rx='3' fill='%23d81b31'/%3E%3Crect x='30' y='26' width='10' height='11' fill='%23f5c97a'/%3E%3Cellipse cx='26' cy='21' rx='9' ry='6' fill='%23f5c97a'/%3E%3Cellipse cx='44' cy='21' rx='9' ry='6' fill='%23f5c97a'/%3E%3Ccircle cx='35' cy='23' r='3.4' fill='%23ffdca8'/%3E%3Crect x='66' y='46' width='44' height='30' rx='3' fill='%230f8a56'/%3E%3Crect x='82' y='46' width='9' height='30' fill='%23f5c97a'/%3E%3Crect x='66' y='38' width='44' height='9' rx='2' fill='%230a6b42'/%3E%3Crect x='82' y='38' width='9' height='9' fill='%23f5c97a'/%3E%3C/svg%3E");
  --svg-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.6l3 7.1 7.7.7-5.8 5.1 1.7 7.6-6.6-4-6.6 4 1.7-7.6L1.3 9.4l7.7-.7z' fill='%23f5c97a'/%3E%3C/svg%3E");
  --svg-pine: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 130'%3E%3Cpath d='M50 26 72 66H28z' fill='%23081712'/%3E%3Cpath d='M50 48 80 96H20z' fill='%2306100c'/%3E%3Crect x='45' y='96' width='10' height='24' fill='%2306100c'/%3E%3C/svg%3E");
  --display: 'Bricolage Grotesque', 'Helvetica Neue', system-ui, sans-serif;
  --ui: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', Georgia, serif;

  --r-xl: 34px;
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Ambient light + film grain, fixed behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(46vw 38vw at 4% -12%, rgba(244, 38, 60, 0.30), transparent 62%),
    radial-gradient(52vw 44vw at 12% -6%, rgba(18, 160, 106, 0.26), transparent 64%),
    radial-gradient(44vw 40vw at 96% 0%, rgba(18, 160, 106, 0.24), transparent 66%),
    radial-gradient(34vw 30vw at 78% 10%, rgba(245, 201, 122, 0.12), transparent 70%),
    radial-gradient(60vw 50vw at 52% 118%, rgba(244, 38, 60, 0.20), transparent 62%);
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 2.2vw, 30px) clamp(16px, 3vw, 44px);
}

/* ── Type ─────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; line-height: 0.98; }
h1 em, h2 em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.16em; font-size: 11px; color: var(--dim); }
.lede { color: var(--muted); font-size: clamp(14px, 1.5vw, 17px); max-width: 46ch; }

/* ── Top bar ──────────────────────────────────────────────── */
.topbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; padding-bottom: 12px; }
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, rgba(245, 201, 122, 0.55), rgba(255, 77, 109, 0.28) 34%, rgba(255, 255, 255, 0.06) 68%, transparent);
}

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.brand b { color: var(--text); font-weight: 600; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(47, 230, 168, 0.16), 0 0 16px var(--mint); animation: pulse 2.6s infinite; }
.brand .sep { color: var(--dim); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  backdrop-filter: blur(14px);
}
.chip b { color: var(--text); font-weight: 600; }
.chip.gold { border-color: rgba(245, 201, 122, 0.38); background: rgba(245, 201, 122, 0.09); color: var(--gold); }
.chip.gold b { color: var(--gold); }

/* ── Screens ──────────────────────────────────────────────── */
main { flex: 1 1 auto; min-height: 0; position: relative; display: flex; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(14px) scale(0.995);
  transition: opacity 0.42s var(--ease), transform 0.42s var(--ease), visibility 0.42s;
  overflow-y: auto; overflow-x: hidden;
  padding-top: clamp(10px, 1.8vh, 22px);
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; }
.screen::-webkit-scrollbar { width: 0; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  appearance: none; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text);
  font-family: var(--ui); font-size: 15px; font-weight: 500;
  padding: 15px 26px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.24s var(--snap), background 0.24s, border-color 0.24s, box-shadow 0.24s;
  touch-action: manipulation; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.28); }
.btn:active { transform: scale(0.965); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  border: 0; color: #14050a; font-weight: 650;
  background: linear-gradient(135deg, #ff8fa3 0%, var(--coral) 45%, #ff2f5c 100%);
  box-shadow: 0 14px 40px -12px rgba(255, 77, 109, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-primary:hover { box-shadow: 0 18px 50px -12px rgba(255, 77, 109, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.btn-lg { font-size: 17px; padding: 19px 34px; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-icon { width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 18px; }

/* ══ STEP 1 · scene picker ══════════════════════════════════ */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: clamp(16px, 2.6vw, 40px); flex-wrap: wrap; margin-bottom: clamp(10px, 1.6vh, 18px); }

.eyebrow { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); }
.eyebrow svg { flex: 0 0 auto; }
.eyebrow .rule { display: block; width: clamp(24px, 4vw, 54px); height: 1px; background: linear-gradient(90deg, rgba(245, 201, 122, 0.75), transparent); }

.hero h1 { font-size: clamp(30px, 4vw, 62px); margin-top: 7px; }
.hero h1 em {
  background: linear-gradient(100deg, #fff 6%, var(--gold) 52%, var(--coral) 96%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lede { margin-top: 7px; font-size: clamp(13px, 1.15vw, 15.5px); max-width: 54ch; }

.howto { display: flex; align-items: stretch; gap: 8px; list-style: none; }
.howto li {
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 13px 8px; min-width: 84px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03);
}
.howto li { position: relative; padding-top: 9px; }
.howto li::before { content: ''; position: absolute; top: 0; left: 0; width: 16px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--gold), rgba(245,201,122,0.15)); }
.howto i { display: none; }
.howto b { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.howto span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }

/* ── Scene grid: eight fat touch targets ──────────────────── */
.theme-grid {
  flex: 1 1 auto; min-height: 0;
  display: grid; gap: clamp(9px, 1.05vw, 15px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  padding-bottom: 2px;
}

.theme-card {
  position: relative; overflow: hidden; isolation: isolate; text-align: left; cursor: pointer;
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  padding: 7px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.02));
  color: var(--text); font-family: var(--ui);
  min-height: 0;
  transition: transform 0.3s var(--snap), border-color 0.3s, box-shadow 0.3s;
  animation: rise 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  touch-action: manipulation;
}
.theme-card:hover { transform: translateY(-5px); border-color: rgba(245, 201, 122, 0.42); box-shadow: 0 30px 70px -34px rgba(245, 201, 122, 0.55); }
.theme-card:active { transform: scale(0.972); }
.theme-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

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

/* ── Snow drift (booth only) ──────────────────────────────── */
.snowfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.snowfield i {
  position: absolute; top: -8vh; border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 7px rgba(234, 242, 255, 0.8);
  animation: snowFall linear infinite;
}
@keyframes snowFall {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(var(--drift, 24px), 116vh, 0); }
}

/* ── Camera ───────────────────────────────────────────────── */
.cam-wrap { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr); gap: clamp(18px, 3vw, 44px); align-items: center; }

.cam-stage {
  position: relative; height: 100%; min-height: 0;
  border-radius: var(--r-xl); overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #000;
  box-shadow: 0 40px 120px -50px rgba(255, 77, 109, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.cam-stage video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-stage .bracket { position: absolute; width: 46px; height: 46px; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 6px; }
.cam-stage .bracket.tl { top: 18px; left: 18px; border-right: 0; border-bottom: 0; }
.cam-stage .bracket.tr { top: 18px; right: 18px; border-left: 0; border-bottom: 0; }
.cam-stage .bracket.bl { bottom: 18px; left: 18px; border-right: 0; border-top: 0; }
.cam-stage .bracket.br { bottom: 18px; right: 18px; border-left: 0; border-top: 0; }

.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(7, 8, 13, 0.42); backdrop-filter: blur(2px);
  font-family: var(--display); font-weight: 800; font-size: clamp(96px, 22vh, 220px);
  color: #fff; text-shadow: 0 20px 60px rgba(255, 77, 109, 0.7);
  opacity: 0; pointer-events: none;
}
.countdown.is-on { opacity: 1; }
.countdown.is-on span { animation: pop 0.9s var(--snap); display: block; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1); opacity: 1; } }

.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.is-on { animation: flash 0.5s ease-out; }
@keyframes flash { 0% { opacity: 0.92; } 100% { opacity: 0; } }

.cam-side { display: flex; flex-direction: column; gap: 18px; }
.cam-side h2 { font-size: clamp(30px, 3.6vw, 46px); }
.cam-step { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.cam-step i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-style: normal; font-size: 10px; color: var(--muted); }
.cam-step.is-now { color: var(--text); }
.cam-step.is-now i { background: var(--coral); border-color: var(--coral); color: #180409; font-weight: 700; }
.cam-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }

.shutter {
  width: clamp(76px, 9vw, 96px); height: clamp(76px, 9vw, 96px); border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85); background: transparent;
  display: grid; place-items: center; cursor: pointer;
  transition: transform 0.22s var(--snap), border-color 0.2s;
}
.shutter span { width: 76%; height: 76%; border-radius: 50%; background: linear-gradient(135deg, #fff, #ffd7dd); box-shadow: inset 0 -4px 10px rgba(0, 0, 0, 0.18); }
.shutter:active { transform: scale(0.92); }
.shutter:hover { border-color: #fff; }

/* ── Preview ──────────────────────────────────────────────── */
.preview-wrap { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: clamp(20px, 3vw, 48px); align-items: center; }
.shot-stage { height: 100%; min-height: 0; border-radius: var(--r-xl); overflow: hidden; border: 1px solid var(--line-strong); background: #000; display: grid; place-items: center; }
.shot-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-side { display: flex; flex-direction: column; gap: 16px; }
.preview-side h2 { font-size: clamp(30px, 3.8vw, 48px); }
.preview-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.preview-actions .btn { width: 100%; }

/* ── Thank you ────────────────────────────────────────────── */
.thanks { flex: 1 1 auto; display: grid; place-items: center; text-align: center; }
.thanks-inner { max-width: 780px; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.thanks h2 { font-size: clamp(52px, 9vw, 128px); letter-spacing: -0.045em; background: linear-gradient(102deg, #fff 10%, #ffc9d3 46%, var(--coral) 82%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.thanks .lede { font-size: clamp(15px, 1.7vw, 19px); text-align: center; max-width: 40ch; }
.timer-line { width: min(360px, 70vw); height: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-top: 8px; }
.timer-line i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--coral), var(--amber)); transform-origin: left; }
.timer-line.is-running i { animation: drain 7s linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.thanks-badge { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(47, 230, 168, 0.35); background: rgba(47, 230, 168, 0.1); color: var(--mint); font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }

/* ── Closed / error states ────────────────────────────────── */
.state-card { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 520px; }
.state-card h2 { font-size: clamp(30px, 4vw, 46px); }

/* ══ TV WALL ════════════════════════════════════════════════ */
body.tv-page { overflow: hidden; background: #000; }
.tv-page::before { opacity: 0.45; }

.tv-shell {
  position: relative; z-index: 1; height: 100%;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(8px, 1.2vh, 14px);
  padding: clamp(12px, 1.7vh, 22px) clamp(14px, 2vw, 30px) clamp(14px, 1.9vh, 24px);
}

.tv-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 9px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.tv-top-right { display: flex; align-items: center; gap: 8px; }
.tv-top .btn-icon { width: 38px; height: 38px; font-size: 10px; letter-spacing: 0.1em; }
.tv-top .chip { padding: 7px 12px; font-size: 10px; }

.tv-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(12px, 1.5vw, 24px); min-height: 0; }
body.tv-empty-mode .tv-body { grid-template-columns: minmax(0, 1fr); }

/* hero player */
.tv-hero { position: relative; min-height: 0; display: grid; place-items: center; border-radius: 22px; overflow: hidden; }
.tv-backdrop {
  position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover;
  filter: blur(34px) saturate(1.65); opacity: 0.46; transform: scale(1.2);
  -webkit-mask-image: radial-gradient(closest-side at 50% 50%, #000 22%, transparent 74%);
  mask-image: radial-gradient(closest-side at 50% 50%, #000 22%, transparent 74%);
}
.tv-video {
  position: relative; z-index: 1; height: 100%; width: auto; max-width: 100%;
  border-radius: 16px; background: #000;
  box-shadow: 0 46px 130px -40px rgba(139, 92, 246, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.tv-empty { position: relative; z-index: 1; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.tv-empty h1 { font-size: clamp(40px, 6.4vw, 88px); }
.tv-empty .orb { width: clamp(110px, 14vw, 180px); height: clamp(110px, 14vw, 180px); border-radius: 50%; background: conic-gradient(from 0deg, var(--gold), var(--coral), var(--violet), var(--mint), var(--gold)); filter: blur(22px); opacity: 0.55; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tv-toast {
  position: absolute; top: clamp(12px, 2vh, 22px); left: 50%; transform: translate(-50%, -14px);
  z-index: 5; padding: 10px 19px; border-radius: 999px;
  background: rgba(245, 201, 122, 0.16); border: 1px solid rgba(245, 201, 122, 0.46);
  backdrop-filter: blur(18px); color: var(--gold);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  opacity: 0; transition: opacity 0.4s, transform 0.4s var(--snap); pointer-events: none; white-space: nowrap;
}
.tv-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* the filmstrip — every clip on the wall, newest first, two columns */
.tv-rail { display: flex; flex-direction: column; gap: 7px; min-height: 0; width: clamp(196px, 17.5vw, 336px); }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255, 255, 255, 0.42); }
.rail-head b { color: var(--gold); font-weight: 500; font-size: 12px; letter-spacing: 0.06em; }
.rail-list { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 7px; }
.rail-foot { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255, 255, 255, 0.3); }

.rail-item {
  position: relative; overflow: hidden; padding: 0; appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 11px;
  background: #0b0d15; cursor: pointer;
  transition: transform 0.25s var(--snap), border-color 0.25s, box-shadow 0.25s;
}
.rail-item img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.62; transition: opacity 0.3s; }
.rail-item::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), transparent 56%); }
.rail-item:hover img { opacity: 0.8; }
.rail-item:hover { transform: translateY(-2px); }
.rail-item.is-now { border-color: rgba(245, 201, 122, 0.95); box-shadow: 0 0 0 2px rgba(245, 201, 122, 0.22), 0 16px 40px -18px rgba(245, 201, 122, 0.8); }
.rail-item.is-now img { opacity: 1; }
.rail-tag {
  position: absolute; z-index: 2; top: 5px; left: 5px;
  font-family: var(--mono); font-size: 8px; letter-spacing: 0.1em;
  padding: 2px 5px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.55); color: rgba(255, 255, 255, 0.8); backdrop-filter: blur(6px);
}
.rail-item.is-now .rail-tag { background: var(--gold); color: #1a1206; }
.rail-p { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.14); }
.rail-p i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--coral), var(--amber)); }

.tv-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-top: 6px; }
.tv-title { font-family: var(--display); font-weight: 700; font-size: clamp(21px, 2.6vh, 38px); letter-spacing: -0.03em; line-height: 1; }
.tv-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255, 255, 255, 0.48); margin-top: 5px; }
.tv-count { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; color: rgba(255, 255, 255, 0.48); text-align: right; white-space: nowrap; }

.tv-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.1); z-index: 4; }
.tv-progress i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--coral), var(--amber)); transition: width 0.2s linear; }

/* ── Admin ────────────────────────────────────────────────── */
body.admin-page { overflow-y: auto; }
body.admin-page .shell { min-height: 100%; height: auto; }

.admin-wrap { width: min(1240px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: clamp(16px, 2.4vw, 28px); padding-bottom: 60px; }

.login-card {
  margin: 12vh auto 0; width: min(440px, 92vw); padding: clamp(24px, 3vw, 40px);
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(20px); display: flex; flex-direction: column; gap: 18px;
}
.login-card h1 { font-size: 34px; }
.pin-input {
  width: 100%; padding: 16px 18px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.35); color: var(--text);
  font-family: var(--mono); font-size: 22px; letter-spacing: 0.4em; text-align: center;
}
.pin-input:focus { outline: 2px solid rgba(255, 77, 109, 0.55); outline-offset: 2px; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 18px 20px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); }
.kpi .mono { margin-bottom: 8px; }
.kpi b { font-family: var(--display); font-size: clamp(26px, 3vw, 36px); font-weight: 700; letter-spacing: -0.03em; display: block; }
.kpi small { color: var(--dim); font-size: 12px; }

.panel { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 20px; }
.panel-body { padding: 18px 22px; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 18px 22px; }
.video-card { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; }
.video-thumb { aspect-ratio: 9 / 16; background: #05060a center/cover no-repeat; position: relative; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.video-meta b { font-size: 13px; font-weight: 600; }
.video-meta .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.video-actions { display: flex; gap: 6px; }
.mini { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; padding: 6px 9px; border-radius: 8px; cursor: pointer; }
.mini:hover { color: var(--text); border-color: var(--line-strong); }
.mini.danger:hover { color: var(--coral); border-color: rgba(255, 77, 109, 0.5); }

.status-pill { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status-ready { color: var(--mint); border-color: rgba(47, 230, 168, 0.35); background: rgba(47, 230, 168, 0.08); }
.status-generating, .status-queued { color: var(--amber); border-color: rgba(255, 180, 77, 0.35); background: rgba(255, 180, 77, 0.08); }
.status-failed { color: var(--coral); border-color: rgba(255, 77, 109, 0.4); background: rgba(255, 77, 109, 0.08); }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.field input, .field select {
  padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.32); color: var(--text); font-family: var(--ui); font-size: 14px;
}
.field input:focus, .field select:focus { outline: 2px solid rgba(255, 77, 109, 0.4); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  z-index: 90; padding: 13px 24px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(20px); font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.35s var(--snap); white-space: nowrap;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(255, 77, 109, 0.5); background: rgba(255, 77, 109, 0.18); }

/* Flex/grid containers must not defeat the hidden attribute */
[hidden] { display: none !important; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 999px) {
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(232px, 1fr); }
  .theme-body { min-height: 0; }
  .theme-title { min-height: 0; }
  .howto li { min-width: 78px; }
}

@media (max-width: 820px) {
  .theme-grid { gap: 9px; grid-auto-rows: minmax(168px, 1fr); }
  .theme-card .theme-tag { display: none; }
  .theme-body { padding: 8px 9px 6px; gap: 3px; }
  .theme-card .theme-title { font-size: clamp(19px, 4.4vw, 27px); }
  .theme-num { font-size: clamp(28px, 6.4vw, 40px); }
  .howto { display: none; }
  .cam-wrap, .preview-wrap { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 16px; }
  .cam-side, .preview-side { gap: 12px; }
  .cam-side h2, .preview-side h2 { font-size: 26px; }
  .cam-side .lede, .preview-side .lede { display: none; }
  .topbar .chip { display: none; }
}

@media (max-height: 720px) {
  .hero h1 { font-size: clamp(28px, 3.6vw, 46px); }
  .hero .lede { max-width: 62ch; }
  .theme-card p, .theme-card .theme-tag { display: none; }
  .theme-body { padding: 8px 10px 7px; row-gap: 5px; }
  .theme-num { font-size: clamp(26px, 2.85vw, 38px); }
}

@media (max-height: 640px) {
  .theme-card { min-height: 176px; }
  .theme-card p, .theme-card .theme-of { display: none; }
  .theme-num { font-size: 27px; }
  .howto { display: none; }
  .scene { min-height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ── Scene card text (spans, not headings, inside a <button>) ── */


/* ══ v5 · Xmas pass ═══════════════════════════════════════════
   Red + green as the primary pair, gold as the only luxury accent.
   Candy-cane edge on the cards, gifts/tree/stars inside every scene. */

.theme-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 5;
  border-radius: var(--r-lg) var(--r-lg) 0 0; opacity: 0.92;
  background: repeating-linear-gradient(115deg,
    var(--coral) 0 9px, #f8faff 9px 18px, var(--pine) 18px 27px, #f8faff 27px 36px);
}
.theme-card:hover {
  border-color: rgba(244, 38, 60, 0.5);
  box-shadow: 0 30px 70px -34px rgba(244, 38, 60, 0.62), 0 0 0 1px rgba(18, 160, 106, 0.2);
}
.theme-card:hover @media (max-width: 999px) {
  .loc-grid { grid-template-columns: 1fr; grid-auto-rows: minmax(120px, 1fr); }
  .loc-code { font-size: clamp(38px, 9vw, 62px); }
  .loc-row { grid-template-columns: 54px 1fr auto; }
  .loc-row .loc-bar { display: none; }
}

/* ── TV wall · site picker ────────────────────────────────── */
.tv-loc {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  padding: clamp(20px, 4vh, 52px) clamp(24px, 4vw, 64px);
  background:
    radial-gradient(60vw 50vw at 8% 0%, rgba(244, 38, 60, 0.26), transparent 62%),
    radial-gradient(64vw 54vw at 96% 100%, rgba(18, 160, 106, 0.26), transparent 64%),
    #05070c;
  animation: rise 0.4s var(--ease) both;
}
.tv-loc-inner { width: min(1240px, 100%); display: flex; flex-direction: column; gap: clamp(14px, 2.4vh, 28px); }
.tv-loc-title { font-family: var(--display); font-weight: 800; font-size: clamp(38px, 6vw, 84px); letter-spacing: -0.04em; line-height: 0.94; }
.tv-loc-title em { font-family: var(--serif); font-style: italic; font-weight: 400; background: linear-gradient(100deg, #fff 6%, var(--gold) 50%, var(--coral) 96%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.loc-grid.tv { grid-auto-rows: minmax(190px, 1fr); max-height: 50vh; }
.loc-grid.tv .loc-scene { display: none; }
.loc-grid.tv .loc-code { font-size: clamp(40px, 4.4vw, 66px); }
.loc-grid.tv .loc-card { padding: clamp(16px, 1.8vw, 26px); }
.video-card .loc-tag { color: var(--gold); }

/* ══ v9.2 · Themes are type-only tiles ══════════════════════
   The cover illustration is gone. The name is the artwork: each
   tile is a colour field drawn from that scene's own accent pair,
   with the scene name set as the largest element and the index
   demoted to something the eye finds second, not first. */

.theme-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: block; text-align: left; cursor: pointer;
  padding: 0; min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--r-lg);
  background: #07080d;
  color: #fff; font-family: var(--ui);
  transition: transform 0.3s var(--snap), border-color 0.3s, box-shadow 0.3s;
  touch-action: manipulation;
}

/* colour field — the only "picture" a tile gets */
.theme-field {
  position: absolute; inset: 0; z-index: 0; opacity: 0.32;
  background:
    radial-gradient(118% 104% at 4% 0%, var(--a1) 0%, transparent 58%),
    radial-gradient(104% 96% at 104% 104%, var(--a2) 0%, transparent 62%),
    linear-gradient(166deg, #161a26 0%, #0a0c14 62%, #07080d 100%);
  filter: saturate(1.15);
  transition: opacity 0.35s var(--ease), transform 0.6s var(--ease);
}
.theme-card:hover .theme-field { opacity: 0.52; transform: scale(1.04); }

.theme-body {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: center; gap: clamp(8px, 1.5vh, 17px);
  padding: clamp(11px, 1.15vw, 16px) clamp(12px, 1.25vw, 17px) clamp(12px, 1.3vw, 18px);
}

/* the index is the tile's only graphic: a big outlined numeral with the
   count hanging off its baseline. One number per card, read from 2 m. */
.theme-idx { display: flex; align-items: flex-end; gap: 7px; flex: 0 0 auto; }
.theme-num {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(56px, 7.4vw, 106px); line-height: 0.7; letter-spacing: -0.07em;
  font-variant-numeric: tabular-nums;
  color: transparent; -webkit-text-stroke: 1.4px rgba(255, 255, 255, 0.62);
  transition: -webkit-text-stroke-color 0.3s, transform 0.3s var(--snap);
}
.theme-of {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.4); padding-bottom: 0.55em;
}
.theme-card:hover .theme-num { -webkit-text-stroke-color: var(--gold); transform: translateY(-2px); }

/* the name owns the tile: bottom-anchored so every title sits on one
   optical baseline across the shelf, no matter how many lines it takes */
.theme-meta { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.theme-title {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: clamp(23px, 2.95vw, 36px); line-height: 0.9;
  letter-spacing: -0.042em; color: #fff;
  text-wrap: balance;
}
.theme-zh {
  display: block; font-family: var(--tc); font-weight: 500;
  font-size: clamp(13px, 1.18vw, 17px); letter-spacing: 0.08em; line-height: 1.2;
  color: var(--gold); opacity: 0.95;
}
.theme-card .theme-tag, .theme-card p { display: none; }

.theme-arrow {
  position: absolute; top: clamp(9px, 1vw, 13px); right: clamp(9px, 1vw, 13px); z-index: 4;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(7, 8, 13, 0.42); border: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(8px); color: #fff; opacity: 0.75;
  transition: transform 0.3s var(--snap), background 0.25s, color 0.25s, border-color 0.25s, opacity 0.25s;
}
.theme-card:hover .theme-arrow { background: var(--gold); border-color: transparent; color: #1a1206; transform: translateX(3px); opacity: 1; }
.theme-card:hover .theme-title { color: #fff; }

@media (max-width: 999px) {
  .theme-title { font-size: clamp(27px, 5vw, 42px); }
  .theme-num { font-size: clamp(64px, 10.5vw, 120px); }
  .theme-zh { font-size: clamp(15px, 2.4vw, 20px); }
}
@media (max-width: 820px) {
  .theme-title { font-size: clamp(24px, 5.6vw, 34px); }
}
@media (max-height: 720px) {
  .theme-title { font-size: clamp(20px, 2.3vw, 30px); }
  .theme-num { font-size: clamp(48px, 6.6vw, 92px); }
  .theme-body { gap: 4px; padding: 9px 11px 10px; }
}
@media (max-height: 640px) {
  .theme-card { min-height: 148px; }
  .theme-title { font-size: 19px; }
  .theme-zh { font-size: 12.5px; }
  .theme-of { display: none; }
}

/* ══ v9.3 · ten scenes + share ticket ═══════════════════════════ */

/* Five-up grid: ten scenes still fit two rows on a landscape iPad.
   Type scales down one notch so the longest single word (Gingerbread)
   never touches the card edge at the narrower column width. */
.theme-grid[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.theme-grid[data-cols="5"] .theme-num { font-size: clamp(40px, 5.1vw, 72px); }
.theme-grid[data-cols="5"] .theme-title { font-size: clamp(17px, 2.05vw, 25px); letter-spacing: -0.045em; }
.theme-grid[data-cols="5"] .theme-zh { font-size: clamp(11px, 1.05vw, 14px); }
.theme-grid[data-cols="5"] .theme-idx { gap: 5px; }
.theme-grid[data-cols="5"] .theme-of { font-size: 8px; }
@media (max-width: 999px) {
  .theme-grid[data-cols="5"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(150px, 1fr); overflow-y: auto; overscroll-behavior: contain; }
  .theme-grid[data-cols="5"] .theme-num { font-size: clamp(46px, 9vw, 86px); }
  .theme-grid[data-cols="5"] .theme-title { font-size: clamp(21px, 3.8vw, 31px); }
  .theme-grid[data-cols="5"] .theme-zh { font-size: clamp(13px, 2.2vw, 18px); }
}

/* ── Thanks: render clock on the left, QR ticket on the right ── */
.screen[data-screen="thanks"].is-active { display: flex; flex-direction: column; }
.thanks2 {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(232px, 25vw, 306px);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "main ticket" "end ticket";
  column-gap: clamp(16px, 3vw, 46px); row-gap: clamp(6px, 1.2vh, 12px);
  padding: 0;
}
.thanks-main {
  position: relative; min-width: 0; grid-area: main;
  display: flex; flex-direction: column; justify-content: center;
  align-items: flex-start; gap: clamp(6px, 1.15vh, 13px);
  text-align: left;
}
.thanks-main .burst { position: absolute; inset: -8% -4%; pointer-events: none; }
.thanks-main .thanks-deco { display: none; }
.thanks-main h2 {
  font-family: var(--display); font-size: clamp(42px, 6.1vw, 82px); line-height: 0.86;
  letter-spacing: -0.052em; margin: 0; padding: 0;
  background: linear-gradient(102deg, #fff 12%, #ffd3da 50%, var(--coral) 88%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.thanks-main .lede {
  font-size: clamp(13px, 1.32vw, 16px); line-height: 1.5; max-width: 41ch;
  text-align: left; color: rgba(234, 242, 255, 0.66);
}

/* the clock: a draining ring with mono digits inside */
.clock-row { display: flex; align-items: center; gap: clamp(12px, 1.8vw, 22px); margin-top: clamp(2px, 0.7vh, 9px); }
.clock-ring { position: relative; width: clamp(84px, 9.6vw, 112px); aspect-ratio: 1; flex: 0 0 auto; }
.clock-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.clock-ring .ring-track { fill: none; stroke: rgba(255, 255, 255, 0.11); stroke-width: 4.5; }
.clock-ring .ring-fill {
  fill: none; stroke: var(--gold); stroke-width: 4.5; stroke-linecap: round;
  transition: stroke-dashoffset 0.28s linear, stroke 0.4s ease;
}
.clock-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.clock-face b { font-family: var(--mono); font-weight: 500; font-size: clamp(19px, 2.1vw, 26px); letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.clock-face span { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(234, 242, 255, 0.4); }
.clock-copy { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.clock-copy .mono { color: rgba(234, 242, 255, 0.42); }
.render-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: clamp(7px, 1.1vw, 15px); }
.render-steps li {
  position: relative; padding-left: 13px; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.11em; text-transform: uppercase; color: rgba(234, 242, 255, 0.32);
  transition: color 0.25s ease;
}
.render-steps li::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.16); transition: background 0.25s ease;
}
.render-steps li.is-done::before { background: var(--mint); }
.render-steps li.is-now { color: var(--snow); }
.render-steps li.is-now::before { background: var(--gold); box-shadow: 0 0 0 3px rgba(245, 201, 122, 0.16); animation: pulseDot 1.5s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

#thanksRoot[data-state="ready"] .ring-fill { stroke: var(--mint); }
#thanksRoot[data-state="failed"] .ring-fill { stroke: var(--coral); }
#thanksRoot[data-state="ready"] .clock-copy .mono { color: rgba(47, 230, 168, 0.7); }
#thanksRoot[data-state="ready"] .thanks-badge { border-color: rgba(47, 230, 168, 0.42); background: rgba(47, 230, 168, 0.12); color: var(--mint); }
#thanksRoot[data-state="failed"] .thanks-badge { border-color: rgba(244, 38, 60, 0.38); background: rgba(244, 38, 60, 0.1); color: #ff8494; }

.end-btn { grid-area: end; justify-self: start; margin: 0; }

/* the ticket: boarding-pass styling, perforated edge, QR panel */
.share-ticket {
  position: relative; display: flex; flex-direction: column; gap: clamp(9px, 1.1vh, 13px);
  grid-area: ticket; align-self: center;
  padding: clamp(13px, 1.5vw, 18px); border-radius: 18px;
  background: linear-gradient(168deg, #181c28, #0a0c14 64%, #07080d);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 26px 60px -34px rgba(0, 0, 0, 0.92);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.share-ticket[data-state="ready"] {
  border-color: rgba(47, 230, 168, 0.4);
  box-shadow: 0 0 0 1px rgba(47, 230, 168, 0.1), 0 30px 70px -34px rgba(47, 230, 168, 0.32);
}
.ticket-perf {
  position: absolute; left: 14px; right: 14px; top: 0; height: 1px; margin-top: -1px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.26) 0 6px, transparent 6px 12px);
}
.ticket-top { display: flex; align-items: center; justify-content: space-between; padding-top: 2px; }
.ticket-top .mono { color: rgba(234, 242, 255, 0.4); }
.ticket-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(245, 201, 122, 0.14); animation: pulseDot 1.5s ease-in-out infinite; }
.share-ticket[data-state="ready"] .ticket-dot { background: var(--mint); box-shadow: 0 0 0 3px rgba(47, 230, 168, 0.18); animation: none; }
.share-ticket[data-state="failed"] .ticket-dot { background: var(--coral); animation: none; }
.qr-frame { position: relative; aspect-ratio: 1; border-radius: 12px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.qr-frame canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; transition: opacity 0.35s ease; }
.share-ticket[data-state="ready"] .qr-frame canvas { opacity: 1; }
.qr-wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 14px; text-align: center; }
.qr-wait b { font-family: var(--display); font-size: 15px; color: #171c26; letter-spacing: -0.015em; }
.qr-wait span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: #7d8698; }
.share-ticket[data-state="ready"] .qr-wait { display: none; }
.qr-spin { width: 17px; height: 17px; border-radius: 50%; border: 2px solid rgba(10, 12, 20, 0.13); border-top-color: var(--coral); animation: qrSpin 0.85s linear infinite; margin-bottom: 3px; }
.share-ticket[data-state="failed"] .qr-spin { display: none; }
@keyframes qrSpin { to { transform: rotate(360deg); } }
.ticket-meta { display: flex; flex-direction: column; gap: 3px; }
.ticket-meta b { font-family: var(--display); font-size: clamp(15px, 1.45vw, 18px); letter-spacing: -0.02em; }
.ticket-meta span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(234, 242, 255, 0.4); }
.btn-wide { width: 100%; justify-content: center; }

@media (max-width: 900px) {
  .thanks2 { grid-template-columns: minmax(0, 1fr) clamp(190px, 28vw, 240px); gap: 16px; }
}
@media (max-width: 720px) {
  .thanks2 { grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
  .thanks-main h2 { font-size: clamp(36px, 9vw, 54px); }
  .share-ticket { width: min(230px, 58vw); }
  .thanks-main .thanks-deco { display: none; }
}

/* ══ Thanks · PORTRAIT (the iPad stands upright) ═══════════════
   QR is the hero: it eats every pixel the clock and End button
   don't need. No reserved padding, full-bleed ticket, 46 px clock. */
@media (orientation: portrait) {
  .screen[data-screen="thanks"] { padding: clamp(6px, 1.1vh, 14px) clamp(8px, 1.5vw, 18px); }
  .thanks2 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "main" "ticket" "end";
    column-gap: 0; row-gap: clamp(8px, 1.5vh, 16px); padding: 0;
    align-content: center; align-items: stretch;
  }
  .thanks-main { align-items: center; justify-content: flex-start; text-align: center; gap: clamp(6px, 1.05vh, 11px); }
  .thanks-main h2 { font-size: clamp(40px, 6.2vh, 66px); line-height: 0.9; }
  .thanks-main .lede { text-align: center; max-width: 44ch; font-size: clamp(13px, 1.65vh, 17px); line-height: 1.42; }
  .thanks-badge { padding: 8px 16px; }

  .clock-row { margin: 0; gap: clamp(18px, 3vh, 32px); align-items: center; justify-content: center; }
  .clock-ring { width: clamp(126px, 17.5vh, 196px); }
  .clock-ring .ring-track, .clock-ring .ring-fill { stroke-width: 6; }
  .clock-face { gap: 3px; }
  .clock-face b { font-size: clamp(36px, 5.1vh, 58px); }
  .clock-face span { font-size: 10px; letter-spacing: 0.18em; }
  .clock-copy { gap: 10px; }
  .clock-copy .mono { font-size: 10.5px; letter-spacing: 0.18em; }
  .render-steps { gap: 12px; }
  .render-steps li { font-size: 10.5px; padding-left: 14px; }

  .share-ticket {
    align-self: start; width: 100%; min-height: 0;
    padding: clamp(10px, 1.4vh, 16px); gap: clamp(8px, 1.1vh, 13px); border-radius: 22px;
  }
  /* deterministic square: 42% of the tall viewport, capped by width */
  .qr-frame {
    flex: 0 0 auto; width: min(42vh, 88vw); height: min(42vh, 88vw);
    margin: 0 auto; aspect-ratio: 1;
  }
  .qr-frame canvas { width: 100%; height: 100%; }
  .qr-wait { gap: 8px; }
  .qr-wait b { font-size: clamp(15px, 2.1vh, 22px); }
  .qr-wait span { font-size: 10px; }
  .ticket-perf { left: 18px; right: 18px; }
  .ticket-meta { align-items: center; text-align: center; gap: 4px; }
  .ticket-meta b { font-size: clamp(16px, 2.3vh, 24px); }
  .ticket-meta span { font-size: 10px; letter-spacing: 0.14em; }

  .end-btn {
    grid-area: end; justify-self: stretch; width: 100%;
    font-size: clamp(16px, 2.4vh, 22px); font-weight: 600; letter-spacing: -0.01em;
    padding: clamp(16px, 2.7vh, 27px) 20px; border-radius: 18px;
    border-color: rgba(255, 255, 255, 0.22); color: var(--text);
    background: rgba(255, 255, 255, 0.05);
  }
}

/* ══ Thanks · WAITING: no QR until the clip exists ═════════════
   A white square with a spinner reads as "here comes a QR" that the
   guest can try to scan. Nothing to scan yet = nothing on screen. */
#thanksRoot[data-state="wait"] .qr-frame,
#thanksRoot[data-state="failed"] .qr-frame { display: none; }

#thanksRoot[data-state="wait"] .share-ticket,
#thanksRoot[data-state="failed"] .share-ticket {
  background: linear-gradient(168deg, rgba(24, 28, 40, 0.72), rgba(7, 8, 13, 0.72));
  gap: 7px; padding: clamp(11px, 1.5vh, 16px) clamp(13px, 1.5vw, 17px);
  box-shadow: 0 16px 40px -34px rgba(0, 0, 0, 0.9);
}
#thanksRoot[data-state="wait"] .share-ticket { border-style: dashed; border-color: rgba(255, 255, 255, 0.16); }
#thanksRoot[data-state="wait"] .ticket-meta b,
#thanksRoot[data-state="failed"] .ticket-meta b { font-size: clamp(14px, 1.5vw, 17px); }

@media (orientation: portrait) {
  /* the QR's absence is the countdown's gain: the ring becomes the hero */
  #thanksRoot[data-state="wait"] .clock-row { flex-direction: column; gap: clamp(10px, 1.6vh, 18px); }
  #thanksRoot[data-state="wait"] .clock-ring { width: clamp(210px, 30vh, 330px); }
  #thanksRoot[data-state="wait"] .clock-ring .ring-track,
  #thanksRoot[data-state="wait"] .clock-ring .ring-fill { stroke-width: 7; }
  #thanksRoot[data-state="wait"] .clock-face b { font-size: clamp(56px, 8.4vh, 96px); }
  #thanksRoot[data-state="wait"] .clock-face span { font-size: 12px; }
  #thanksRoot[data-state="wait"] .clock-copy { align-items: center; gap: 12px; }
  #thanksRoot[data-state="wait"] .clock-copy .mono { font-size: 11px; }
  #thanksRoot[data-state="wait"] .render-steps { justify-content: center; gap: 16px; }
  #thanksRoot[data-state="wait"] .render-steps li { font-size: 11.5px; }

  #thanksRoot[data-state="wait"] .share-ticket { align-self: stretch; width: 100%; }
  #thanksRoot[data-state="wait"] .ticket-meta { align-items: center; text-align: center; }
  #thanksRoot[data-state="wait"] .ticket-meta b { font-size: clamp(17px, 2.4vh, 24px); }
  #thanksRoot[data-state="wait"] .ticket-meta span { font-size: 10.5px; letter-spacing: 0.14em; }
}

/* ── camera permission gate ──────────────────────────────────────
   A denied camera used to leave a dead shutter with a toast nobody read.
   This is the one place we ask for a tap, and it explains why only once. */
.cam-gate{position:fixed;inset:0;z-index:80;display:grid;place-items:center;padding:24px;background:rgba(7,8,13,.86);backdrop-filter:blur(14px)}
.cam-gate[hidden]{display:none}
.cam-gate-card{width:min(420px,92vw);padding:clamp(22px,3vh,34px);border-radius:22px;background:linear-gradient(160deg,rgba(18,160,106,.16),rgba(11,13,21,.96) 55%);border:1px solid rgba(47,230,168,.28);text-align:center}
.cam-gate-card .mono{font-size:10px;letter-spacing:.2em;text-transform:uppercase;color:var(--mint)}
.cam-gate-card h2{margin:10px 0 8px;font-size:23px;letter-spacing:-.03em}
.cam-gate-card p{margin:0 0 18px;font-size:14px;line-height:1.55;color:rgba(234,242,255,.66)}
.cam-gate-card b{color:var(--gold)}
