:root {
  color-scheme: dark;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  /* deep midnight-forest backdrop behind the WebGL canvas */
  background:
    radial-gradient(90% 70% at 50% 8%, rgba(40, 70, 92, 0.22) 0%, transparent 55%),
    radial-gradient(120% 100% at 50% 60%, #0a1410 0%, #060d0c 42%, #03070a 74%, #010304 100%);
}

/* Soft vignette for depth + focus on the swarm. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 46%, transparent 50%, rgba(0, 0, 0, 0.62) 100%);
  z-index: 5;
}

#app {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---- Loading veil ---- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(120% 100% at 50% 50%, #0a1410 0%, #04080a 60%, #010304 100%);
  transition: opacity 0.9s ease;
}
#loading.hidden {
  opacity: 0;
  pointer-events: none;
}
#loading .spark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f6ffb0;
  box-shadow:
    0 0 8px 2px rgba(220, 255, 130, 0.9),
    0 0 26px 8px rgba(180, 255, 120, 0.55),
    0 0 60px 22px rgba(120, 220, 120, 0.28);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.55; }
  50%      { transform: scale(1.25); opacity: 1; }
}
#loading .loadtext {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(214, 255, 196, 0.62);
}

/* ---- Remix link (top banner) ---- */
#remix {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  pointer-events: auto;
  max-width: calc(100% - 28px);
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
  font-size: 10px;
  line-height: 1.7;
  letter-spacing: 0.1em;
  color: rgba(210, 240, 210, 0.32);
}
#remix em {
  font-style: normal;
  font-weight: 600;
  color: rgba(224, 255, 200, 0.55);
}
#remix span {
  font-weight: 500;
  white-space: nowrap;
  color: rgba(224, 255, 200, 0.46);
  border-bottom: 1px solid rgba(224, 255, 200, 0.14);
}

/* ---- HUD ---- */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
  user-select: none;
  z-index: 6;
}

/* HUD + remix banner ease in with the scene reveal */
#hud,
#remix {
  opacity: 0;
  transition: opacity 1.1s ease 0.3s;
}
#app.ready #hud,
#app.ready #remix {
  opacity: 1;
}
#hud .title {
  font-size: 13px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  text-indent: 0.5em;
  font-weight: 600;
  background: linear-gradient(90deg, #fdffc0, #c8ff9a, #8fe6b6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(180, 255, 140, 0.25);
}
#hud .hint {
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: rgba(226, 255, 214, 0.66);
  text-shadow: 0 0 12px rgba(150, 230, 150, 0.2);
  text-align: center;
  padding: 0 14px;
}
#hud .credit {
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.03em;
  color: rgba(220, 240, 220, 0.24);
  pointer-events: auto;
  text-align: center;
  padding: 0 16px;
  max-width: 640px;
  line-height: 1.5;
}
#hud .credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(220, 240, 220, 0.14);
}

/* ---- Re-form button ---- */
#reform {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  right: calc(env(safe-area-inset-right) + 16px);
  z-index: 8;
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(226, 255, 214, 0.7);
  background: rgba(12, 24, 18, 0.42);
  border: 1px solid rgba(150, 230, 150, 0.22);
  border-radius: 999px;
  padding: 8px 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.6s ease, transform 0.1s ease;
  opacity: 0;
}
/* always discoverable once the scene is in, brighter after first stir / on hover */
#app.ready #reform { opacity: 0.5; }
#reform.show { opacity: 1; }
#reform:hover {
  background: rgba(24, 44, 30, 0.6);
  border-color: rgba(180, 255, 150, 0.45);
  color: rgba(240, 255, 224, 0.95);
}
#reform:active { transform: scale(0.96); }

@media (max-width: 560px) {
  #hud .hint { font-size: 11.5px; }
  #remix { font-size: 9px; }
  #reform { font-size: 10px; padding: 7px 12px; }
}
