@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&family=Patrick+Hand&display=swap');

body {
  font-family: 'Fredoka', 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
  background-color: #fff0f6;
  background-image: radial-gradient(#fcc2d7 1px, transparent 0);
  background-size: 24px 24px;
  color: #4a3b32;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

header, section, footer, .album-item, button, .game-win-message, .card, .timeline-item, .thank-you-message, .timeline-photo {
  filter: url(#crayon);
}

.crayon-border {
  border: 3px solid #4a3b32;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
}

header {
  background-color: #ffdeeb;
  width: 90%;
  max-width: 800px;
  text-align: center;
  padding: 20px;
  margin: 30px 0 20px 0;
  box-shadow: 3px 5px 0px #4a3b32;
}

header h1 {
  margin: 0;
  font-size: 3rem;
  color: #ff6b6b;
  text-shadow: 2px 2px 0 #fff;
}

header p {
  margin: 10px 0 0 0;
  font-size: 1.4rem;
}

main {
  width: 90%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

section {
  background-color: #fff;
  padding: 25px;
  box-shadow: 4px 6px 0px #4a3b32;
}

section h2 {
  font-size: 2.2rem;
  margin-top: 0;
  color: #e64980;
  border-bottom: 2px dashed #fcc2d7;
  padding-bottom: 10px;
}

section p {
  font-size: 1.2rem;
  line-height: 1.5;
}

/* Thả tim */
.heart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
  position: relative;
  width: 100%;
}

#heart-btn {
  background-color: #ff8787;
  color: white;
  border-width: 3px;
  padding: 12px 30px;
  font-size: 1.5rem;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 2px 4px 0px #4a3b32;
  transition: transform 0.1s, box-shadow 0.1s;
}

#heart-btn:active {
  transform: translate(2px, 4px);
  box-shadow: 0px 0px 0px #4a3b32;
}

.heart-counter {
  margin-top: 15px;
  font-size: 1.4rem;
  font-weight: bold;
}

.thank-you-message {
  background-color: #fff0f6;
  border: 3px dashed #ff8787;
  padding: 15px 25px;
  font-size: 1.3rem;
  color: #e64980;
  font-weight: bold;
  text-align: center;
  margin: 10px 0;
}

/* Tim bay hiệu ứng */
.floating-heart {
  position: absolute;
  font-size: 2rem;
  pointer-events: none;
  z-index: 100;
  animation: floatUp 1.5s ease-out forwards;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-200px) scale(1.5) rotate(var(--rot));
    opacity: 0;
  }
}

/* Album */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.album-item {
  background-color: #fffef0;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 2px 3px 0px #4a3b32;
}

.album-item:hover {
  transform: scale(1.03) rotate(2deg);
}

.album-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid #4a3b32;
  border-radius: 10px;
}

.album-caption {
  text-align: center;
  font-size: 1.1rem;
  margin-top: 8px;
  font-weight: bold;
}

/* Timeline hành trình */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  padding-left: 20px;
  margin-top: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-left: 4px dashed #ff8787;
}

.timeline-item {
  background-color: #fff0f6;
  border: 3px solid #4a3b32;
  border-radius: 20px 10px 20px 10px;
  padding: 15px;
  position: relative;
  margin-left: 15px;
  box-shadow: 3px 4px 0px #4a3b32;
}

.timeline-item::before {
  content: '🌸';
  position: absolute;
  left: -40px;
  top: 12px;
  font-size: 1.5rem;
  background-color: #fff;
  border-radius: 50%;
  padding: 2px;
}

.timeline-month {
  font-weight: bold;
  font-size: 1.3rem;
  color: #e64980;
  margin-bottom: 5px;
}

.timeline-desc {
  font-size: 1.1rem;
  line-height: 1.4;
}

.timeline-photos {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.timeline-photo {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border: 2px solid #4a3b32;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
  background-color: #fff;
}

.timeline-photo:hover {
  transform: scale(1.08) rotate(-3deg);
}

/* Game Board */
.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.3rem;
  margin-bottom: 15px;
}

#reset-game-btn {
  background-color: #ffc078;
  font-family: inherit;
  padding: 6px 15px;
  font-size: 1.1rem;
  cursor: pointer;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 500px;
  margin: 0 auto;
}

.game-card {
  aspect-ratio: 1;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s;
  cursor: pointer;
}

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

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 3px solid #4a3b32;
  border-radius: 15px;
  box-shadow: 2px 3px 0px #4a3b32;
}

.card-front {
  background-color: #fff0f6;
  font-size: 2.5rem;
  transform: rotateY(180deg);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.card-back {
  background-color: #fcc2d7;
  font-size: 2rem;
  color: #fff;
}

.game-win-message {
  background-color: #d3f9d8;
  text-align: center;
  margin-top: 20px;
  padding: 15px;
  box-shadow: 3px 4px 0px #4a3b32;
}

.game-win-message h3 {
  margin: 0;
  color: #2b8a3e;
  font-size: 2rem;
}

.hidden {
  display: none !important;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(74, 59, 50, 0.9);
  justify-content: center;
  align-items: center;
}

.lightbox-content {
  max-width: 80%;
  max-height: 80%;
  border: 6px solid #fff;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  filter: url(#crayon);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
}

footer {
  width: 90%;
  max-width: 800px;
  background-color: #ffdeeb;
  text-align: center;
  padding: 15px;
  margin: 40px 0;
  box-shadow: 3px 4px 0px #4a3b32;
}

footer p {
  margin: 0;
  font-size: 1.2rem;
}

/* Rocket styles (US-09) */
.rocket-container {
  position: fixed;
  width: 60px;
  height: 60px;
  z-index: 999;
  cursor: pointer;
  filter: url(#crayon);
  transition: left 4s ease-in-out, top 4s ease-in-out, transform 1.2s ease-in-out;
  will-change: left, top, transform;
  transform: translate3d(0, 0, 0);
}
.rocket-container img {
  width: 100%;
  height: 100%;
}

/* Smoke particles (US-09) */
.rocket-smoke {
  position: fixed;
  width: 15px;
  height: 15px;
  background-color: rgba(240, 240, 240, 0.8);
  border-radius: 50%;
  pointer-events: none;
  z-index: 998;
  filter: url(#crayon);
  animation: smokeFade 1.2s ease-out forwards;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
}
@keyframes smokeFade {
  0% {
    transform: scale(0.3);
    opacity: 0.8;
    background-color: #ffd8a8;
  }
  30% {
    background-color: #fcc2d7;
    transform: scale(1.0);
  }
  100% {
    transform: scale(1.6) translate(var(--dx, 0px), var(--dy, 0px));
    opacity: 0;
  }
}

/* Background floating particles (US-10) */
.floating-particle {
  position: fixed;
  bottom: -50px;
  pointer-events: none;
  z-index: 0;
  filter: url(#crayon);
  animation: floatUp 15s linear forwards;
  user-select: none;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
}
@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: var(--max-op, 0.35);
  }
  90% {
    opacity: var(--max-op, 0.35);
  }
  100% {
    transform: translateY(-115vh) rotate(360deg) translateX(var(--sway, 50px));
    opacity: 0;
  }
}

/* Rocket Shake animation (US-13) */
.rocket-shake {
  animation: rocketShake 0.15s linear infinite;
}
@keyframes rocketShake {
  0% { transform: rotate(var(--rot-deg, 45deg)) translate(0, 0); }
  25% { transform: rotate(var(--rot-deg, 45deg)) translate(-2px, 2px); }
  50% { transform: rotate(var(--rot-deg, 45deg)) translate(2px, -2px); }
  75% { transform: rotate(var(--rot-deg, 45deg)) translate(-2px, -2px); }
  100% { transform: rotate(var(--rot-deg, 45deg)) translate(0, 0); }
}

/* Music player styles (US-11) */
.music-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  background-color: #ffe3e3;
  border: 3px solid #ffb3b3;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 999;
  font-size: 24px;
  filter: url(#crayon);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
  user-select: none;
}
.music-container:hover {
  transform: scale(1.1);
}
.music-playing {
  animation: musicSpin 3s linear infinite;
}
@keyframes musicSpin {
  100% {
    transform: rotate(360deg);
  }
}

/* Hero slideshow and Heart Overlay styles (US-12) */
.hero-section {
  position: relative;
  padding: 0;
  margin-bottom: 30px;
  overflow: hidden;
}
.hero-slideshow {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  border: 3px solid #4a3b32;
  border-radius: 15px;
  filter: url(#crayon);
  background-color: #fffef0;
}
.slides-container {
  width: 100%;
  height: 100%;
  position: relative;
}
.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  z-index: 1;
}
.slide.active {
  opacity: 1;
  z-index: 2;
}
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.7);
  border: 2px solid #4a3b32;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: background-color 0.2s;
}
.slide-nav:hover {
  background-color: #ffe3e3;
}
.slide-prev {
  left: 15px;
}
.slide-next {
  right: 15px;
}
.hero-heart-overlay {
  position: absolute;
  right: 20px;
  top: 20px;
  bottom: 20px;
  width: 300px;
  background-color: rgba(255, 254, 240, 0.92);
  border: 3px solid #ffb3b3;
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 12;
  box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.1);
}
.hero-heart-overlay h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-family: 'Fredoka', cursive;
  color: #ff6b6b;
  font-size: 1.4rem;
}
.hero-heart-overlay .thank-you-message {
  margin: 5px 0;
  padding: 8px 12px;
  font-size: 1.1rem;
}
.hero-heart-overlay .heart-counter {
  margin-top: 8px;
  font-size: 1.2rem;
}
@media (max-width: 768px) {
  .hero-slideshow {
    height: 300px;
  }
  .hero-section {
    overflow: visible;
  }
  .hero-heart-overlay {
    position: relative;
    right: auto;
    top: auto;
    bottom: auto;
    width: 100%;
    margin-top: 15px;
    box-shadow: none;
  }
}

/* Game list & Overlay styles (US-16) */
.game-list {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.game-item {
  background-color: #fff9db;
  border: 3px solid #fcc419;
  border-radius: 20px;
  padding: 20px;
  width: 220px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 3px 4px 0px #4a3b32;
  filter: url(#crayon);
}
.game-item:hover {
  transform: translateY(-5px);
  box-shadow: 3px 8px 0px #4a3b32;
}
.game-item h3 {
  margin: 10px 0 5px 0;
  font-family: 'Fredoka', cursive;
  color: #e8590c;
  font-size: 1.3rem;
}
.game-item p {
  font-size: 0.95rem;
  color: #4a3b32;
  margin: 0;
}
.game-icon {
  font-size: 3rem;
}

/* Fullscreen Game Overlay */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #fff0f6;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Patrick Hand', cursive;
}
.game-overlay.hidden {
  display: none !important;
}
.game-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background-color: #ffdeeb;
  border-bottom: 4px solid #fcc2d7;
  filter: url(#crayon);
}
.game-overlay-header h2 {
  margin: 0;
  font-family: 'Fredoka', cursive;
  color: #d6336c;
  font-size: 1.8rem;
}
.close-game-btn {
  font-size: 2.5rem;
  color: #d6336c;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  transition: transform 0.15s ease;
}
.close-game-btn:hover {
  transform: scale(1.2);
}
.game-container-area {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: auto;
  position: relative;
}

/* Bubble pop game styles */
.bubble-game-wrapper {
  width: 90%;
  max-width: 600px;
  height: 80%;
  max-height: 500px;
  background-color: #e8f7ff;
  border: 4px solid #74c0fc;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 4px 6px 0px #4a3b32;
  filter: url(#crayon);
}
.bubble-game-info {
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  display: flex;
  justify-content: space-between;
  font-size: 1.4rem;
  font-family: 'Fredoka', cursive;
  color: #1c7ed6;
  z-index: 10;
  pointer-events: none;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  user-select: none;
  animation: floatUp 4s linear forwards;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset -5px -5px 10px rgba(0,0,0,0.1), 2px 2px 5px rgba(0,0,0,0.05);
  will-change: bottom, transform;
  transform: translate3d(0, 0, 0);
}
@keyframes floatUp {
  0% {
    bottom: -80px;
    transform: translateX(0);
  }
  100% {
    bottom: 105%;
    transform: translateX(var(--sway-x, 0px));
  }
}
.bubble-pop-effect {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: rgba(255,255,255,0.8);
  animation: popExplode 0.3s ease-out forwards;
  pointer-events: none;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
}
@keyframes popExplode {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Tối ưu hiệu năng mobile / iOS Safari (US-18) */
@media (max-width: 768px) {
  header, section, footer, .album-item, button, .game-win-message, .card, .timeline-item, .thank-you-message, .timeline-photo, .rocket-container, .rocket-smoke, .hero-slideshow, .game-item, .game-overlay-header, .bubble-game-wrapper, .lightbox-content {
    filter: none !important;
  }
}

/* Hiệu ứng pháo giấy (US-19) */
.confetti-piece {
  position: fixed;
  left: 0;
  top: 0;
  width: 8px;
  height: 12px;
  z-index: 3000;
  pointer-events: none;
  will-change: transform, opacity;
  animation: confettiExplode 3s ease-out forwards;
}
@keyframes confettiExplode {
  0% {
    transform: translate(var(--x-start), var(--y-start)) rotate(0deg);
    opacity: 1;
  }
  35% {
    transform: translate(var(--x-mid), var(--y-peak)) rotate(180deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x-end), var(--y-end)) rotate(360deg);
    opacity: 0;
  }
}
