<!-- SOLIDIVISM · part 57 -->
6-B, 256-B-L); x.stroke();
    
    // Red data stripes
    x.fillStyle = '#FF0000';
    x.fillRect(0, 110, 256, 10);
    x.fillRect(0, 128, 256, 4);
    
    // Circuit traces
    x.strokeStyle = '#FF4444';
    x.lineWidth = 2;
    x.beginPath(); x.moveTo(24, 190); x.lineTo(90, 190); x.lineTo(90, 210); x.lineTo(170, 210); x.stroke();
    x.beginPath(); x.moveTo(232, 50); x.lineTo(170, 50); x.lineTo(170, 70); x.stroke();
    x.fillStyle = '#FF0000';
    x.beginPath(); x.arc(170, 210, 7, 0, 7); x.fill();
    x.beginPath(); x.arc(170, 70, 7, 0, 7); x.fill();
    
    // Hazard chevrons
    for (let i = 0; i < 8; i++) {
      x.fillStyle = (i % 2 === 0) ? '#FF0000' : '#0a0a0c';
      x.fillRect(i * 32, 240, 32, 16);
    }
    
    // Label
    if (label) {
      x.fillStyle = '#FFFFFF';
      x.font = 'bold 18px monospace';
      x.textAlign = 'center';
      x.fillText(label.substring(0, 12).toUpperCase(), 128, 100);
    }
    
    // Central diamond emblem
    x.strokeStyle = '#FF0000';
    x.lineWidth = 3;
    x.beginPath();
    x.moveTo(128, 30); x.lineTo(165, 67); x.lineTo(128, 104); x.lineTo(91, 67);
    x.closePath(); x.stroke();
    
    return new THREE.CanvasTexture(c);
  }

  // ── BUILDING: Solid and visible — ONE system ──
  function addBuilding(bx, bz, width, height, depth, label) {
    // VISUAL: Must render
    const tex = createTacticalTexture(label);
    const geo = new THREE.BoxGeometry(width, height, depth);
    const mat = new THREE.MeshStandardMaterial({
      map: tex,
      roughness: 0.6,
      metalness: 0.4
    });
    const mesh = new THREE.Mesh(geo, mat);
    mesh.position.set(bx, height / 2, bz);
    
    // CRITICAL: Add to scene IMMEDIATELY in same frame as creation
    // Do not defer. Do not batch. Add now.
    scene.add(mesh);
    
    // SOLID: Must block — registered at the SAME TIME as visual
    // One function. One moment. Visual and solid together.
    const collider = {
      minX: bx - width / 2, maxX: bx + width / 2,
      minZ: bz - depth / 2, maxZ: bz + depth / 2,
      mesh: mesh  // Linked: if mesh is removed, collider goes too
    };
    colliders.push(collider);
    buildings.push({ mesh, collider, label });
    
    return mesh;
  }

  // ── COLLISION: The wall that holds ──
  function checkCollision(px, pz, radius) {
    for (const c of colliders) {
      if (px + radius > c.minX && px - radius < c.maxX &&
          pz + radius > c.minZ && pz - radius < c.maxZ) {
        return c; // Return the collider, not just true
      }
    }
    return null;
  }

  // ── MOVEMENT: Respects solidity ──
  function tryMove(dx, dz) {
    const r = 0.8;
    const newX = player.position.x + dx;
    const newZ = player.position.z + dz;
    
    // Check X alone (slide along walls)
    if (!checkCollision(newX, player.position.z, r)) {
      player.position.x = newX;
    }
    // Check Z alone
    if (!checkCollision(player.position.x, newZ, r)) {
      player.position.z = newZ;
    }
  }

  // ── INPUT: Touch and keys ──
  const keys = {};
  const joystick = { active: false, dx: 0, dy: 0 };

  function setupInput() {
    window.addEventListener('keydown', e => keys[e.key.toLowerCase()] = true);
    window.addEventListener('keyup', e => keys[e.key.toLowerCase()] = false);
    
    const joyZone = document.getElementById('joystick');
    if (joyZone && 'ontouchstart' in window) {
      joyZone.style.display = 'block';
      joyZone.style.zIndex = '50';
      let touchId = null, startX = 0, startY = 0;
      joyZone.addEventListener('touchstart', e => {
        const t = e.changedTouches[0];
        touchId = t.identifier;
        startX = t.clientX; startY = t.clientY;
        joystick.active = true;
        e.preventDefault();
      }, { passive: false });
      joyZone.addEventListener('touchmove', e => {
        for (const t of e.changedTouches) {
          if (t.identifier === touchId) {
            joystick.dx = Math.max(-1, Math.min(1, (t.clientX - startX) / 50));
            joystick.dy = Math.max(-1, Math.min(1, (t.clientY - startY) / 50));
          }
        }
        e.preventDefault();
      }, { passive: false });
      joyZone.addEventListener('touchend', e => {
        for (const t of e.changedTouches) {
          if (t.identifier === touchId) {
            joystick.active = false;
            joystick.dx = 0; joystick.dy = 0;
          }
        }
      });
    }
  }

  // ── THE LOOP: Where solid meets visible ──
  function animate() {
    requestAnimationFrame(animate);
    
    // Movement
    let mx = 0, mz = 0;
    if (keys['w'] || keys['arrowup']) mz -= 1;
    if (keys['s'] || keys['arrowdown']) mz += 1;
    if (keys['a'] || keys['arrowleft']) mx -= 1;
    if (keys['d'] || keys['arrowright']) mx += 1;
    if (joystick.active) { mx += joystick.dx; mz += joystick.dy; }
    
    const len = Math.sqrt(mx * mx + mz * mz);
    if (len > 1) { mx /= len; mz /= len; }
    
    const speed = 8;
    tryMove(mx * speed * 0.016, mz * sp