/* --- Variables & Reset --- */
:root {
  --bg-pastel: #fff5f7;
  --bg-night: #1a1a2e;
  --primary: #ff8fab;
  --secondary: #fb6f92;
  --text-color: #4a4a4a;
  --cream: #fffdd0;
  --font-head: "Fredoka One", cursive;
  --font-body: "Poppins", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-pastel);
  color: var(--text-color);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  transition: background-color 1s ease;
}

/* --- Layout --- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
  padding: 20px;
  text-align: center;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  z-index: 10;
}

.content {
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* Reduced gap slightly to fit everything */
}

/* --- Typography & Images --- */
h1,
h2,
h3 {
  font-family: var(--font-head);
  color: var(--secondary);
}

h1 {
  font-size: 2.5rem;
}
h2 {
  font-size: 1.8rem;
}
p {
  font-size: 1rem;
  line-height: 1.5;
}

.hero-gif {
  width: 160px; /* Slightly smaller to fit screens better */
  height: auto;
  border-radius: 10px;
}

.highlight {
  color: #ffb3c6;
}

/* --- Buttons --- */
.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 50px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  touch-action: manipulation;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.95);
}

.btn.primary {
  background-color: var(--secondary);
  color: white;
  box-shadow: 0 4px 15px rgba(251, 111, 146, 0.4);
}

.btn.secondary {
  background-color: white;
  color: var(--secondary);
  border: 2px solid var(--secondary);
  margin-left: 10px;
}

.btn.glow {
  background-color: #ffd700;
  color: #333;
  box-shadow: 0 0 20px #ffd700;
  animation: pulse 2s infinite;
}

/* --- Night Mode --- */
#screen-night {
  background-color: var(--bg-night);
  color: white;
}
.star-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(white, rgba(255, 255, 255, 0.2) 2px, transparent 3px),
    radial-gradient(white, rgba(255, 255, 255, 0.15) 1px, transparent 2px);
  background-size:
    550px 550px,
    350px 350px;
  background-position:
    0 0,
    40px 60px;
  z-index: -1;
}

/* --- Balloons --- */
.balloon {
  position: absolute;
  bottom: -100px;
  width: 50px;
  height: 70px;
  background-color: var(--primary);
  border-radius: 50%;
  opacity: 0.8;
  animation: floatUp 6s linear infinite;
}
.balloon::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  width: 2px;
  height: 40px;
  background: rgba(0, 0, 0, 0.2);
}

/* --- Cake Cutting Interaction --- */
#cake-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 10px auto;
  user-select: none;
  touch-action: none;
}

#cake-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease-out;
  pointer-events: none;
}

#cake-img.cut {
  transform: scale(0.9) rotate(10deg);
}

.instruction {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 5px;
  transition: opacity 0.5s;
  animation: fadeInOut 2s infinite;
}

.hidden {
  display: none;
}

/* --- WISHES FLIP CARDS (REDESIGNED FOR 4 CARDS) --- */
.cards-container {
  display: grid; /* Changed to Grid */
  grid-template-columns: 1fr 1fr; /* 2 Columns */
  gap: 15px;
  width: 100%;
  max-width: 320px; /* Keep it neat */
  margin-top: 10px;
  perspective: 1000px;
}

.flip-card {
  background-color: transparent;
  width: 100%; /* Fills the grid cell */
  height: 130px; /* Increased height for text */
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.flip-card-front {
  background-color: var(--primary);
  color: white;
  font-size: 2.5rem;
}

.flip-card-back {
  background-color: white;
  color: var(--text-color);
  transform: rotateY(180deg);
  font-size: 0.85rem; /* Better font size */
  line-height: 1.3;
  border: 2px solid var(--primary);
  padding: 8px; /* Padding keeps text off edges */
  overflow: hidden;
}

.progress-container {
  width: 200px;
  height: 8px;
  background: #eee;
  border-radius: 5px;
  margin: 20px auto 0;
  overflow: hidden;
}

#progress-bar {
  width: 0%;
  height: 100%;
  background: var(--secondary);
  transition: width 0.3s;
}

/* --- Keyframes --- */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-110vh) rotate(20deg);
    opacity: 0;
  }
}

@keyframes fadeInOut {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Mobile Tweak */
@media (max-width: 380px) {
  h1 {
    font-size: 2rem;
  }
  .hero-gif {
    width: 140px;
  }
  #cake-container {
    width: 180px;
    height: 180px;
  }
  /* Ensure grid still looks good on very small phones */
  .cards-container {
    gap: 10px;
  }
  .flip-card {
    height: 120px;
  }
  .flip-card-back {
    font-size: 0.75rem;
  }
}
