:root {
  --primary: #31205c;
  --secondary: #d1beff;
  --accent: #dcfa66;
  --paper: #f9f6f0;
  --ink: #201a28;
  --surface: #fff;
  --line: #726b79;
  --soft: #eae5ed;
  color-scheme: light;
  font:
    16px/1.45 var(--sans);
}
:root[data-palette="citrus"] {
  --primary: #542019;
  --secondary: #ffb99c;
  --accent: #ffd65b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --paper: #18151d;
    --ink: #f7f1f7;
    --surface: #28242d;
    --soft: #383241;
    --line: #b7acbc;
    color-scheme: dark;
  }
}
:root[data-mode="dark"] {
  --paper: #18151d;
  --ink: #f7f1f7;
  --surface: #28242d;
  --soft: #383241;
  --line: #b7acbc;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
header {
  border-bottom: 1px solid var(--line);
  padding: 14px max(6vw, calc((100vw - 640px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header {
  background: var(--cely-canvas);
  color: var(--cely-text);
}
header strong {
  font: 650 27px var(--serif);
}
header span,
.kicker {
  font-size: 12px;
  letter-spacing: 0.09em;
}
main {
  max-width: 460px;
  padding: 22px 16px 52px;
  margin: auto;
}
h1 {
  font: 500 clamp(48px, 12vw, 70px) / 1 var(--serif);
  margin: 3px 0;
  letter-spacing: -0.06em;
}
.kicker {
  font-weight: 750;
  margin: 0;
}
.intro {
  margin: 8px 0 20px;
}
button,
select,
input {
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button {
  padding: 11px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-weight: 650;
  min-height: 44px;
}
button[hidden] {
  display: none;
}
button:disabled {
  opacity: 0.6;
  cursor: default;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
.link {
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
}
.stage {
  perspective: 950px;
  position: relative;
}
.card {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1.55;
  position: relative;
  transform-style: preserve-3d;
  background: none;
  padding: 0;
  border-radius: 22px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.card.flipped {
  transform: rotateY(180deg);
}
.side {
  position: absolute;
  inset: 0;
  background: var(--primary);
  color: white;
  border-radius: 22px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: left;
  box-shadow: 0 12px 22px -15px #13091f99;
}
.front {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6%;
  isolation: isolate;
}
.brand {
  font-weight: 680;
  font-size: clamp(14px, 4vw, 18px);
}
.edition {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}
.reward {
  font: 500 clamp(30px, 8.5vw, 46px) / 0.92 var(--serif);
  margin: auto 0;
}
.reward i {
  color: var(--secondary);
}
.bottom b {
  font-size: 20px;
  color: var(--accent);
}
.bottom span {
  font-size: 13px;
}
.flower {
  position: absolute;
  z-index: -1;
  right: 2%;
  top: 31%;
  width: 36%;
  aspect-ratio: 1;
}
.flower i {
  position: absolute;
  left: 43%;
  bottom: 50%;
  height: 49%;
  width: 16%;
  transform-origin: 50% 100%;
  background: var(--secondary);
  border-radius: 80% 6% 80% 5%;
}
.flower:after {
  content: "";
  position: absolute;
  left: 43%;
  top: 43%;
  width: 15%;
  aspect-ratio: 1;
  border-radius: 100%;
  background: var(--accent);
}
.front:before {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: -2;
  background: radial-gradient(ellipse at 82% 45%, #ffffff1c, transparent 34%);
}
.back {
  transform: rotateY(180deg);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
}
.back img {
  width: min(26vw, 124px);
  height: auto;
}
.back small {
  font-weight: 450;
}
.progress {
  padding: 14px 0 19px;
}
.progress > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.progress b {
  font-size: 14px;
}
h2 {
  font: 500 26px Georgia;
  margin: 0.2em 0;
}
.rail {
  height: 5px;
  background: var(--soft);
  border-radius: 9px;
  overflow: hidden;
}
.rail i {
  display: block;
  background: var(--ink);
  height: 100%;
  transform: scaleX(0);
  transform-origin: left;
}
#stamps {
  display: flex;
  justify-content: space-between;
  margin: 10px 0 13px;
}
#stamps span {
  display: grid;
  place-items: center;
  width: 39px;
  aspect-ratio: 1;
  color: var(--ink);
  border: 1px dashed var(--line);
  border-radius: 50%;
  font-weight: 650;
}
#stamps .filled {
  background: var(--accent);
  color: var(--primary);
  border: 1px solid var(--primary);
  font-size: 25px;
}
.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.actions button,
.desk button {
  font-size: 14px;
  background: var(--soft);
  color: var(--ink);
}
#status {
  min-height: 1.5em;
}
.desk {
  border-top: 1px solid var(--line);
  padding: 12px 0;
  font-size: 14px;
}
.desk summary {
  cursor: pointer;
  font-weight: 700;
}
.desk button {
  margin-bottom: 5px;
}
label {
  display: block;
  margin: 12px 0;
}
input,
select {
  border: 1px solid var(--line);
  padding: 8px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
}
input {
  width: 100%;
}
dialog {
  width: min(400px, 90vw);
  border: 0;
  border-radius: 18px;
  padding: 22px;
  background: var(--surface);
  color: var(--ink);
}
dialog::backdrop {
  background: #120f1c80;
}
dialog button {
  margin: 5px 3px;
}
#confetti {
  position: absolute;
  top: 0;
  inset-inline: 0;
  pointer-events: none;
}
#confetti i {
  position: absolute;
  width: 6px;
  height: 10px;
}
@media (prefers-reduced-motion: no-preference) {
  .stage {
    animation: arrive 520ms ease-out;
  }
  .card {
    transition: transform 480ms cubic-bezier(0.22, 0.78, 0.18, 1);
  }
  .rail i {
    transition: transform 420ms cubic-bezier(0.2, 1.35, 0.4, 1);
  }
  button:not(.card) {
    transition: scale 200ms ease-out;
  }
  button:not(.card):active {
    scale: 0.97;
  }
  .front:before {
    animation: light 5s ease-in-out alternate 2;
  }
  .unlocked .front:after {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0;
    background: linear-gradient(
      110deg,
      transparent 40%,
      #fff4 50%,
      transparent 60%
    );
    animation: shine 560ms ease-out both;
  }
  .unlocked ~ #redeem,
  #redeem.pulse {
    animation: pulse 540ms ease-out;
  }
  @keyframes arrive {
    from {
      opacity: 0.3;
      transform: translateY(15px) rotateX(9deg);
      filter: drop-shadow(0 0 0 transparent);
    }
    to {
      transform: none;
      filter: drop-shadow(0 4px 4px #19101c18);
    }
  }
  @keyframes light {
    to {
      transform: translate(-8%, 5%);
    }
  }
  @keyframes shine {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(100%);
    }
  }
  @keyframes pulse {
    50% {
      transform: scale(1.035);
    }
  }
}

@media screen and (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.cely-signature {
  display: inline-flex;
  align-items: center;
  color: inherit;
  font: 650 1.25rem var(--serif);
  text-decoration: none;
}
.cely-signature img { margin-inline-end: -.1em; }
