<!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>Loading...</title>
    
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@10/swiper-bundle.min.css">
    
    <style>
        /* ORIGINAL 91CLUB FONT */
        @font-face {
            font-family: 'Bahnschrift';
            src: url('https://91appt.com/assets/woff2/bahnschrift-610d57ac.woff2') format('woff2');
            font-display: swap;
        }

        :root {
            --bg-body: #F7F8FA;         
            --card-bg: #FFFFFF;         
            --primary: #ff4a4a;         
            --primary-grad: linear-gradient(135deg, #ff6c6b, #ff4a4a);
            --text-dark: #333333;
            --text-muted: #888888;
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
            --nav-inactive: #a4b0be;
        }

        * { font-family: -apple-system, sans-serif; -webkit-tap-highlight-color: transparent; box-sizing: border-box; margin: 0; padding: 0;}
        .bahnschrift { font-family: 'Bahnschrift', sans-serif !important; }
        
        body { 
            background-color: var(--bg-body); color: var(--text-dark); max-width: 480px; 
            margin: 0 auto; box-shadow: 0 0 20px rgba(0,0,0,0.05); 
            padding-top: 60px; padding-bottom: 80px; min-height: 100vh; position: relative; overflow-x: hidden;
        }

        /* HEADER */
        .app-header { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--card-bg); height: 60px; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,0.02);}
        .logo { font-size: 20px; font-weight: 900; color: var(--primary); display:flex; align-items:center; gap:5px; letter-spacing: -0.5px;}
        .profile-icon-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--primary); box-shadow: 0 2px 5px rgba(243, 89, 91, 0.2);}

        /* NOTICE BAR */
        .notice-bar { background: #fff; margin: 10px 15px; border-radius: 20px; display: flex; align-items: center; padding: 5px 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.01); overflow: hidden;}
        .notice-icon { width: 18px; height: 18px; fill: var(--primary); margin-right: 10px;}
        .notice-text { font-size: 11px; color: #666; white-space: nowrap; overflow: hidden; position: relative; flex: 1; height: 16px;}
        .notice-content { position: absolute; white-space: nowrap; animation: marquee 20s linear infinite;}
        @keyframes marquee { 0% { transform: translateX(100%); } 100% { transform: translateX(-180%); } }

        /* BANNERS */
        .swiper { margin: 10px 15px 15px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); background: #eee;}
        .banner-loading { width: 100%; height: 160px; display: flex; align-items: center; justify-content: center; color: #aaa;}
        .swiper-slide img { width: 100%; height: 160px; object-fit: cover; border-radius: 12px; }
        .swiper-pagination-bullet-active { background: var(--primary); }

        /* WALLET SECTION */
        .wallet-box { 
            display: flex; align-items: center; justify-content: space-between; gap: 10px;
            background: #fff; margin: 0 15px 15px; border-radius: 12px; padding: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.04);
        }
        .w-left { flex: 1; min-width: 0; }
        .w-label { font-size: 12px; color: #999; display: flex; align-items: center; gap: 5px; margin-bottom: 5px; font-weight: bold;}
        .w-label svg { width: 14px; height: 14px; fill: #F5B000;}
        .w-amt { 
            font-size: 22px; font-weight: bold; color: #333; display: flex; align-items: center; gap: 5px; 
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
        }
        #walletBalanceText {
            display: inline-block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .refresh-btn { width: 18px; height: 18px; fill: #999; cursor: pointer; transition: 0.5s; flex-shrink: 0;}
        .refresh-btn.spin { transform: rotate(360deg); fill: var(--primary); }

        .w-right { display: flex; gap: 8px; flex-shrink: 0; }
        .btn-action { 
            color: #fff; padding: 8px 12px; border-radius: 20px; text-decoration: none; 
            font-size: 11px; font-weight: bold; display: flex; flex-direction: column; 
            align-items: center; gap: 4px; min-width: 80px; transition: all 0.3s ease;
        }
        .btn-withdraw { background: linear-gradient(135deg, #FFC107, #FF9800); animation: pulseYellow 2s infinite alternate; }
        .btn-deposit { background: linear-gradient(135deg, #FF6C6B, #FF4A4A); animation: pulseRed 2s infinite alternate; }
        .btn-action:active { transform: scale(0.95); }
        .btn-action svg { width: 20px; height: 20px; fill: #fff; }

        @keyframes pulseRed { 0% { box-shadow: 0 0 5px rgba(243,89,91,0.4); } 100% { box-shadow: 0 0 15px rgba(243,89,91,0.8), 0 0 25px rgba(243,89,91,0.4); } }
        @keyframes pulseYellow { 0% { box-shadow: 0 0 5px rgba(255,152,0,0.4); } 100% { box-shadow: 0 0 15px rgba(255,152,0,0.8), 0 0 25px rgba(255,152,0,0.4); } }

        /* CATEGORY TABS */
        .cat-nav { display: flex; gap: 20px; padding: 0 15px; margin-bottom: 15px; overflow-x: auto; font-size: 13px; font-weight: bold; color: #888; border-bottom: 1px solid #f0f0f0; background: #fff;}
        .cat-nav::-webkit-scrollbar { display: none; }
        .cat-tab { padding: 12px 0; position: relative; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
        .cat-tab.active { color: var(--primary); }
        .cat-tab.active::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 3px; background: var(--primary); border-radius: 3px; }
        .cat-tab img { height: 20px; width: auto; object-fit: contain;}
        .cat-icon-placeholder { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: #ccc;}

        /* GAMES GRID */
        .sec-title { font-size: 15px; font-weight: bold; margin: 0 15px 10px; display: flex; align-items: center; gap: 6px;}
        .sec-title svg { width: 16px; height: 16px; fill: var(--primary); }
        
        .game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 15px 20px; }
        .game-card { border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); background: #fff; position: relative; aspect-ratio: 1; text-decoration: none;}
        .game-card:active { transform: scale(0.95); }
        .game-card img { width: 100%; height: 100%; object-fit: cover; }
        .game-card-title { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); color: white; font-size: 10px; text-align: center; padding: 15px 5px 5px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
        .hidden-game { display: none !important; }

        /* LIVE WINNING RANKING */
        .winning-wrap { background: var(--card-bg); border-radius: 12px; margin: 0 15px 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); overflow: hidden;}
        .win-table-header { display: flex; justify-content: space-between; padding: 12px 15px; background: #fff; font-size: 12px; font-weight: bold; color: #777; border-bottom: 2px solid #f7f8fa;}
        .win-table-header div { flex: 1; }
        .win-table-header div:nth-child(2) { text-align: center; }
        .win-table-header div:nth-child(3) { text-align: right; }
        
        .winning-list { height: 300px; overflow: hidden; position: relative; padding: 0 15px; background: #fff;}
        .winning-list::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 30px; background: linear-gradient(to bottom, transparent, #fff); pointer-events: none;}
        .winning-track { animation: scrollUp 25s linear infinite; display: flex; flex-direction: column;}
        
        .win-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px dashed #f5f5f5; }
        .win-item:last-child { border-bottom: none; }
        .win-col-1 { flex: 1.2; display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: bold; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .win-col-1 img { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; background: #f0f0f0; }
        .win-col-2 { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; font-weight: 600; color: #333; }
        .win-col-2 img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: #f0f0f0; }
        .win-col-3 { flex: 1; text-align: right; font-size: 13px; font-weight: 800; color: var(--primary); }
        @keyframes scrollUp { 0% { transform: translateY(0); } 100% { transform: translateY(-50%); } }

        /* TERMS */
        .terms-wrap { padding: 25px 15px; border-top: 1px solid #eee; background: #fff; text-align: center; }
        .cert-icon { width: 65px; margin-bottom: 20px;}
        .terms-txt-p { display: flex; align-items: flex-start; gap: 8px; font-size: 11px; color: #999; line-height: 1.6; text-align: left; margin-bottom: 12px;}
        .terms-txt-p svg { width: 14px; height: 14px; fill: #d0d0d0; flex-shrink: 0; margin-top: 2px;}
        .age-warn { font-size: 11px; font-weight: bold; color: #bbb; margin-top: 5px;}

        /* FLOATING ICONS */
        .floating-menu { position: fixed; right: 15px; bottom: 90px; display: flex; flex-direction: column; gap: 12px; z-index: 999; }
        .float-btn { width: 45px; height: 45px; border-radius: 50%; display: none; align-items: center; justify-content: center; text-decoration: none; overflow: hidden; transition: 0.3s;}
        .float-btn img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 5px rgba(0,0,0,0.2)); }
        .fallback-btn { background: white; box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
        .fallback-chat { background: var(--primary-grad); color: white;}

        /* =========================================
           🔥 BOTTOM NAV (PERFECT RED ACTIVE FIX) 🔥 
           ========================================= */
        .bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: white; height: 65px; display: flex; justify-content: space-around; align-items: center; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); z-index: 1000; border-top: 1px solid #eee; padding-bottom: 5px;}
        
        .nav-item { display: flex; flex-direction: column; align-items: center; color: var(--nav-inactive); font-size: 10px; font-weight: bold; text-decoration: none; transition: 0.2s; gap: 4px;}
        
        /* 🚀 SVG will automatically take the text color (currentColor) 🚀 */
        .nav-item svg { width: 24px; height: 24px; fill: currentColor; transition: 0.3s;}
        
        /* When ACTIVE, text and SVG become RED */
        .nav-item.active { color: var(--primary); }
        
        /* Promotion Diamond specific styling */
        .nav-promo { position: relative; top: -15px; }
        .promo-circle { width: 50px; height: 50px; background: var(--card-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 -4px 10px rgba(0,0,0,0.05); color: var(--nav-inactive); transition: 0.3s;}
        .promo-circle svg { width: 28px; height: 28px; fill: currentColor; }
        
        /* Promo Diamond Active State */
        .nav-item.active .promo-circle { background: var(--primary-grad); color: #fff; border: 3px solid #fff; box-shadow: 0 4px 10px rgba(243, 89, 91, 0.3); }
        
        .promo-tag { font-size: 9px; color: var(--nav-inactive); background: #f0f0f0; font-weight: bold; padding: 2px 8px; border-radius: 10px; margin-top: -5px; position: relative; z-index: 2; text-transform: uppercase; transition: 0.3s;}
        .nav-item.active .promo-tag { color: #000; background: linear-gradient(135deg, #F6D365, #FDA085); }
    </style>
</head>
<body>

    <svg xmlns="http://www.w3.org/2000/svg" style="display: none; width: 0; height: 0; position: absolute; visibility: hidden;">
        <symbol id="icon-notice" viewBox="0 0 24 24"><path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"/></symbol>
        <symbol id="icon-point" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></symbol>
        
        <symbol id="icon-wg_home" viewBox="0 0 40 41" fill="none">
            <path d="M11.4893 13.611C10.8243 13.6042 10.1723 13.7952 9.61611 14.1598C9.05989 14.5243 8.62455 15.0459 8.36537 15.6584C8.10619 16.2708 8.03487 16.9465 8.16046 17.5996C8.28604 18.2526 8.60288 18.8537 9.07072 19.3263C9.53857 19.799 10.1363 20.1219 10.7881 20.2541C11.4398 20.3864 12.1162 20.322 12.7313 20.0691C13.3463 19.8161 13.8723 19.3861 14.2425 18.8337C14.6128 18.2812 14.8104 17.6312 14.8105 16.9661C14.8083 16.0828 14.4588 15.2358 13.8374 14.6081C13.216 13.9803 12.3726 13.6221 11.4893 13.611Z" fill="currentColor"/>
            <path d="M39.9999 11.2266C39.9976 9.30527 39.2334 7.46332 37.8748 6.10476C36.5163 4.74619 34.6743 3.98197 32.753 3.97971H27.5329C26.9884 3.97295 26.4535 4.12262 25.9915 4.41094C25.5296 4.69926 25.1602 5.11411 24.9271 5.60621C24.6827 6.13525 24.2925 6.58366 23.8023 6.89888C23.3121 7.2141 22.7423 7.38307 22.1595 7.38599H17.6802C17.1118 7.35058 16.5639 7.16052 16.0956 6.83634C15.6273 6.51216 15.2566 6.06618 15.0233 5.5466C14.7802 5.07782 14.4139 4.68421 13.9637 4.40812C13.5136 4.13203 12.9967 3.98391 12.4686 3.97971H7.08672C5.16542 3.98197 3.32347 4.74619 1.96491 6.10476C0.606346 7.46332 -0.157883 9.30527 -0.160137 11.2266V30.8978C-0.162217 31.7387 0.00311668 32.5716 0.326226 33.3479C0.649336 34.1243 1.12376 34.8285 1.72183 35.4196C2.32519 36.012 3.04002 36.4788 3.82495 36.793C4.60988 37.1073 5.44934 37.2628 6.29476 37.2505C9.8458 37.2505 11.4042 35.8114 12.5708 31.6131L13.8993 27.5767H25.949L27.2859 31.6642C28.5207 35.2919 29.9003 37.259 33.6131 37.259C35.3056 37.2545 36.9275 36.5802 38.1243 35.3834C39.321 34.1867 39.9954 32.5648 39.9999 30.8723V11.2266ZM11.4893 22.7313C10.3491 22.7313 9.23447 22.3932 8.2864 21.7597C7.33833 21.1262 6.5994 20.2258 6.16305 19.1724C5.7267 18.1189 5.61253 16.9597 5.83498 15.8414C6.05743 14.7231 6.60651 13.6959 7.41277 12.8896C8.21904 12.0833 9.24629 11.5342 10.3646 11.3118C11.4829 11.0893 12.6421 11.2035 13.6955 11.6399C14.749 12.0762 15.6494 12.8151 16.2829 13.7632C16.9163 14.7113 17.2545 15.8259 17.2545 16.9661C17.2522 18.4945 16.6441 19.9595 15.5634 21.0402C14.4827 22.1209 13.0176 22.729 11.4893 22.7313ZM32.9148 18.1754H29.5596V21.522C29.5596 21.6808 29.5284 21.8381 29.4676 21.9848C29.4068 22.1315 29.3177 22.2648 29.2055 22.3771C29.0932 22.4894 28.9599 22.5785 28.8132 22.6392C28.6665 22.7 28.5092 22.7313 28.3504 22.7313C28.1916 22.7313 28.0344 22.7 27.8877 22.6392C27.7409 22.5785 27.6076 22.4894 27.4954 22.3771C27.3831 21.7619 27.294 22.1315 27.2332 21.9848C27.1725 21.8381 27.1412 21.6808 27.1412 21.522V18.1754H23.786C23.4653 18.1754 23.1577 18.048 22.9309 17.8212C22.7042 17.0915 22.5768 16.7839 22.5768 16.4632C22.5768 16.1425 22.7042 15.8349 22.9309 15.6082C23.1577 15.3814 23.4653 15.7569 23.786 15.7569H27.1412V12.4017C27.1412 12.081 27.2686 11.7735 27.4954 11.5467C27.7221 11.3199 28.0297 11.1925 28.3504 11.1925C28.6711 11.1925 28.9787 11.3199 29.2055 11.5467C29.4322 11.7735 29.5596 12.081 29.5596 12.4017V15.7569H32.9148C33.2355 15.7569 33.5431 15.8843 33.7699 16.1111C33.9966 16.3379 34.124 16.6454 34.124 16.9661C34.124 17.2869 33.9966 17.5944 33.7699 17.8212C33.5431 18.048 33.2355 18.1754 32.9148 18.1754Z" fill="currentColor"/>
        </symbol>
        <symbol id="icon-wg_activity" viewBox="0 0 40 40" fill="none">
            <path fill-rule="evenodd" clip-rule="evenodd" d="M20.2138 8.95674C20.2139 8.34093 19.9981 7.74069 19.5989 7.27016L16.2509 3.32352C13.8088 0.444672 9.19912 2.2197 9.19912 6.03895C9.19912 7.89284 10.4006 9.51984 12.138 10.0187L17.0449 11.4277C18.4915 11.8431 19.9649 10.8615 20.1864 9.33484C20.2047 9.2088 20.2137 9.08245 20.2138 8.95674ZM20.2138 8.95674C20.2138 9.08245 20.2228 9.2088 20.2411 9.33484C20.4626 10.8615 21.936 11.8431 23.3826 11.4277L28.2895 10.0187C30.0269 9.51984 31.2284 7.89284 31.2284 6.03895C31.2284 2.2197 26.6188 0.444672 24.1766 3.32352L20.8286 7.27016C20.4294 7.74069 20.2137 8.34093 20.2138 8.95674Z" fill="currentColor"/>
            <path d="M18.1664 19.9551C18.1664 19.4028 17.7187 18.9551 17.1664 18.9551H4.49829C3.94601 18.9551 3.49829 19.4028 3.49829 19.9551V36.33C3.49829 37.8028 4.69221 38.9967 6.16499 38.9967H17.1664C17.7187 38.9967 18.1664 38.549 18.1664 37.9967L18.1664 19.9551Z" fill="currentColor"/>
            <path d="M21.8339 37.9967C21.8339 38.549 22.2816 38.9967 22.8339 38.9967H33.8352C35.308 38.9967 36.5019 37.8028 36.5019 36.33V19.9551C36.5019 19.4028 36.0542 18.9551 35.5019 18.9551H22.8339C22.2816 18.9551 21.8339 19.4028 21.8339 19.9551L21.8339 37.9967Z" fill="currentColor"/>
            <path d="M1.99805 11.2051C1.99805 10.3766 2.66962 9.70508 3.49805 9.70508H36.502C37.3304 9.70508 38.002 10.3767 38.002 11.2051V14.3717C38.002 15.2002 37.3304 15.8717 36.502 15.8717H3.49805C2.66962 15.8717 1.99805 15.2002 1.99805 14.3717V11.2051Z" fill="currentColor"/>
        </symbol>
        <symbol id="icon-wg_promotion" viewBox="0 0 40 40" fill="none">
            <path d="M18.5142 4.69585L12.4561 10.7481L12.169 11.0488C8.98571 14.6677 9.11851 19.927 12.4132 23.2216C13.9519 24.7604 16.0068 25.6735 18.1801 25.7843C20.3534 25.895 22.4906 25.1955 24.1778 23.8212L24.3672 23.6591L24.7832 23.2763L26.91 21.1495L32.4349 26.6725L22.7677 36.3396C22.0353 37.0719 21.042 37.4832 20.0063 37.4832C18.9705 37.4832 17.9772 37.0719 17.2448 36.3396L3.43736 22.5322C1.35745 20.455 0.134259 17.6718 0.0104128 14.7349C-0.113434 11.7979 0.871112 8.92173 2.76876 6.67675C4.66641 4.43178 7.33853 2.98204 10.2551 2.61512C13.1717 2.24819 16.1196 2.99087 18.5142 4.69585ZM36.2783 5.67428L36.6122 5.99652L36.7372 6.12542L37.0107 6.41445C37.3544 6.79723 37.6707 7.19954 37.9559 7.61357L37.7782 7.36164C37.8778 7.5003 37.9754 7.64091 38.0711 7.78348L37.9559 7.61357C38.0633 7.76981 38.1648 7.92604 38.2625 8.08228L38.0711 7.78348C38.1551 7.91042 38.2352 8.03736 38.3133 8.16821L38.2625 8.08228C38.3445 8.21703 38.4246 8.35179 38.5027 8.48849L38.3133 8.16821C38.4129 8.33031 38.5086 8.49631 38.5984 8.66231L38.5008 8.48849C38.573 8.61544 38.6414 8.74238 38.7078 8.86932L38.5984 8.66231C38.6765 8.80878 38.7546 8.95525 38.8269 9.10563L38.7097 8.87127C38.7976 9.04118 38.8796 9.21304 38.9597 9.38686L38.8269 9.10563C38.8913 9.23843 38.9538 9.37318 39.0124 9.50794L38.9597 9.38686C39.0417 9.56848 39.1198 9.74815 39.1921 9.93368L39.0124 9.50794C39.89 11.5138 40.1912 13.7245 39.8821 15.8919C39.573 18.0594 38.6659 20.0978 37.2626 21.7784L36.915 22.1807L36.7294 22.3721L36.579 22.5322L33.8156 25.2917L28.2926 19.7688C27.9264 19.4027 27.4298 19.197 26.9119 19.197C26.3941 19.197 25.8974 19.4027 25.5312 19.7688L23.461 21.8409L23.0939 22.1787L22.9435 22.3076C21.6312 23.3763 19.9691 23.9202 18.2789 23.834C16.5887 23.7477 14.9906 23.0376 13.7939 21.8409C11.341 19.388 11.1262 15.5055 13.3193 12.7127L13.583 12.3964L13.8369 12.1288L20.057 5.91059L20.1254 5.84419L20.4496 5.53953C20.6933 5.31944 20.9461 5.10964 21.2073 4.91068L20.9554 5.10988C21.0921 5.00051 21.2288 4.89505 21.3655 4.79155L21.2093 4.91068C21.3323 4.81694 21.4573 4.72515 21.5842 4.63726L21.3675 4.7935C21.5059 4.69146 21.6465 4.59248 21.7893 4.49665L21.5842 4.63726C21.7164 4.54399 21.8506 4.45349 21.9865 4.3658L21.7893 4.49665C21.9299 4.40291 22.0705 4.31307 22.2131 4.22519L21.9865 4.3658C22.1233 4.27987 22.26 4.19589 22.3986 4.11582L22.2131 4.22519C22.3537 4.13926 22.4963 4.05724 22.6408 3.97912L22.3986 4.11582C22.5392 4.0338 22.6818 3.95373 22.8244 3.87952L22.6408 3.97716C22.7775 3.90295 22.9181 3.82874 23.0587 3.75843L22.8244 3.87952C22.965 3.8053 23.1075 3.73304 23.2501 3.66469L23.0587 3.75843L23.4923 3.55337L23.2501 3.66469C23.4005 3.59438 23.5528 3.52603 23.7052 3.45963L23.4923 3.55337C23.6427 3.48697 23.795 3.42252 23.9473 3.36198L23.7052 3.45963C23.8594 3.39518 24.0137 3.33269 24.17 3.2741L23.9473 3.36198C26.0117 2.54719 28.2642 2.33213 30.4455 2.74157C32.6267 3.15101 34.648 4.16829 36.2763 5.67624L36.2783 5.67428Z" fill="currentColor"/>
        </symbol>
        <symbol id="icon-wallet2" viewBox="0 0 36 36" fill="none">
            <path fill-rule="evenodd" clip-rule="evenodd" d="M13.4844 8.97668L23.8363 3L27.2956 8.99168L13.4844 8.97668Z" fill="currentColor"/>
            <path d="M3 10.5C3 9.67155 3.67157 9 4.5 9H31.5C32.3284 9 33 9.67155 33 10.5V31.5C33 32.3284 32.3284 33 31.5 33H4.5C3.67157 33 3 32.3284 3 31.5V10.5Z" fill="currentColor"/>
            <path fill-rule="evenodd" clip-rule="evenodd" d="M33.5625 25.5H27C24.8254 25.5 23.0625 23.8211 23.0625 21.75C23.0625 19.679 24.8254 18 27 18H33.5625V25.5ZM26.3848 22.75C27.0061 22.75 27.5098 22.2463 27.5098 21.625C27.5098 21.0037 27.0061 20.5 26.3848 20.5C25.7634 20.5 25.2598 21.0037 25.2598 21.625C25.2598 22.2463 25.7634 22.75 26.3848 22.75Z" fill="currentColor"/>
        </symbol>
        <symbol id="icon-user" viewBox="0 0 48 48" fill="none">
            <path d="M24 24C26.6522 24 29.1957 22.9464 31.0711 21.0711C32.9464 19.1957 34 16.6522 34 14C34 11.3478 32.9464 8.8043 31.0711 6.92893C29.1957 5.05357 26.6522 4 24 4C21.3478 4 18.8043 5.05357 16.9289 6.92893C15.0536 8.8043 14 11.3478 14 14C14 16.6522 15.0536 19.1957 16.9289 21.0711C18.8043 22.9464 21.3478 24 24 24Z" fill="currentColor"/>
            <path d="M6 44C6 35.1634 13.1634 28 22 28H26C34.8366 28 42 35.1634 42 44H6Z" fill="currentColor"/>
        </symbol>
    </svg>

    <div class="app-header">
        <div class="logo" id="siteLogoBox">
            <i class="fas fa-gem"></i> <span id="siteNameText">Loading...</span>
        </div>
        <div id="headerAuthArea">
            <i class="fas fa-spinner fa-spin text-muted"></i>
        </div>
    </div>

    <div class="notice-bar">
        <svg class="notice-icon"><use href="#icon-notice"></use></svg>
        <div class="notice-text">
            <div class="notice-content">
                Welcome to our platform! Enjoy fair games, instant deposits, and 24/7 self-service support. Gambling can be addictive, please play rationally. Only for users above 18.
            </div>
        </div>
    </div>

    <div class="swiper mySwiper">
        <div class="swiper-wrapper" id="bannerContainer">
            <div class="swiper-slide"><div class="banner-loading"><i class="fas fa-spinner fa-spin fs-3"></i></div></div>
        </div>
        <div class="swiper-pagination"></div>
    </div>

    <div class="wallet-box">
        <div class="w-left">
            <div class="w-label">
                <svg viewBox="0 0 24 24"><path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.11.89-2 2-2h14c1.1 0 2 .89 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"/></svg>
                Wallet balance
            </div>
            <div class="w-amt bahnschrift">
                ₹<span id="walletBalanceText">0.00</span>
                <svg class="refresh-btn" id="refreshBtn" viewBox="0 0 24 24"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>
            </div>
        </div>
        <div class="w-right">
            <a href="withdraw.php" class="btn-action btn-withdraw">
                <svg viewBox="0 0 24 24"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>
                Withdraw
            </a>
            <a href="deposit.php" class="btn-action btn-deposit">
                <svg viewBox="0 0 24 24"><path d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"/></svg>
                Deposit
            </a>
        </div>
    </div>

    <div class="cat-nav" id="categoryContainer">
        <div class="cat-tab active" onclick="filterGames('all', this)">
            <i class="fas fa-fire me-1" style="color:var(--primary);"></i> Lobby
        </div>
    </div>

    <div class="sec-title">
        <svg viewBox="0 0 24 24"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>
        Recommended Games
    </div>
    <div class="game-grid" id="gamesContainer"></div>

    <div class="sec-title">
        <i class="fas fa-trophy text-warning me-1"></i> Live Winning Ranking
    </div>
    <div class="winning-wrap">
        <div class="win-table-header">
            <div>Game</div>
            <div>User</div>
            <div>Winning amount</div>
        </div>
        <div class="winning-list">
            <div class="winning-track" id="winTrack">
                <div class="text-center text-muted py-5"><i class="fas fa-spinner fa-spin fs-4"></i></div>
            </div>
        </div>
    </div>

    <div class="terms-wrap">
        <svg class="cert-icon" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg">
            <circle cx="35" cy="35" r="33" stroke="#FA2221" stroke-width="4"></circle>
            <path d="M25.38 33.7v3.19H12.71v-3.19H25.38zM20.78 28.69v13.45H17.32V28.69h3.46zM36.35 25.48V44h-3.66V29.69l-4.39 1.4v-2.88l7.65-2.73h.4zM54.82 38.93c0 1.16-.27 2.14-.81 2.93-.54.79-1.29 1.39-2.24 1.79-.94.4-2.01.6-3.2.6-1.19 0-2.26-.2-3.21-.6-.95-.4-1.7-.1-2.25-.89-.55-.79-.82-1.77-.82-2.93 0-.78.16-1.48.47-2.11.31-.63.75-1.17 1.31-1.62.56-.46 1.23-.81 1.99-1.04.76-.24 1.59-.37 2.49-.37 1.2 0 2.28.21 3.22.63.95.42 1.7.1 2.24.79.54.77.81 1.68.81 2.72zm-3.68-.24c0-.57-.11-1.05-.33-1.46-.21-.41-.51-.73-.9-.95-.39-.22-.84-.33-1.36-.33-.52 0-.97.11-1.36.33-.39.22-.69.54-.9.95-.21.41-.32.89-.32 1.46 0 .56.11 1.04.32 1.45.21.41.51.72.9.94.4.22.86.33 1.38.33.52 0 .97-.11 1.36-.33.39-.22.69-.53.9-.94.21-.41.31-.89.31-1.45zm3.29-8.27c0 .94-.25 1.77-.75 2.5-.5.72-1.19 1.28-2.08 1.69-.88.4-1.89.6-3.02.6-1.14 0-2.16-.2-3.05-.6-.89-.4-1.58-.97-2.08-1.69-.5-.73-.75-1.56-.75-2.5 0-1.12.25-2.06.75-2.82.51-.77 1.2-1.35 2.08-1.75.89-.4 1.9-.6 3.03-.6 1.14 0 2.15.2 3.04.6.89.4 1.58.98 2.08 1.75.51.76.76 1.7.76 2.82zm-3.66.16c0-.5-.09-.93-.27-1.3-.18-.37-.43-.66-.76-.86-.32-.2-.72-.3-1.19-.3-.46 0-.85.1-1.18.3-.32.19-.57.48-.75.85-.17.37-.25.81-.25 1.32 0 .5.09.94.26 1.31.18.37.43.66.76.87.33.21.73.32 1.19.32.47 0 .86-.11 1.18-.32.33-.21.58-.5.75-.87.18-.37.26-.81.26-1.3z" fill="#FA2221"/>
        </svg>

        <div class="terms-txt-p"><svg><use href="#icon-point"></use></svg><span>The platform advocates fairness, justice, and openness. We mainly operate fair lottery, blockchain games, live casinos, and slot machine games.</span></div>
        <div class="terms-txt-p"><svg><use href="#icon-point"></use></svg><span>Works with more than 10,000 online live game dealers and slot games, all of which are verified fair games.</span></div>
        <div class="terms-txt-p"><svg><use href="#icon-point"></use></svg><span>Supports fast deposit and withdrawal, and looks forward to your visit.</span></div>
        <div class="age-warn">Gambling can be addictive, please play rationally.</div>
        <div class="age-warn">Accepts customers above the age of 18.</div>
    </div>

    <div class="floating-menu">
        <a href="spin.php" class="float-btn" id="floatSpinBtn"></a>
        <a href="#" class="float-btn" id="floatTelegramBtn" target="_blank"></a>
        <a href="support.php" class="float-btn" id="floatChatBtn"></a>
    </div>

    <div class="bottom-nav">
        <a href="index.php" class="nav-item active">
            <svg class="nav-svg"><use href="#icon-wg_home"></use></svg>
            <div>Home</div>
        </a>
        <a href="activity.php" class="nav-item">
            <svg class="nav-svg"><use href="#icon-wg_activity"></use></svg>
            <div>Activity</div>
        </a>
        <a href="promotion.php" class="nav-item nav-promo text-center">
            <div class="promo-circle">
                <svg width="28" height="28" fill="#fff"><use href="#icon-wg_promotion"></use></svg>
            </div>
            <div class="promo-tag">Promotion</div>
        </a>
        <a href="wallet.php" class="nav-item">
            <svg class="nav-svg"><use href="#icon-wallet2"></use></svg>
            <div>Wallet</div>
        </a>
        <a href="profile.php" class="nav-item">
            <svg class="nav-svg"><use href="#icon-user"></use></svg>
            <div>Account</div>
        </a>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/swiper@10/swiper-bundle.min.js"></script>
    <script>
        let swiper;
        function initSwiper() {
            swiper = new Swiper('.mySwiper', { 
                loop: true, autoplay: { delay: 3000, disableOnInteraction: false }, 
                pagination: { el: '.swiper-pagination', clickable: true },
                observer: true, observeParents: true
            });
        }

        // 1. FAST PROFILE FETCH
        function loadProfileData() {
            const refreshIcon = document.getElementById('refreshBtn');
            if(refreshIcon) refreshIcon.classList.add('spin');
            
            fetch('getuserinfo.php')
                .then(res => res.json())
                .then(res => {
                    const authArea = document.getElementById('headerAuthArea');
                    if(res.code === 0 && res.isLoggedIn) {
                        authArea.innerHTML = `<a href="profile.php"><img src="assets/images/default.png" class="profile-icon-img" alt="User" onerror="this.src='https://dd.55dk.site/assets/images/games/default-game.png'"></a>`;
                        document.getElementById('walletBalanceText').innerText = parseFloat(res.data.balance).toFixed(2);
                    } else {
                        authArea.innerHTML = `<a href="login.php" class="btn btn-sm" style="background:var(--primary-grad); color:white; font-weight:800; border-radius:6px; border:none; padding:6px 16px;">Log in</a>`;
                    }
                    setTimeout(() => { if(refreshIcon) refreshIcon.classList.remove('spin'); }, 500);
                }).catch(e => {
                    setTimeout(() => { if(refreshIcon) refreshIcon.classList.remove('spin'); }, 500);
                });
        }
        loadProfileData();
        document.getElementById('refreshBtn').addEventListener('click', loadProfileData);

        // 2. FETCH SETTINGS & RENDER FLOATING ICONS
        fetch('gethomeseting.php')
            .then(res => res.json())
            .then(res => {
                if(res.code === 0) {
                    const conf = res.data;
                    document.title = conf.projectName || 'Home';
                    document.getElementById('siteNameText').innerText = conf.projectName;
                    // Favicon from admin
                    if(conf.faviconUrl) {
                        let link = document.querySelector('link[rel="icon"]') || document.createElement('link');
                        link.rel = 'icon';
                        link.href = conf.faviconUrl;
                        if(!document.querySelector('link[rel="icon"]')) document.head.appendChild(link);
                        else document.head.querySelector('link[rel="icon"]').href = conf.faviconUrl;
                    }
                    // Logo in header from admin
                    const logoBox = document.getElementById('siteLogoBox');
                    if(conf.projectLogo && logoBox) {
                        logoBox.innerHTML = '<img src="' + conf.projectLogo + '" alt="" style="height:28px;object-fit:contain;" onerror="this.style.display=\'none\'"> <span id="siteNameText">' + (conf.projectName || '') + '</span>';
                    }
                    // Theme from admin (primary color & box shadow)
                    if(conf.primaryColor) document.documentElement.style.setProperty('--primary', conf.primaryColor);
                    if(conf.boxShadow) {
                        const shadows = { soft: '0 2px 8px rgba(0,0,0,0.04)', medium: '0 4px 16px rgba(0,0,0,0.08)', strong: '0 6px 24px rgba(0,0,0,0.12)' };
                        document.documentElement.style.setProperty('--shadow-sm', shadows[conf.boxShadow] || shadows.soft);
                    }
                    if(conf.isOpenTurntable || conf.homeBigTurntableSwitch) { 
                        const spinBtn = document.getElementById('floatSpinBtn');
                        spinBtn.style.display = 'flex'; 
                        if(conf.homeBigTurntableImgUrl) {
                            spinBtn.innerHTML = `<img src="${conf.homeBigTurntableImgUrl}" alt="Spin">`;
                        } else {
                            spinBtn.innerHTML = `<i class="fas fa-dharmachakra text-danger fs-4"></i>`;
                            spinBtn.classList.add('fallback-btn');
                        }
                    }
                    
                    if(conf.telegramExternalLink && conf.telegramExternalLink.trim() !== "") {
                        const tgBtn = document.getElementById('floatTelegramBtn');
                        tgBtn.style.display = 'flex'; 
                        tgBtn.href = conf.telegramExternalLink;
                        if(conf.telegramImgUrl) {
                            tgBtn.innerHTML = `<img src="${conf.telegramImgUrl}" alt="Telegram" onerror="this.innerHTML='<i class=\\'fab fa-telegram-plane text-primary fs-4\\'></i>'; this.classList.add('fallback-btn');">`;
                        } else {
                            tgBtn.innerHTML = `<i class="fab fa-telegram-plane text-primary fs-4"></i>`;
                            tgBtn.classList.add('fallback-btn');
                        }
                    }
                    
                    if(conf.isSelfCustomerService || conf.customerServiceLink) {
                        const chatBtn = document.getElementById('floatChatBtn');
                        chatBtn.style.display = 'flex'; 
                        chatBtn.href = conf.customerServiceLink || 'support.php';
                        if(conf.customerServiceImgUrl) {
                            chatBtn.innerHTML = `<img src="${conf.customerServiceImgUrl}" alt="Chat" onerror="this.innerHTML='<i class=\\'fas fa-headset\\'></i>'; this.classList.add('fallback-chat');">`;
                        } else {
                            chatBtn.innerHTML = `<i class="fas fa-headset"></i>`;
                            chatBtn.classList.add('fallback-btn', 'fallback-chat');
                        }
                    }
                }
            }).catch(e => console.log("Settings error"));

        // 3. FETCH BANNERS
        fetch('getbanner.php')
            .then(res => res.json())
            .then(res => {
                if(res.success && res.data.length > 0) {
                    let html = '';
                    res.data.forEach(b => {
                        html += `<div class="swiper-slide"><img src="assets/images/banners/${b.image}" onerror="this.style.display='none'"></div>`;
                    });
                    document.getElementById('bannerContainer').innerHTML = html;
                    initSwiper();
                } else {
                    document.getElementById('bannerContainer').innerHTML = '<div class="swiper-slide"><div class="banner-loading">No Banners</div></div>';
                }
            });

        // 4. FETCH CATEGORIES
        fetch('getcatrya.php')
            .then(res => res.json())
            .then(res => {
                if(res.success && res.data.length > 0) {
                    let html = `
                    <div class="cat-tab active" onclick="filterGames('all', this)">
                        <i class="fas fa-fire me-1" style="color:var(--primary);"></i> Lobby
                    </div>`;
                    res.data.forEach(c => {
                        let mediaContent = '';
                        if (c.image && c.image !== '') {
                            mediaContent = `<img src="assets/images/categories/${c.image}" alt="${c.name}" onerror="this.outerHTML='<span class=\\'cat-icon-placeholder\\'><i class=\\'fas fa-gamepad\\'></i></span>'">`;
                        } else {
                            mediaContent = `<span class="cat-icon-placeholder"><i class="fas fa-${c.icon || 'gamepad'}"></i></span>`;
                        }
                        html += `<div class="cat-tab" onclick="filterGames('${c.id}', this)">${mediaContent} ${c.name}</div>`;
                    });
                    document.getElementById('categoryContainer').innerHTML = html;
                }
            });

        // 5. FETCH GAMES
        fetch('getallgamelist.php')
            .then(res => res.json())
            .then(res => {
                if(res.success && res.data.length > 0) {
                    let html = '';
                    res.data.forEach(g => {
                        let fileName = (g.game_file && g.game_file.trim() !== '') ? g.game_file : g.type;
                        
                        html += `
                        <a href="games/${fileName}.php?id=${g.id}" class="game-card" data-category="${g.category_id}">
                            <img src="assets/images/games/${g.image}" onerror="this.src='assets/images/games/default.png'">
                            <div class="game-card-title">${g.name}</div>
                        </a>`;
                    });
                    document.getElementById('gamesContainer').innerHTML = html;
                }
            });

        // 6. FETCH WINNINGS
        fetch('getwining.php')
            .then(res => res.json())
            .then(res => {
                if(res.code === 0 && res.data.length > 0) {
                    let html = '';
                    const loopData = [...res.data, ...res.data]; 
                    loopData.forEach(win => {
                        html += `
                        <div class="win-item">
                            <div class="win-col-1">
                                <img src="assets/images/games/${win.gameImage}" onerror="this.src='assets/images/games/default-icon.png'">
                                ${win.gameName}
                            </div>
                            <div class="win-col-2">
                                <img src="assets/images/face.png" onerror="this.src='assets/images/default.png'">
                                ${win.userName}
                            </div>
                            <div class="win-col-3 bahnschrift">₹${parseFloat(win.winAmount).toFixed(2)}</div>
                        </div>`;
                    });
                    document.getElementById('winTrack').innerHTML = html;
                }
            });

        function filterGames(catId, el) {
            document.querySelectorAll('.cat-tab').forEach(item => item.classList.remove('active'));
            el.classList.add('active');
            
            document.querySelectorAll('.game-card').forEach(game => {
                if(catId === 'all' || game.getAttribute('data-category') === catId) {
                    game.classList.remove('hidden-game');
                } else {
                    game.classList.add('hidden-game');
                }
            });
        }
    </script>
</body>
</html>