<!-- SOLIDIVISM-STAGING · part 11 -->
ent });
    
    // Lights: dramatic tactical lighting
    const ambient = new THREE.AmbientLight(0xffffff, 0.4);
    scene.add(ambient);
    
    const keyLight = new THREE.DirectionalLight(0xff3333, 1.2);
    keyLight.position.set(30, 50, 30);
    scene.add(keyLight);
    
    const fillLight = new THREE.DirectionalLight(0x3388ff, 0.5);
    fillLight.position.set(-30, 20, -30);
    scene.add(fillLight);
    
    const rimLight = new THREE.PointLight(0xff0000, 1.2, 150);
    rimLight.position.set(0, 10, 0);
    scene.add(rimLight);
    
    // Ground: tactical grid
    createGround();
    
    // Player: the avatar
    createPlayer();
    
    // Start the loop
    animate();
    
    // Handle resize
    window.addEventListener('resize', onResize);
  }

  // ── GROUND: Futuristic motherboard floor (seamless 4-side loop) ──
  function createMotherboardTexture() {
    const S = 512;
    const c = document.createElement('canvas');
    c.width = S; c.height = S;
    const x = c.getContext('2d');
    
    // PCB base: deep black-green
    x.fillStyle = '#0a0f0a';
    x.fillRect(0, 0, S, S);
    
    // Subtle PCB texture noise
    x.fillStyle = '#0d130d';
    for (let i = 0; i < 200; i++) {
      const px = Math.floor(Math.random() * S);
      const py = Math.floor(Math.random() * S);
      x.fillRect(px, py, 2, 2);
    }
    
    // Circuit traces: red copper lines (keep away from edges for seamless loop)
    const M = 24; // margin — nothing crosses the edge
    x.strokeStyle = '#CC0000';
    x.lineWidth = 3;
    
    // Horizontal traces
    const hLines = [80, 150, 230, 320, 410, 470];
    hLines.forEach(y => {
      x.beginPath();
      x.moveTo(M, y);
      // Zigzag like real motherboard traces
      let cx = M;
      while (cx < S - M - 40) {
        const seg = 40 + Math.random() * 60;
        x.lineTo(cx + seg, y);
        if (Math.random() > 0.5 && cx + seg < S - M - 40) {
          const dy = (Math.random() > 0.5 ? 1 : -1) * 30;
          x.lineTo(cx + seg, y + dy);
          x.lineTo(cx + seg + 30, y + dy);
          x.lineTo(cx + seg + 30, y);
          cx += seg + 30;
        } else {
          cx += seg;
        }
      }
      x.lineTo(S - M, y);
      x.stroke();
    });
    
    // Vertical traces
    const vLines = [70, 140, 250, 340, 430];
    vLines.forEach(px => {
      x.beginPath();
      x.moveTo(px, M);
      let cy = M;
      while (cy < S - M - 40) {
        const seg = 40 + Math.random() * 60;
        x.lineTo(px, cy + seg);
        cy += seg;
      }
      x.lineTo(px, S - M);
      x.stroke();
    });
    
    // Vias: connection points (red dots with dark centers)
    x.fillStyle = '#FF0000';
    for (let i = 0; i < 40; i++) {
      const px = M + Math.random() * (S - 2 * M);
      const py = M + Math.random() * (S - 2 * M);
      x.beginPath(); x.arc(px, py, 6, 0, 7); x.fill();
      x.fillStyle = '#0a0f0a';
      x.beginPath(); x.arc(px, py, 3, 0, 7); x.fill();
      x.fillStyle = '#FF0000';
    }
    
    // Chip pads: rectangles (like CPU sockets)
    x.strokeStyle = '#FF3333';
    x.lineWidth = 2;
    const chips = [[100, 100, 80, 60], [300, 250, 100, 80], [150, 380, 70, 50], [380, 120, 60, 60]];
    chips.forEach(([cx, cy, w, h]) => {
      x.strokeRect(cx - w/2, cy - h/2, w, h);
      // Inner pins
      x.fillStyle = '#FF0000';
      for (let px = cx - w/2 + 8; px < cx + w/2 - 4; px += 12) {
        x.fillRect(px, cy - h/2 - 4, 6, 4);
        x.fillRect(px, cy + h/2, 6, 4);
      }
    });
    
    // Glowing red edge frame (seamless — same on all sides)
    x.strokeStyle = '#FF0000';
    x.lineWidth = 4;
    x.strokeRect(2, 2, S-4, S-4);
    x.strokeStyle = '#660000';
    x.lineWidth = 2;
    x.strokeRect(10, 10, S-20, S-20);
    
    const tex = new THREE.CanvasTexture(c);
    tex.wrapS = THREE.RepeatWrapping;
    tex.wrapT = THREE.RepeatWrapping;
    tex.repeat.set(8, 8); // Tile 8x8 across the floor
    return tex;
  }

  function createGround() {
    const tex = createMotherboardTexture();
    const geo = new THREE.PlaneGeometry(400, 400);
    const mat = new THREE.MeshStandardMaterial({ 
      map: tex,
      roughness: 0.7,
      metalness: 0.3,
      emissive: 0x330000,
      emissiveIntensity: 0.2
    });
    const ground = new THREE.Mesh(geo, mat);
    ground.rotation.x = -Math.PI / 2;
    ground.position.y = 0;
    scene.add(ground);
  }

  // ── PLAYER: World-class avatar ──
  // Design: Valve read hierarchy — silhouette first, 60-30-10 color,
  // glow = prestige (Destiny), idle = alive (not mannequin)
  let avatarParts = {};
  let avatarTime = 0;

  function createPlayer() {
    const group = new THREE.Group();

    // 60% — Near-black tactical suit (#0B0C0E)
    const suitMat = new THREE.MeshStandardMaterial({
      color: 0x0B0C0E, roughness: 0.55, metalness: 0.25
    });
    // 30% — Gunmetal armor plates (#23262B)
    const armorMat = new THREE.MeshStandardMaterial({
      color: 0x23262B, roughness: 0.35, metal