body {
  margin: 0;
  background: #000;
  color: #fff;
  font-family: 'Lexend', sans-serif;
  font-weight: 100;
}
#threejs-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}
#threejs-canvas canvas {
  touch-action: none;
  outline: none;
}

#orbit-hud {
  position: fixed;
  left: 50%;
  bottom: max(20px, calc(14px + env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.orbit-hint {
  pointer-events: none;
  margin: 0;
  max-width: 320px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 230, 245, 0.9);
  font-family: 'Playpen Sans', cursive;
  font-size: 11px;
  text-align: center;
  transition: opacity 0.8s ease;
}
#controls {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  background: rgba(0,0,0,0.7);
  padding: 10px 20px;
  border-radius: 10px;
}
#text-select {
  font-size: 1rem;
  padding: 5px 10px;
  border-radius: 5px;
  border: none;
}
#yt-audio {
  width: 0;
  height: 0;
  border: none;
  position: absolute;
  left: -9999px;
}

/* Màn loading với nút trái tim */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 90% 50% at 30% 60%, var(--theme-nebula-a, rgba(160, 90, 220, 0.22)), transparent 55%),
    radial-gradient(ellipse 70% 40% at 75% 35%, var(--theme-nebula-b, rgba(255, 100, 180, 0.16)), transparent 50%),
    radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease-in-out;
  overflow: hidden;
}

/* Hiệu ứng sao lấp lánh */
.loading-screen::before,
.loading-screen::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  background: white;
  box-shadow:
    0 0 10px #fff,
    0 0 20px #fff,
    0 0 30px #fff;
  animation: twinkle 1s infinite;
}

.loading-screen::before {
  right: 40%;
  top: 40%;
  animation-delay: .4s;
}

.loading-screen::after {
  left: 30%;
  top: 60%;
  animation-delay: .6s;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  animation: twinkle 1.5s infinite;
}

.heart-button {
  background: none;
  border: none;
  cursor: pointer;
  transform-origin: center;
  animation: pulse 1.5s infinite;
  transition: all 0.5s ease;
  position: relative;
  z-index: 2;
}

.heart-button:hover {
  transform: scale(1.1) translateY(-10px);
}

.heart-button svg {
  width: 100px;
  height: 100px;
  filter:
    drop-shadow(0 0 12px var(--theme-glow, rgba(255, 120, 180, 0.85)))
    drop-shadow(0 0 28px var(--theme-glow-soft, rgba(160, 100, 255, 0.45)));
}

.heart-button path {
  fill: var(--theme-heart, #ac2c2c);
}

/* Hiệu ứng bay lên khi click */
.heart-button.clicked {
  animation: float-away 1.5s ease-in forwards;
}

@keyframes float-away {
  0% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  50% {
    transform: scale(1.2) translateY(-100px);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.5) translateY(-300px);
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.loading-text {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-family: 'Playpen Sans', cursive;
  font-size: 1.2em;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  z-index: 2;
}

/* Hiệu ứng fade out mượt mà hơn */
.fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease-in-out;
}

/* Hiệu ứng fade in cho canvas */
.fade-in {
  opacity: 0;
  animation: fade-in 2s ease-in forwards;
  animation-delay: 0.5s;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Đĩa CD nhạc — góc phải dưới */
.cd-music-btn {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, calc(14px + env(safe-area-inset-bottom)));
  z-index: 30;
  width: 52px;
  height: 52px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.55));
  transition: transform 0.2s ease, opacity 0.25s ease;
  pointer-events: auto;
}

.cd-music-btn[hidden] {
  display: none !important;
}

.cd-music-btn:hover {
  transform: scale(1.08);
}

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

.cd-disc {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #1a1018 0 12%, transparent 13%),
    repeating-conic-gradient(
      from 0deg,
      #f0d0e0 0deg 8deg,
      #c48aaa 8deg 16deg,
      #ffe4f0 16deg 24deg,
      #a06080 24deg 32deg
    );
  box-shadow:
    inset 0 0 0 2px rgba(255, 220, 240, 0.4),
    inset 0 0 14px rgba(0, 0, 0, 0.4),
    0 0 0 3px rgba(255, 120, 180, 0.28),
    0 0 22px rgba(255, 80, 160, 0.35);
}

.cd-disc__ring {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.28);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.4), transparent 55%);
  pointer-events: none;
}

.cd-disc__label {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  height: 42%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--theme-base, #ff4da6), #ff85c8 55%, #ff2d8a);
  opacity: 0.95;
  pointer-events: none;
}

.cd-disc__hole {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16%;
  height: 16%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #0a0610;
  box-shadow: inset 0 0 0 2px rgba(255, 200, 220, 0.55);
  pointer-events: none;
  z-index: 1;
}

.cd-music-btn.is-playing .cd-disc {
  animation: cdSpin 2.6s linear infinite;
}

.cd-music-btn:not(.is-playing) .cd-disc {
  animation: none;
  filter: grayscale(0.25) brightness(0.88);
}

@keyframes cdSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cd-music-btn.is-playing .cd-disc {
    animation: none;
  }
}
