<!-- SAGA-SOLID · part 49 -->
try(2, 16, 16), bodyMat);
  head.userData.target = new THREE.Vector3(0, 18, 0);
  head.visible = false; playaG.add(head); parts.push(head);
  // Body
  var body = new THREE.Mesh(new THREE.CylinderGeometry(1.5, 2, 8, 12), bodyMat);
  body.userData.target = new THREE.Vector3(0, 12, 0);
  body.visible = false; playaG.add(body); parts.push(body);
  // Arms
  var armL = new THREE.Mesh(new THREE.CylinderGeometry(0.5, 0.5, 6, 8), bodyMat);
  armL.userData.target = new THREE.Vector3(-4, 13, 0);
  armL.rotation.z = Math.PI/3; armL.visible = false; playaG.add(armL); parts.push(armL);
  var armR = new THREE.Mesh(new THREE.CylinderGeometry(0.5, 0.5, 6, 8), bodyMat);
  armR.userData.target = new THREE.Vector3(4, 13, 0);
  armR.rotation.z = -Math.PI/3; armR.visible = false; playaG.add(armR); parts.push(armR);
  // Legs
  var legL = new THREE.Mesh(new THREE.CylinderGeometry(0.6, 0.6, 7, 8), bodyMat);
  legL.userData.target = new THREE.Vector3(-1.2, 4, 0);
  legL.visible = false; playaG.add(legL); parts.push(legL);
  var legR = new THREE.Mesh(new THREE.CylinderGeometry(0.6, 0.6, 7, 8), bodyMat);
  legR.userData.target = new THREE.Vector3(1.2, 4, 0);
  legR.visible = false; playaG.add(legR); parts.push(legR);
  // Diamond chest emblem
  var emblem = new THREE.Mesh(new THREE.OctahedronGeometry(1), diamondMat);
  emblem.userData.target = new THREE.Vector3(0, 13, 1.8);
  emblem.visible = false; playaG.add(emblem); parts.push(emblem);
  // Cyan eyes
  var eyeL = new THREE.Mesh(new THREE.SphereGeometry(0.3, 8, 8), cyanMat);
  eyeL.userData.target = new THREE.Vector3(-0.7, 18.5, 1.7);
  eyeL.visible = false; playaG.add(eyeL); parts.push(eyeL);
  var eyeR = new THREE.Mesh(new THREE.SphereGeometry(0.3, 8, 8), cyanMat);
  eyeR.userData.target = new THREE.Vector3(0.7, 18.5, 1.7);
  eyeR.visible = false; playaG.add(eyeR); parts.push(eyeR);
  scene.add(playaG);
  var unfolded = false;
  var unfoldT = 0;
  window._unfoldPlaya = function(){
    if(unfolded) return;
    unfolded = true;
    unfoldT = 0;
    // Show all parts at center, then animate to targets
    parts.forEach(function(p){
      p.visible = true;
      p.position.set(0, 6, 0);
    });
    if(typeof say === 'function') say('Playa 2.0 unfolds');
  };
  window._foldPlaya = function(){
    unfolded = false;
    parts.forEach(function(p){ p.visible = false; });
    folded.visible = true;
  };
  // Unfold animation loop
  function animatePlaya(){
    try{
      if(unfolded && unfoldT < 1){
        unfoldT += 0.02;
        var t = Math.min(1, unfoldT);
        // Ease out
        t = 1 - Math.pow(1 - t, 3);
        parts.forEach(function(p){
          p.position.lerpVectors(new THREE.Vector3(0, 6, 0), p.userData.target, t);
        });
        if(unfoldT >= 1) folded.visible = false;
      } else if(unfolded){
        // Idle: gentle bob, emblem spins
        playaG.position.y = Math.sin(Date.now()*0.002)*0.5;
        emblem.rotation.y += 0.02;
      } else {
        // Folded: diamond spins
        folded.rotation.y += 0.01;
      }
    }catch(e){ console.error(e); }
    requestAnimationFrame(animatePlaya);
  }
  animatePlaya();
  // Gold unfold button (next to the align button)
  var btnMat = new THREE.MeshStandardMaterial({color:0xffd700, roughness:0.2, metalness:0.9, emissive:0xaa8800, emissiveIntensity:0.5});
  var ubase = new THREE.Mesh(new THREE.CylinderGeometry(6, 6, 2, 24), btnMat);
  ubase.rotation.x = Math.PI/2;
  ubase.position.set(cx - 25, 8, cz);
  scene.add(ubase);
  var utop = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 1.5, 24), btnMat);
  utop.rotation.x = Math.PI/2;
  utop.position.set(cx - 25, 8, cz + 1.5);
  utop.userData.playaButton = true;
  scene.add(utop);
  // Diamond icon on button
  var dico = new THREE.Mesh(new THREE.OctahedronGeometry(1.5), diamondMat);
  dico.position.set(cx - 25, 8, cz + 2.5);
  scene.add(dico);
  function pulseU(){
    try{
      var s = 1 + Math.sin(Date.now()*0.005 + 1)*0.15;
      utop.scale.set(s, s, 1);
      dico.rotation.y += 0.02;
    }catch(e){ console.error(e); }
    requestAnimationFrame(pulseU);
  }
  pulseU();
  // Tap handler
  var raycaster = new THREE.Raycaster();
  var mouse = new THREE.Vector2();
  document.addEventListener('click', function(e){
    if(!window._sagaCamera) return;
    var panel = document.getElementById('creator-ui');
    if(panel && panel.style.display === 'flex') return;
    var x = (e.clientX / window.innerWidth) * 2 - 1;
    var y = -(e.clientY / window.innerHeight) * 2 + 1;
    mouse.set(x, y);
    raycaster.setFromCamera(mouse, window._sagaCamera);
    var hits = raycaster.intersectObject(utop);
    if(hits.length > 0){
      if(!unfolded) window._unfoldPlaya();
      else window._foldPlaya();
      utop.position.z = cz + 0.5;
      setTimeout(function(){ utop.position.z = cz + 1.5; }, 200);
    }
  });
  if(typeof trackNewThing === 'function') trackNewThing('playa2', 'Playa 2.0 — unfolds with the gold diamond button');
})();


/* IN-WORLD CREATOR v2 — 