:root {
  --bg: #120206;
  --bg-deep: #1a060b;
  --panel: rgba(36, 8, 14, 0.92);
  --gold: #e8c56b;
  --gold-2: #fff1c2;
  --gold-deep: #a07828;
  --ink: #f8f1e6;
  --muted: rgba(248, 241, 230, 0.74);
  --line: rgba(232, 197, 107, 0.38);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.2, 0.8, 0.2, 1);
  --curtain: cubic-bezier(0.77, 0, 0.18, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(122, 24, 40, 0.55), transparent 52%),
    radial-gradient(circle at 12% 88%, rgba(196, 150, 48, 0.1), transparent 26%),
    radial-gradient(circle at 90% 70%, rgba(196, 150, 48, 0.08), transparent 22%),
    var(--bg);
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 3px;
}

::selection { background: rgba(232, 197, 107, 0.35); color: #fff; }

#sparks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar,
.workspace,
.footer {
  width: min(1120px, calc(100% - 28px));
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(16px + env(safe-area-inset-top)) 0 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold-2);
}

.brand .cap { width: 36px; height: 36px; flex: none; }

.brand strong {
  display: block;
  font-family: Cinzel, Palatino, serif;
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.when {
  margin: 0;
  color: var(--gold);
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  text-align: right;
  line-height: 1.3;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(290px, 390px);
  gap: 28px;
  align-items: start;
  padding: 12px 0 28px;
}

.poster-frame {
  position: relative;
  width: 100%;
  border-radius: 10px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(232, 197, 107, 0.22);
  transform: scale(0.985);
  transition: transform 1.15s var(--ease);
}

body.ready .poster-frame { transform: none; }

.poster-base,
.poster-overlay {
  display: block;
  width: 100%;
  height: auto;
}

.poster-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.photo-slot {
  position: absolute;
  overflow: hidden;
  z-index: 2;
  touch-action: auto;
  cursor: default;
}

.photo-slot.has-photo {
  cursor: grab;
  touch-action: none;
}

.photo-slot.is-dragging { cursor: grabbing; }

.photo-slot img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  transition: transform 0.2s var(--ease-soft);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.photo-slot.has-photo img { opacity: 1; }

.photo-slot.is-dragging img,
.photo-slot.is-adjusting img { transition: none; }

.photo-slot.is-dragging,
.photo-slot.is-adjusting {
  box-shadow:
    inset 0 0 0 2px rgba(255, 228, 160, 0.95),
    0 0 26px rgba(232, 197, 107, 0.42);
}

.slot-hint {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-content: center;
  text-align: center;
  color: #6d2432;
  font-family: Cinzel, Palatino, serif;
  letter-spacing: 0.04em;
  line-height: 1.35;
  pointer-events: none;
}

.slot-hint small {
  display: block;
  margin-top: 4px;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0;
  opacity: 0.8;
}

.photo-slot.has-photo .slot-hint { display: none; }

.glow {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 160, 0.8), rgba(255, 196, 70, 0.18) 46%, transparent 70%);
  mix-blend-mode: screen;
  animation: glowPulse 2.6s ease-in-out infinite;
}

.glow-banner {
  border-radius: 50%;
  transform: translate(-50%, -68%);
  animation-delay: 0.5s;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 0.9; }
}

.panel {
  background:
    linear-gradient(180deg, rgba(74, 22, 32, 0.55), rgba(22, 5, 9, 0.2) 28%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px 18px;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 236, 190, 0.18);
  opacity: 0;
  transform: translateY(16px);
}

body.curtains-open .panel,
html.reduce .panel {
  opacity: 1;
  transform: none;
  transition: opacity 0.8s var(--ease) 0.15s, transform 0.8s var(--ease) 0.15s;
}

.kicker {
  margin: 0 0 4px;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

h1 {
  margin: 0;
  font-family: "Great Vibes", "Segoe Script", cursive;
  font-size: clamp(3.4rem, 8vw, 4.8rem);
  font-weight: 400;
  line-height: 0.85;
  background: linear-gradient(100deg, #fff6d2, #e8c56b 45%, #fff 70%, #c4963a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.98rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.chips li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  color: var(--gold-2);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.steps {
  counter-reset: step;
  list-style: none;
  margin: 16px 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.95rem;
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #2a1408;
  background: linear-gradient(180deg, #fff1c2, #e0b44a);
  font-size: 0.8rem;
  font-weight: 600;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s var(--ease-soft), box-shadow 0.18s var(--ease-soft), filter 0.18s ease, background 0.18s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px) scale(0.985); }

.btn-upload {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold-2);
  letter-spacing: 0.04em;
  font-weight: 600;
  overflow: hidden;
}

.btn-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.btn-upload:hover {
  background: rgba(232, 197, 107, 0.12);
  box-shadow: 0 8px 24px rgba(232, 197, 107, 0.12);
}

.file-note {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.control { margin-bottom: 14px; }
.control.is-off { opacity: 0.45; }

.control-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
}

.control-label strong { color: var(--gold-2); font-weight: 600; }

.control-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
}

.control-row button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 241, 194, 0.06);
  color: var(--gold-2);
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.16s var(--ease-soft), background 0.16s ease, border-color 0.16s ease;
}

.control-row button:hover { background: rgba(232, 197, 107, 0.16); transform: translateY(-1px); }
.control-row button:active { transform: scale(0.94); }
.control-row button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]:disabled { cursor: not-allowed; }

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) var(--p, 0%), rgba(255, 255, 255, 0.16) var(--p, 0%));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6d2, #e0b44a 55%, #8a6418);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.16s var(--ease-soft), box-shadow 0.16s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.16);
  box-shadow: 0 0 0 6px rgba(232, 197, 107, 0.22);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--gold);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #e8c56b;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(248, 241, 230, 0.22);
  color: var(--ink);
  min-height: 44px;
}

.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-download {
  overflow: hidden;
  min-height: 54px;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: #2a1408;
  background: linear-gradient(180deg, #fff3cc, #e6c15a 42%, #c4963a);
  box-shadow: 0 10px 24px rgba(180, 130, 40, 0.28);
}

.btn-download::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55), transparent 70%);
  transform: translateX(-120%);
}

.btn-download:hover {
  box-shadow: 0 14px 28px rgba(180, 130, 40, 0.4);
}

.btn-download:hover::after { transform: translateX(120%); transition: transform 0.65s ease; }

.btn-download.is-busy { filter: saturate(0.8); cursor: progress; }

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--gold-2);
}

.status.is-error { color: #ffb4b4; }

.footer {
  padding: 4px 0 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.footer .credit {
  margin: 8px 0 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
}

.noscript {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 24px;
}

.is-shake { animation: shake 0.42s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: #140308;
}

.curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 54%;
  overflow: hidden;
  transition: transform 1.55s var(--curtain);
  box-shadow: inset 0 0 90px rgba(70, 36, 0, 0.45);
}

.curtain-left { left: 0; }
.curtain-right { right: 0; }

.curtain-left,
.curtain-right {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 14%, transparent 86%, rgba(0, 0, 0, 0.38)),
    repeating-linear-gradient(
      90deg,
      #7a5a10 0px,
      #f6e7a4 7px,
      #d4b14a 14px,
      #fff4c4 20px,
      #b48a22 30px,
      #e8c56b 40px,
      #6d5010 52px
    );
}

.curtain::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  animation: sheen 2.8s ease-in-out infinite;
}

.curtain-left::after,
.curtain-right::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 46px;
}

.curtain-left::after {
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.38));
}

.curtain-right::after {
  left: 0;
  background: linear-gradient(270deg, transparent, rgba(0, 0, 0, 0.38));
}

body.curtains-open .curtain-left { transform: translateX(-108%); }
body.curtains-open .curtain-right { transform: translateX(108%); }

@keyframes sheen {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(430%); }
}

.intro-copy {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  pointer-events: none;
  transition: opacity 0.55s ease, transform 0.7s var(--ease);
}

body.curtains-open .intro-copy {
  opacity: 0;
  transform: scale(1.05);
}

.eyebrow,
.script,
.gala,
.sub {
  opacity: 0;
  transform: translateY(18px);
  animation: riseIn 0.9s var(--ease) forwards;
}

.eyebrow { animation-delay: 0.12s; }
.script { animation-delay: 0.32s; }
.gala { animation-delay: 0.52s; }
.sub { animation-delay: 0.78s; }

@keyframes riseIn {
  to { opacity: 1; transform: none; }
}

.eyebrow, .sub {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--gold-2);
}

.title-wrap { filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45)); }

.script, .gala {
  margin: 0;
  background: linear-gradient(105deg, #8d6a22 0%, #ffe7a3 24%, #fff 42%, #e6c15a 55%, #fff6d0 68%, #a8841c 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation:
    riseIn 0.9s var(--ease) forwards,
    shimmer 2.6s linear infinite;
}

.script {
  font-family: "Great Vibes", cursive;
  font-size: clamp(4rem, 12vw, 7rem);
  line-height: 0.8;
  animation-delay: 0.32s, 0.4s;
}

.gala {
  font-family: "Cinzel Decorative", Cinzel, serif;
  font-size: clamp(3.2rem, 10vw, 6.4rem);
  letter-spacing: 0.04em;
  line-height: 0.95;
  animation-delay: 0.52s, 0.4s;
}

.sub { margin-top: 10px; animation-delay: 0.78s; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.skip {
  position: absolute;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 4;
  transform: translateX(-50%);
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 241, 194, 0.55);
  background: rgba(20, 3, 8, 0.35);
  color: var(--gold-2);
  cursor: pointer;
  transition: transform 0.18s var(--ease-soft), background 0.18s ease;
}

.skip:hover { background: rgba(232, 197, 107, 0.16); transform: translateX(-50%) translateY(-2px); }
.skip:active { transform: translateX(-50%) scale(0.98); }

body.ready .intro {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

body.skip-motion .curtain,
body.skip-motion .intro-copy,
body.skip-motion .intro {
  transition: none !important;
  animation: none !important;
}

h1 { padding: 0 4px 0 12px; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; gap: 16px; }
  .topbar { align-items: flex-start; gap: 10px; }
  .when {
    max-width: 46%;
    font-size: 0.72rem;
    line-height: 1.3;
  }
  .panel { padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .intro { display: none !important; }
  .glow { opacity: 0.4; }
}

html.reduce .intro { display: none !important; }
html.reduce .poster-frame { transform: none; }
html.reduce .glow { animation: none; opacity: 0.4; }
