: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 forest-night backdrop behind the canvas. */
  background:
    radial-gradient(90% 70% at 50% 18%, #0b1418 0%, #070d10 45%, #03070a 78%, #010406 100%);
}

#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;
}

/* Soft vignette for depth. */
#app::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 48%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 5;
}

/* ---- 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(60% 50% at 50% 45%, #0a1316 0%, #04080b 70%, #020406 100%);
  transition: opacity 0.9s ease;
}
#loading.hidden {
  opacity: 0;
  pointer-events: none;
}
#loading .spark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cfffa6;
  box-shadow:
    0 0 12px 4px rgba(180, 255, 130, 0.85),
    0 0 30px 10px rgba(150, 230, 110, 0.45);
  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 .loading-text {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: rgba(206, 255, 166, 0.55);
}

/* ---- HUD (title / hint / credits) ---- */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  pointer-events: none;
  user-select: none;
  z-index: 6;
  text-align: center;
  transition: opacity 1.1s ease;
}
#hud.dim { opacity: 0.18; }
#hud .title {
  font-size: 13px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  text-indent: 0.5em;
  font-weight: 600;
  background: linear-gradient(90deg, #f3ffc4, #b6ff7a, #7fe6c0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(150, 255, 130, 0.22);
}
#hud .hint {
  font-size: 12px;
  letter-spacing: 0.09em;
  color: rgba(225, 255, 210, 0.6);
  text-shadow: 0 0 12px rgba(150, 230, 120, 0.18);
  max-width: 640px;
}
#hud .credit {
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.03em;
  line-height: 1.5;
  color: rgba(225, 255, 210, 0.24);
  pointer-events: auto;
  max-width: 680px;
}
#hud .credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(225, 255, 210, 0.14);
}

/* ---- Optional perf readout (?debug) ---- */
#fps {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 12px;
  z-index: 9;
  display: none;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #d6ffb0;
  background: rgba(4, 10, 8, 0.5);
  border: 1px solid rgba(160, 230, 140, 0.18);
  border-radius: 7px;
  padding: 6px 9px;
  white-space: pre;
  pointer-events: none;
}
#fps.show { display: block; }

@media (max-width: 640px) {
  #hud .hint { font-size: 11px; letter-spacing: 0.06em; }
  #hud { bottom: calc(env(safe-area-inset-bottom) + 40px); }
}

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