 <?php

error_reporting(E_ALL);

ini_set('display_errors',1);


// ---------------------------------------------------------

// 1. EXTRACT EXPECTED PACKAGE NAME FIRST (No DB required yet)

// ---------------------------------------------------------

$pkg = $_GET['pkg'] ?? $_GET['pkg_name'] ?? '';


// Sanitize and auto-extract parameters if they got merged due to URL shift-5 separators

if (strpos($pkg, '?') !== false) {

    $parts = explode('?', $pkg);

    $pkg = $parts[0];

    

    // Parse the rest of the string as query parameters

    for ($i = 1; $i < count($parts); $i++) {

        parse_str($parts[$i], $subParams);

        foreach ($subParams as $k => $v) {

            $_GET[$k] = $v;

        }

    }

}


// ---------------------------------------------------------

// 2. ENHANCED HACKER DETECTION LOGIC (Global Protection)

// ---------------------------------------------------------

$actualAndroidPkg = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '';

$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';

$referer = $_SERVER['HTTP_REFERER'] ?? '';

$isHacker = false;


// A. Standard Mismatch Check

if (!empty($actualAndroidPkg) && $actualAndroidPkg !== 'XMLHttpRequest' && !empty($pkg) && $actualAndroidPkg !== $pkg) {

    $isHacker = true; // Busted: Spoofed header doesn't match

}


// B. Stripped Header Trap (Android WebViews MUST send X-Requested-With)

$isWebview = (strpos($userAgent, '; wv)') !== false || strpos($userAgent, 'WebView') !== false);

if ($isWebview && empty($actualAndroidPkg) && !isset($_GET['ajax'])) {

    $isHacker = true; // Busted: Hacker maliciously stripped the header

}


// C. User-Agent Leak Trap (WebViews often append the real package name to the UA)

if (!empty($pkg)) {

    $uaParts = explode(' ', trim($userAgent));

    $lastUaPart = end($uaParts);

    if (strpos($lastUaPart, '.') !== false && $lastUaPart !== $pkg) {

        $whitelist = ['Safari/537.36', 'Mobile', 'AppleWebKit/537.36', 'Gecko)'];

        if (!in_array($lastUaPart, $whitelist) && preg_match('/^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)+$/', $lastUaPart)) {

            $isHacker = true; // Busted: Real package leaked in User-Agent

        }

    }

}


// D. Referer Scheme Trap

if (strpos($referer, 'android-app://') === 0) {

    $refPkg = str_replace('android-app://', '', $referer);

    $refPkg = trim(explode('/', $refPkg)[0]);

    if (!empty($pkg) && $refPkg !== $pkg) {

        $isHacker = true; // Busted: Real package leaked in Referer

    }

}


// ---------------------------------------------------------

// 3. API PROXY FOR CORS BYPASS (Now Protected)

// ---------------------------------------------------------

if(isset($_GET['ajax'])){

    header('Content-Type: application/json');

    

    // Kill the API connection instantly if it's the hacker

    if($isHacker) {

        echo '{"error":true,"message":"ACCESS DENIED"}';

        exit;

    }


    $action = $_GET['ajax'];

    $gameCode = $_GET['gameCode'] ?? 'WinGo_30S';

    

    if($action === 'issue'){
        if(isset($_GET['game']) && $_GET['game'] === 'fantasy') {
            $url = "https://draw.ar-lottery01.com/WinGo/" . urlencode($gameCode) . ".json?ts=" . time();
        } else {
            $url = "https://pakclub.club/webapi/kv/issue/" . urlencode($gameCode);
        }
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
        $res = curl_exec($ch);
        curl_close($ch);
        
        if(isset($_GET['game']) && $_GET['game'] === 'fantasy') {
            $parsed = json_decode($res, true);
            if ($parsed && isset($parsed['current'])) {
                $now = time();
                $endTime = floor($parsed['current']['endTime'] / 1000);
                $countdown = max(0, $endTime - $now);
                $mapped = [
                    "code" => 0,
                    "data" => [
                        "issueNumber" => $parsed['current']['issueNumber'],
                        "countdown" => $countdown
                    ]
                ];
                echo json_encode($mapped);
                exit;
            }
        }
        
        echo $res ?: '{"error":true}';
        exit;
    }

    if($action === 'history'){
        if(isset($_GET['game']) && $_GET['game'] === 'fantasy') {
            $url = "https://draw.ar-lottery01.com/WinGo/" . urlencode($gameCode) . "/GetHistoryIssuePage.json?ts=" . time();
        } else {
            $url = "https://draw.ar-lottery01.com/WinGo/" . urlencode($gameCode) . "/GetHistoryIssuePage.json";
        }
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
        $res = curl_exec($ch);
        curl_close($ch);
        echo $res ?: '{"error":true}';
        exit;
    }

}


// ---------------------------------------------------------

// 4. LOAD DATABASE AND RENDER UI

// ---------------------------------------------------------

require_once __DIR__.'/config.php';


$isWingo = ($_GET['wingo'] ?? $_GET['wingo'] ?? '0') === '1';

$balance = (int)($_GET['balance'] ?? $_GET['balance'] ?? 0);

$isApp = ($_GET['app'] ?? $_GET['app'] ?? '0') === '1';

$isAuth = ($_GET['auth'] ?? $_GET['auth'] ?? '0') === '1';

$gameType = $_GET['game'] ?? '';

$isFantasy = ($gameType === 'fantasy');


$appName = 'PAKClub';

$whatsappLink = '';

$referLink = '';

$validApp = false;

if(!empty($pkg)){

  try{

    $db=getDB();

    $st=$db->prepare("SELECT app_name,whatsapp_link,refer_link FROM apps WHERE pkg_name=? LIMIT 1");

    $st->execute([$pkg]);

    $app=$st->fetch();

    if($app){

      $appName=$app['app_name'];

      $whatsappLink=$app['whatsapp_link']??'';

      if(!empty($app['refer_link']))$referLink=buildReferLink($app['refer_link']);

      $validApp = true;

    }

  }catch(Exception $e){}

}


if (!$validApp && !isset($_GET['ajax'])) {

    header('HTTP/1.1 403 Forbidden');

    ?>

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">

    <title>Under Maintenance</title>

    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@700;900&family=Inter:wght@400;600;700&display=swap" rel="stylesheet">

    <style>

    * { 
      margin: 0; 
      padding: 0; 
      box-sizing: border-box; 
      -webkit-tap-highlight-color: transparent;
      user-select: none;
      -webkit-user-select: none;
    }

    body {

      font-family:'Inter',sans-serif;

      background: #05060b;

      color:#f0f0f0;

      min-height:100vh;

      display: flex;

      align-items: center;

      justify-content: center;

      overflow: hidden;

      position: relative;

    }

    .scanlines {

      position:absolute;

      inset:0;

      background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.3));

      background-size: 100% 4px;

      z-index: 2;

      pointer-events:none;

    }

    .denied-container {

      max-width: 400px;

      width: 90%;

      background: rgba(9, 10, 18, 0.8);

      border: 1px solid #1f274a;

      border-radius: 20px;

      padding: 40px 30px;

      text-align: center;

      position: relative;

      z-index: 10;

      box-shadow: 0 0 50px rgba(74, 143, 231, 0.05), inset 0 0 30px rgba(74, 143, 231, 0.02);

      backdrop-filter: blur(10px);

      animation: floatCard 4s ease-in-out infinite alternate;

    }

    @keyframes floatCard {

      0% { transform: translateY(0px); }

      100% { transform: translateY(-10px); }

    }

    .status-icon {

      font-size: 60px;

      display: block;

      margin-bottom: 25px;

      filter: drop-shadow(0 0 15px rgba(74, 143, 231, 0.4));

      animation: pulseIcon 2s ease-in-out infinite alternate;

      user-select: none;

    }

    @keyframes pulseIcon {

      0% { transform: scale(1); }

      100% { transform: scale(1.05); }

    }

    .title {

      font-family:'Orbitron',sans-serif;

      font-size: 20px;

      font-weight: 900;

      color: #4a8fe7;

      letter-spacing: 2px;

      text-transform: uppercase;

      margin-bottom: 15px;

      text-shadow: 0 0 10px rgba(74, 143, 231, 0.3);

    }

    .message {

      font-size: 13px;

      color: #8fa0dd;

      line-height: 1.6;

      margin-bottom: 30px;

      font-weight: 500;

    }

    .badge {

      display: inline-block;

      padding: 6px 12px;

      background: rgba(74, 143, 231, 0.1);

      border: 1px solid rgba(74, 143, 231, 0.3);

      color: #4a8fe7;

      font-size: 10px;

      font-weight: 700;

      border-radius: 30px;

      text-transform: uppercase;

      letter-spacing: 1px;

      font-family: 'Orbitron', sans-serif;

    }

    </style>

    <script>

      // Anti-inspect removed

      });

    </script>

    </head>

    <body>

    <div class="scanlines"></div>

    <div class="denied-container">

      <div class="status-icon">⚙️</div>

      <h1 class="title">System Offline</h1>

      <p class="message">The requested connection is temporarily unavailable. We are updating database schemas. Please try again later.</p>

      <div class="badge">Code: 503_MAINTENANCE</div>

    </div>

    </body>

    </html>

    <?php

    exit;

}


$showHackPanel = $isWingo;

$serverMs = rand(12,89);


$mainDomain = getSetting('main_domain', '');

$mainDomainUrl = '';

if (!empty($mainDomain)) {

    $mainDomainUrl = rtrim($mainDomain, '/');

    if (!preg_match('/^https?:\/\//', $mainDomainUrl)) {

        $mainDomainUrl = 'https://' . $mainDomainUrl;

    }

}

$rechargeUrl = !empty($mainDomainUrl) ? $mainDomainUrl . '/wallet/recharge' : '/wallet/recharge';


ob_start();

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">

<title><?=$appName?> - AI Prediction</title>

<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">

<style>

* { margin:0; padding:0; box-sizing:border-box; }


/* ===== FANTASY THEME ===== */

<?php if($isFantasy): ?>

body.fantasy-theme {
  color: #e8f5e9;
  background: transparent;
}

.fantasy-theme .steps-card {
  background: linear-gradient(145deg, #0a1a12, #0d2218, #0a1610);
  border: 1.5px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(16, 185, 129, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: fantasyBorderGlow 3s ease-in-out infinite alternate;
}

@keyframes fantasyBorderGlow {
  0% {
    box-shadow: inset 0 1px 0 rgba(16,185,129,0.08);
    border-color: rgba(16, 185, 129, 0.2);
  }
  100% {
    box-shadow: inset 0 1px 0 rgba(16,185,129,0.08);
    border-color: rgba(16, 185, 129, 0.5);
  }
}

.fantasy-theme .scanlines {
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.12) 50%, rgba(0,0,0,0.12));
  background-size: 100% 4px;
}

.fantasy-theme .app-name {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(10px, 4.5vw, 16px);
  white-space: nowrap;
  color: #10b981;
  text-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.fantasy-theme .app-tag {
  color: #34d399;
  font-weight: 800;
}

.fantasy-theme .hdr {
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
}

.fantasy-theme .btn-sync {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.fantasy-theme .sync-dot {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e, 0 0 16px #22c55e;
}

.fantasy-theme .meta-info {
  color: #10b981;
}

.fantasy-theme .meta-period span,
.fantasy-theme .meta-timer {
  color: #e8f5e9;
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.fantasy-theme .pred-card {
  background: linear-gradient(145deg, #0d1f16, #081a10);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: 16px;
  box-shadow: inset 0 0 40px rgba(16, 185, 129, 0.03);
  padding: 8px;
  min-height: 100px;
}

.fantasy-theme .pred-status {
  color: #10b981;
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
  font-size: 20px;
}

.fantasy-theme .pred-size {
  color: #e8f5e9;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
}

.fantasy-theme .pred-size.green { color: #22c55e; text-shadow: 0 0 15px rgba(34, 197, 94, 0.4); }
.fantasy-theme .pred-size.red { color: #ef4444; text-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }
.fantasy-theme .pred-size.violet { color: #a78bfa; text-shadow: 0 0 15px rgba(167, 139, 250, 0.4); }

.fantasy-theme .pred-sub {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.fantasy-theme .pred-num {
  color: #e8f5e9;
}

.fantasy-theme .pred-color-text {
  color: #a7f3d0;
}

.fantasy-theme .radar-sweep {
  background: conic-gradient(from 0deg, transparent 0deg, transparent 270deg, rgba(16, 185, 129, 0.2) 360deg);
}

.fantasy-theme .hex-center polygon {
  stroke: rgba(16, 185, 129, 0.25);
}

.fantasy-theme .hud-frame path {
  stroke: rgba(16, 185, 129, 0.2);
}

.fantasy-theme .hud-frame line {
  stroke: rgba(16, 185, 129, 0.08);
}

.fantasy-theme .tv-sweep {
  background: linear-gradient(to bottom, transparent, rgba(16, 185, 129, 0.04), transparent);
}

/* 3D Buttons */
.fantasy-theme .btn-start {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 40%, #15803d 100%);
  color: #fff;
  box-shadow:
    0 6px 0 #0d6832,
    0 8px 20px rgba(16, 185, 129, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.25);
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
  border: none;
  transform: translateY(0);
  transition: all 0.1s ease;
}

.fantasy-theme .btn-start:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #0d6832,
    0 3px 10px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

.fantasy-theme .btn-start.running {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 40%, #b91c1c 100%);
  box-shadow:
    0 6px 0 #7f1d1d,
    0 8px 20px rgba(239, 68, 68, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

.fantasy-theme .btn-start.running:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #7f1d1d,
    0 3px 10px rgba(239, 68, 68, 0.25),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

.fantasy-theme .btn-hide {
  background: linear-gradient(180deg, #1e3a2f 0%, #14292a 40%, #0f2120 100%);
  border: 1.5px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  box-shadow:
    0 6px 0 #091610,
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(16, 185, 129, 0.1);
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
  transform: translateY(0);
  transition: all 0.1s ease;
}

.fantasy-theme .btn-hide:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #091610,
    0 3px 10px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(16, 185, 129, 0.1);
}

.fantasy-theme .server-info {
  color: #6b7280;
}

.fantasy-theme .serv-dot {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.fantasy-theme .serv-ms {
  color: #22c55e;
}

.fantasy-theme .steps-title {
  color: #10b981;
}

.fantasy-theme .step {
  background: rgba(16, 185, 129, 0.04);
  border: 1px solid rgba(16, 185, 129, 0.1);
}

.fantasy-theme .step-num {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.fantasy-theme .step-txt {
  color: #a7f3d0;
}

.fantasy-theme .btn-funds {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 40%, #15803d 100%);
  color: #fff;
  box-shadow:
    0 6px 0 #0d6832,
    0 8px 20px rgba(16, 185, 129, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.25);
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
  transform: translateY(0);
  transition: all 0.1s ease;
}

.fantasy-theme .btn-funds:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #0d6832,
    0 3px 10px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

.fantasy-theme .btn-hide-panel {
  background: linear-gradient(180deg, #1e3a2f 0%, #14292a 40%, #0f2120 100%) !important;
  border: 1.5px solid rgba(16, 185, 129, 0.25) !important;
  color: #34d399 !important;
  box-shadow:
    0 6px 0 #091610,
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(16, 185, 129, 0.1) !important;
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.3) !important;
  transform: translateY(0);
  transition: all 0.1s ease;
}

.fantasy-theme .btn-hide-panel:active {
  transform: translateY(4px) !important;
  box-shadow:
    0 2px 0 #091610,
    0 3px 10px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(16, 185, 129, 0.1) !important;
}

/* Fantasy ball images */
.fantasy-balls-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 8px;
  padding: 10px 0;
}

.fantasy-ball-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fantasy-ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  animation: ballBounce 2s ease-in-out infinite;
  transition: transform 0.3s ease;
  position: relative;
  z-index: 2;
}

.fantasy-ball:nth-child(1) { animation-delay: 0s; }
.fantasy-ball:nth-child(2) { animation-delay: 0.15s; }
.fantasy-ball:nth-child(3) { animation-delay: 0.3s; }

/* Center ball is bigger */
.fantasy-ball-wrap:nth-child(2) .fantasy-ball {
  width: 52px;
  height: 52px;
}

.fantasy-ball-glow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(16, 185, 129, 0.5) 0%, rgba(16, 185, 129, 0.15) 50%, transparent 80%);
  filter: blur(3px);
  z-index: 1;
  animation: glowPulse 2s ease-in-out infinite;
}

.fantasy-ball-wrap:nth-child(2) .fantasy-ball-glow {
  width: 60px;
  height: 16px;
  background: radial-gradient(ellipse, rgba(16, 185, 129, 0.65) 0%, rgba(16, 185, 129, 0.2) 50%, transparent 80%);
}

@keyframes ballBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.7; transform: translateX(-50%) scaleX(1); }
  50% { opacity: 1; transform: translateX(-50%) scaleX(1.15); }
}

/* Fantasy READY screen */
/* Fantasy READY screen - Compact Scanner Style */
.fantasy-ready-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  position: relative;
  z-index: 2;
}

.fantasy-ready-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
  border: 1px solid rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 6px;
  overflow: hidden;
}

.fantasy-ready-ring::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 270deg, rgba(16, 185, 129, 0.4) 360deg);
  transform-origin: 0 0;
  animation: readyRadarSpin 2s linear infinite;
}

@keyframes readyRadarSpin {
  0% { transform: rotate(0deg) translate(-50%, -50%); }
  100% { transform: rotate(360deg) translate(-50%, -50%); }
}

.fantasy-ready-icon {
  font-size: 18px;
  position: relative;
  z-index: 2;
  color: #10b981;
}

.fantasy-ready-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: #10b981;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.fantasy-ready-sub {
  font-size: 9px;
  font-weight: 600;
  color: rgba(16, 185, 129, 0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
  font-family: 'Orbitron', sans-serif;
}

.fantasy-confidence-bar {
  width: 100%;
  margin-top: 12px;
}

.fantasy-confidence-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.fantasy-confidence-value {
  color: #22c55e;
  font-size: 12px;
}

.fantasy-confidence-track {
  width: 100%;
  height: 6px;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.fantasy-confidence-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #10b981, #22c55e);
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

/* Fantasy countdown display */
.fantasy-countdown-box {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.06), rgba(16, 185, 129, 0.02));
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: 14px;
  padding: 8px 14px;
  margin-bottom: 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.fantasy-countdown-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.fantasy-countdown-time {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: #22c55e;
  letter-spacing: 4px;
  text-shadow: 0 0 25px rgba(34, 197, 94, 0.35);
}

.fantasy-countdown-progress {
  width: 100%;
  height: 3px;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.fantasy-countdown-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #22c55e);
  border-radius: 2px;
  transition: width 1s linear;
}

/* Fantasy size/color panels - Flat sleek style */
.fantasy-pills {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  width: 100%;
}

.fantasy-pill {
  flex: 1;
  padding: 6px 0;
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  background: rgba(16, 185, 129, 0.05);
  box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.05);
  transition: all 0.2s;
}

.fantasy-pill-size {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.05);
  box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.05);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.fantasy-pill-color.pill-green {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
  box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.05);
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.fantasy-pill-color.pill-red {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.05);
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.fantasy-pill-color.pill-violet {
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.05);
  box-shadow: inset 0 0 10px rgba(139, 92, 246, 0.05);
  text-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

/* Remade Auth & Steps UI */
.fantasy-auth-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
.fantasy-auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
  padding-bottom: 12px;
}
.fantasy-auth-icon {
  background: rgba(16, 185, 129, 0.1);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  animation: authIconPulse 2s infinite alternate;
}
@keyframes authIconPulse {
  0% { box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.1); }
  100% { box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.3); }
}
.fantasy-auth-title {
  font-family: 'Orbitron', sans-serif;
  color: #ef4444;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}
.fantasy-auth-subtitle {
  font-size: 10px;
  color: #6b7280;
  letter-spacing: 4px;
}
.fantasy-auth-grid {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.1);
  border-radius: 8px;
  padding: 12px;
  position: relative;
  text-align: center;
}
.fantasy-auth-status {
  color: #a7f3d0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.fantasy-auth-desc {
  color: #6b7280;
  font-size: 11px;
  line-height: 1.5;
}
.fantasy-theme .hack-container {
  padding: 4px;
}
.fantasy-theme .steps-card {
  padding: 10px 14px !important;
}


<?php endif; ?>

/* ===== END FANTASY THEME ===== */

html { background: transparent; }

body {

  font-family:'Inter',sans-serif;

  color:#f0f0f0;

  min-height:100vh;

  overflow-x:hidden;

  position:relative;

  background: transparent;

}


/* CRT Scanlines */

.scanlines {

  position:absolute;

  inset:0;

  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.15));

  background-size: 100% 4px;

  z-index:9;

  pointer-events:none;

  border-radius: inherit;

}


.flash {

  position:fixed;

  inset:0;

  z-index:998;

  background:rgba(255,255,255,0.2);

  pointer-events:none;

  animation:flashAnim 0.3s ease-out forwards;

}

@keyframes flashAnim { from {opacity:1} to {opacity:0} }


.app-wrapper {

  max-width: 420px;

  margin: 0 auto;

  position: relative;

  z-index: 10;

  display: flex;

  flex-direction: column;

}


.hdr {

  position:relative;

  z-index:10;

  display:flex;

  justify-content:space-between;

  align-items:flex-start;

  padding:0 0 10px 0;

  border-bottom:1px solid rgba(255,255,255,0.05);

  margin-bottom:10px;

  background:transparent;

}

.app-name {
  font-family:'Orbitron',sans-serif;
  font-size: clamp(12px, 5vw, 18px);
  white-space: nowrap;
  font-weight:900;
  color:#ff9e00;
  letter-spacing:1px;
  text-shadow:0 0 15px rgba(255,158,0,0.6);
  text-transform:uppercase;
}

.app-tag {

  font-size:11px;

  font-weight:700;

  color:#4a8fe7;

  letter-spacing:3px;

  margin-top:4px;

}

.btn-sync {

  background:rgba(0,0,0,0.3);

  border:1px solid #4a8fe7;

  color:#fff;

  font-size:10px;

  font-weight:700;

  padding:6px 14px;

  border-radius:20px;

  display:flex;

  align-items:center;

  gap:6px;

  box-shadow: 0 0 10px rgba(74,143,231,0.2);

}

.sync-dot {

  width:6px;

  height:6px;

  background:#ff9e00;

  border-radius:50%;

  box-shadow:0 0 10px #ff9e00, 0 0 20px #ff9e00;

  animation: livePulse 1s ease infinite;

}

@keyframes livePulse { 0%,100% {opacity:1} 50% {opacity:0.4} }


#hack-panel, #steps-panel, #auth-panel {

  position:relative;

  z-index:10;

  padding:10px 20px 20px;

}

.pred-card {

  background: #090a12;

  border: 1px solid #1f274a;

  border-radius: 12px;

  padding: 12px 16px;

  text-align: center;

  position: relative;

  overflow: hidden;

  box-shadow: inset 0 0 60px rgba(10,20,50,0.8), 0 0 30px rgba(0,0,0,0.5);

  min-height: 120px;

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

  margin-bottom: 20px;

}


.radar-container {

  position:absolute;

  inset:0;

  overflow:hidden;

  pointer-events:none;

  z-index:0;

  opacity:0.6;

}

.radar-sweep {

  position: absolute;

  top: -50%; left: -50%;

  width: 200%; height: 200%;

  background: conic-gradient(from 0deg, transparent 0deg, transparent 270deg, rgba(255, 0, 102, 0.4) 360deg);

  animation: spin 3s linear infinite;

}

@keyframes spin { 100% { transform: rotate(360deg); } }


.hud-frame {

  position:absolute;

  inset:0;

  width:100%;

  height:100%;

  pointer-events:none;

  z-index:1;

  opacity:0.8;

}


.hex-center {

  position:absolute;

  top:50%; left:50%;

  transform:translate(-50%,-50%);

  width:120px;

  height:120px;

  z-index:1;

  opacity:0.15;

  pointer-events:none;

  animation: pulseHex 4s ease infinite;

}

@keyframes pulseHex { 0%,100% {opacity:0.15; transform:translate(-50%,-50%) scale(1);} 50% {opacity:0.3; transform:translate(-50%,-50%) scale(1.05);} }


.meta-info {

  display:flex;

  justify-content:space-between;

  align-items:center;

  margin-bottom:10px;

  padding:0 4px;

  font-family:'Orbitron',sans-serif;

  font-size:12px;

  color:#4a8fe7;

  font-weight:700;

  letter-spacing:1px;

}

.meta-period span, .meta-timer {

  color:#fff;

  text-shadow:0 0 10px rgba(255,255,255,0.4);

}


.tv-sweep {

  position:absolute;

  top:0;

  left:0;

  width:100%;

  height:30%;

  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.08), transparent);

  animation: tvSweepAnim 4s linear infinite;

  pointer-events: none;

  z-index: 10;

}

@keyframes tvSweepAnim {

  0% { transform: translateY(-100%); }

  100% { transform: translateY(400%); }

}


.pred-status {

  font-family:'Orbitron',sans-serif;

  font-size:24px;

  font-weight:900;

  letter-spacing:4px;

  color:#ff2a5f;

  text-shadow:0 0 20px rgba(255,42,95,0.6);

  position:relative;

  z-index:2;

  text-transform:uppercase;

}


.pred-result {

  display:flex;

  flex-direction:column;

  align-items:center;

  position:relative;

  z-index:2;

  animation:resultIn 0.4s cubic-bezier(.4,0,.2,1);

}

@keyframes resultIn { from {opacity:0; transform:scale(0.8) translateY(10px)} to {opacity:1; transform:scale(1) translateY(0)} }


.pred-size {

  font-family:'Orbitron',sans-serif;

  font-size:36px;

  font-weight:900;

  color:#fff;

  letter-spacing:4px;

  text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;

  margin-bottom: 4px;

}

.pred-size.green { color: #00ff66; }

.pred-size.red { color: #ff1a1a; }

.pred-size.violet { color: #cc00ff; }


.pred-sub {

  display:flex;

  align-items:center;

  gap:8px;

  background: rgba(0,0,0,0.5);

  padding: 6px 16px;

  border-radius: 20px;

  border: 1px solid rgba(255,255,255,0.1);

}

.pred-dot {

  width:10px;

  height:10px;

  border-radius:50%;

}

.pred-num {

  font-family:'Orbitron',sans-serif;

  font-size:16px;

  font-weight:700;

  color:#fff;

}

.pred-color-text {

  font-family:'Orbitron',sans-serif;

  font-size:14px;

  font-weight:900;

  color:#fff;

  letter-spacing:1px;

}


@keyframes glitch { 0% {transform:translate(0)} 20% {transform:translate(-3px,3px)} 40% {transform:translate(-3px,-3px)} 60% {transform:translate(3px,3px)} 80% {transform:translate(3px,-3px)} 100% {transform:translate(0)} }

.glitching { animation:glitch 0.1s linear 5; }


.pred-actions {

  display:flex;

  gap:16px;

}

.btn-action-panel {

  flex:1;

  padding:16px 0;

  border:none;

  border-radius:12px;

  font-family:'Orbitron',sans-serif;

  font-size:16px;

  font-weight:900;

  letter-spacing:2px;

  cursor:pointer;

  transition:all 0.2s;

  position:relative;

  overflow:hidden;

}

.btn-start {

  background:linear-gradient(135deg, #d49a00, #a87900);

  color:#fff;

  box-shadow:0 0 20px rgba(212,154,0,0.4);

  text-shadow: 0 2px 4px rgba(0,0,0,0.5);

}

.btn-start.running {

  background:linear-gradient(135deg, #cc0033, #990026);

  box-shadow:0 0 20px rgba(204,0,51,0.4);

}

.btn-hide {

  background:linear-gradient(135deg, #4b26cc, #341999);

  color:#fff;

  box-shadow:0 0 20px rgba(75,38,204,0.4);

  text-shadow: 0 2px 4px rgba(0,0,0,0.5);

}

.btn-action-panel:active { transform:scale(0.96); }


.server-info {

  text-align:center;

  margin-top:24px;

  font-size:11px;

  color:#555;

  display:flex;

  align-items:center;

  justify-content:center;

  gap:8px;

  font-family:'Orbitron',sans-serif;

  letter-spacing: 2px;

}

.serv-dot {

  width:6px;

  height:6px;

  background:#00ff5e;

  box-shadow:0 0 8px #00ff5e;

  display:inline-block;

  border-radius: 50%;

  animation:livePulse 1s ease infinite;

}

.serv-ms { color:#00ff5e; font-weight:700; margin-left:12px;}


.steps-card {

  background:#090a12;

  border:1px solid #ff2a5f;

  border-radius:16px;

  padding:12px 12px;

  margin-top:10px;

  position:relative;

  overflow:hidden;

  animation: borderGlow 2s ease-in-out infinite alternate;

}

@keyframes borderGlow {

  0% { box-shadow: inset 0 0 40px rgba(255,42,95,0.1), 0 0 10px rgba(255,42,95,0.2); border-color: #ff2a5f; }

  100% { box-shadow: inset 0 0 40px rgba(255,42,95,0.3), 0 0 30px rgba(255,42,95,0.6); border-color: #ff7396; }

}

@keyframes authBorderGlow {

  0% { box-shadow: inset 0 0 40px rgba(255,158,0,0.1), 0 0 10px rgba(255,158,0,0.2); border-color: #ff9e00; }

  100% { box-shadow: inset 0 0 40px rgba(255,158,0,0.3), 0 0 30px rgba(255,158,0,0.6); border-color: #ffb74d; }

}

@keyframes lockPulse {

  0% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(255,158,0,0.4)); }

  100% { transform: scale(1.08); filter: drop-shadow(0 0 25px rgba(255,158,0,0.8)); }

}

@keyframes trollPulse {

  0% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(255,42,95,0.4)); }

  100% { transform: scale(1.2); filter: drop-shadow(0 0 30px rgba(255,42,95,0.8)); }

}

.steps-title {

  font-family:'Orbitron',sans-serif;

  font-size:15px;

  font-weight:900;

  color:#ff2a5f;

  text-align:center;

  margin-bottom:12px;

  letter-spacing:1px;

  text-transform:uppercase;

}

.step {

  display:flex;

  align-items:center;

  gap:12px;

  padding:8px 12px;

  margin-bottom:6px;

  background:rgba(255,255,255,0.02);

  border:1px solid rgba(255,255,255,0.05);

  border-radius:10px;

}

.step-num {

  width:24px;

  height:24px;

  border-radius:50%;

  background:linear-gradient(135deg,rgba(255,42,95,0.2),rgba(255,42,95,0.05));

  border:1px solid rgba(255,42,95,0.4);

  display:flex;

  align-items:center;

  justify-content:center;

  font-family:'Orbitron',sans-serif;

  font-size:11px;

  font-weight:900;

  color:#ff2a5f;

  flex-shrink:0;

}

.step-txt { font-size:13px; font-weight:600; color:#ddd; }

.btn-action {

  display:block;

  text-align:center;

  padding:10px;

  border-radius:10px;

  font-size:13px;

  font-weight:800;

  text-decoration:none;

  margin-top:8px;

  letter-spacing:1px;

}

.btn-funds {

  background:linear-gradient(135deg,#ff2a5f,#b30033);

  color:#fff;

  box-shadow:0 0 20px rgba(255,42,95,0.3);

}

</style>

</head>

<body<?php if($isFantasy): ?> class="fantasy-theme"<?php endif; ?>>


<div class="app-wrapper">

  <?php ob_start(); ?>

  <header class="hdr" style="flex-direction: column; align-items: stretch;">

    <div class="app-name" style="text-align: center; margin-bottom: 8px;"><?=$appName?></div>

    <div style="display: flex; justify-content: space-between; align-items: center; width: 100%;">

      <div class="app-tag" style="margin-top: 0;"><?= $isFantasy ? '🎯 AI PREDICTION' : '⚡ AI PREDICTION' ?></div>

      <button class="btn-sync" style="margin-top: 0;"><span class="sync-dot"></span> SYNC</button>

    </div>

  </header>

  <?php $headerHTML = ob_get_clean(); ?>


  <?php if($isHacker): ?>

  <div id="hack-panel">

    <div class="steps-card" style="min-height: 400px; display: flex; flex-direction: column; justify-content: center; align-items: center;">

      <div class="scanlines"></div>

      <?=$headerHTML?>

      

      <div style="text-align: center; margin: 40px 0; width: 100%;">

        <span style="font-size: 80px; display: block; margin-bottom: 30px; animation: trollPulse 1.5s ease-in-out infinite alternate;">🖕</span>

        <div style="font-family:'Orbitron',sans-serif; font-size: 22px; font-weight: 900; color: #ff2a5f; text-transform: uppercase; letter-spacing: 3px; text-shadow: 0 0 15px rgba(255,42,95,0.6); margin-bottom: 10px;">

          NICE TRY THIEF

        </div>

      </div>

      

      <div class="server-info" style="margin-top:auto; margin-bottom: 20px;">

        <span class="serv-dot" style="background:#ff2a5f; box-shadow:0 0 8px #ff2a5f;"></span> Access Denied <span class="serv-ms">999ms</span>

      </div>

    </div>

  </div>


  <?php elseif($isAuth): ?>

  <div id="auth-panel">

    <div class="steps-card" style="<?php if($isFantasy): ?>border-color: rgba(16,185,129,0.35); animation: fantasyBorderGlow 3s ease-in-out infinite alternate;<?php else: ?>border-color: #ff9e00; box-shadow: inset 0 0 40px rgba(255,158,0,0.1), 0 0 10px rgba(255,158,0,0.2); animation: authBorderGlow 2s ease-in-out infinite alternate;<?php endif; ?>">

      <div class="scanlines"></div>

      <?=$headerHTML?>

      

      <?php if($isFantasy): ?>
      <div class="fantasy-auth-wrapper">
        <div class="fantasy-auth-header">
           <div class="fantasy-auth-icon">
              <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>
           </div>
           <div class="fantasy-auth-title">SYSTEM LOCKED</div>
           <div class="fantasy-auth-subtitle">AUTHENTICATION REQUIRED</div>
        </div>
        <div class="fantasy-auth-grid">
           <div class="fantasy-auth-status">STATUS: UNAUTHORIZED</div>
           <div class="fantasy-auth-desc">Please complete the login process to grant AI bypass permissions.</div>
        </div>
        <div style="display: flex; gap: 12px; margin-top: 10px; width: 100%;">
          <a href="javascript:void(0)" onclick="triggerHide()" class="btn-hide-panel" style="flex: 1; margin-top: 0; background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.3); display: flex; align-items: center; justify-content: center; padding: 12px; border-radius:10px; font-weight:800; font-size:13px; text-decoration:none; letter-spacing:1px; transition: all 0.2s;">INITIATE LOGIN</a>
          <a href="javascript:void(0)" onclick="triggerHide()" class="btn-hide-panel" style="flex: 1; margin-top: 0; background: rgba(255,42,95,0.1); color: #ff2a5f; border: 1px solid rgba(255,42,95,0.3); display: flex; align-items: center; justify-content: center; padding: 12px; border-radius:10px; font-weight:800; font-size:13px; text-decoration:none; letter-spacing:1px; transition: all 0.2s;">HIDE</a>
        </div>
      </div>
      <?php else: ?>
      <div class="steps-title" style="color: #ff9e00; letter-spacing: 0.5px; border-bottom: 1.5px solid rgba(255,158,0,0.2); padding-bottom: 10px; margin-bottom: 16px;">🔒 Authentication Required</div>
      <div style="text-align: center; margin: 30px 0; padding: 0 10px;">
        <span style="font-size: 54px; display: block; margin-bottom: 20px; filter: drop-shadow(0 0 15px rgba(255,158,0,0.4)); animation: lockPulse 2s ease-in-out infinite alternate;">🔑</span>
        <div style="font-size: 14px; font-weight: 800; color: #fff; line-height: 1.7; text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 0 8px rgba(255,255,255,0.2);">
          Please login or sign up<br>to use hack
        </div>
      </div>
      <div style="display: flex; justify-content: center; width: 100%; margin-top: 10px;">
        <a href="javascript:void(0)" onclick="triggerHide()" class="btn-action btn-hide-panel" style="flex: 1; margin-top: 0; background: linear-gradient(135deg, #4b26cc, #341999); color: #fff; box-shadow: 0 0 20px rgba(75,38,204,0.4); display: flex; align-items: center; justify-content: center; gap: 4px; padding: 12px; border-radius:10px; font-weight:800; font-size:13px; text-decoration:none; letter-spacing:1px; transition: all 0.2s;">❌ Hide</a>
      </div>
      <?php endif; ?>

      

      <div class="server-info" style="margin-top:20px;">

        <span class="serv-dot" style="background:<?= $isFantasy ? '#22c55e' : '#ff9e00' ?>; box-shadow:0 0 8px <?= $isFantasy ? '#22c55e' : '#ff9e00' ?>;"></span> Server Active <span class="serv-ms"><?=$serverMs?>ms</span>

      </div>

    </div>

  </div>

  

  <?php elseif($showHackPanel): ?>

  <div id="hack-panel">

    <div class="steps-card">

      <div class="scanlines"></div>

      <?=$headerHTML?>

      

      <?php if($isFantasy): ?>
      <!-- Fantasy Layout: Countdown box + balls + confidence -->
      <div class="meta-info">
        <div class="meta-period"><?php echo $isFantasy ? '' : 'PERIOD: '; ?><span id="period-num">Connecting...</span></div>
        <div class="meta-timer" id="live-timer">00:00</div>
      </div>

      <div class="fantasy-countdown-box">
        <div class="fantasy-countdown-label">NEXT ROUND IN</div>
        <div class="fantasy-countdown-time" id="fantasy-timer">00:30</div>
        <div class="fantasy-countdown-progress">
          <div class="fantasy-countdown-progress-fill" id="fantasy-progress" style="width:50%"></div>
        </div>
      </div>

      <div class="pred-card" id="pred-card">
        <div class="tv-sweep"></div>
        <div class="radar-container"><div class="radar-sweep"></div></div>

        <svg class="hex-center" viewBox="0 0 100 100">
          <polygon points="50,5 95,27 95,72 50,95 5,72 5,27" fill="none" stroke="rgba(16,185,129,0.25)" stroke-width="2"/>
          <polygon points="50,15 85,32 85,67 50,85 15,67 15,32" fill="none" stroke="rgba(16,185,129,0.12)" stroke-width="1"/>
        </svg>

        <svg class="hud-frame" viewBox="0 0 100 100" preserveAspectRatio="none">
          <path d="M 5,15 L 5,5 L 15,5" fill="none" stroke="rgba(16,185,129,0.2)" stroke-width="1"/>
          <path d="M 85,5 L 95,5 L 95,15" fill="none" stroke="rgba(16,185,129,0.2)" stroke-width="1"/>
          <path d="M 5,85 L 5,95 L 15,95" fill="none" stroke="rgba(16,185,129,0.2)" stroke-width="1"/>
          <path d="M 85,95 L 95,95 L 95,85" fill="none" stroke="rgba(16,185,129,0.2)" stroke-width="1"/>
          <line x1="50" y1="0" x2="50" y2="10" stroke="#fff" stroke-opacity="0.05" stroke-width="0.5"/>
          <line x1="50" y1="90" x2="50" y2="100" stroke="#fff" stroke-opacity="0.05" stroke-width="0.5"/>
          <line x1="0" y1="50" x2="10" y2="50" stroke="#fff" stroke-opacity="0.05" stroke-width="0.5"/>
          <line x1="90" y1="50" x2="100" y2="50" stroke="#fff" stroke-opacity="0.05" stroke-width="0.5"/>
        </svg>
        
        <div class="pred-status" id="pred-status" style="display:none"></div>

        <!-- Fantasy READY screen -->
        <div class="fantasy-ready-container" id="fantasy-ready">
          <div class="fantasy-ready-ring">
            <span class="fantasy-ready-icon">🎯</span>
          </div>
          <div class="fantasy-ready-text"><?= ($balance < 500) ? 'RS:500 REQ' : 'READY' ?></div>
          <div class="fantasy-ready-sub">AI ENGINE STANDBY</div>
        </div>
        
        <div class="pred-result" id="pred-result" style="display:none; flex-direction:column; gap:8px;">
          <div class="fantasy-pills" id="fantasy-pills" style="display:none; margin-top:0;">
            <div class="fantasy-pill fantasy-pill-size" id="fantasy-size-pill">BIG</div>
            <div class="fantasy-pill fantasy-pill-color pill-green" id="fantasy-color-pill">GREEN</div>
          </div>
          <div class="fantasy-balls-container" id="fantasy-balls" style="margin:4px 0; padding:4px 0;">
            <div class="fantasy-ball-wrap">
              <img class="fantasy-ball" id="ball-left" src="https://www.fantasygems20.com/assets/png/ball_5-46891538.webp" alt="ball">
              <div class="fantasy-ball-glow"></div>
            </div>
            <div class="fantasy-ball-wrap">
              <img class="fantasy-ball" id="ball-center" src="https://www.fantasygems20.com/assets/png/ball_5-46891538.webp" alt="ball">
              <div class="fantasy-ball-glow"></div>
            </div>
            <div class="fantasy-ball-wrap">
              <img class="fantasy-ball" id="ball-right" src="https://www.fantasygems20.com/assets/png/ball_5-46891538.webp" alt="ball">
              <div class="fantasy-ball-glow"></div>
            </div>
          </div>
        </div>
      </div>

      <div class="pred-actions">
        <?php if($balance < 500): ?>
          <button class="btn-action-panel btn-start" id="btn-start" onclick="triggerDeposit()">DEPOSIT</button>
        <?php else: ?>
          <button class="btn-action-panel btn-start" id="btn-start" onclick="toggleHack()">START</button>
        <?php endif; ?>
        <button class="btn-action-panel btn-hide" id="btn-hide" onclick="triggerHide()">HIDE</button>
      </div>

      <div class="fantasy-confidence-bar" id="fantasy-confidence" style="display:none">
        <div class="fantasy-confidence-label">
          <span>CONFIDENCE</span>
          <span class="fantasy-confidence-value" id="confidence-pct">78%</span>
        </div>
        <div class="fantasy-confidence-track">
          <div class="fantasy-confidence-fill" id="confidence-fill" style="width:78%"></div>
        </div>
      </div>
    
      <div class="server-info">
        <span class="serv-dot"></span> SYSTEM ONLINE <span class="serv-ms"><?=$serverMs?>ms</span>
      </div>

      <?php else: ?>
      <!-- Original WinGo Layout -->
      <div class="meta-info">

      <div class="meta-period">PERIOD: <span id="period-num">Connecting...</span></div>

      <div class="meta-timer" id="live-timer">00:00</div>

    </div>

    

    <div class="pred-card" id="pred-card">

      <div class="tv-sweep"></div>

      

      <div class="radar-container"><div class="radar-sweep"></div></div>

      

      <svg class="hex-center" viewBox="0 0 100 100">

        <polygon points="50,5 95,27 95,72 50,95 5,72 5,27" fill="none" stroke="#ff2a5f" stroke-width="2"/>

        <polygon points="50,15 85,32 85,67 50,85 15,67 15,32" fill="none" stroke="#4a8fe7" stroke-width="1"/>

      </svg>


      <svg class="hud-frame" viewBox="0 0 100 100" preserveAspectRatio="none">

        <path d="M 5,15 L 5,5 L 15,5" fill="none" stroke="#d7e000" stroke-width="1"/>

        <path d="M 85,5 L 95,5 L 95,15" fill="none" stroke="#d7e000" stroke-width="1"/>

        <path d="M 5,85 L 5,95 L 15,95" fill="none" stroke="#d7e000" stroke-width="1"/>

        <path d="M 85,95 L 95,95 L 95,85" fill="none" stroke="#d7e000" stroke-width="1"/>

        <line x1="50" y1="0" x2="50" y2="10" stroke="#fff" stroke-opacity="0.1" stroke-width="0.5"/>

        <line x1="50" y1="90" x2="50" y2="100" stroke="#fff" stroke-opacity="0.1" stroke-width="0.5"/>

        <line x1="0" y1="50" x2="10" y2="50" stroke="#fff" stroke-opacity="0.1" stroke-width="0.5"/>

        <line x1="90" y1="50" x2="100" y2="50" stroke="#fff" stroke-opacity="0.1" stroke-width="0.5"/>

      </svg>

      

      <div class="pred-status" id="pred-status"><?= ($balance < 500) ? 'RS:500 REQ' : 'READY' ?></div>

      

      <div class="pred-result" id="pred-result" style="display:none">

        <div class="pred-size green" id="pred-size">BIG</div>

        <div class="pred-sub">

          <span class="pred-dot" id="pred-color" style="background:#00ff66;box-shadow:0 0 10px #00ff66"></span>

          <span class="pred-color-text" id="pred-color-text">GREEN</span>

          <span class="pred-num" style="margin-left:8px">NUM: <span id="pred-number">7</span></span>

        </div>

      </div>

    </div>


    <div class="pred-actions">

      <?php if($balance < 500): ?>

        <button class="btn-action-panel btn-start" id="btn-start" onclick="triggerDeposit()">DEPOSIT</button>

      <?php else: ?>

        <button class="btn-action-panel btn-start" id="btn-start" onclick="toggleHack()">START</button>

      <?php endif; ?>

      <button class="btn-action-panel btn-hide" id="btn-hide" onclick="triggerHide()">HIDE</button>

    </div>

    

    <div class="server-info">

      <span class="serv-dot"></span> SYSTEM ONLINE <span class="serv-ms"><?=$serverMs?>ms</span>

    </div>

      <?php endif; ?>

    </div>

  </div>


  <?php else: ?>

  <div id="steps-panel">

    <div class="steps-card">

      <div class="scanlines"></div>

      <?=$headerHTML?>

      <?php if($isFantasy): ?>
      <div class="fantasy-auth-wrapper">
        <div class="fantasy-auth-header">
           <div class="fantasy-auth-icon">
              <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20"></path><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"></path></svg>
           </div>
           <div class="fantasy-auth-title" style="color:#fbbf24; text-shadow:0 0 10px rgba(245,158,11,0.4);">ACTIVATION REQUIRED</div>
           <div class="fantasy-auth-subtitle">INSUFFICIENT FUNDS DETECTED</div>
        </div>
        <div class="fantasy-auth-grid">
           <div class="step" style="background:rgba(16,185,129,0.05); border:1px solid rgba(16,185,129,0.1); padding:8px; display:flex; align-items:center; border-radius:6px; margin-bottom:6px;"><span style="color:#10b981; font-weight:bold; margin-right:8px;">1.</span><span style="color:#a7f3d0; font-size:11px;">Deposit 500 Minimum</span></div>
           <div class="step" style="background:rgba(16,185,129,0.05); border:1px solid rgba(16,185,129,0.1); padding:8px; display:flex; align-items:center; border-radius:6px; margin-bottom:6px;"><span style="color:#10b981; font-weight:bold; margin-right:8px;">2.</span><span style="color:#a7f3d0; font-size:11px;">Add E-Wallet Account</span></div>
           <div class="step" style="background:rgba(16,185,129,0.05); border:1px solid rgba(16,185,129,0.1); padding:8px; display:flex; align-items:center; border-radius:6px; margin-bottom:6px;"><span style="color:#10b981; font-weight:bold; margin-right:8px;">3.</span><span style="color:#a7f3d0; font-size:11px;">High Deposit = High Accuracy</span></div>
        </div>
        <div style="display: flex; gap: 12px; margin-top: 10px; width: 100%;">
          <a href="javascript:void(0)" onclick="triggerDeposit()" class="btn-hide-panel" style="flex: 1; margin-top: 0; background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.3); display: flex; align-items: center; justify-content: center; padding: 12px; border-radius:10px; font-weight:800; font-size:13px; text-decoration:none; letter-spacing:1px; transition: all 0.2s;">DEPOSIT NOW</a>
          <a href="javascript:void(0)" onclick="triggerHide()" class="btn-hide-panel" style="flex: 1; margin-top: 0; background: rgba(255,42,95,0.1); color: #ff2a5f; border: 1px solid rgba(255,42,95,0.3); display: flex; align-items: center; justify-content: center; padding: 12px; border-radius:10px; font-weight:800; font-size:13px; text-decoration:none; letter-spacing:1px; transition: all 0.2s;">HIDE</a>
        </div>
      </div>
      <?php else: ?>
      <div class="steps-title">⚠️ Activation Required</div>
      <div class="step"><span class="step-num">1</span><span class="step-txt">Deposit 500</span></div>
      <div class="step"><span class="step-num">2</span><span class="step-txt">Add E-Wallet Account</span></div>
      <div class="step"><span class="step-num">3</span><span class="step-txt">Open Wingo to use hack</span></div>
      <div class="step"><span class="step-num">4</span><span class="step-txt">High Deposit = High Profit</span></div>
      <div style="display: flex; gap: 12px; margin-top: 10px; width: 100%;">
        <a href="javascript:void(0)" onclick="triggerDeposit()" class="btn-action btn-funds" style="flex: 1; margin-top: 0; display: flex; align-items: center; justify-content: center; gap: 4px;">Deposit</a>
        <a href="javascript:void(0)" onclick="triggerHide()" class="btn-action btn-hide-panel" style="flex: 1; margin-top: 0; background: linear-gradient(135deg, #4b26cc, #341999); color: #fff; box-shadow: 0 0 20px rgba(75,38,204,0.4); display: flex; align-items: center; justify-content: center; gap: 4px; border-radius:10px; font-weight:800; font-size:13px; text-decoration:none; letter-spacing:1px;">❌ Hide</a>
      </div>
      <?php endif; ?>

      <div class="server-info" style="margin-top:20px">

        <span class="serv-dot"></span> Server Live <span class="serv-ms"><?=$serverMs?>ms</span>

      </div>

    </div>

  </div>

  <?php endif; ?>

</div>


<script>

const IS_FANTASY = <?= $isFantasy ? 'true' : 'false' ?>;

const BALL_IMAGES = {
  0: 'https://www.fantasygems20.com/assets/png/ball_0-053d2b99.webp',
  1: 'https://www.fantasygems20.com/assets/png/ball_1-49176bf8.webp',
  2: 'https://www.fantasygems20.com/assets/png/ball_2-62fbe730.webp',
  3: 'https://www.fantasygems20.com/assets/png/ball_3-31762cc1.webp',
  4: 'https://www.fantasygems20.com/assets/png/ball_4-ba9fa4ff.webp',
  5: 'https://www.fantasygems20.com/assets/png/ball_5-46891538.webp',
  6: 'https://www.fantasygems20.com/assets/png/ball_6-9319baa4.webp',
  7: 'https://www.fantasygems20.com/assets/png/ball_7-4e868eee.webp',
  8: 'https://www.fantasygems20.com/assets/png/ball_8-832f9a99.webp',
  9: 'https://www.fantasygems20.com/assets/png/ball_9-9cf62e12.webp'
};

let predRunning = false;

let analyzeInt = null;


const currentModeKey = new URLSearchParams(window.location.search).get('mode') || 'unknown';

function saveState(state, num = null) {

    sessionStorage.setItem('predRunning_' + currentModeKey, predRunning ? 'true' : 'false');

    sessionStorage.setItem('hack_state_' + currentModeKey, state);

    sessionStorage.setItem('hack_issue_' + currentModeKey, currentIssue);

    if (num !== null) sessionStorage.setItem('hack_num_' + currentModeKey, num);

}


function restoreState() {

    const savedRunning = sessionStorage.getItem('predRunning_' + currentModeKey);

    const savedState = sessionStorage.getItem('hack_state_' + currentModeKey);

    const savedNum = sessionStorage.getItem('hack_num_' + currentModeKey);

    const startBtn = document.getElementById('btn-start');


    if (startBtn && startBtn.textContent.trim() !== 'DEPOSIT') {

        if (savedRunning === 'true') {

            predRunning = true;

            if (savedState === 'RESULT' && savedNum !== null) {

                startBtn.textContent = 'STOP';

                startBtn.classList.add('running');

                document.getElementById('pred-status').style.display = 'none';

                if(IS_FANTASY) {
                  const readyEl = document.getElementById('fantasy-ready');
                  if(readyEl) readyEl.style.display = 'none';
                }

                document.getElementById('pred-result').style.display = 'flex';

                displayPrediction(parseInt(savedNum));

            } else if (savedState === 'ANALYZING') {

                runPredictionFlow(true);

            }

        }

    }

}


function triggerDeposit() {

  if (window.HackBridge && typeof window.HackBridge.openDeposit === 'function') {

    window.HackBridge.openDeposit();

  } else {

    window.location.href = '<?=$rechargeUrl?>';

  }

}


function triggerHide() {

  if (window.HackBridge && typeof window.HackBridge.hidePanel === 'function') {

    window.HackBridge.hidePanel();

  } else {

    const panel = document.getElementById('hack-panel') || document.getElementById('steps-panel') || document.getElementById('auth-panel');

    if (panel) panel.style.display = 'none';

  }

}


const urlParams = new URLSearchParams(window.location.search);

let MODE = urlParams.get('mode') || '30sec';

let GAME_CODE = 'WinGo_30S';

if(MODE === '1min') GAME_CODE = 'WinGo_1M';

if(MODE === '3min') GAME_CODE = 'WinGo_3M';

if(MODE === '5min') GAME_CODE = 'WinGo_5M';


function screenFlash(){

  const f=document.createElement('div');

  f.className='flash';

  document.body.appendChild(f);

  setTimeout(()=>f.remove(), 400);

}


let currentIssue = "";

let currentCountdown = 0;


async function fetchLiveIssue() {

    <?php if($isHacker): ?> return; <?php endif; ?>

    try {

        let json;
        if (IS_FANTASY) {
            let res = await fetch(`https://draw.ar-lottery01.com/WinGo/${GAME_CODE}.json?ts=` + Date.now());
            let rawJson = await res.json();
            if(rawJson && rawJson.current) {
                let endTime = Math.floor(rawJson.current.endTime / 1000);
                json = {
                    data: {
                        issueNumber: rawJson.current.issueNumber,
                        countdown: Math.max(0, endTime - Math.floor(Date.now() / 1000))
                    }
                };
            }
        } else {
            let res = await fetch(`wingo.php?ajax=issue&gameCode=${GAME_CODE}&pkg=<?= urlencode($pkg) ?>&game=normal`);
            json = await res.json();
        }

        

        if(json && json.data) {

            let newIssue = json.data.issueNumber;

            currentCountdown = json.data.countdown;

            

            document.getElementById('period-num').textContent = newIssue;

            updateTimerDisplay(currentCountdown);

            

            if (currentIssue === "") {
                const savedIssue = sessionStorage.getItem('hack_issue_' + currentModeKey);
                if (savedIssue && savedIssue !== newIssue && predRunning) {
                    currentIssue = newIssue;
                    runPredictionFlow();
                    return;
                }
            }

            if(currentIssue !== "" && currentIssue !== newIssue && predRunning) {

                currentIssue = newIssue;

                runPredictionFlow(); 

            } else {

                currentIssue = newIssue;

            }

        }

    } catch(e) {

        console.log("Sync error:", e);

    }

}


async function fetchHistory() {

    try {

        let json;
        if (IS_FANTASY) {
            let res = await fetch(`https://draw.ar-lottery01.com/WinGo/${GAME_CODE}/GetHistoryIssuePage.json?ts=` + Date.now());
            json = await res.json();
        } else {
            let res = await fetch(`wingo.php?ajax=history&gameCode=${GAME_CODE}&pkg=<?= urlencode($pkg) ?>&game=normal`);
            json = await res.json();
        }

        if(json && json.data && json.data.list) {

            return json.data.list;

        }

    } catch(e) {}

    return [];

}


setInterval(() => {

    if(currentCountdown > 0) {

        currentCountdown--;

        updateTimerDisplay(currentCountdown);

    } else if (currentCountdown === 0 && currentIssue !== "") {

        currentCountdown = -1; 

        setTimeout(fetchLiveIssue, 1500);

    }

}, 1000);


function updateTimerDisplay(seconds) {

    if(seconds < 0) seconds = 0;

    const m = Math.floor(seconds / 60);

    const s = seconds % 60;

    const timeStr = m.toString().padStart(2,'0') + ':' + s.toString().padStart(2,'0');

    const timerEl = document.getElementById('live-timer');

    if(timerEl) timerEl.textContent = timeStr;

    // Fantasy countdown sync
    if(IS_FANTASY) {
      const fantasyTimer = document.getElementById('fantasy-timer');
      if(fantasyTimer) fantasyTimer.textContent = timeStr;
      const fantasyProgress = document.getElementById('fantasy-progress');
      if(fantasyProgress) {
        let maxTime = 30;
        if(typeof GAME_CODE !== 'undefined') {
          if(GAME_CODE === 'WinGo_1M') maxTime = 60;
          else if(GAME_CODE === 'WinGo_3M') maxTime = 180;
          else if(GAME_CODE === 'WinGo_5M') maxTime = 300;
        }
        const pct = Math.min(100, (seconds / maxTime) * 100);
        fantasyProgress.style.width = pct + '%';
      }
    }

}


fetchLiveIssue();

setInterval(fetchLiveIssue, 10000);


function seededRandom(seedStr) {

    let hash = 0;

    for (let i = 0; i < seedStr.length; i++) {

        hash = ((hash << 5) - hash) + seedStr.charCodeAt(i);

        hash |= 0; 

    }

    let x = Math.sin(hash++) * 10000;

    return x - Math.floor(x);

}


async function simulateAIVoting(issueNum, historyData) {

    const numModels = 30;

    const votes = Array(10).fill(0);
    
    const urlParams = new URLSearchParams(window.location.search);
    const currentMode = urlParams.get('mode') || 'unknown';

    let histNums = (historyData || []).slice(0, 50).map(h => parseInt(h.number));

    if (histNums.length === 0) histNums = [0,1,2,3,4,5,6,7,8,9]; 

    let freq = Array(10).fill(0);

    histNums.forEach(n => { if(!isNaN(n)) freq[n]++; });

    let shortTerm = histNums.slice(0, 5);

    let movingAvg = Math.round(shortTerm.reduce((a,b)=>a+b, 0) / (shortTerm.length || 1));

    let recentSizes = shortTerm.map(n => n >= 5 ? 'B' : 'S');

    let isStreak = recentSizes.every(s => s === recentSizes[0]);

    let sizeBias = isStreak ? (recentSizes[0] === 'B' ? 'S' : 'B') : recentSizes[0];

    for(let i = 0; i < numModels; i++) {

        let seed = issueNum + "_" + currentMode + "_ml_v2_" + i;

        let rand = seededRandom(seed);
        
        // Inject 30% pure AI randomness deterministically based on issue
        if (seededRandom(seed + "_chance") < 0.3) {
            rand = seededRandom(seed + "_val");
        }

        let predictedNumber = 0;

        let voteWeight = 1;


        if (i < 8) {

            let offset = Math.floor(seededRandom(seed + "lstm") * 5) - 2;

            predictedNumber = Math.max(0, Math.min(9, movingAvg + offset));

            voteWeight = 2; 

        } else if (i < 16) {

            if (sizeBias === 'B') {

                predictedNumber = Math.floor(seededRandom(seed + "kmeansB") * 5) + 5; 

            } else {

                predictedNumber = Math.floor(seededRandom(seed + "kmeansS") * 5); 

            }

            voteWeight = 1.5;

        } else if (i < 24) {

            let maxFreq = Math.max(...freq);

            let hotNums = [];

            freq.forEach((f, idx) => { if(f >= maxFreq - 1) hotNums.push(idx); });

            let pick = Math.floor(seededRandom(seed + "rf") * hotNums.length);

            predictedNumber = hotNums[pick] !== undefined ? hotNums[pick] : Math.floor(rand * 10);

            voteWeight = 1.2;

        } else {

            predictedNumber = Math.floor(rand * 10);

            voteWeight = 0.8;

        }


        if ((predictedNumber === 0 || predictedNumber === 5) && seededRandom(seed + "viol") > 0.15) {

            if (predictedNumber === 0) predictedNumber = seededRandom(seed + "shiftS") > 0.5 ? 2 : 4;

            if (predictedNumber === 5) predictedNumber = seededRandom(seed + "shiftB") > 0.5 ? 7 : 9;

        }


        votes[predictedNumber] += voteWeight;

    }


    let maxVotes = -1;

    let winner = 0;

    for(let i=0; i<10; i++){

        if(votes[i] > maxVotes){

            maxVotes = votes[i];

            winner = i;

        }

    }


    const oppositeMap = {

        0: 5, 1: 7, 2: 8, 3: 9, 4: 6,

        5: 0, 6: 4, 7: 1, 8: 2, 9: 3 

    };

    

    winner = oppositeMap[winner];

    return winner;

}


function toggleHack(){

  if(predRunning){

    stopHack();

  } else {

    predRunning = true;

    runPredictionFlow();

  }

}


async function runPredictionFlow(isRestore = false) {

  const statusEl = document.getElementById('pred-status');

  const resultEl = document.getElementById('pred-result');

  const btnStart = document.getElementById('btn-start');


  btnStart.textContent = 'STOP';

  btnStart.classList.add('running');

  

  statusEl.style.display = 'block';

  resultEl.style.display = 'none';

  statusEl.textContent = 'ANALYZING';

  statusEl.style.fontSize = '20px';

  statusEl.style.color = IS_FANTASY ? '#10b981' : '#ff9e00'; 

  statusEl.style.textShadow = IS_FANTASY ? '0 0 20px rgba(16,185,129,0.5)' : '0 0 20px rgba(255,158,0,0.6)';

  // Hide confidence bar & ready screen during analysis in fantasy mode
  if(IS_FANTASY) {
    const confBar = document.getElementById('fantasy-confidence');
    if(confBar) confBar.style.display = 'none';
    const readyEl = document.getElementById('fantasy-ready');
    if(readyEl) readyEl.style.display = 'none';
    const statusE = document.getElementById('pred-status');
    if(statusE) statusE.style.display = 'block';
  }


  saveState('ANALYZING');


  if(analyzeInt) clearInterval(analyzeInt);

  let dots = 0;

  analyzeInt = setInterval(()=>{

    dots = (dots+1)%4;

    statusEl.textContent = 'ANALYZING' + '.'.repeat(dots);

  }, 300);


  let history = await fetchHistory();

  

  let waitTime = isRestore ? 200 : (1500 + Math.random()*1500);


  setTimeout(async () => {

    if(!predRunning) { clearInterval(analyzeInt); return; } 

    

    let winningNumber = await simulateAIVoting(currentIssue, history);

    

    clearInterval(analyzeInt);

    statusEl.style.display = 'none';

    resultEl.style.display = 'flex';

    if (!isRestore) screenFlash();

    

    saveState('RESULT', winningNumber);

    displayPrediction(winningNumber);

    

  }, waitTime); 

}


function displayPrediction(num){

  const isGreen = num === 0 ? false : (num % 2 !== 0); 

  const isViolet = num === 0 || num === 5;

  

  let color = 'green';

  let hex = '#00ff66';

  

  if(isViolet){

    color = 'violet';

    hex = '#cc00ff';

  } else if(!isGreen){

    color = 'red';

    hex = '#ff1a1a';

  }

  

  const size = num >= 5 ? 'BIG' : 'SMALL';


  if(IS_FANTASY) {

    // Hide ready screen, show results
    const readyEl = document.getElementById('fantasy-ready');
    if(readyEl) readyEl.style.display = 'none';

    // Fantasy mode: show ball images
    const ballLeft = document.getElementById('ball-left');
    const ballCenter = document.getElementById('ball-center');
    const ballRight = document.getElementById('ball-right');
    if(ballLeft && ballCenter && ballRight) {
      ballLeft.src = BALL_IMAGES[num];
      ballCenter.src = BALL_IMAGES[num];
      ballRight.src = BALL_IMAGES[num];
    }

    // Show confidence bar
    const confBar = document.getElementById('fantasy-confidence');
    if(confBar) confBar.style.display = 'block';
    const confPct = 65 + Math.floor(Math.random() * 25);
    const confPctEl = document.getElementById('confidence-pct');
    const confFill = document.getElementById('confidence-fill');
    if(confPctEl) confPctEl.textContent = confPct + '%';
    if(confFill) confFill.style.width = confPct + '%';

    // Show size/color pills
    const pillsEl = document.getElementById('fantasy-pills');
    if(pillsEl) pillsEl.style.display = 'flex';
    const sizePill = document.getElementById('fantasy-size-pill');
    if(sizePill) sizePill.textContent = size;
    const colorPill = document.getElementById('fantasy-color-pill');
    if(colorPill) {
      colorPill.textContent = color.toUpperCase();
      colorPill.className = 'fantasy-pill fantasy-pill-color pill-' + color;
    }

  } else {

    // Original WinGo mode
    document.getElementById('pred-number').textContent = num;

    

    const sizeEl = document.getElementById('pred-size');

    sizeEl.textContent = size;

    sizeEl.className = 'pred-size ' + color; 

    

    const dotEl = document.getElementById('pred-color');

    dotEl.style.background = hex;

    dotEl.style.boxShadow = '0 0 10px ' + hex;

    

    const colorTextEl = document.getElementById('pred-color-text');

    colorTextEl.textContent = color.toUpperCase();

  }

}


function stopHack(){

  predRunning = false;

  saveState('IDLE');


  if(analyzeInt) clearInterval(analyzeInt);

  const statusEl = document.getElementById('pred-status');

  const resultEl = document.getElementById('pred-result');

  const btnStart = document.getElementById('btn-start');


  btnStart.textContent = 'START';

  btnStart.classList.remove('running');

  

  resultEl.style.display = 'none';

  statusEl.style.display = 'block';

  statusEl.textContent = 'READY';

  statusEl.style.fontSize = '';

  statusEl.style.color = IS_FANTASY ? '#10b981' : '#ff2a5f'; 

  statusEl.style.textShadow = IS_FANTASY ? '0 0 15px rgba(16,185,129,0.4)' : '0 0 20px rgba(255,42,95,0.6)';

  // Hide confidence bar and pills, show ready screen when stopped
  if(IS_FANTASY) {
    const confBar = document.getElementById('fantasy-confidence');
    if(confBar) confBar.style.display = 'none';
    const pillsEl = document.getElementById('fantasy-pills');
    if(pillsEl) pillsEl.style.display = 'none';
    // Show ready screen again
    const readyEl = document.getElementById('fantasy-ready');
    if(readyEl) readyEl.style.display = 'flex';
    // Hide pred-status text (ready screen replaces it)
    statusEl.style.display = 'none';
  }

}


setInterval(()=>{

  document.querySelectorAll('.serv-ms').forEach(el=>{

    if(el.textContent !== '999ms') el.textContent = Math.floor(Math.random()*40 + 12) + 'ms';

  });

}, 2500);


window.updatePanelBalance = function(newBal) {
  const readyTexts = document.querySelectorAll('.fantasy-ready-text, #pred-status');
  const btnStart = document.getElementById('btn-start');
  if (newBal >= 500) {
    readyTexts.forEach(el => {
      if (el.textContent.includes('REQ')) el.textContent = 'READY';
    });
    if (btnStart && btnStart.textContent.includes('DEPOSIT')) {
      btnStart.textContent = 'START';
      btnStart.onclick = window.togglePrediction;
    }
  } else {
    readyTexts.forEach(el => {
      if (el.textContent === 'READY') el.textContent = 'RS:500 REQ';
    });
    if (btnStart && btnStart.textContent === 'START') {
      btnStart.textContent = 'DEPOSIT';
      btnStart.onclick = window.triggerDeposit;
    }
  }
};

restoreState();


<?php if(!$isApp): ?>

(function() {

})();

<?php endif; ?>

</script>

</body>

</html> 