/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #990000;
  /* đỏ Tết truyền thống */
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  /* Use dvh for mobile browsers to account for address bars */
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  /* Prevent scroll */
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  /* Disable double-tap zoom on some mobile browsers */
  touch-action: manipulation;
}

/* CANVAS */
#fireworks {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: auto;
  /* Allow clicks on canvas */
}

/* CARD */
.card {
  position: relative;
  z-index: 10;
  /* Ensure card is above fireworks/petals */
  background: rgba(0, 0, 0, 0.75);
  border: 4px solid gold;
  border-radius: 20px;
  padding: 15px;
  text-align: center;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
  backdrop-filter: blur(5px);
  /* Modern glass effect */

  /* Ensure it fits on small vertical screens */
  max-height: 90dvh;
  overflow-y: auto;
  scrollbar-width: none;
  /* Hide scrollbar for cleaner look */
}

/* Hide scrollbar for Chrome/Safari inside card if content overflows */
.card::-webkit-scrollbar {
  display: none;
}

/* TEXT */
.year {
  font-size: 2rem;
  color: gold;
  text-shadow: 0 0 15px red;
  margin-bottom: 10px;
}

.title {
  font-size: 1.8rem;
  font-weight: bold;
  margin-bottom: 20px;
  color: gold; /* Màu vàng kim */
  /* Thêm đổ bóng để tạo hiệu ứng 3D và phát sáng */
  text-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.5),
    0 0 10px rgba(255, 215, 0, 0.8);
  text-transform: uppercase; /* Luôn viết hoa */
}

.wish-box {
  margin: 15px 0;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px dashed rgba(255, 215, 0, 0.3);
  border-bottom: 1px dashed rgba(255, 215, 0, 0.3);
  padding: 10px;
  overflow: hidden;
}

#wishText {
  font-style: italic; /* Chữ nghiêng cho nghệ thuật */
  color: #fff6d1; /* Màu vàng đồng */
  font-size: 1.2rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  padding: 15px;
}

/* COUPLET */
.couplet {
  font-size: 0.95rem;
  font-weight: bold;
  color: gold;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* CARD */
.card {
  position: relative;
  z-index: 10;
  background: rgba(27, 27, 27, 0.75);
  border: 4px solid gold;
  border-radius: 20px;
  padding: 15px;
  text-align: center;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
  backdrop-filter: blur(5px);
  max-height: 90dvh;
  overflow-y: auto;
  scrollbar-width: none;
}

.card::-webkit-scrollbar {
  display: none;
}

/* BUTTON */
button {
  position: relative;
  background: gold;
  color: #990000;
  border: none;
  padding: 12px 30px;
  border-radius: 50px;
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* Remove mobile tap highlight */

  /* Phát sáng */
  box-shadow:
    0 0 10px gold,
    0 0 20px rgba(255, 215, 0, 0.6);
}

/* Glow animation element */
button::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.4) 0%,
    transparent 60%
  );
  animation: glowRotate 4s linear infinite;
  pointer-events: none;
}

/* WISH BUTTON STYLE */
.wish-btn {
  position: relative;
}

/* Active state for better mobile feedback */
button:active {
  transform: scale(0.95);
  background: #fff;
  color: #a00;
  box-shadow: 0 0 15px white;
}

button.clicked {
  background: white;
  color: #a00;
  transform: scale(0.95);
}

/* Hover meant for desktop */
@media (hover: hover) {
  button:hover {
    transform: scale(1.05);
    box-shadow:
      0 0 20px gold,
      0 0 40px gold;
  }
}

/* Animation xoay ánh sáng */
@keyframes glowRotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* SIGNATURE */
.signature {
  margin-top: 15px;
  font-size: 0.8rem;
  border-top: 1px solid rgba(255, 215, 0, 0.4);
  padding-top: 10px;
  opacity: 0.9;
}

.signature span {
  color: gold;
  font-weight: bold;
}

/* FADE EFFECT */
.fade {
  animation: fade 0.6s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* RESPONSIVE */
@media (max-width: 380px) {
  .card {
    padding: 12px;
    width: 95%;
    max-width: 400px;
  }

  .envelope {
    padding: 12px;
  }

  .envelope-body {
    padding: 15px;
  }

  .envelope-flap {
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
    border-top: 45px solid #d4a574;
    top: -6px;
  }

  .envelope-text {
    font-size: 1.2rem;
  }

  .year {
    font-size: 1.6rem;
    margin-bottom: 8px;
  }

  .title {
    font-size: 0.95rem;
    letter-spacing: 0.5px;
  }

  .wish-box {
    height: 100px;
    margin: 10px 0;
    padding: 8px;
    min-height: auto;
  }

  #wishText {
    font-size: 1.1rem;
    line-height: 1.4;
  }

  .couplet {
    font-size: 0.75rem;
    line-height: 1.4;
    margin-bottom: 15px;
  }

  button {
    padding: 10px 20px;
    font-size: 0.95rem;
    border-radius: 40px;
  }

  .signature {
    font-size: 0.7rem;
    padding-top: 8px;
    margin-top: 10px;
  }
}

/* Landscape mode handling for phones */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    /* Allow scrolling if needed */
    overflow-y: auto;
  }

  .card {
    margin: 20px auto;
  }
}

/* TAP HINT OVERLAY */
.tap-hint {
  position: fixed;
  top: 3.5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  text-align: center;
  pointer-events: none;
  animation:
    hintFadeIn 0.8s ease-out,
    hintFadeOut 0.8s ease-in 4s forwards;
}

.hint-icon {
  font-size: 2rem;
  /* Thêm dòng này để khi JS đổi scale/translate nó sẽ chuyển động mượt */
  transition: transform 0.2s ease-out;
  animation: tapPulse 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
}

.hint-text {
  margin-top: 1px;
  font-size: 0.7rem;
  color: gold;
  font-weight: bold;
  text-shadow:
    0 0 10px rgba(0, 0, 0, 0.8),
    0 0 20px rgba(255, 215, 0, 0.8);
  background: rgba(0, 0, 0, 0.8);
  padding: 6px 14px;
  border-radius: 18px;
  backdrop-filter: blur(5px);
}

/* Animations for hint */
@keyframes hintFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes hintFadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes tapPulse {
  0%,
  100% {
    transform: scale(1) translateY(0);
  }

  50% {
    transform: scale(1.2) translateY(-10px);
  }
}

/* Hide hint on small screens in landscape */
@media (max-height: 400px) and (orientation: landscape) {
  .tap-hint {
    display: none;
  }
}

/* Optimize hint for mobile */
@media (max-width: 480px) {
  .tap-hint {
    top: 1%;
  }

  .hint-icon {
    font-size: 1.2rem;
  }

  .hint-text {
    font-size: 0.7rem;
    padding: 5px 10px;
    margin-top: 4px;
  }
}

/* Trang bìa thiệp */
.card-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #b30000, #ff0000);
  z-index: 100; /* Luôn nằm trên cùng */
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 16px; /* Nhỏ hơn border của card chính một chút */
  cursor: pointer;
  transition:
    transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.5s;
  border: 2px solid gold;
}

.cover-content {
  text-align: center;
}

.seal {
  font-size: 4rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
  animation: heartbeat 1.5s infinite;
}

/* Trang bìa thiệp cao cấp */
.card-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Màu đỏ đậm sang trọng với hiệu ứng tỏa sáng tâm */
  background: radial-gradient(circle, #ff3333 0%, #990000 100%);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
  /* Viền kép vàng */
  border: 4px double gold;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

/* Thêm hoa văn chìm cho bìa */
.card-cover::before {
  content: "";
  position: absolute;
  width: 200%;
  height: 200%;
  background-image: url("https://www.transparenttextures.com/patterns/oriental-tiles.png"); /* Hoa văn phương Đông */
  opacity: 0.15;
  pointer-events: none;
}

.cover-content {
  position: relative;
  z-index: 2;
  text-align: center;
}

.seal {
  font-size: 5rem;
  margin-bottom: 20px;
  display: block;
  filter: drop-shadow(0 0 15px gold);
  animation: float 3s ease-in-out infinite;
}

.card-cover p {
  color: gold;
  font-size: 1.2rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Hiệu ứng khi mở: Bay lên và lật nhẹ */
.card-cover.opened {
  transform: translateY(-120%) rotate(-5deg);
  opacity: 0;
  pointer-events: none;
}

/* Hiệu ứng trôi lửng lơ cho phong bao */
@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  50% {
    transform: translateY(-15px) rotate(5deg);
  }
}

/* Hiệu ứng khi mở */
.card-cover.opened {
  transform: scale(1.2) rotate(10deg); /* Phóng lớn một chút rồi biến mất */
  opacity: 0;
  pointer-events: none;
  transition: all 0.6s ease-in-out;
}

/* Nhịp tim cho phong bao lì xì */
@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
