@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&family=Playfair+Display:wght@600&display=swap');

:root {
  --cream: #fffdf7;
  --sage: #dff5e1;
  --green: #2ecc71;
  --gold: #f4d03f;
  --lav: #f3e8ff;
  --moon: #f8f9ff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  background: linear-gradient(135deg, var(--cream), var(--lav));
  color: #2c3e50;
  min-height: 100vh;
  overflow-x: hidden;
  transition: opacity .8s ease;
}

.fade-in {
  animation: fadeIn 1.2s ease;
}

.fade-out {
  opacity: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.center-box {
  /* height:100vh; */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
}

h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  background: linear-gradient(45deg, var(--gold), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

button {
  margin-top: 20px;
  padding: 12px 28px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(45deg, var(--green), var(--gold));
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: .3s;
}

button:hover {
  transform: scale(1.1);
}

input {
  padding: 10px;
  border-radius: 20px;
  border: 1px solid #ccc;
  margin-top: 15px;
}

.card {
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(15px);
  padding: 20px;
  margin: 20px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .05);
}

img.responsive {
  width: 100%;
  /* full width of card */
  height: auto;
  /* maintain aspect ratio */
  max-height: 300px;
  /* prevents very tall images */
  object-fit: cover;
  /* keeps it nicely cropped if needed */
  border-radius: 20px;
  display: block;
}

.question {
  margin-bottom: 20px;
  text-align: left;
}

.quiz-option {
  display: block;
  padding: 10px;
  margin: 8px 0;
  background: #f9f9f9;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.3s ease;
}

.quiz-option:hover {
  background: #d6e5d8;
  transform: scale(1.02);
}

/* ---------- SPARKLE EFFECT ---------- */

.correct-answer {
  background: #d4edda !important;
  position: relative;
  animation: glow 0.6s ease forwards;
}

@keyframes glow {
  0% {
    box-shadow: 0 0 0px transparent;
  }

  50% {
    box-shadow: 0 0 20px var(--deep-yellow);
  }

  100% {
    box-shadow: 0 0 10px var(--primary-green);
  }
}

/* Sparkle stars */
.correct-answer::after {
  content: "✨ ✨ ✨";
  position: absolute;
  right: 10px;
  top: 8px;
  font-size: 14px;
  animation: sparkle 1s ease-in-out infinite alternate;
}

@keyframes sparkle {
  from {
    opacity: 0.4;
    transform: translateY(0px);
  }

  to {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ---------- QUESTION REVEAL ---------- */

.hidden-qn {
  opacity: 0;
  transform: translateY(15px);
}

.show {
  opacity: 1;
  transform: translateY(0);
  transition: 0.6s ease;
}

.question {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.4s ease;
}

.question.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.option {
  padding: 10px;
  margin: 8px 0;
  background: #e8f5e9;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.3s ease;
}

.option:hover {
  transform: scale(1.03);
}

.correct-answer {
  background: #c8f7c5;
  box-shadow: 0 0 15px #ffd43b;
}

.wrong-answer {
  background: #ffd6d6;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#result {
  margin-top: 15px;
  font-weight: 600;
  font-size: 18px;
}

/* ---------------- PROGRESS BAR ---------------- */

/* Progress bar */
.progress-container {
  background: #f1f1f1;
}

#progress-bar {
  background: linear-gradient(90deg, var(--primary-green), var(--deep-yellow));
}

/* Quiz options */
.quiz-option {
  background: var(--soft-green);
  border: 1px solid #d4edda;
  border-radius: 12px;
  transition: 0.3s ease;
}

.quiz-option:hover {
  background: #d8f8d8;
  transform: scale(1.02);
}

/* ---------------- CORRECT / WRONG ANIMATION ---------------- */

.quiz-option.correct-answer {
  background: #d4edda;
  animation: pop 0.4s ease;
}

.quiz-option.wrong-answer {
  background: #f8d7da;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

/* ---------------- CONFETTI CANVAS ---------------- */

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  z-index: 999;
}

.letter {
  opacity: 0;
  transform: translateY(20px);
  transition: 1.2s ease;
}

.letter.show {
  opacity: 1;
  transform: translateY(0);
}

.letter-image {
  width: 100%;
  max-width: 200px;
  border-radius: 15px;
  margin: 20px 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: scale(0.9);
  transition: 1s ease;
}

.letter.show .letter-image {
  opacity: 1;
  transform: scale(1);
}

/* Floating birthday items */
.floating {
  position: fixed;
  bottom: -30px;
  animation: floatUp 8s linear infinite;
  font-size: 18px;
  opacity: .8;
}

@keyframes floatUp {
  to {
    transform: translateY(-120vh);
    opacity: 0;
  }
}

/* Confetti */
.confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  top: 0;
  animation: fall 3s linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(100vh) rotate(720deg);
  }
}

/* Puzzle */
.puzzle-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  max-width: 300px;
  margin: auto;
}

.piece {
  width: 100%;
  height: 100px;
  background-size: 300px 300px;
  cursor: pointer;
}

@media(max-width:768px) {
  h1 {
    font-size: 1.8rem;
  }

  button {
    padding: 10px 22px;
  }
}

/* Mysterious background */
.mystery-bg {
  background: radial-gradient(circle at center, #f8f9ff 0%, #e8ecff 40%, #dfe6ff 100%);
}

.moon-container {
  position: relative;
  margin: 40px auto 0px auto;
  width: 360px;
  /* increased */
  height: 360px;
  /* increased */
}

.moon-glow {
  font-size: 90px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 2s infinite alternate;
}

@keyframes pulse {
  from {
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    transform: translate(-50%, -50%) scale(1.1);
  }
}

.stars {
  position: absolute;
  width: 100%;
  height: 100%;
}

.star {
  position: absolute;
  font-size: 28px;
  cursor: pointer;
  transition: 0.3s;
}

.star:nth-child(1) {
  top: 8%;
  left: 10%;
}

.star:nth-child(2) {
  top: 20%;
  right: 12%;
}

.star:nth-child(3) {
  bottom: 18%;
  left: 12%;
}

.star:nth-child(4) {
  bottom: 12%;
  right: 20%;
}

.star:nth-child(5) {
  top: 0%;
  left: 50%;
  transform: translateX(-50%);
}

.star {
  position: absolute;
  width: 80px;
  height: 80px;
  cursor: pointer;
  transition: 0.3s ease;
}

/* OUTER STAR (border layer) */
.star::before {
  content: "";
  position: absolute;
  inset: 0;
  background: white;
  /* border color */
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%,
      50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* INNER STAR (image) */
.star img {
  position: absolute;
  inset: 6px;
  /* THIS controls border thickness */
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: cover;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%,
      50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.star.active::before {
  background: gold;
  filter: drop-shadow(0 0 10px gold);
}

.star.active {
  transform: scale(1.25);
}

/* Selected memory cards below */
.selected-memories {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.selected-card {
  width: 70px;
  height: 70px;
  border-radius: 12px;
  overflow: hidden;
  animation: fadeInUnlock 0.4s ease;
}

.selected-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes fadeInUnlock {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Smaller screens: shrink cards to fit one line */
@media (max-width: 480px) {
  .selected-card {
    width: 50px;
    height: 50px;
  }

  .selected-memories {
    gap: 6px;
    /* reduce gap a bit */
  }
}

/* Optional: very small screens */
@media (max-width: 350px) {
  .selected-card {
    width: 40px;
    height: 40px;
  }

  .selected-memories {
    gap: 4px;
  }
}

/* Puzzle styles */
/* Magical background */
body.fade-in {
  background: radial-gradient(circle at top, #fdf6e3 0%, #e0f7fa 60%, #cfe9f5 100%);
  min-height: 100vh;
  font-family: 'Poppins', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* Moon sparkle overlay behind puzzle */
.moon-glow-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

/* Puzzle container */
.puzzle-container {
  display: grid;
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  gap: 5px;
  margin: 20px auto;
  position: relative;
  z-index: 1;
}

/* Puzzle pieces */
.puzzle-piece {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.2s;
  position: relative;
  z-index: 1;
}

.puzzle-piece.dragging {
  opacity: 0.7;
  box-shadow: 0 0 20px rgba(244, 208, 63, 0.8);
  transform: scale(1.1);
}

.puzzle-piece {
  touch-action: none;
  user-select: none;
}

.puzzle-placeholder {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Hearts */
.heart {
  position: fixed;
  /* fixed so it stays in viewport */
  width: 15px;
  height: 15px;
  background-color: #f4d03f;
  transform: rotate(45deg);
  z-index: 9999;
  /* make sure it’s above everything */
  opacity: 0.8;
  pointer-events: none;
  animation: floatUpHeart 1.5s ease-out forwards;
}

.heart::before,
.heart::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  background-color: #f4d03f;
  border-radius: 50%;
}

.heart::before {
  top: -7.5px;
  left: 0;
}

.heart::after {
  left: -7.5px;
  top: 0;
}

@keyframes floatUpHeart {
  0% {
    transform: translate(0, 0) rotate(45deg);
    opacity: 1;
  }

  100% {
    transform: translate(0, -120px) rotate(45deg);
    opacity: 0;
  }
}

/* Mobile scaling */
@media (max-width:500px) {
  .puzzle-container {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
  }

  .puzzle-piece {
    width: 80px;
    height: 80px;
    background-size: 240px 240px;
  }
}

/* Wrong move shake */
@keyframes shake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  20% {
    transform: translate(-5px, 0) rotate(-5deg);
  }

  40% {
    transform: translate(5px, 0) rotate(5deg);
  }

  60% {
    transform: translate(-5px, 0) rotate(-5deg);
  }

  80% {
    transform: translate(5px, 0) rotate(5deg);
  }

  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

.wrong-glow {
  box-shadow: 0 0 15px 5px rgba(255, 0, 0, 0.7);
  animation: shake 0.5s;
  border-radius: 10px;
}

/* Heart animation with sparkling trail */
@keyframes sparkle-heart {
  0% {
    transform: translateY(0) rotate(0);
    opacity: 1;
  }

  50% {
    transform: translateY(-20px) rotate(180deg);
    opacity: 0.8;
  }

  100% {
    transform: translateY(0) rotate(360deg);
    opacity: 1;
  }
}

@keyframes glitter {
  0% {
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.9), 0 0 20px rgba(255, 215, 0, 0.7);
  }

  100% {
    box-shadow: 0 0 12px rgba(255, 255, 255, 1), 0 0 25px rgba(255, 215, 0, 0.7);
  }
}

/* Hidden container */
.hidden {
  display: none;
}

/* Audio visual container */
#audioVisual {
  display: flex;
  gap: 6px;
  margin-top: 25px;
  justify-content: center;
  align-items: flex-end;
  height: 30px;
}

/* Green-Yellow Bars */
.bar {
  width: 8px;
  height: 30px;
  background: linear-gradient(to top, #2ecc71, #f1c40f);
  border-radius: 4px;
  transform-origin: bottom;
  animation: bounce 0.6s infinite alternate ease-in-out;
}

@keyframes bounce {
  from {
    transform: scaleY(0.2);
  }

  to {
    transform: scaleY(1);
  }
}

.bar:nth-child(2) {
  animation-delay: 0.1s;
}

.bar:nth-child(3) {
  animation-delay: 0.2s;
}

.bar:nth-child(4) {
  animation-delay: 0.3s;
}

/* Image card styling */
.image-card {
  margin-top: 30px;
  padding: 15px;
  border-radius: 18px;
  background: linear-gradient(145deg, #f1f8e9, #fffde7);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  width: 260px;
  text-align: center;
  animation: fadeInImg 1s ease forwards;
}

.image-card img {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 10px;
}

@keyframes fadeInImg {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Subtle disabled look */
button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  /* soft fade */
  filter: saturate(0.85);
  /* slightly muted colors */
}

.center-box {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
}

/* Wrap all cards in a container for row layout */
.cards-container {
  display: flex;
  flex-wrap: wrap;
  /* allows cards to move to the next row */
  justify-content: center;
  /* center cards horizontally */
  gap: 20px;
  /* space between cards */
  width: 100%;
  max-width: 1200px;
  /* optional max width for layout */
}

.card-memory {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(15px);
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  flex: 1 1 250px;
  /* flexible: grow, shrink, base width 250px */
  max-width: 250px;
  /* optional max width for each card */
  box-sizing: border-box;
}

img.responsive {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  border-radius: 20px;
  display: block;
}

.hidden {
  display: none;
}

#message {
  text-align: center;
}

.count-animate {
  font-weight: 600;
  text-align: center;

  /* Responsive font size */
  font-size: clamp(22px, 6vw, 60px);

  white-space: nowrap;
  /* Prevent multiline */
}

.pop {
  transform: scale(1.3);
}

.big-bounce {
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.2);
  }
}

@keyframes fadeInFinal {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Confetti canvas */
#confetti {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
}

.controls {
  display: flex;
  width: 260px;
  /* adjust as needed */
  margin: 10px auto;
  border-radius: 30px;
  overflow: hidden;
  /* makes it look like one shape */
  /* border: 2px solid #fff3; 
    backdrop-filter: blur(8px); */
  background: linear-gradient(45deg, var(--green), var(--gold));
}

/* Common button style */
.seg-btn {
  all: unset;
  transform: none;
  /* background: linear-gradient(45deg, var(--green), var(--gold)); */
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
}

/* Divider line */
.seg-btn.left {
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

/* Hover effects */
.seg-btn:hover {
  transform: none;
  background: rgba(255, 255, 255, 0.08);
  /* subtle highlight without replacing gradient */
  opacity: 0.95;
  /* optional soft glow */
}

/* Different hover tones (optional but cool) */
/* #backBtn:hover {
    background: rgba(100, 150, 255, 0.3);
}

#resetBtn:hover {
    background: rgba(255, 120, 120, 0.3);
} */

/* Active press */
.seg-btn:active {
  opacity: 0.5;
}

/* Disabled state */
.seg-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  /* filter: saturate(0.85); */
  /* background: rgba(255, 255, 255, 0.08); */
}