:root {
  --bg1: #1e1b4b;
  --bg2: #4c1d95;
  --bg3: #831843;
  --card-bg: #fffdf7;
  --card-back: #fbf7ee;
  --ink: #3b2f4a;
  --accent: #c2410c;
  --gold: #d4af37;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3));
  background-size: 400% 400%;
  animation: bgShift 18s ease infinite;
  padding: 24px 18px;
  overflow-x: hidden;
}

@keyframes bgShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== Wadah flip ===== */
.flip {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 3 / 4.4;
  perspective: 1400px;
  cursor: pointer;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
}

.face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 20px;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 24px;
  overflow: hidden;
  background: var(--card-bg);
  color: var(--ink);
}
.face.back { transform: rotateY(180deg); }

.face::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1.5px solid rgba(212, 175, 55, 0.45);
  border-radius: 13px;
  pointer-events: none;
  z-index: 2;
}

/* ===== Panel: Sampul ===== */
.p-cover .emoji { font-size: 3.4rem; margin-bottom: 16px; animation: floaty 3s ease-in-out infinite; }
.p-cover h1 { font-size: 1.5rem; color: var(--accent); line-height: 1.3; }
.p-cover .subtitle {
  margin-top: 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gold);
}

/* ===== Panel: Pesan ===== */
.p-msg { display: flex; flex-direction: column; justify-content: space-between; height: 100%; width: 100%; }
.p-msg .top-emoji { font-size: 2rem; margin-bottom: 6px; }
.p-msg .message {
  font-size: 1rem;
  line-height: 1.75;
  white-space: pre-line;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 2px;
}
.p-msg .divider { width: 54px; height: 2px; background: var(--gold); border: none; margin: 14px auto; }
.p-msg .signature { font-style: italic; font-size: 0.95rem; }
.p-msg .signature strong { font-style: normal; color: var(--accent); }

/* ===== Panel: Foto ===== */
.face.has-photo { padding: 0; }
.p-photo { position: absolute; inset: 0; }
.p-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-photo .caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 34px 20px 18px;
  font-size: 0.95rem;
  color: #fff;
  text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

/* ===== Petunjuk ketuk ===== */
.tap {
  position: absolute;
  bottom: 18px;
  left: 0; right: 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  animation: pulse 2s ease-in-out infinite;
  z-index: 3;
}
.p-cover ~ .tap, .face:not(.has-photo) .tap { color: rgba(59, 47, 74, 0.55); text-shadow: none; }

@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ===== Indikator titik ===== */
.step-dots { display: flex; gap: 7px; }
.step-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.3s ease, transform 0.3s ease;
}
.step-dots i.on { background: var(--gold); transform: scale(1.3); }

/* ===== Confetti ===== */
.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 13px;
  z-index: 5;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0.15; } }

/* ===== Layar besar ===== */
@media (min-width: 600px) {
  .flip { max-width: 380px; }
  .p-cover h1 { font-size: 1.7rem; }
  .p-msg .message { font-size: 1.05rem; }
}
