:root {
  --bg1: #fff6fa;
  --bg2: #ffd6e6;
  --pink: #ff5c9a;
  --pink-d: #d63384;
  --pink-l: #ffe3ee;
  --ink: #5a1f3d;
  --glass: rgba(255, 255, 255, 0.72);
  --shadow: 0 10px 24px rgba(214, 51, 132, 0.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  font-family: "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Layout ---------- */
main { position: relative; z-index: 2; }
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 64px 20px 36px;
}
.screen.active { display: flex; animation: screenIn 0.55s ease both; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

h1, h2 { margin: 0; line-height: 1.2; }
h1.name {
  font-family: "Pacifico", cursive;
  font-weight: 400;
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  color: var(--pink-d);
}
h2 { font-size: clamp(1.4rem, 6vw, 1.9rem); color: var(--pink-d); }
.eyebrow { margin: 0; letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.8rem; color: var(--pink); }
.sub, .hint { margin: 0; opacity: 0.85; }
.hint { min-height: 3em; font-size: 1.05rem; }
.say { margin: 0; min-height: 1.6em; font-size: 1.05rem; color: var(--pink-d); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, #ff7eb0, var(--pink));
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  min-height: 48px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(0.94); }
.btn:focus-visible, .card:focus-visible, .lily-btn:focus-visible, .mute:focus-visible {
  outline: 3px solid var(--pink-d);
  outline-offset: 3px;
}
.btn.ghost { background: #fff; color: var(--pink-d); box-shadow: 0 6px 16px rgba(214, 51, 132, 0.15); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.mute {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  font-size: 1.2rem;
  background: var(--glass);
  box-shadow: 0 4px 12px rgba(214, 51, 132, 0.2);
  cursor: pointer;
}

/* ---------- Message card ---------- */
.msg {
  background: var(--glass);
  backdrop-filter: blur(6px);
  border: 2px solid #fff;
  border-radius: 24px;
  padding: 18px 20px;
  width: 100%;
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  line-height: 1.5;
}
.msg p { margin: 0; }
.msg-emoji { font-size: 2.6rem; margin-bottom: 6px; }
.msg.pop-in { animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Lily SVG (tahap mekar lewat class s0..s3) ---------- */
.lily-svg { overflow: visible; }
.lily-svg.s0 { --k: 0.04; --sc: 0.55; --so: 0; }
.lily-svg.s1 { --k: 0.25; --sc: 0.7; --so: 0; }
.lily-svg.s2 { --k: 0.6; --sc: 0.88; --so: 0.6; }
.lily-svg.s3 { --k: 1; --sc: 1; --so: 1; }
.lily-svg .petal {
  transform: rotate(calc(var(--r) * var(--k))) scale(var(--sc));
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform 0.9s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.lily-svg .stamens { opacity: var(--so); transition: opacity 0.8s ease; }

.lily-btn {
  background: none;
  border: 0;
  padding: 0;
  width: min(62vw, 260px);
  cursor: pointer;
  animation: sway 3.5s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.lily-btn svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 8px 12px rgba(214, 51, 132, 0.25)); }
.lily-btn.tap { animation: boing 0.5s ease; }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes boing {
  0% { transform: scale(1); }
  30% { transform: scale(1.12, 0.9); }
  60% { transform: scale(0.94, 1.08); }
  100% { transform: scale(1); }
}

/* ---------- Mood ---------- */
.mood-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.mood-row .btn { padding: 12px 20px; font-size: 1.05rem; }
.mood-row .btn.on { background: linear-gradient(135deg, var(--pink-d), #a3185f); }

/* ---------- Tombol Tidak kabur ---------- */
.play {
  position: relative;
  width: 100%;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 2px dashed rgba(214, 51, 132, 0.3);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.4);
}
.btn.yes { z-index: 1; transition: font-size 0.2s ease, transform 0.15s ease; }
.btn.no { background: #fff; color: var(--pink-d); box-shadow: 0 6px 16px rgba(214, 51, 132, 0.2); }
.btn.no.free { position: absolute; transition: left 0.22s ease, top 0.22s ease, transform 0.15s ease; }
.btn.no.final { background: linear-gradient(135deg, #ff7eb0, var(--pink)); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- Kartu ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.card {
  position: relative;
  aspect-ratio: 3 / 4;
  background: none;
  border: 0;
  padding: 0;
  perspective: 700px;
  cursor: pointer;
}
.card .inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.card.open .inner { transform: rotateY(180deg); }
.card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.card .front {
  font-size: 2.2rem;
  color: #fff;
  background: repeating-linear-gradient(45deg, #ff7eb0, #ff7eb0 10px, #ff6aa2 10px, #ff6aa2 20px);
  border: 3px solid #fff;
}
.card .back {
  font-size: 2.8rem;
  background: #fff;
  border: 3px solid var(--pink);
  transform: rotateY(180deg);
}
.card:not(.open):hover .inner { transform: translateY(-4px) rotate(-2deg); }
.progress { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 0.95rem; }
.progress .dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--pink); transition: background 0.3s, transform 0.3s; }
.progress .dot.on { background: var(--pink); transform: scale(1.2); }
#card-msg { min-height: 5.5em; display: flex; align-items: center; justify-content: center; }

/* ---------- Bouquet ---------- */
.bouquet { width: min(86vw, 340px); }
.bouquet svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 14px rgba(214, 51, 132, 0.25)); }
.blily { cursor: pointer; }
.pop {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: lilyPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes lilyPop { from { transform: scale(0); } to { transform: scale(1); } }
.wig { transform-box: fill-box; transform-origin: 50% 100%; }
.wig.go { animation: wig 0.6s ease; }
@keyframes wig {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg) scale(1.08); }
  50% { transform: rotate(12deg) scale(1.08); }
  75% { transform: rotate(-6deg); }
}

.letter {
  background: var(--glass);
  border: 2px solid #fff;
  border-radius: 24px;
  padding: 18px 20px;
  line-height: 1.6;
  box-shadow: var(--shadow);
  animation: popIn 0.6s 1.6s both;
}
.letter p { margin: 0 0 10px; }
.letter .sign { font-family: "Pacifico", cursive; font-weight: 400; font-size: 1.5rem; color: var(--pink-d); margin: 6px 0 0; }
#restart { animation: popIn 0.6s 2s both; }

/* ---------- Efek ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
.floaty { position: fixed; z-index: 31; pointer-events: none; font-size: 1.6rem; animation: floatUp 1.2s ease-out forwards; }
@keyframes floatUp {
  from { opacity: 1; transform: translate(-50%, 0) scale(0.6); }
  to { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -90px) scale(1.3); }
}
#petals-bg { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
#petals-bg span { position: absolute; top: -40px; opacity: 0.55; animation: fall linear infinite; }
@keyframes fall {
  to { transform: translate(var(--drift, 30px), 110vh) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  #petals-bg { display: none; }
}
