<!-- SAGA-STAGING · part 79 -->
ign:center;";
      div.innerHTML =
        "<h2 style='margin:0 0 16px;'>SET UP YOUR PROFILE</h2>" +
        "<p style='font-size:14px;color:#aaa;'>Same login as epistles.xyz</p>" +
        "<input id='prof-user' type='text' placeholder='username' " +
        "style='display:block;width:80%;margin:10px auto;padding:12px;font-size:18px;" +
        "background:#111;border:1px solid #d8a920;color:#ffd700;border-radius:8px;text-align:center;' />" +
        "<input id='prof-pass' type='password' placeholder='password' " +
        "style='display:block;width:80%;margin:10px auto;padding:12px;font-size:18px;" +
        "background:#111;border:1px solid #d8a920;color:#ffd700;border-radius:8px;text-align:center;' />" +
        "<input id='prof-confirm' type='password' placeholder='confirm password' " +
        "style='display:block;width:80%;margin:10px auto;padding:12px;font-size:18px;" +
        "background:#111;border:1px solid #d8a920;color:#ffd700;border-radius:8px;text-align:center;' />" +
        "<div id='prof-error' style='color:#ff6666;font-size:14px;min-height:20px;'></div>" +
        "<button id='prof-send' style='background:#d8a920;color:#111;border:none;" +
        "padding:14px 40px;font-size:20px;border-radius:8px;cursor:pointer;margin-top:10px;'>SEND</button>";
      document.body.appendChild(div);
      document.getElementById("prof-send").addEventListener("click", function(){
        var u = document.getElementById("prof-user").value.trim();
        var p = document.getElementById("prof-pass").value;
        var c = document.getElementById("prof-confirm").value;
        fetch("/api/game/register", {method: "POST",
          headers: {"Content-Type": "application/json"},
          body: JSON.stringify({username: u, password: p, confirm: c})})
          .then(function(r){ return r.json(); })
          .then(function(d){
            if(d.ok){
              div.remove();
              if(callback) callback(d.user);
            } else {
              document.getElementById("prof-error").textContent = d.error || "Failed";
            }
          });
      });
    })
    .catch(function(){ if(callback) callback(null); });
}

/* ===== TINY WIN GAME — v88, King's order: win big, fast ===== */
function startTinyWinGame(username){
  var taps = 0;
  var div = document.createElement("div");
  div.id = "tiny-win";
  div.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;z-index:320;" +
    "background:rgba(0,0,0,0.9);display:flex;flex-direction:column;" +
    "align-items:center;justify-content:center;color:#ffd700;" +
    "font-family:sans-serif;text-align:center;";
  div.innerHTML =
    "<h1 style='margin:0 0 10px;'>WELCOME, " + (username || "PLAYER").toUpperCase() + "</h1>" +
    "<p>Tap the octahedron 3 times — fast!</p>" +
    "<div id='tiny-octa' style='width:100px;height:100px;margin:20px;" +
    "background:radial-gradient(circle,#00ccff,#0088aa);cursor:pointer;" +
    "clip-path:polygon(50% 0%,100% 50%,50% 100%,0% 50%);'></div>" +
    "<div id='tiny-count' style='font-size:24px;'>0 / 3</div>";
  document.body.appendChild(div);
  var octa = document.getElementById("tiny-octa");
  /* Make it bounce */
  var bounce = 0;
  var bounceDir = 1;
  var bounceInt = setInterval(function(){
    bounce += bounceDir * 5;
    if(bounce > 20 || bounce < -20) bounceDir *= -1;
    octa.style.transform = "translateY(" + bounce + "px)";
  }, 50);
  octa.addEventListener("click", function(){
    taps++;
    document.getElementById("tiny-count").textContent = taps + " / 3";
    if(typeof say === "function") say(taps === 3 ? "BIG WIN!" : "Tap again!");
    if(taps >= 3){
      clearInterval(bounceInt);
      /* BIG WIN */
      div.innerHTML =
        "<h1 style='font-size:48px;margin:0;'>YOU WIN BIG!</h1>" +
        "<p style='font-size:24px;'>That was fast.</p>" +
        "<div style='font-size:64px;'>STAR TROPHY CROWN</div>" +
        "<div id='treasure-box' style='margin:20px auto;width:120px;height:100px;" +
        "background:linear-gradient(135deg,#8b5a2b,#5a3a1a);border:3px solid #d8a920;" +
        "border-radius:8px;position:relative;cursor:pointer;'>" +
        "<div style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:40px;'>LOCK</div>" +
        "<div style='position:absolute;top:-10px;left:50%;transform:translateX(-50%);font-size:12px;color:#d8a920;'>TREASURE</div></div>" +
        "<p style='color:#ff9999;'>The box is locked. It needs solidicism.</p>" +
        "<button id='tiny-done' style='background:#d8a920;color:#111;border:none;" +
        "padding:14px 40px;font-size:20px;border-radius:8px;cursor:pointer;margin-top:20px;'>OPEN THE BOX</button>";
      document.getElementById("tiny-done").addEventListener("click", function(){
        div.innerHTML =
          "<h1 style='font-size:36px;'>PRIZE WINNINGS</h1>" +
          "<div style='font-size:24px;margin:20px;'>100 GOLD COINS<br>STAR TROPHY<br>GOLDEN CROWN<br>SWIFT SHOES</div>"