<!-- SOLIDIVISM · part 44 -->
e = '#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);
    legR.position.set(0.32, 0.65, 0);
    group.add(legR);

    // THIGH PLATES: armor
    const thighGeo = new THREE.BoxGeometry(0.4, 0.5, 0.35);
    const thighL = new THREE.Mesh(thighGeo, armorMat);
    thighL.position.set(-0.32, 0.9, 0.1);
    group.add(thighL);
    const thighR = new THREE.Mesh(thighGeo, armorMat);
    thighR.position.set(0.32, 0.9, 0.1);
    group.add(thighR);

    // HELMET: sphere (armor)
    const helmGeo = new THREE.SphereGeometry(0.5, 16, 12);
    const helmet = new THREE.Mesh(helmGeo, armorMat);
    helmet.position.y = 2.85;
    group.add(helmet);
    avatarParts.helmet = helmet;

    // VISOR: glowing slit — the "face" (highest payoff detail)
    const visorGeo = new THREE.BoxGeometry(0.65, 0.14, 0.2);
    const visor = new THREE.Mesh(visorGeo, glowMat);
    visor.position.set(0, 2.88, 0.38);
    group.add(visor);
    avatarParts.visor = visor;

    // HELMET FIN: rear silhouette signature (third-person camera sees back)
    const finGeo = new THREE.BoxGeometry(0.08, 0.5, 0.4);
    const fin = new THREE.Mesh(finGeo, armorMat);
    fin.position.set(0, 3.15, -0.35);
    fin.rotation.x = -0.3;
    group.add(fin);

    // BACKPACK: box