:root {
  color-scheme: light;
  --paper: #faf7f0;
  --ink: #29213c;
  --muted: #5f566e;
  --purple: #5b40b3;
  --purple-dark: #493093;
  --lavender: #e9e0ff;
  --line: #e9e1d7;
  font-family: "DM Sans", "Avenir Next", Avenir, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .68; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #2e55aa; outline-offset: 4px; }
h1:focus, h2:focus { outline: none; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.shell {
  width: min(100%, 1280px);
  height: 100svh;
  min-height: 480px;
  margin-inline: auto;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 4.5vw, 62px) max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 2.6svh, 28px);
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: none;
  font-size: clamp(1rem, 2.1vw, 1.26rem);
  font-weight: 850;
  letter-spacing: -.06em;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: clamp(31px, 4.3vw, 39px);
  aspect-ratio: 1;
  border-radius: 11px;
  background: var(--purple);
  color: #fff2b8;
  transform: rotate(-7deg);
}
.brand-second { color: var(--purple); }
.event {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #51416c;
  background: #f0e9fd;
  border-radius: 99px;
  padding: 7px 12px;
  font-size: .75rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}
.event > span { width: 6px; height: 6px; border-radius: 50%; background: #7e58c6; }

.workspace { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: clamp(10px, 2.8svh, 29px); min-height: 0; }
.stage {
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  container-type: size;
  border-radius: clamp(24px, 4vw, 42px);
  border: 1px solid #d9ccf5;
  background: radial-gradient(circle at center, #fff8 1px, transparent 1.4px) 0 0 / 15px 15px, var(--lavender);
}
.stage-art { position: absolute; inset: 0; pointer-events: none; }
.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 77%;
  aspect-ratio: 1;
  max-height: 88%;
  transform: translate(-50%, -50%) rotate(-24deg);
  border: 1px solid #bca9e6;
  border-radius: 50%;
}
.orbit-two { width: 89%; max-height: 100%; opacity: .62; }
.spark { position: absolute; z-index: 1; }
.spark .icon { width: 100%; height: 100%; }
.spark-top { top: 12%; right: 13%; width: clamp(21px, 8cqw, 48px); aspect-ratio: 1; color: #7655bf; transform: rotate(13deg); }
.spark-bottom { bottom: 14%; left: 10%; width: clamp(21px, 7cqw, 42px); aspect-ratio: 1; color: #7655bf; transform: rotate(-13deg); }
.dot { position: absolute; width: 7px; aspect-ratio: 1; border-radius: 50%; background: #ab8cde; }
.dot-one { top: 21%; left: 13%; }
.dot-two { bottom: 22%; right: 10%; background: #8758c7; }
.sticker {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(39px, 14cqw, 86px);
  aspect-ratio: 1;
  filter: drop-shadow(0 4px 3px #3b24542e);
}
.sticker-flower { bottom: 13%; right: 10%; transform: rotate(14deg); }
.sticker-flower .icon { z-index: 1; width: 36%; height: 36%; color: #4e2a59; }
.flower-shape, .flower-shape::before, .flower-shape::after {
  position: absolute;
  background: #fbbad4;
  inset: 0 25%;
  border-radius: 999px;
}
.flower-shape::before, .flower-shape::after { content: ""; inset: 0; transform: rotate(60deg); }
.flower-shape::after { transform: rotate(-60deg); }
.sticker-smile { top: 17%; left: 10%; width: clamp(40px, 12cqw, 76px); transform: rotate(-17deg); background: #ffdf7d; border-radius: 50%; border: 3px solid #fff5cb; }
.sticker-smile::before { content: ""; position: absolute; width: 8%; height: 13%; left: 33%; top: 30%; border-radius: 50%; background: #493751; box-shadow: .58em 0 #493751; font-size: clamp(12px, 4cqw, 26px); }
.sticker-smile span { width: 32%; height: 17%; margin-top: 20%; border-bottom: 2px solid #493751; border-radius: 0 0 50% 50%; }

.sample { position: relative; width: 100%; height: 100%; }
.print {
  --print-width: min(51cqw, 56cqh);
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--print-width);
  aspect-ratio: 1919 / 2560;
  border: clamp(4px, 1.2cqw, 10px) solid #fffdf8;
  border-radius: 7px;
  background: #174d99;
  box-shadow: 0 5px 10px #39226828, 0 17px 40px #39226833;
  overflow: hidden;
}
.print-back { --print-width: min(43cqw, 48cqh); transform: translate(-6%, -51%) rotate(14deg); }
.print-front { transform: translate(-68%, -49%) rotate(-8deg); animation: photo-in .7s cubic-bezier(.2,.8,.24,1) both; }
.artwork { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.avatar { position: absolute; left: 20.32%; top: 31.75%; width: 59.42%; height: 43.98%; object-fit: cover; }

.controls { display: grid; align-items: center; min-width: 0; }
.panel { width: min(100%, 450px); margin-inline: auto; text-align: center; animation: panel-in .28s ease-out both; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: clamp(5px, 1svh, 12px);
  color: var(--purple-dark);
  font-size: .69rem;
  font-weight: 850;
  letter-spacing: .115em;
}
.eyebrow .icon { width: 15px; height: 15px; }
h1 {
  margin: 0;
  font-size: clamp(2.25rem, 9.8vw, 4.4rem);
  font-weight: 880;
  letter-spacing: -.087em;
  line-height: .99;
}
h1 em { color: var(--purple); font-style: normal; }
.panel p {
  max-width: 31ch;
  margin: clamp(7px, 1.8svh, 17px) auto clamp(10px, 2.2svh, 23px);
  color: var(--muted);
  font-size: clamp(.875rem, 2.7vw, 1rem);
  line-height: 1.45;
}
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  padding: 10px 17px;
  border: 0;
  border-radius: 15px;
  text-decoration: none;
  font-weight: 780;
  font-size: .98rem;
  transition: background .17s ease, transform .17s ease, box-shadow .17s ease;
}
.primary { background: var(--purple); color: white; box-shadow: 0 4px 0 #402783, 0 8px 16px #492c8d24; }
.primary:hover { background: var(--purple-dark); }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #402783; }
.privacy { display: flex; justify-content: center; align-items: center; gap: 5px; margin-top: clamp(10px, 1.8svh, 17px); color: var(--muted); font-size: .75rem; }
.privacy .icon, .credit .icon { width: 14px; height: 14px; }
.text-button, .back { background: transparent; border: 0; color: var(--purple-dark); font-weight: 750; font-size: .875rem; }
.text-button { min-height: 38px; display: inline-flex; justify-content: center; align-items: center; gap: 5px; margin-top: 5px; padding: 4px 10px; }
.text-button:hover, .back:hover, .credit:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-button .icon, .back .icon { width: 16px; height: 16px; }
.back { display: inline-flex; gap: 3px; align-items: center; min-height: 36px; margin-bottom: 4px; padding: 0 8px; }
.empty-stage { display: grid; place-items: center; width: 100%; height: 100%; padding: 16px; }
.upload-target {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  width: min(69%, 310px);
  height: min(75%, 260px);
  min-width: min(100%, 192px);
  border: 1.5px dashed #a083d4;
  border-radius: 24px;
  background: #fcf9fff0;
  color: var(--ink);
  z-index: 3;
  transition: background .18s, border-color .18s;
  text-align: center;
}
.upload-target:hover, .stage.drag-over .upload-target { background: #fff; border-color: var(--purple-dark); }
.upload-target strong { font-size: .98rem; }
.upload-target > span:last-child { color: var(--muted); font-size: .8rem; }
.upload-art { position: relative; display: grid; place-items: center; margin-bottom: 5px; width: clamp(34px, 9cqh, 66px); aspect-ratio: 1; background: #ede3ff; color: var(--purple); border-radius: 14px; transform: rotate(-8deg); }
.upload-art > .icon { width: 54%; height: 54%; }
.upload-art span { position: absolute; right: -6px; bottom: -4px; display: grid; place-items: center; width: 21px; aspect-ratio: 1; border-radius: 50%; background: #ffdc79; color: #493751; }
.upload-art span .icon { width: 12px; height: 12px; }
.canvas-wrap {
  z-index: 3;
  width: min(77cqw, 66cqh);
  aspect-ratio: 1919 / 2560;
  outline: 5px solid #fffdf8;
  border-radius: 4px;
  box-shadow: 0 10px 26px #39226855;
  background: #174d99;
  animation: panel-in .25s ease-out both;
}
.canvas-wrap canvas, .canvas-wrap img { display: block; width: 100%; height: 100%; border-radius: 4px; }
.canvas-wrap canvas { cursor: grab; touch-action: none; }
.canvas-wrap canvas:active { cursor: grabbing; }
.result-wrap { animation: reveal .45s cubic-bezier(.2,.8,.24,1) both; }
.stage[data-mode="crop"] .sticker, .stage[data-mode="preview"] .sticker { opacity: .8; }
.crop-settings {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -4px auto 9px;
  width: min(100%, 380px);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}
.crop-settings input { flex: 1; min-width: 48px; accent-color: var(--purple); }
.crop-settings .text-button { min-height: 30px; margin: 0; padding: 2px; white-space: nowrap; font-size: .8rem; }
.panel .error { color: #9c254f; margin-block: 5px 11px; font-size: .82rem; }
footer { display: grid; place-items: center; border-top: 1px solid var(--line); padding-top: clamp(6px, 1.5svh, 14px); }
.credit { display: inline-flex; align-items: center; gap: 6px; color: #59476f; text-decoration: none; font-size: .78rem; font-weight: 730; min-height: 23px; }
.credit .icon { color: #8554b3; }

.sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(calc(100% - 12px), 465px);
  max-width: none;
  max-height: calc(100svh - 16px);
  margin: 0 auto;
  border: 1px solid #e6daf8;
  border-radius: 32px 32px 0 0;
  padding: 12px 23px max(20px, env(safe-area-inset-bottom));
  background: #fffcf8;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 0 70px #30224a45;
}
.sheet[open] { animation: sheet-up .4s cubic-bezier(.16,1,.3,1) both; }
.sheet::backdrop { background: #251b3b76; animation: backdrop-in .25s ease both; }
.sheet-handle { height: 4px; width: 38px; border-radius: 9px; background: #d9cbe8; margin: 0 auto 10px; }
.sheet-close { position: absolute; top: 14px; right: 16px; display: grid; place-items: center; width: 38px; aspect-ratio: 1; border: 0; border-radius: 50%; background: #f0e8fa; color: var(--purple-dark); }
.sheet-burst { width: 126px; height: 96px; margin: 0 auto 5px; position: relative; display: grid; place-items: center; }
.sheet-medallion { display: grid; place-items: center; width: 66px; aspect-ratio: 1; border-radius: 24px; background: #e8dbff; color: var(--purple); transform: rotate(-10deg); box-shadow: 0 5px 0 #d9c4ff; animation: bob 1.2s ease-in-out infinite alternate; }
.sheet-medallion .icon { width: 33px; height: 33px; }
.sheet-burst > span { position: absolute; width: 7px; aspect-ratio: 1; border-radius: 2px; background: #af8be7; transform: rotate(25deg); }
.sheet-burst > span:nth-child(1) { left: 7%; top: 21%; background: #f4adcb; }
.sheet-burst > span:nth-child(2) { right: 6%; top: 13%; background: #f5c65b; }
.sheet-burst > span:nth-child(3) { left: 10%; bottom: 16%; background: #f5c65b; }
.sheet-burst > span:nth-child(4) { right: 9%; bottom: 20%; }
.sheet-burst > span:nth-child(5) { right: 1%; top: 53%; background: #f4adcb; }
.sheet-burst > span:nth-child(6) { left: 26%; top: 4%; }
.sheet h2 { margin: 0; font-size: clamp(1.75rem, 7vw, 2.35rem); letter-spacing: -.065em; line-height: 1.06; }
.sheet p { margin: 8px 0 15px; color: var(--muted); font-size: .92rem; }
.loader { position: relative; overflow: hidden; height: 5px; width: min(180px, 65%); margin: 0 auto 6px; background: #ebdff8; border-radius: 99px; }
.loader span { position: absolute; inset: 0 auto 0 0; width: 45%; border-radius: 99px; background: #8a64ce; animation: loading 1s ease-in-out infinite; }
.sheet-actions { display: grid; justify-items: center; gap: 10px; }
.check-icon, .sheet[data-mode="thanks"] .magic-icon { display: none; }
.sheet[data-mode="thanks"] .check-icon { display: block; }
.sheet[data-mode="thanks"] .sheet-medallion { background: #f8df8c; box-shadow: 0 5px 0 #f7c762; color: #443254; animation: celebrate .55s cubic-bezier(.2,.85,.3,1.35) both; }
.sheet[data-mode="thanks"] .sheet-burst > span { animation: confetti .7s cubic-bezier(.2,.85,.3,1) both; }
.sheet[data-mode="thanks"] .sheet-burst > span:nth-child(even) { animation-delay: 75ms; }

@keyframes photo-in { from { opacity: 0; transform: translate(-62%, -44%) rotate(-1deg) scale(.96); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes reveal { from { opacity: 0; transform: translateY(10px) scale(.95) rotate(-3deg); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes bob { to { transform: translateY(-6px) rotate(7deg); } }
@keyframes loading { from { transform: translateX(-110%); } to { transform: translateX(235%); } }
@keyframes celebrate { from { transform: scale(.3) rotate(30deg); } to { transform: scale(1) rotate(-10deg); } }
@keyframes confetti { from { opacity: 0; transform: scale(0); } 65% { transform: rotate(110deg) scale(1.35); } }

@media (min-width: 760px) and (min-height: 550px) {
  .shell { padding-top: max(25px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .workspace { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); grid-template-rows: minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); }
  .stage { grid-column: 2; grid-row: 1; }
  .controls { grid-column: 1; grid-row: 1; }
  .panel { text-align: left; margin-left: 0; }
  h1 { font-size: clamp(2.9rem, 5.4vw, 5.4rem); }
  .panel p { margin-left: 0; }
  .panel .button { max-width: 320px; min-height: 54px; }
  .privacy { justify-content: flex-start; }
  .text-button, .back { padding-left: 0; }
  .crop-settings { margin-left: 0; }
  .sheet { margin-bottom: 18px; border-radius: 32px; padding-bottom: 20px; }
}
@media (max-width: 370px) {
  .masthead { gap: 6px; }
  .brand { gap: 6px; }
  .event { gap: 5px; padding-inline: 8px; font-size: .69rem; }
}
@media (max-height: 680px) {
  .shell { gap: 9px; }
  .workspace { gap: 11px; }
  .panel p { margin-block: 6px 11px; }
  .privacy { margin-top: 9px; }
  footer { padding-top: 5px; }
}
@media (max-width: 759px) and (max-height: 650px) {
  .panel h1 { font-size: clamp(2rem, 8.4vw, 2.65rem); }
  .eyebrow { margin-bottom: 5px; }
}
@media (orientation: landscape) and (max-height: 549px) and (min-width: 600px) {
  .shell { min-height: 340px; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .stage { grid-column: 2; grid-row: 1; }
  .controls { grid-column: 1; grid-row: 1; }
  h1 { font-size: clamp(1.9rem, 7svh, 2.8rem); }
  .panel .button { min-height: 40px; }
  .sheet-burst { height: 72px; }
  .sheet-medallion { width: 52px; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
