* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: manipulation;
}

body {
  overflow: hidden;
  background: linear-gradient(135deg, #0a0518, #1d0a35, #36175c);
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Poppins', sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.header {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  text-align: center;
  z-index: 100;
  width: 100%;
  pointer-events: none;
}

h1 {
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  margin-bottom: 10px;
  background: linear-gradient(45deg, #ff9ec5, #ffb3d9, #ffcce6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 15px rgba(255, 117, 140, 0.3);
  animation: glow 2s infinite alternate;
  font-weight: 600;
  font-family: 'Dancing Script', cursive;
  letter-spacing: 1px;
}


.controls {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 100;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90%;
}

.btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  color: white;
  border: 1px solid rgba(255, 182, 193, 0.4);
  padding: 12px 20px;
  border-radius: 25px;
  font-size: clamp(0.8rem, 3.5vw, 0.9rem);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  z-index: 200;
  min-width: 120px;
  justify-content: center;
}
.btn-music {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  color: white;
  border: 1px solid rgba(255, 182, 193, 0.4);
  padding: 12px 20px;
  border-radius: 25px;
  font-size: clamp(0.8rem, 3.5vw, 0.9rem);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  z-index: 200;
  min-width: 120px;
  justify-content: center;
}

.btn:hover {
  background: rgba(255, 182, 193, 0.25);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(255, 182, 193, 0.3);
}

.all-in-one-btn {
  background: linear-gradient(45deg, #ff6b9d, #ffcc00);
  color: white;
  font-weight: 600;
  min-width: 140px;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.all-in-one-btn:hover {
  background: linear-gradient(45deg, #ff5190, #ffbf00);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 5px 20px rgba(255, 107, 157, 0.4);
}

@keyframes glow {
  0% {
    text-shadow: 0 0 8px rgba(255, 117, 140, 0.3);
  }

  100% {
    text-shadow: 0 0 25px rgba(255, 117, 140, 0.6), 0 0 40px rgba(255, 117, 140, 0.4);
  }
}

.floating-text {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 25px;
  border-radius: 30px;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  color: #ffcc00;
  z-index: 100;
  animation: float 4s ease-in-out infinite;
  pointer-events: none;
  display: none;
}

@keyframes float {
  0% {
    transform: translate(-50%, 0px);
  }

  50% {
    transform: translate(-50%, -10px);
  }

  100% {
    transform: translate(-50%, 0px);
  }
}

.candle-highlight {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 100, 0.9) 0%, rgba(255, 180, 60, 0.6) 50%, rgba(255, 120, 0, 0) 70%);
  filter: blur(40px);
  transform: translate(-50%, -50%);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  mix-blend-mode: screen;
}

.music-control {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 100;
}

.birthday-card {
  position: absolute;
  top: 50%;
  left: -100px;
  transform: translateY(-50%);
  width: 120px;
  height: 160px;
  background: linear-gradient(135deg, #ff0066, #ff9ec5);
  border-radius: 0 10px 10px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.birthday-card:hover {
  left: 0;
}

.birthday-card .icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  color: white;
  text-shadow: 0 0 10px rgba(255, 0, 102, 0.5);
  animation: heartbeat 1.5s infinite;
}

.birthday-card .text {
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-expanded {
  width: 400px;
  height: 500px;
  left: 0;
  z-index: 300;
  background: linear-gradient(135deg, #ffcce6, #f0f0ff);
  backdrop-filter: blur(20px);
  padding: 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  cursor: default;
  border-radius: 0 10px 10px 0;
}

.card-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.5s ease;
}

.card-expanded .card-content {
  opacity: 1;
  transform: scale(1);
}

.card-title {
  font-size: clamp(2rem, 8vw, 2.5rem);
  margin-bottom: 20px;
  color: #ff0066;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-weight: 700;
  background: linear-gradient(45deg, #ff0066, #ff9ec5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-family: 'Dancing Script', cursive;
}

.card-message {
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  line-height: 1.6;
  color: #5a3a7a;
  margin-bottom: 20px;
  font-weight: 500;
  padding: 0 15px;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 310;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.close-btn::before,
.close-btn::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 2px;
  background: #ff0066;
}

.close-btn::before {
  transform: rotate(45deg);
}

.close-btn::after {
  transform: rotate(-45deg);
}

.signature {
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  font-weight: bold;
  color: #ff6b9d;
  margin-top: 15px;
  font-style: italic;
  font-family: 'Dancing Script', cursive;
}

.decorations {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.decoration {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.6;
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
  }

  14% {
    transform: scale(1.15);
  }

  28% {
    transform: scale(1);
  }

  42% {
    transform: scale(1.15);
  }

  70% {
    transform: scale(1);
  }
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 5, 24, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top: 5px solid #ff6b9d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: #ffb3d9;
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.glitter-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect fill='none' width='100' height='100'/%3E%3Cpath fill='rgba(255,255,255,0.2)' d='M50,10 L60,40 L90,40 L65,60 L75,90 L50,70 L25,90 L35,60 L10,40 L40,40 Z'/%3E%3C/svg%3E");
  background-size: 50px 50px;
  opacity: 0.3;
  mix-blend-mode: screen;
}

.landed-petal {
  position: absolute;
  font-size: 24px;
  opacity: 0.8;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.5s ease, transform 0.5s ease;
  user-select: none;
}

.countdown {
  position: absolute;
  top: max(60px, calc(env(safe-area-inset-top) + 40px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 1.1rem;
  color: #ffcc00;
  z-index: 100;
  display: none;
  pointer-events: none;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
  }

  100% {
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.8);
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 2.2rem;
    margin-top: env(safe-area-inset-top);
  }

  .btn {
    padding: 24px 18px;
    font-size: 0.85rem;
    min-width: 100px;
    margin: 10px;
    margin-bottom: 30px;
  }
  .btn-music {
    padding: 14px 10px;
    font-size: 0.85rem;
    min-width: 100px;
    margin-top: 60px;
    margin: 60px, 10px,0,0;
  }

  .all-in-one-btn {
    min-width: 120px;
    font-size: 0.9rem;
  }

  .floating-text {
    font-size: 1.2rem;
    top: 35%;
    padding: 10px 20px;
  }

  .controls {
    bottom: calc(15px + env(safe-area-inset-bottom));
    gap: 6px;
  }

  .candle-highlight {
    width: 150px;
    height: 150px;
    filter: blur(30px);
  }

  .birthday-card {
    width: 100px;
    height: 140px;
    left: -80px;
  }

  .birthday-card:hover {
    left: 0;
  }

  .card-expanded {
    width: 90%;
    height: 80%;
    max-height: 80vh;
    left: 5%;
    top: 10%;
    transform: none;
    border-radius: 10px;
  }

  .landed-petal {
    font-size: 20px;
  }

  .countdown {
    top: max(50px, calc(env(safe-area-inset-top) + 30px));
    font-size: 0.95rem;
    padding: 6px 12px;
  }
}

@media (max-width: 480px) {
  .controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .btn {
    flex: 1 0 calc(50% - 10px);
    min-width: auto;
    padding: 12px 10px;
    font-size: 0.8rem;
  }
  .btn-music {
    flex: 1 0 calc(50% - 10px);
    min-width: auto;
    padding: 12px 10px;
    font-size: 0.8rem;
  }

  .all-in-one-btn {
    min-width: auto;
    flex: 1 0 100%;
    order: -1;
    margin-bottom: 8px;
  }

  .music-control {
    top: max(15px, env(safe-area-inset-top));
    right: max(15px, env(safe-area-inset-right));
  }

  .birthday-card {
    width: 90px;
    height: 120px;
    left: -70px;
  }

  .birthday-card .icon {
    font-size: 2rem;
  }

  .birthday-card .text {
    font-size: 0.85rem;
  }

  .card-expanded {
    width: 95%;
    height: 85%;
    left: 2.5%;
    top: 7.5%;
  }

  .landed-petal {
    font-size: 18px;
  }

  .countdown {
    top: max(40px, calc(env(safe-area-inset-top) + 20px));
    font-size: 0.85rem;
    padding: 5px 10px;
  }
}
