:root {
  --ink: #432830;
  --soft-ink: #7c5962;
  --cream: #fff9f1;
  --paper: #fffdfa;
  --rose: #ee7b7c;
  --rose-deep: #c84b59;
  --lilac: #b799d2;
  --gold: #efbd55;
  --mint: #77bba4;
  --shadow: rgba(102, 51, 58, .17);
  --glow: rgba(238, 123, 124, .23);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #f6d9d3;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 7%, rgba(255, 250, 238, .92) 0 10%, transparent 30%),
    radial-gradient(circle at 92% 82%, rgba(216, 99, 118, .18), transparent 34%),
    repeating-linear-gradient(112deg, rgba(110, 71, 49, .024) 0 1px, transparent 1px 10px),
    linear-gradient(150deg, #f9e4d6, #f3d0d2);
  overflow-x: hidden;
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid rgba(200, 75, 89, .38);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  pointer-events: none;
  filter: blur(18px);
  border-radius: 50%;
  animation: breathe 6s ease-in-out infinite alternate;
}

.ambient-one {
  width: 190px;
  height: 190px;
  top: 11%;
  left: -76px;
  background: rgba(255, 209, 172, .27);
}

.ambient-two {
  right: -90px;
  bottom: 10%;
  width: 220px;
  height: 220px;
  background: rgba(216, 108, 128, .18);
  animation-delay: -2s;
}

@keyframes breathe {
  to { transform: translateY(14px) scale(1.08); }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 17px max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.card {
  border: 1px solid rgba(113, 66, 57, .11);
  border-radius: 28px;
  background: rgba(255, 250, 243, .88);
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 55px var(--shadow), inset 0 1px rgba(255, 255, 255, .72);
}

/* Welcome card */
.welcome {
  padding: 32px 24px 25px;
  text-align: center;
  overflow: hidden;
  position: relative;
  animation: land .62s cubic-bezier(.22, .85, .3, 1);
}

.welcome::before,
.welcome::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.welcome::before {
  top: -78px;
  right: -78px;
  width: 178px;
  height: 178px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #f7c07a, #ec7776);
  opacity: .31;
}

.welcome::after {
  left: -40px;
  bottom: -66px;
  width: 135px;
  height: 135px;
  border-radius: 50%;
  background: rgba(232, 120, 127, .09);
}

@keyframes land {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--rose-deep);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .2em;
}

.love-note {
  display: inline-block;
  margin: 0 0 17px;
  padding: 7px 13px;
  border: 1px solid rgba(200, 75, 89, .12);
  border-radius: 999px;
  color: var(--soft-ink);
  background: rgba(255, 244, 231, .78);
  font-family: Georgia, serif;
  font-size: .78rem;
  font-style: italic;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4.2rem, 21vw, 5.8rem);
  font-weight: 500;
  letter-spacing: -.075em;
  line-height: .83;
}

h1 span {
  color: var(--rose-deep);
  font-style: italic;
}

.intro {
  margin: 25px auto 24px;
  max-width: 336px;
  color: var(--soft-ink);
  font-size: .98rem;
  line-height: 1.56;
}

.primary,
.secondary,
.play-again {
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primary {
  position: relative;
  width: 100%;
  padding: 17px 18px;
  color: white;
  background: linear-gradient(122deg, #d35362, #c24552);
  box-shadow: 0 11px 27px rgba(197, 66, 77, .29);
}

.primary span { margin-left: 5px; }
.primary:active, .secondary:active, .play-again:active { transform: scale(.98); }

.signed {
  position: relative;
  margin: 18px 8px 0;
  color: var(--soft-ink);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: .89rem;
}

/* Controls and prompt */
.play {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: land .42s ease;
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}

.game-head .eyebrow { margin: 0 0 7px; }

.progress { display: flex; gap: 4px; }

.progress span {
  width: 18px;
  height: 4px;
  border-radius: 5px;
  background: rgba(116, 74, 79, .18);
  transition: background .28s ease, width .28s ease;
}

.progress span.active {
  width: 25px;
  background: var(--rose-deep);
}

.tools { display: flex; gap: 3px; }

.tool {
  border: 1px solid rgba(126, 80, 75, .11);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--soft-ink);
  background: rgba(255, 247, 239, .68);
  font-size: .73rem;
  font-weight: 700;
}

.tool[aria-pressed="true"] {
  color: var(--rose-deep);
  background: rgba(255, 241, 232, .94);
}

.prompt { padding: 16px 18px 15px; }

.step,
.stamp {
  margin: 0 0 5px;
  color: var(--rose-deep);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .18em;
}

h2 {
  margin: 0 0 5px;
  font-family: Georgia, serif;
  font-size: 1.48rem;
  font-weight: 600;
}

.instruction {
  margin: 0;
  color: var(--soft-ink);
  font-size: .88rem;
  line-height: 1.4;
}

/* Paper fortune teller */
.paper-stage {
  position: relative;
  min-height: 302px;
  display: grid;
  place-items: center;
}

.count-pill {
  position: absolute;
  z-index: 5;
  top: 9px;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--rose-deep);
  background: var(--cream);
  box-shadow: 0 4px 12px rgba(73, 37, 39, .12);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .15em;
}

.catcher {
  position: relative;
  width: min(75vw, 288px);
  aspect-ratio: 1;
  filter: drop-shadow(0 19px 15px rgba(74, 37, 38, .18));
  transform: perspective(680px) rotateX(0deg) rotateZ(0deg);
  transition: transform .17s cubic-bezier(.34, .7, .4, 1), filter .22s ease;
}

.catcher.open-a {
  transform: perspective(680px) rotateX(12deg) rotateY(-7deg) rotateZ(-2deg) scale(.97);
}

.catcher.open-b {
  transform: perspective(680px) rotateX(-10deg) rotateY(7deg) rotateZ(2deg) scale(.97);
}

.corner {
  position: absolute;
  width: 51%;
  height: 51%;
  border: 0;
  display: grid;
  place-items: center;
  font-size: .84rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  transition: transform .18s ease, filter .18s ease;
}

.corner:active { filter: brightness(.96); }

.corner span {
  padding: 7px 11px;
  border-radius: 999px;
  color: rgba(63, 39, 48, .78);
  background: rgba(255, 253, 248, .6);
}

.coral { left: 0; top: 0; background: linear-gradient(135deg, #f39387 0 49%, #f8aaa0 50%); }
.lavender { top: 0; right: 0; background: linear-gradient(225deg, #c3a6d5 0 49%, #d3bde0 50%); }
.gold { bottom: 0; left: 0; background: linear-gradient(45deg, #f3c769 0 49%, #f7d890 50%); }
.mint { right: 0; bottom: 0; background: linear-gradient(315deg, #89c5af 0 49%, #acdac8 50%); }
.coral span { transform: translate(28px, -28px) rotate(45deg); }
.lavender span { transform: translate(-28px, -28px) rotate(-45deg); }
.gold span { transform: translate(28px, 28px) rotate(-45deg); }
.mint span { transform: translate(-28px, 28px) rotate(45deg); }

.crease {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.crease-a, .crease-b {
  border-left: 1px dashed rgba(90, 55, 50, .21);
  border-top: 1px dashed rgba(90, 55, 50, .21);
}

.crease-a { transform: rotate(45deg) scale(.71); }
.crease-b { transform: rotate(135deg) scale(.71); }

.center-mark {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 49px;
  height: 49px;
  border: 0;
  transform: translate(-50%, -50%) rotate(45deg);
  color: var(--rose-deep);
  background: var(--paper);
  box-shadow: 0 3px 10px rgba(80, 38, 42, .14);
  transition: transform .18s ease, color .18s ease;
}

.center-mark.kissed {
  color: #ed7180;
  transform: translate(-50%, -50%) rotate(45deg) scale(1.14);
}

.number-grid {
  width: min(80vw, 306px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  animation: pop-in .25s ease;
}

.number {
  min-height: 125px;
  border: 2px solid rgba(108, 71, 62, .09);
  border-radius: 22px 7px 22px 7px;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(255,245,235,.9));
  box-shadow: 0 10px 18px rgba(74, 37, 38, .09);
  transition: transform .16s ease, box-shadow .16s ease;
}

.number:nth-child(2), .number:nth-child(3) { border-radius: 7px 22px 7px 22px; }
.number:active { transform: scale(.97); }
.number strong { display: block; font-family: Georgia, serif; font-size: 2.25rem; }
.number small {
  display: block;
  margin-top: 3px;
  color: var(--soft-ink);
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* Fortunes */
.results {
  padding: 16px 15px 15px;
  animation: rise .36s ease;
}

.flaps {
  margin: 16px 0 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.flap {
  position: relative;
  min-height: 79px;
  border: 1px dashed rgba(126, 71, 69, .29);
  border-radius: 16px;
  color: var(--rose-deep);
  background: linear-gradient(140deg, #fff9f1, #ffede3);
  transition: transform .18s ease, background .22s ease;
}

.flap:active { transform: rotate(-1deg) scale(.98); }
.flap span { display: block; font-family: Georgia, serif; font-size: 1.5rem; font-weight: 700; }
.flap small { color: var(--soft-ink); font-size: .63rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

.flap.open {
  border-style: solid;
  color: white;
  background: linear-gradient(130deg, #d45262, #bf4554);
  box-shadow: 0 7px 18px rgba(193, 66, 79, .2);
}

.flap.open small { color: rgba(255, 255, 255, .74); }

.secondary {
  width: 100%;
  padding: 13px 16px;
  color: var(--rose-deep);
  background: #f7dfd6;
}

.secret {
  position: relative;
  overflow: hidden;
  padding: 19px 18px 16px;
  text-align: center;
  background: rgba(255, 249, 239, .97);
  animation: rise .42s cubic-bezier(.22, .85, .3, 1);
}

.secret::before {
  content: "";
  position: absolute;
  inset: -45% 52% 25% -35%;
  background: radial-gradient(circle, rgba(245, 195, 107, .18), transparent 66%);
}

.rare {
  position: relative;
  display: inline-block;
  margin: 0 0 12px;
  padding: 7px 11px;
  border-radius: 99px;
  color: #985d12;
  background: #ffe9ae;
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.fortune {
  position: relative;
  margin: 12px auto 12px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: clamp(1.2rem, 5.25vw, 1.5rem);
  font-weight: 600;
  line-height: 1.38;
}

.seal {
  position: relative;
  margin: 0 0 15px;
  color: var(--soft-ink);
  font-size: .76rem;
  font-style: italic;
}

.play-again {
  position: relative;
  padding: 11px 20px;
  color: var(--rose-deep);
  background: #f7dfd6;
  font-size: .83rem;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(.975); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(9px) rotate(-.4deg); }
}

/* Delight effects */
.effects {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  bottom: 13%;
  left: var(--left);
  transform: scale(var(--scale));
  animation: float-away 1.2s ease-out var(--delay) forwards;
}

.particle.heart { color: #d75667; font-size: 1.13rem; }
.particle.sparkle { color: #df9e31; font-size: 1.25rem; }

@keyframes float-away {
  from { opacity: 0; transform: translate(0, 0) scale(.45); }
  15% { opacity: 1; }
  to { opacity: 0; transform: translate(var(--drift), -185px) rotate(22deg) scale(var(--scale)); }
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100vw - 35px);
  padding: 11px 15px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: white;
  background: rgba(68, 36, 47, .92);
  box-shadow: 0 12px 26px rgba(50, 23, 30, .2);
  font-size: .83rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  animation: toast-in .2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

.hidden { display: none !important; }

@media (max-height: 735px) {
  .shell { justify-content: start; padding-top: max(15px, env(safe-area-inset-top)); }
  .paper-stage { min-height: 260px; }
  .catcher { width: min(67vw, 248px); }
  .number { min-height: 104px; }
  .welcome { padding-top: 25px; }
  .intro { margin-top: 19px; margin-bottom: 19px; }
}

@media (min-width: 700px) {
  .shell { width: min(100%, 520px); }
}

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