:root {
  color-scheme: light;
  --bg-a: #fff6fb;
  --bg-b: #ffe2ee;
  --ink: #382632;
  --muted: #866a78;
  --pink: #ff7fb1;
  --pink-dark: #e95792;
  --cream: #fffdf8;
  --line: rgba(84, 45, 67, 0.16);
  --shadow: 0 24px 60px rgba(189, 74, 121, 0.22);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 14%, rgba(255, 255, 255, 0.9) 0 8%, transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.7) 0 7%, transparent 24%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b) 60%, #ffd0e2);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 44vmin;
  height: 44vmin;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.36);
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  left: -18vmin;
  bottom: 4vmin;
}

body::after {
  right: -20vmin;
  top: 22vmin;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 24px);
  display: grid;
  place-items: center;
}

.hero,
.result {
  width: 100%;
  animation: rise 560ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.hidden {
  display: none;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--pink-dark);
}

h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.05em;
}

.lead {
  margin: 16px 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.coupon-stage {
  perspective: 900px;
}

.coupon-card {
  position: relative;
  min-height: 302px;
  padding: 24px 22px 20px;
  border: 1.5px solid var(--line);
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 249, 252, 0.86)),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(255, 127, 177, 0.055) 18px 36px);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-style: preserve-3d;
}

.coupon-card::before,
.coupon-card::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--bg-b);
  border: 1.5px solid var(--line);
  transform: translateY(-50%);
}

.coupon-card::before {
  left: -16px;
}

.coupon-card::after {
  right: -16px;
}

.coupon-card.is-flipping {
  animation: flip 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.coupon-ribbon {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #ffe1ee;
  color: var(--pink-dark);
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 900;
}

.coupon-label {
  margin: 26px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.coupon-card h2 {
  margin: 0;
  font-size: clamp(29px, 8vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.05em;
}

.coupon-copy {
  min-height: 54px;
  margin: 16px 0 28px;
  color: #624858;
  font-size: 15px;
  line-height: 1.7;
}

.coupon-copy:empty {
  display: none;
}

.coupon-copy:empty + .coupon-footer {
  margin-top: 42px;
}

.coupon-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-top: 16px;
  border-top: 1px dashed rgba(84, 45, 67, 0.24);
  color: var(--muted);
  font-size: 13px;
}

.coupon-footer strong {
  color: var(--ink);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

button {
  appearance: none;
  border: 0;
  min-height: 54px;
  border-radius: 18px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    filter 160ms ease;
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: grayscale(0.35);
}

.primary {
  grid-column: 1 / -1;
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  box-shadow: 0 12px 24px rgba(233, 87, 146, 0.28);
}

.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.confirm {
  color: white;
  background: #392936;
}

.remaining,
.hint {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.save-frame {
  margin-top: 22px;
}

.coupon-card.final {
  min-height: 280px;
  background:
    linear-gradient(135deg, #fff, #fff6fa),
    repeating-linear-gradient(-45deg, transparent 0 20px, rgba(255, 127, 177, 0.06) 20px 40px);
}

.message {
  margin: 18px 0 0;
  padding: 16px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  color: #5c4050;
  line-height: 1.7;
  text-align: center;
  font-weight: 750;
}

.result-actions {
  margin-top: 18px;
}

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

@keyframes flip {
  0% {
    transform: rotateY(0deg) translateY(0);
  }
  45% {
    transform: rotateY(90deg) translateY(-4px);
  }
  100% {
    transform: rotateY(0deg) translateY(0);
  }
}

@media (max-height: 720px) {
  .app-shell {
    padding-top: calc(env(safe-area-inset-top) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  }

  .lead {
    margin-bottom: 18px;
  }

  .coupon-card {
    min-height: 276px;
  }
}
