<!-- SOLUV · part 480 -->
(i + vec3(0,1,0)), h3(i + vec3(1,1,0)), f.x), f.y),
             mix(mix(h3(i + vec3(0,0,1)), h3(i + vec3(1,0,1)), f.x), mix(h3(i + vec3(0,1,1)), h3(i + vec3(1,1,1)), f.x), f.y), f.z); }
float fbm(vec3 p){ float a = 0.5, s = 0.0; for (int i = 0; i < 5; i++) { s += a * n3(p); p *= 2.03; a *= 0.5; } return s; }
void main(){
  #include <logdepthbuf_fragment>
  vec3 d = normalize(vD); float up = d.y;
  vec3 col = vec3(0.0);
  col += vec3(0.0, 0.09, 0.13) * exp(-abs(up) * 10.0);                       // thin cyan horizon haze
  col += vec3(0.015, 0.008, 0.05) * smoothstep(0.05, 1.0, up);               // deep indigo zenith
  float band = exp(-pow(dot(d, normalize(vec3(0.55, 0.30, 0.78))), 2.0) * 10.0);  // tilted nebula band (a galaxy arm)
  float n = fbm(d * 3.2 + vec3(0.0, uT * 0.004, 0.0));
  col += band * (vec3(0.11, 0.03, 0.20) * n * n * 2.2 + vec3(0.0, 0.12, 0.16) * pow(n, 3.0) * 2.4);
  // the black sky grid the King liked, faint, thinning toward the zenith
  float lon = atan(d.z, d.x) / 6.28318 * 72.0; float lat = asin(clamp(d.y, -1.0, 1.0)) / 1.5708 * 18.0;
  vec2 g = abs(fract(vec2(lon, lat) - 0.5) - 0.5) / max(fwidth(vec2(lon, lat)), vec2(1e-4));
  float l = 1.0 - min(1.0, min(g.x, g.y) / 1.2);
  col += vec3(0.03, 0.15, 0.21) * l * (1.0 - smoothstep(0.55, 0.98, abs(up))) * 0.75;
  gl_FragColor = vec4(col, 1.0);
}`;
const STAR_VS = `attribute float aSize; attribute float aPhase; attribute vec3 aColor; uniform float uT; uniform float uPR; varying vec3 vC; varying float vA;
void main(){ vec4 mv = modelViewMatrix * vec4(position, 1.0); gl_Position = projectionMatrix * mv;
  float tw = 0.72 + 0.28 * sin(uT * (0.8 + aPhase) * 1.9 + aPhase * 37.0);
  gl_PointSize = aSize * uPR * (0.85 + 0.3 * tw); vC = aColor; vA = tw; }`;
const STAR_FS = `varying vec3 vC; varying float vA;
void main(){ vec2 c = gl_PointCoord - 0.5; float r = length(c); float a = smoothstep(0.5, 0.0, r); a *= a; gl_FragColor = vec4(vC * a * vA, 1.0); }`;

const FLOOR_VS = `${LOGV}
varying vec3 vW;
void main(){ vec4 wp = modelMatrix * vec4(position, 1.0); vW = wp.xyz; gl_Position = projectionMatrix * viewMatrix * wp;
  #include <logdepthbuf_vertex>
}`;
const FLOOR_FS = `${LOGF}
varying vec3 vW; uniform float uT;
void main(){
  #include <logdepthbuf_fragment>
  vec2 p = vW.xz; vec2 fw = fwidth(p); float r = length(p);
  vec2 g = abs(fract(p / 10.0 - 0.5) - 0.5) * 10.0;                           // the same 10-unit blocks as Playa's gold grid
  float l = 1.0 - min(1.0, min(g.x / (fw.x * 1.2 + 0.03), g.y / (fw.y * 1.2 + 0.03)));
  l *= 1.0 - smoothstep(1.5, 6.0, max(fw.x, fw.y));
  vec2 g2 = abs(fract(p / 100.0 - 0.5) - 0.5) * 100.0;
  float l2 = 1.0 - min(1.0, min(g2.x / (fw.x * 1.2 + 0.06), g2.y / (fw.y * 1.2 + 0.06)));
  float near = exp(-r / 260.0);
  float pulse = 0.5 + 0.5 * sin(r * 0.06 - uT * 1.4);                         // slow energy ripples out from the tower
  vec3 cyan = vec3(0.37, 0.96, 1.0);
  vec3 col = vec3(0.004, 0.006, 0.012);
  col += cyan * l * (0.05 + 0.30 * near) + cyan * l2 * (0.08 + 0.25 * near);
  col += vec3(0.0, 0.22, 0.30) * exp(-r / 38.0) * (0.75 + 0.25 * pulse);      // light pool at the foot
  col += vec3(0.83, 0.63, 0.09) * smoothstep(${PLATFORM_R - 10}.0, ${PLATFORM_R}.0, r) * 0.7;   // gold rim of the platform
  gl_FragColor = vec4(col, 1.0);
}`;
const AURA_VS = `${LOGV}
varying vec3 vW; varying vec3 vN;
void main(){ vec4 wp = modelMatrix * vec4(position, 1.0); vW = wp.xyz; vN = normalize(mat3(modelMatrix) * normal); gl_Position = projectionMatrix * viewMatrix * wp;
  #include <logdepthbuf_vertex>
}`;
const AURA_FS = `${LOGF}
varying vec3 vW; varying vec3 vN; uniform vec3 uCam; uniform float uT; uniform float uTop; uniform float uK;
void main(){
  #include <logdepthbuf_fragment>
  vec3 V = normalize(uCam - vW); float f = abs(dot(normalize(vN), V)); float a = pow(f, 4.0);
  float dist = length(uCam - vW); float far = smoothstep(80.0, 700.0, dist);    // up close the aura steps aside so the text stays clear
  float h = vW.y / uTop; float ends = smoothstep(0.0, 0.04, h) * (1.0 - smoothstep(0.93, 1.0, h));
  float scan = 0.8 + 0.2 * sin(vW.y * 0.035 - uT * 2.2);                       // light climbing the tower
  gl_FragColor = vec4(vec3(0.12, 0.72, 1.0) * a * far * ends * scan * uK, 1.0);
}`;
const BEAM_VS = `${LOGV}
varying float vY;
void main(){ vY = uv.y; vec4 wp = modelMatrix * vec4(position, 1.0); gl_Position = projectionMatrix * viewMatrix * wp;
  #include <logdepthbuf_vertex>
}`;
const BEAM_FS = `${LOGF}
varying float vY; uniform float uT;
void main(){
  #include <logdepthbuf_fragment>
  float a = pow(1.0 - vY, 2.2) * (0.85 + 0.15 * sin(uT * 3.0 - vY * 40.0));
  gl_FragColor = vec4(vec3(0.45, 0.95, 1.0) * a * 0.8, 1.0);
}`;

export async function mountSoluvSpace(container) {
  const t0 = performance.now();
  injectStyle();
  container.classList.add('sp-root');
  const wrap = document.createElement('div'); wrap.className = 'sp-wrap';
  wrap.innerHTML = `<div class="sp-top"><div c