<!-- SAGA-SOLID · part 79 -->

    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>" +
          "<button id='prize-collect' style='background:#d8a920;color:#111;border:none;" +
          "padding:14px 40px;font-size:20px;border-radius:8px;cursor:pointer;'>COLLECT</button>";
        document.getElementById("prize-collect").addEventListener("click", function(){
          if(typeof grantSwiftShoes === "function") grantSwiftShoes();
          if(typeof grantTouch === "function") grantTouch();
          div.remove();
          if(typeof say === "function") say("Prize collected. Now run to the old computer.");
        });
      });
    }
  });
}
/* Hook: after profile setup, start the tiny game */
(function(){
  var _origCallback = null;
  /* Wrap showProfileSetup to trigger tiny game after login */
  var _checkInt = setInterval(function(){
    if(typeof showProfileSetup === "function"){
      clearInterval(_checkInt);
      var _orig = showProfileSetup;
      showProfileSetup = function(callback){
        _orig(function(user){
          if(user) startTinyWinGame(user);
          if(callback) callback(user);
        });
      };
    }
  }, 500);
})();

/* ===== ACT 2: LOG IN — v90 ===== */
function showLoginAct(callback){
  var div = document.createElement("div");
  div.id = "login-act";
  div.style.cssText = "position:fixed;top:25%;left:10%;right:10%;z-index:310;" +
    "background:rgba(0,0,0,0.95);border:2px solid #d8a920;border-radius:12px;" +
    "padding:24px;color:#ffd700;font-family:sans-serif;text-align:center;";
  div.innerHTML =
    "<h2 style='margin:0 0 8px;'>ACT 2: LOG IN</h2>" +
    "<p style='font-size:14px;color:#aaa;'>You registered. Now log in.</p>" +
    "<input id='login-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='login-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;' />" +
    "<div id='login-error' style='color:#ff6666;font-size:14px;min-height:20px;'></div>" +
    "<button id='login-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("login-send").addEventListener("click", function(){
    var u = document.getElementById("login-user").value.trim();
    var p = document.getElementById("login-pass").value;
    fetch("/api/game/login", {method: "POST",
      headers: {"Content-Type": "application/json"},
      body: JSON.stringify({username: u, password: p})})
      .then(function(r){ return r.json(); })
      .then(function(d){
        if(d.ok){
          div.remove();
          if(callback) callback(d.user);
        } else {
          document.getElementById("login-error").textContent = d.error || "Failed";
        }
      });
  });
}

/* ===== EXISTENTIAL DIALOGUE — v91 ===== */
function solidExistentialDialogue(username, callback){
  var lines = [
    "Wait a second...",
    "Now who even are you?",
    "What even is all of this?",
    "Why am I... or you... even here?",
    "Who, what, when, why, how... and WHERE even are we?"
  ];
  var div = document.createElement("div");
  div.id = "existential";
  div.style.cssText = "position:fixed;top:20%;left:8%;right:8%;z-index:315;" +
    "background:rgba(0,0,0,0.95);border:2px solid #00ccff;border-radius:12px;" +
    "p