html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background: #1a0b2e;
  background: linear-gradient(160deg, #1a0b2e 0%, #2d1b4e 55%, #1a0b2e 100%);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
  forced-color-adjust: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas-wrap {
  position: relative;
  box-shadow: 0 0 60px rgba(120, 60, 200, 0.35);
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#video-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#video-layer video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background:
    radial-gradient(120% 90% at 50% 115%, rgba(155, 89, 232, 0.22) 0%, transparent 55%),
    linear-gradient(160deg, #1a0b2e 0%, #2d1b4e 55%, #1a0b2e 100%);
  z-index: 100;
  transition: opacity 0.4s ease;
  overflow: hidden;
}

/* Breathing ambient orbs: brand-purple glows drifting behind the card,
   pure CSS, no image dependency (first paint stays instant). */
#loading-ambient-a, #loading-ambient-b {
  position: absolute;
  width: 46vmin;
  height: 46vmin;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.32;
  pointer-events: none;
}
#loading-ambient-a {
  background: #7a3bd8;
  top: -8vmin; left: -10vmin;
  animation: drift-a 9s ease-in-out infinite alternate;
}
#loading-ambient-b {
  background: #d94f9e;
  bottom: -12vmin; right: -8vmin;
  animation: drift-b 11s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(9vmin, 7vmin) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-8vmin, -9vmin) scale(0.9); } }

@media (prefers-reduced-motion: reduce) {
  #loading-ambient-a, #loading-ambient-b { animation: none; }
}

#loading-core {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 40px 44px 34px;
  border-radius: 22px;
  background: rgba(24, 12, 44, 0.55);
  border: 1px solid rgba(176, 107, 232, 0.35);
  box-shadow: 0 18px 60px rgba(8, 3, 20, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  max-width: 86vw;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading-title {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #ffd6f2 0%, #b06be8 60%, #7a3bd8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 24px rgba(176, 107, 232, 0.35);
}

#loading-bar-outer {
  width: min(78vw, 340px);
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}

#loading-bar {
  width: 0%;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #9b59e8, #ff7ad0);
  transition: width 0.2s ease;
}

#loading-sub {
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 6px;
  color: rgba(255, 214, 242, 0.65);
  margin-top: -10px;
}

#loading-pct {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(180deg, #ffd6f2 0%, #b06be8 65%, #8b46d6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 30px rgba(176, 107, 232, 0.25);
}

#loading-pct .pct-sign {
  font-size: 30px;
  font-weight: 700;
  margin-left: 2px;
}

#loading-tip {
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  transition: opacity 0.3s ease;
}

#loading-facts {
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.38);
  margin-top: 2px;
}

#rotate-overlay, #browser-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 5, 20, 0.92);
  z-index: 200;
}

#rotate-overlay.visible, #browser-overlay.visible {
  display: flex;
}

.overlay-card {
  font-family: -apple-system, "PingFang SC", sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: #f3e8ff;
  text-align: center;
  line-height: 1.8;
  padding: 32px 40px;
  border-radius: 16px;
  background: rgba(60, 30, 100, 0.6);
  border: 1px solid rgba(176, 107, 232, 0.4);
}

.overlay-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}
