<!-- SOLIDIVISM · part 50 -->
 + 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, metalness: 0.85
    });
    // 10% — Hot-red emissive (#FF2200) — the hero accent
    const glowMat = new THREE.MeshStandardMaterial({
      color: 0xFF2200, emissive: 0xFF2200, emissiveIntensity: 2.5,
      roughness: 0.4, metalness: 0.1
    });

    // TORSO: tapered cylinder (suit)
    const torsoGeo = new THREE.CylinderGeometry(0.65, 0.85, 1.6, 12);
    const torso = new THREE.Mesh(torsoGeo, suitMat);
    torso.position.y = 1.6;
    group.add(torso);
    avatarParts.torso = torso;

    // CHEST PLATE: flattened box (armor) — brightest at chest (Valve)
    const chestGeo = new THREE.BoxGeometry(1.1, 0.7, 0.5);
    const chest = new THREE.Mesh(chestGeo, armorMat);
    chest.position.set(0, 1.9, 0.35);
    group.add(chest);

    // CHEST EMBLEM: glowing chevron (the identity mark)
    const emblemGeo = new THREE.PlaneGeometry(0.4, 0.25);
    const emblem = new THREE.Mesh(emblemGeo, glowMat);
    emblem.position.set(0, 1.9, 0.62);
    group.add(emblem);
    avatarParts.emblem = emblem;

    // SHOULDER PADS: asymmetric (one larger) — silhouette breakers
    const padGeoL = new THREE.BoxGeometry(0.55, 0.35, 0.6);
    const padL = new THREE.Mesh(padGeoL, armorMat);
    padL.position.set(-0.75, 2.3, 0);
    padL.rotation.z = 0.15;
    group.add(padL);

    const padGeoR = new THREE.BoxGeometry(0.7, 0.42, 0.7);
    const padR = new THREE.Mesh(padGeoR, armorMat);
    padR.position.set(0.8, 2.32, 0);
    padR.rotation.z = -0.12;
    group.add(padR);

    // ARMS: cylinders (suit) with glow circuit strips
    const armGeo = new THREE.CylinderGeometry(0.22, 0.28, 1.2, 10);
    const armL = new THREE.Mesh(armGeo, suitMat);
    armL.position.set(-0.85, 1.4, 0);
    group.add(armL);
    avatarParts.armL = armL;

    const armR = new THREE.Mesh(armGeo, suitMat);
    armR.position.set(0.85, 1.4, 0);
    group.add(armR);
    avatarParts.armR = armR;

    // ARM CIRCUIT LINES: thin emissive strips (Tron signature)
    const stripGeo = new THREE.BoxGeometry(0.06, 0.9, 0.06);
    const stripL = new THREE.Mesh(stripGeo, glowMat);
    stripL.position.set(-0.85, 1.4, 0.26);
    group.add(stripL);
    const stripR = new THREE.Mesh(stripGeo, glowMat);
    stripR.position.set(0.85, 1.4, 0.26);
    group.add(stripR);

    // LEGS: tapered cylinders
    const legGeo = new THREE.CylinderGeometry(0.28, 0.22, 1.3, 10);
    const legL = new THREE.Mesh(legGeo, suitMat);
    legL.position.set(-0.32, 0.65, 0);
    group.add(legL);
    const legR = new THREE.Mesh(legGeo, suitMat);
    leg