<!-- SOLIDIVISM-STAGING · part 7 -->
  }
    const speed = sprinting ? 57.6 : 28.8;
    tryMove(mx * speed * 0.016, mz * speed * 0.016);
    updateAvatar(0.016);
    
    // Camera: independent control via camstick (right joystick)
    // camstick.dx = yaw, camstick.dy = pitch
    if (camstick.active) {
      camYaw -= camstick.dx * 0.06;
      camPitch = Math.max(-0.5, Math.min(1.2, camPitch + camstick.dy * 0.04));
    }
    // Camera orbits player at distance, controlled by yaw/pitch
    const camDist = 20;
    const camHeight = 10;
    const cx = player.position.x + Math.sin(camYaw) * camDist * Math.cos(camPitch);
    const cz = player.position.z + Math.cos(camYaw) * camDist * Math.cos(camPitch);
    const cy = player.position.y + camHeight + Math.sin(camPitch) * camDist * 0.5;
    const camTarget = new THREE.Vector3(cx, cy, cz);
    camera.position.lerp(camTarget, 0.12);
    camera.lookAt(player.position.x, player.position.y + 2, player.position.z);
    
    // Render: the moment of truth
    renderer.render(scene, camera);

    // Performance tracking
    const frameEnd = performance.now();
    frameTimes.push(frameEnd - frameStart);
    if (frameTimes.length > 100) frameTimes.shift();
    frameCount++;
    const now = Date.now();
    if (now - lastFpsTime >= 1000) {
      currentFps = frameCount;
      frameCount = 0;
      lastFpsTime = now;
    }
  }

  function getPerformanceStats() {
    const avg = frameTimes.length ? frameTimes.reduce((a,b) => a+b, 0) / frameTimes.length : 0;
    const max = frameTimes.length ? Math.max(...frameTimes) : 0;
    return {
      fps: currentFps,
      avgFrameMs: avg.toFixed(2),
      maxFrameMs: max.toFixed(2),
      samples: frameTimes.length
    };
  }

  function onResize() {
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize(window.innerWidth, window.innerHeight);
  }

  // ── VIDEO CONTROL PANEL: Glass screen playing video in 3D ──
  // Wall-design preserved: panel uses solid wall construction with glass inset
  let videoPanel = null;

  function createVideoPanel(bx, bz, videoUrl, label) {
    const group = new THREE.Group();
    const W = 16, H = 10, D = 1;

    // Wall frame (solid, tactical texture) — the control panel body
    const tex = createTacticalTexture(label || 'VIDEO');
    const frameMat = new THREE.MeshStandardMaterial({
      map: tex, roughness: 0.5, metalness: 0.6,
      emissive: 0x330000, emissiveIntensity: 0.3, emissiveMap: tex,
      side: THREE.DoubleSide
    });

    // Frame: top, bottom, left, right bars around the screen
    const barH = new THREE.BoxGeometry(W, 1, D);
    const topBar = new THREE.Mesh(barH, frameMat);
    topBar.position.set(bx, H + 0.5, bz);
    group.add(topBar);
    const botBar = new THREE.Mesh(barH, frameMat);
    botBar.position.set(bx, 0.5, bz);
    group.add(botBar);

    const barV = new THREE.BoxGeometry(1, H, D);
    const leftBar = new THREE.Mesh(barV, frameMat);
    leftBar.position.set(bx - W/2 + 0.5, H/2 + 0.5, bz);
    group.add(leftBar);
    const rightBar = new THREE.Mesh(barV, frameMat);
    rightBar.position.set(bx + W/2 - 0.5, H/2 + 0.5, bz);
    group.add(rightBar);

    // Support posts (wall-design: solid posts)
    const postGeo = new THREE.BoxGeometry(1, H + 1, 1);
    const postL = new THREE.Mesh(postGeo, frameMat);
    postL.position.set(bx - W/2 + 0.5, (H+1)/2, bz - 1);
    group.add(postL);
    const postR = new THREE.Mesh(postGeo, frameMat);
    postR.position.set(bx + W/2 - 0.5, (H+1)/2, bz - 1);
    group.add(postR);

    // GLASS SCREEN: video texture on a plane
    const video = document.createElement('video');
    video.src = videoUrl;
    video.crossOrigin = 'anonymous';
    video.loop = true;
    video.muted = true;
    video.playsInline = true;
    video.play().catch(() => {});

    const vtex = new THREE.VideoTexture(video);
    vtex.minFilter = THREE.LinearFilter;
    vtex.magFilter = THREE.LinearFilter;

    const screenGeo = new THREE.PlaneGeometry(W - 2, H - 1);
    const screenMat = new THREE.MeshBasicMaterial({ map: vtex });
    const screen = new THREE.Mesh(screenGeo, screenMat);
    screen.position.set(bx, H/2 + 0.5, bz + 0.06);
    group.add(screen);

    // Glass overlay (subtle reflection)
    const glassGeo = new THREE.PlaneGeometry(W - 2, H - 1);
    const glassMat = new THREE.MeshStandardMaterial({
      color: 0x88ccff, transparent: true, opacity: 0.08,
      roughness: 0.1, metalness: 0.9, side: THREE.DoubleSide
    });
    const glass = new THREE.Mesh(glassGeo, glassMat);
    glass.position.set(bx, H/2 + 0.5, bz + 0.1);
    group.add(glass);

    // Red glow strip below (control panel lights)
    const stripGeo = new THREE.BoxGeometry(W - 2, 0.3, 0.2);
    const stripMat = new THREE.MeshStandardMaterial({
      color: 0xFF2200, emissive: 0xFF2200, emissiveIntensity: 2.0
    });
    const strip = new THREE.Mesh(stripGeo, stripMat);
    strip.position.set(bx, 0.2, bz + 0.5);
    group.add(str