/* ---------------- Body & Container ---------------- */
body {
  font-family: 'Georgia', serif;
  background: linear-gradient(-45deg, #fff8f0, #ffeaea, #fff8f0, #ffefea);
  background-size: 400% 400%;
  animation: gradientBG 20s ease infinite;
  color: #333;
  margin: 0;
  padding: 0;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container {
  max-width: 600px;
  margin: 30px auto;
  padding: 20px;
  background: rgba(255, 250, 240, 0.95);
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

h1 {
  text-align: center;
  color: #c85c5c;
  font-size: 1.8em;
  margin-bottom: 15px;
}

/* ---------------- Letters Container ---------------- */
.letters-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 60vh;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.letters-container::-webkit-scrollbar { width: 0; background: transparent; }

.letters-container::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,250,240,0) 0%, rgba(255,245,240,1) 100%);
  border-radius: 0 0 20px 20px;
  z-index: 5;
}

/* ---------------- Letters ---------------- */
.letter {
  border: 2px solid #e8c4b6;
  padding: 15px;
  border-radius: 15px;
  background: #fff8f0;
  transition: all 0.5s ease;
  opacity: 0;
  transform: translateY(20px);
  cursor: pointer;
  perspective: 1000px;
}

.letter.unlocked {
  opacity: 1;
  transform: translateY(0);
  animation: fadeIn 0.8s ease forwards;
}

.letter-title {
  font-weight: bold;
  font-size: 1.2em;
  margin-bottom: 8px;
  color: #c85c5c;
}

.letter-content {
  font-size: 1em;
  color: #333;
}

.locked-message {
  font-style: italic;
  color: #888;
}

/* Flip-card inner */
.letter-inner {
  transition: transform 0.8s;
  transform-style: preserve-3d;
  position: relative;
}

.letter.unlocked .letter-inner:hover {
  transform: rotateY(180deg);
}

.letter-front, .letter-back {
  position: absolute;
  width: 100%;
  backface-visibility: hidden;
  border-radius: 15px;
  padding: 15px;
}

.letter-back {
 
  background-color: #fff0f2; /* very light baby pink */
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAEklEQVR42mP8z/C/HwAIAwMBO0e3KgAAAABJRU5ErkJggg=='); /* subtle paper texture */
  background-repeat: repeat;
  background-size: 20px 20px;
  padding: 15px;
  border-radius: 15px;
  color: #c85c5c; /* soft contrasting text */
  font-family: 'Dancing Script', cursive;
  box-shadow: 0 6px 15px rgba(0,0,0,0.1), inset 0 0 20px rgba(255,255,255,0.2);
  position: relative;
  overflow: hidden;
}


/* ---------------- Modal ---------------- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background-color: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: #fff0f2; /* very light baby pink */
  
  background-size: 20px 20px;
  margin: 10% auto;
  padding: 25px;
  border-radius: 20px;
  width: 90%;
  max-width: 600px;
  transform: scale(0.8);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2), inset 0 0 20px rgba(255,255,255,0.2);
  position: relative;
  overflow: hidden;
}

.modal.show .modal-content {
  transform: scale(1);
  opacity: 1;
}

.close {
  color: #c85c5c;
  float: right;
  font-size: 2em;
  cursor: pointer;
}

.modal-title {
  font-weight: bold;
  font-size: 1.5em;
  margin-bottom: 15px;
  text-align: center;
  color: #c85c5c;
}

.modal-body {
  font-size: 1.1em;
  line-height: 1.6em;
  text-align: justify;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 5px;
  font-family: 'Dancing Script', cursive;
}

/* ---------------- Animations ---------------- */
@keyframes fadeIn {
  from {opacity: 0; transform: translateY(20px);}
  to {opacity: 1; transform: translateY(0);}
}

/* ---------------- Hearts ---------------- */
.heart {
  position: absolute;
  width: 30px;
  height: 30px;
  background: url('data:image/svg+xml;utf8,<svg fill="%23c85c5c" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>') no-repeat center center;
  background-size: contain;
  pointer-events: none;
  animation: floatUp 3s linear forwards;
  z-index: 10;
}

@keyframes floatUp {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-120px) scale(1.5); opacity: 0; }
}

/* ---------------- Sparkles ---------------- */
.sparkle {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.8;
  animation: sparkleMove 2s linear infinite;
}

@keyframes sparkleMove {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(-80px) scale(0.5); opacity: 0; }
}

/* ---------------- Progress + Countdown ---------------- */
.progress, .countdown {
  text-align: center;
  font-size: 1.1em;
  margin-bottom: 10px;
  color: #c85c5c;
}

.progress .heart {
  display: inline-block;
  margin: 0 3px;
  width: 20px;
  height: 20px;
  background: url('data:image/svg+xml;utf8,<svg fill="%23c85c5c" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>') no-repeat center center;
  background-size: contain;
}

/* ---------------- Folded Corner ---------------- */
.modal-content::after,
.letter-back::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,200,190,0.3) 100%);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
  box-shadow: 3px 3px 6px rgba(0,0,0,0.15);
  pointer-events: none;
}

/* ---------------- Confetti ---------------- */
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  background: red;
  opacity: 0.8;
  animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(150px) rotate(360deg); opacity: 0; }
}

/* ---------------- Mobile Responsive ---------------- */
@media (max-width: 480px) {
  .container { padding: 15px; margin: 20px auto; }
  h1 { font-size: 1.5em; }
  .letter { padding: 12px; }
  .letter-title { font-size: 1.1em; }
  .modal-content { padding: 20px; margin: 15% auto; }
}

#greetingModal .modal-content {
  transform: scale(0.5);
  opacity: 0;
  transition: transform 0.5s ease, opacity 0.5s ease;
}

#greetingModal.show .modal-content {
  transform: scale(1);
  opacity: 1;
}