/* Base */
:root {
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(
      1200px 800px at 80% -10%,
      rgba(240, 170, 255, 0.2),
      transparent 60%
    ),
    radial-gradient(
      900px 600px at 0% 100%,
      rgba(96, 165, 250, 0.18),
      transparent 60%
    ),
    #0b0b0f;
  color: #fff;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Headings */
h2 {
  color: #f0a;
}

/* Progress */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0;
  background: #f0a;
  z-index: 1000;
  transform-origin: left;
}

/* Scenes */
.scene {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.hero h1 {
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  margin: 0;
  line-height: 1.08;
}
.hero h1 span {
  color: #f0a;
}
.hero p {
  opacity: 0.85;
  margin-top: 0.6rem;
}
.luna-emoji {
  font-size: 5rem;
  margin-top: 1rem;
  filter: drop-shadow(0 8px 24px rgba(255, 255, 255, 0.12));
}

.kpop .badge {
  font-size: 2.2rem;
  display: inline-grid;
  place-items: center;
  width: 90px;
  height: 90px;
  border-radius: 999px;
  background: rgba(240, 170, 255, 0.12);
  outline: 1px solid rgba(240, 170, 255, 0.28);
  margin-bottom: 1rem;
}
.gallery .grid {
  display: grid;
  grid-template-columns: repeat(2, 110px);
  gap: 1rem;
  margin-top: 1rem;
}
.card {
  background: rgba(255, 255, 255, 0.08);
  padding: 1rem;
  font-size: 2rem;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
button {
  margin: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
button:hover {
  background: rgba(255, 255, 255, 0.12);
}
.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

/* Persistent frame (footer-like) */
.frame {
  position: fixed;
  right: clamp(8px, 2vw, 24px);
  bottom: calc(
    env(safe-area-inset-bottom, 0px) + clamp(8px, 2vw, 24px) +
      var(--vv-offset, 0px)
  );
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  z-index: 1100;
  pointer-events: none; /* prevents blocking scroll */
}
.frame .bubble {
  pointer-events: auto;
  max-width: min(52ch, 70vw);
  min-width: 0; /* allow shrink inside grid */
  background: rgba(22, 22, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.avatar-wrap {
  width: clamp(72px, 12vw, 120px);
  height: clamp(72px, 12vw, 120px);
  display: grid;
  place-items: center;
}
.avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: bob 3s ease-in-out infinite;
  filter: drop-shadow(0 10px 24px rgba(240, 170, 255, 0.18));
}
.emoji-fallback {
  width: 100%;
  height: 100%;
  display: none;
  place-items: center;
  font-size: clamp(2.2rem, 6vw, 4rem);
  animation: bob 3s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .avatar-wrap img,
  .emoji-fallback {
    animation: none !important;
  }
}

/* Twinkling stars */
.twinkle-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: white;
  border-radius: 50%;
  opacity: 0;
  box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.6);
  animation: twinkle 3s infinite ease-in-out;
}

.star1 {
  top: 15%;
  left: 25%;
  animation-delay: 0s;
}
.star2 {
  top: 40%;
  left: 60%;
  animation-delay: 1s;
}
.star3 {
  top: 65%;
  left: 35%;
  animation-delay: 2s;
}
.star4 {
  top: 25%;
  left: 80%;
  animation-delay: 1.5s;
}
.star5 {
  top: 70%;
  left: 15%;
  animation-delay: 0.5s;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Music scene */
.music h2 {
  margin-bottom: 0.75rem;
}

/* Visualizer (decorative) */
.viz {
  display: inline-flex;
  gap: 6px;
  margin: 0.5rem 0 1rem;
  height: 28px;
  align-items: end;
}
.viz .bar {
  width: 6px;
  height: 6px;
  background: #f0a;
  display: inline-block;
  border-radius: 3px;
  animation: bounce 1.2s infinite ease-in-out;
  box-shadow: 0 0 10px rgba(240, 170, 255, 0.5);
}
.viz .b1 {
  animation-delay: 0s;
}
.viz .b2 {
  animation-delay: 0.1s;
}
.viz .b3 {
  animation-delay: 0.2s;
}
.viz .b4 {
  animation-delay: 0.3s;
}
.viz .b5 {
  animation-delay: 0.4s;
}
@keyframes bounce {
  0%,
  100% {
    height: 6px;
  }
  50% {
    height: 28px;
  }
}

/* Playlist container */
.playlist-wrap {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.btn {
  margin-bottom: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Responsive embed (16:9-ish) */
.embed-phantom {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  outline: 1px solid rgba(255, 255, 255, 0.08);
}
.embed-phantom::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}
.embed-phantom iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
}
.open-extern {
  margin-top: 0.5rem;
}
.open-link {
  color: #a5b4fc;
  text-decoration: underline;
}

/* Reduced motion: soften visualizer */
@media (prefers-reduced-motion: reduce) {
  .viz .bar {
    animation: none;
    height: 12px;
  }
}

/* Favourite Movies */
.movies h2 {
  margin-bottom: 0.25rem;
}
.movies .sub {
  opacity: 0.85;
  margin: 0 0 1rem;
}

.poster-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto 1rem;
}
.poster {
  display: grid;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  color: #fff;
  text-align: center;
  transition: transform 0.2s ease, background 0.2s ease;
}
.poster:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.07);
}
.poster img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  background: #15151b;
}
.poster-title {
  font-size: 0.9rem;
  opacity: 0.9;
}

.cinema {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}
.screen {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  outline: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c0c12;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Responsive 16:9 container for video */
.yt-wrap {
  position: relative;
  width: 100%;
}
.yt-wrap::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}
.yt-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.yt-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2rem;
  opacity: 0.35;
}

/* Curtains */
.curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 52%;
  background: repeating-linear-gradient(
    90deg,
    rgba(180, 40, 70, 0.95) 0px,
    rgba(180, 40, 70, 0.95) 14px,
    rgba(140, 20, 50, 0.95) 14px,
    rgba(140, 20, 50, 0.95) 28px
  );
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5) inset;
  z-index: 2;
}
.curtain-left {
  left: 0;
  border-right: 2px solid rgba(255, 255, 255, 0.08);
}
.curtain-right {
  right: 0;
  border-left: 2px solid rgba(255, 255, 255, 0.08);
}

.curtains-btn {
  margin: 0.75rem auto 0;
  display: inline-block;
}

/* Reduced motion: don’t animate curtains automatically */
@media (prefers-reduced-motion: reduce) {
  .curtain {
    transition: none !important;
  }
}

/* Art Gallery */
.gallery h2 {
  margin-bottom: 0.25rem;
}
.gallery .sub {
  opacity: 0.85;
  margin: 0 0 1rem;
}

.art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  max-width: 960px;
  margin: 0 auto;
}
.art-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  line-height: 0;
  transition: transform 0.2s ease, background 0.2s ease;
}
.art-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.06);
}
.art-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 20px;
}
.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 2rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}
.lightbox.show {
  display: flex;
}

/* Reduced motion: no hover lift */
@media (prefers-reduced-motion: reduce) {
  .art-item:hover {
    transform: none;
  }
}

/* Games */
.games h2 {
  margin-bottom: 0.5rem;
}

.games-tabs {
  display: inline-flex;
  gap: 8px;
  margin: 0 0 10px;
  border-radius: 12px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.game-tab {
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.game-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}
.game-tab.is-active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.game-frame-wrap {
  position: relative;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  outline: 1px solid rgba(255, 255, 255, 0.08);
}
.game-frame-wrap::before {
  /* 480p-ish default aspect; many simple games are near-square.
     Adjust or remove if your games control their own height. */
  content: "";
  display: block;
  padding-top: 70%;
}
.game-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b0b0f;
}
.game-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0.5;
  font-size: 1.25rem;
}

/* Reduced motion: no hover lift styles here, tabs stay calm */

/* Global Night Sky */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1; /* behind everything */
  pointer-events: none;
  background: radial-gradient(
      1400px 900px at 80% -10%,
      rgba(240, 170, 255, 0.14),
      transparent 60%
    ),
    radial-gradient(
      1000px 700px at 0% 100%,
      rgba(96, 165, 250, 0.12),
      transparent 60%
    ),
    #0b0b0f; /* base night color */
}

/* Moon (soft glow) */
.sky-moon {
  position: absolute;
  right: 6vw;
  top: 8vh;
  width: clamp(80px, 12vw, 160px);
  aspect-ratio: 1/1;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    #fafafa 0%,
    #f1f1f1 45%,
    #e9e9e9 60%,
    #d5d5d5 75%,
    #bfbfbf 100%
  );
  box-shadow: 0 0 30px 8px rgba(255, 255, 255, 0.25),
    0 0 120px 30px rgba(240, 170, 255, 0.1);
  opacity: 0.95;
  filter: saturate(0.9) brightness(1.05);
}

/* Star canvas fills the viewport */
#starCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Shooting stars container */
#shootingWrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Shooting star element (created by JS) */
.shooting-star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px 3px rgba(255, 255, 255, 0.9),
    0 0 25px 8px rgba(160, 200, 255, 0.6);
  opacity: 0;
}
.shooting-star::after {
  content: "";
  position: absolute;
  left: -140px;
  top: -1px;
  height: 3px;
  width: 140px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.8)
  );
  filter: blur(1px);
  border-radius: 3px;
}

/* Prefer reduced motion: freeze animations */
@media (prefers-reduced-motion: reduce) {
  .shooting-star,
  .sky-moon {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Mobile-first adjustments ---------- */
@media (max-width: 640px) {
  /* Typographic breathing room */
  .hero h1 {
    font-size: clamp(1.6rem, 8vw, 2.4rem);
  }
  .hero p {
    font-size: 0.95rem;
  }

  /* Persistent frame: turn into a top bar so it doesn’t cover content */
  .frame {
    right: calc(env(safe-area-inset-right, 0px) + 8px);
    left: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
    top: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0 8px;
    gap: 8px;
    max-width: calc(
      100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) -
        8px
    );
  }
  .frame .bubble {
    font-size: 0.9rem;
    /* Keep bubble from pushing avatar off-screen */
    max-width: calc(
      100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) -
        /* frame right offset */ 8px - /* frame horizontal padding */ 16px -
        /* avatar width */ 64px - /* gap between columns */ 8px -
        /* bubble padding L+R (~0.9rem*2) */ 1.8rem - /* bubble border L+R */
        2px
    );
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .avatar-wrap {
    width: 64px;
    height: 64px;
  }
  .emoji-fallback {
    font-size: 2rem;
  }

  /* Posters: horizontal scroller with snap */
  .poster-row {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding: 4px 2px;
    scroll-snap-type: x mandatory;
  }
  .poster {
    min-width: 56vw; /* large, tappable card */
    scroll-snap-align: start;
  }
  .poster img {
    height: 48vw;
  } /* keep poster aspect on phones */

  /* Cinema: keep screen visible, reduce visual busy-ness */
  .cinema {
    margin-top: 8px;
  }
  .yt-wrap::before {
    padding-top: 56.25%;
  } /* standard 16:9 */

  /* Art grid: smaller min tiles so more fit */
  .art-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
  }
  .art-item img {
    height: 120px;
  }

  /* Games: tabs wrap and stay big enough to tap */
  .games-tabs {
    flex-wrap: wrap;
    gap: 6px;
  }
  .game-tab {
    font-size: 0.95rem;
    padding: 0.5rem 0.7rem;
  }

  /* Game frame: more square for generic JS games */
  .game-frame-wrap::before {
    padding-top: 90%;
  }

  /* Music: visualizer a bit shorter */
  .viz {
    height: 22px;
  }
  .viz .bar {
    width: 5px;
  }

  /* Moon: slightly smaller so it doesn’t dominate */
  .sky-moon {
    width: clamp(72px, 18vw, 120px);
    right: 4vw;
    top: 6vh;
  }
}

/* Make buttons feel tappable on touch */
button,
.poster,
.art-item {
  touch-action: manipulation;
}
