:root {
  color-scheme: dark;
  font-family: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05040e;
  color: #f9e6d3;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  filter: blur(16px) brightness(1.25);
  opacity: 0;
  transition: filter 3.2s cubic-bezier(0.2, 0.8, 0.25, 1), opacity 2.6s ease-out;
}

canvas.scene-ready {
  filter: blur(0px) brightness(1);
  opacity: 1;
}

canvas:active {
  cursor: grabbing;
}

/* --- MÀN HÌNH CHÀO INTRO 1 DÒNG Ở CHÍNH GIỮA MÀN HÌNH --- */
.intro-screen {
  position: fixed;
  inset: 0;
  background: #05040e;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: auto;
  cursor: default;
  opacity: 1;
  transition: opacity 1.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.intro-screen.hide {
  opacity: 0;
  pointer-events: none;
}

.intro-box {
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(0);
  transition: transform 1.6s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
}

.intro-screen.hide .intro-box {
  transform: translateY(-16px);
}

.intro-line {
  font-family: 'Dancing Script', cursive, sans-serif;
  font-size: clamp(28px, 5.2vw, 46px);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff7ef;
  text-shadow: 0 0 35px rgba(255, 215, 150, 0.75), 0 0 15px rgba(255, 180, 80, 0.5), 0 3px 12px rgba(0, 0, 0, 0.95);
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.65s cubic-bezier(0.2, 0.8, 0.25, 1), transform 0.65s cubic-bezier(0.2, 0.8, 0.25, 1);
  will-change: opacity, transform;
}

.intro-line.visible {
  opacity: 1;
  transform: translateY(0);
}

.intro-line.leaving {
  opacity: 0;
  transform: translateY(-14px);
}

.ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(20px, 3.5vw, 42px);
  z-index: 2;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 1.8s ease-out 1.2s, transform 1.8s cubic-bezier(0.16, 1, 0.3, 1) 1.2s;
}

.ui.ui-ready header {
  opacity: 1;
  transform: translateY(0);
}

header small {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: #f3c7b0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

h1 {
  font-family: 'Dancing Script', cursive, sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: clamp(30px, 4.2vw, 54px);
  line-height: 1.2;
  margin: 4px 0 0;
  color: #fff6ee;
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.9), 0 0 35px rgba(255, 190, 150, 0.35);
}

h1 em {
  font-style: normal;
  font-weight: 700;
  background: linear-gradient(135deg, #ffe0a3, #ffb366);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  flex-shrink: 0;
  margin-top: 6px;
}

.create-gift-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(22, 11, 30, 0.72);
  border: 1.5px solid rgba(255, 218, 155, 0.45);
  border-radius: 30px;
  color: #ffd99d;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 0 15px rgba(255, 180, 80, 0.2);
  transition: all 0.25s ease;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.create-gift-btn:hover {
  transform: scale(1.05);
  border-color: rgba(255, 225, 160, 0.9);
  background: rgba(45, 20, 60, 0.85);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.65), 0 0 25px rgba(255, 180, 80, 0.4);
}

/* --- NÚT BẬT/TẮT NHẠC NỀN TRUNG THU Ở GÓC TRÊN MÀN HÌNH --- */
.music-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 218, 155, 0.45);
  background: rgba(22, 11, 30, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffd99d;
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 0 15px rgba(255, 180, 80, 0.25);
  transition: transform 0.25s ease, border-color 0.25s, box-shadow 0.25s, opacity 0.25s;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}

.music-btn:hover {
  transform: scale(1.08);
  border-color: rgba(255, 225, 160, 0.9);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.65), 0 0 25px rgba(255, 180, 80, 0.5);
}

.music-btn:active {
  transform: scale(0.95);
}

.music-btn .music-icon {
  display: inline-block;
  line-height: 1;
  transition: transform 0.3s ease;
}

.music-btn.playing .music-icon {
  animation: musicDiscSpin 4s linear infinite;
}

.music-btn.muted {
  opacity: 0.6;
  border-color: rgba(255, 255, 255, 0.25);
}

@keyframes musicDiscSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- MODAL THIỆP CHÚC TRUNG THU Ở GIỮA MÀN HÌNH (KHUNG ẢNH DỌC + TEXT 1 DÒNG) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 10, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.wish-card {
  position: relative;
  width: min(88vw, 360px);
  max-height: 92vh;
  background: linear-gradient(165deg, rgba(38, 18, 44, 0.97), rgba(16, 8, 22, 0.99));
  border: 1.5px solid rgba(255, 218, 155, 0.55);
  border-radius: 20px;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.85), 0 0 45px rgba(255, 170, 70, 0.28);
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.modal-backdrop.show .wish-card {
  transform: scale(1) translateY(0);
}

.card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, transform 0.2s;
}

.card-close:hover {
  background: rgba(235, 77, 75, 0.85);
  transform: rotate(90deg);
}

.card-img-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: min(65vh, 480px);
  background: #0f0a1c;
  overflow: hidden;
  position: relative;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.4s ease;
}

.wish-card:hover .card-img-wrap img {
  transform: scale(1.02);
}

.card-content {
  padding: 16px 20px 18px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 10, 26, 0.96);
  border-top: 1px solid rgba(255, 215, 150, 0.25);
}

.card-text {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: #ffe8d2;
  font-weight: 500;
  letter-spacing: 0.015em;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 180, 100, 0.25);
}

@media(max-width: 650px) {
  .wish-card {
    width: min(88vw, 320px);
  }

  .card-img-wrap {
    aspect-ratio: 3 / 4;
    max-height: 58vh;
  }

  .card-text {
    font-size: 13.5px;
  }

  h1 {
    font-size: 28px;
  }

  .music-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
    margin-top: 4px;
  }
}
