fix this so  that there is a working bet  button, and I cannot see input values well at all, make sure its fully functional and dont leave any info outin your response, (function() {
    // Load jQuery if not already loaded
    if (typeof jQuery === 'undefined') {
        var script = document.createElement('script');
        script.src = "https://code.jquery.com/jquery-3.6.0.min.js";
        script.onload = function() {
            console.log("jQuery loaded.");
            initializeScript();
        };
        document.head.appendChild(script);
    } else {
        initializeScript();
    }

    function initializeScript() {
        // CSS Styles for Dark Theme and Responsive Design
        const cssStyles = `
        /* Dark Theme Styles */
        body {
            background-color: #121212;
            color: #e0e0e0;
        }

        #injectedHtml .divContentContainer {
            background-color: #1e1e1e;
            color: #e0e0e0;
            position: fixed !important;
            z-index: 2000 !important;
            top: 10px;
            left: 10px;
            right: 10px;
            max-width: 400px;
            border: 1px solid #333;
            border-radius: 8px;
            overflow: hidden;
        }

        #injectedHtml .divContentContainer table {
            width: 100%;
            border-collapse: collapse;
        }

        #injectedHtml .divContentContainer td {
            padding: 5px;
            text-align: center;
            border: 1px solid #333;
        }

        #injectedHtml .divContentContainer input[type="text"],
        #injectedHtml .divContentContainer select {
            width: 100%;
            padding: 8px;
            background-color: #2c2c2c;
            border: 1px solid #444;
            color: #e0e0e0;
            border-radius: 4px;
        }

        #injectedHtml .divContentContainer button {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            background: linear-gradient(45deg, #ff6b6b, #f94d6a);
            border: none;
            color: #fff;
            font-weight: bold;
            border-radius: 4px;
            cursor: pointer;
            margin-top: 10px;
        }

        #injectedHtml .divContentContainer button:hover {
            background: linear-gradient(45deg, #f94d6a, #ff6b6b);
        }

        #injectedHtml .divContentContainer a {
            color: #ff6b6b;
            cursor: pointer;
        }

        /* Responsive Design */
        @media (max-width: 600px) {
            #injectedHtml .divContentContainer {
                top: 0;
                left: 0;
                right: 0;
                max-width: none;
                border-radius: 0;
            }

            #injectedHtml .divContentContainer table {
                font-size: 14px;
            }

            #injectedHtml .divContentContainer button {
                font-size: 14px;
            }
        }

        /* Gradient Buttons & Borders */
        #injectedHtml .divContentContainer td {
            border: 1px solid #444;
            background: #1e1e1e;
        }

        #injectedHtml .divContentContainer td:hover {
            background: #2c2c2c;
        }
        `;

        // Inject CSS styles
        const styleTag = document.createElement("style");
        styleTag.textContent = cssStyles;
        document.head.appendChild(styleTag);

        // HTML Content with New Features and Improved Layout
        var popupHtml = `
        <div id="injectedHtml">
            <div class="divContentContainer">
                <div>
                    <table>
                        <tr>
                            <td colspan="2" style="background-color: #333;">
                                <a id='aCollasp' onclick='$("#divContent").toggle();' style="font-weight: bold;">Keno Hit Map Show/Hide</a>
                            </td>
                            <td style="background-color: #333;">
                                <a id="aClosePopup" title='Close Popup' onclick='$("#injectedHtml").toggle();' style="font-weight: bold;">X</a>
                            </td>
                        </tr>
                    </table>
                </div>
                <div id='divContent'>
                    <!-- Keno Board -->
                    <table id="kenoBoard">
                        ${[...Array(8)].map((_, row) => `
                            <tr>
                                ${[...Array(5)].map((_, col) => {
                                    let num = row * 5 + col + 1;
                                    return `<td id='num${num}'>${num}</td>`;
                                }).join('')}
                            </tr>
                        `).join('')}
                    </table>

                    <!-- Controls -->
                    <table style="margin-top: 10px;">
                        <tr>
                            <td colspan="2">
                                <input type='radio' id='rbColdMap' name="TemperatureMap" value="coldMap" checked onchange="ColorBasedOnHitHouse()">
                                <label for="rbColdMap">Coldest Numbers</label>
                                <input type='radio' id='rbHotMap' name="TemperatureMap" value="hotMap" onchange="ColorBasedOnHitHouse()">
                                <label for="rbHotMap">Hottest Numbers</label>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input type='checkbox' id='onlyChangeOnHit' onchange="toggleOnlyChangeOnHit()">
                                <label for="onlyChangeOnHit">Only Change on Hit</label>
                            </td>
                        </tr>
                        <tr>
                            <td>Auto Strategy Type:</td>
                            <td>
                                <select id='kenoGameType' onchange='GameTypeChanged()'>
                                    <option value='coldest'>Top X Coldest Numbers</option>
                                    <option value='hottest'>Top X Hottest Numbers</option>
                                    <option value='random'>X Random Numbers</option>
                                    <option value='alternate'>Alternate Hot/Cold Each Win</option>
                                    <option value='both'>Pairs of Hot and Cold Numbers</option>
                                    <option value='pick'>Pick Your Own Numbers</option>
                                </select>
                            </td>
                        </tr>
                        <tr id='manualInput' style="display:none;">
                            <td>Enter Your Numbers (comma-separated):</td>
                            <td><input id="manualInputNumbers" type="text" placeholder="e.g., 1,5,12"></td>
                        </tr>
                        <tr id='numbersToPick'>
                            <td>Number of Numbers to Pick:</td>
                            <td><input id="numOfNums" type="number" value="1" min="1" max="40"></td>
                        </tr>
                        <tr>
                            <td>King of the Hill:</td>
                            <td>
                                <select id='kingOfHill' onchange="selectKingOfHill()">
                                    <option value='full'>Full Board</option>
                                    <option value='topHalf'>Top Half</option>
                                    <option value='bottomHalf'>Bottom Half</option>
                                    <option value='left'>Left Side</option>
                                    <option value='right'>Right Side</option>
                                    <option value='topLeftNine'>Top Left Nine</option>
                                    <option value='topRightNine'>Top Right Nine</option>
                                    <option value='middle'>Middle Section</option>
                                    <option value='bottomRightNine'>Bottom Right Nine</option>
                                    <option value='bottomLeftNine'>Bottom Left Nine</option>
                                    <option value='auto'>Auto Sector</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Number of Games to Play:</td>
                            <td><input id='numberOfGames' type='number' value='200' min="0"></td>
                        </tr>
                        <tr>
                            <td>Base Bet:</td>
                            <td><input id='baseBet' type='number' step="any" placeholder="Use game input"></td>
                        </tr>
                        <tr>
                            <td>Use B2B:</td>
                            <td><input id="useb2b" type="checkbox"></td>
                        </tr>
                        <tr>
                            <td>Percentage of Bankroll for Base Bet:</td>
                            <td><input id='baseBetPercentage' type='number' step="any" value='0.0'></td>
                        </tr>
                        <tr>
                            <td>On Win:</td>
                            <td>
                                <label><input id="resetOnWin" type="checkbox" checked onchange="handleResetCheckbox('resetOnWin', 'onWinMultiplier')"> Reset</label>
                                <label>or Multiply By:</label>
                                <input id="onWinMultiplier" type="number" step="any" disabled>
                            </td>
                        </tr>
                        <tr>
                            <td>On Lose:</td>
                            <td>
                                <label><input id="resetOnLose" type="checkbox" onchange="handleResetCheckbox('resetOnLose', 'onLoseMultiplier')"> Reset</label>
                                <label>or Multiply By:</label>
                                <input id="onLoseMultiplier" type="number" step="any" value="1.35">
                            </td>
                        </tr>
                        <tr>
                            <td>Max Losses Before Skip:</td>
                            <td><input id="maxLossesBeforeSkip" type="number" value="10"></td>
                        </tr>
                        <tr>
                            <td>Stop Loss Amount:</td>
                            <td><input id="stopLossCoinAmount" type="number" step="any" value="20"></td>
                        </tr>
                        <tr>
                            <td>Autovault Threshold:</td>
                            <td><input id="autovaultThreshold" type="number" step="any" value="10"></td>
                        </tr>
                        <tr>
                            <td>Recommended Bet:</td>
                            <td><span id="recommendedBet">N/A</span></td>
                        </tr>
                        <tr>
                            <td>Game Number:</td>
                            <td><label id="lblGameNumber">0</label></td>
                        </tr>
                        <tr>
                            <td>Net Profit:</td>
                            <td><label id="lblNetProfit">0</label></td>
                        </tr>
                        <tr>
                            <td>Current Lose Streak:</td>
                            <td><label id="lblCurrentLose">0</label></td>
                        </tr>
                        <tr>
                            <td>Biggest Lose Streak:</td>
                            <td><label id="lblBiggestLoseStreak">0</label></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <button onclick="StartGames()">Start</button>
                                <button id="stopButton" onclick="Stop()">Stop</button>
                                <button onclick="PlaceSingleBet()">Place Single Bet</button>
                            </td>
                        </tr>
                    </table>

                    <!-- Bet History Panel -->
                    <div id="betHistoryPanel" style="margin-top: 20px;">
                        <h3>Bet History <span style="cursor:pointer; color:#ff6b6b;" onclick="toggleBetHistory()">[Toggle]</span></h3>
                        <div id="betHistoryContent" style="display:none;">
                            <table id="betHistoryTable">
                                <thead>
                                    <tr>
                                        <th>Game #</th>
                                        <th>Bet Amount</th>
                                        <th>Payout</th>
                                        <th>Result</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <!-- Bet history rows will be appended here -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        `;

        // Inject HTML content
        $("body").append(popupHtml);

        // JavaScript Functionality with New Features
        var gameObject;

        function InitializeCommonVariables() {
            SetGameObject();
            initializeHtml();
        }

        function SetGameObject() {
            // Assuming 'dg' is the game object provided by nanogames.io
            gameObject = dg;
        }

        function initializeHtml() {
            // Initialization code here if needed
        }

        var lastHit = [];
        var isLastHitInitialized = false;
        var startingBalance = 0;
        var onlyChangeOnHit = false;
        var selectedKingOfHill = 'full';

        function InitializeLastHitVariable() {
            for (let j = 0; j < 40; j++) {
                lastHit.push({ number: j + 1, gamesSinceLastHit: 0, numberOfTimesHit: 0 });
            }
        }

        dg.on('betEnd', (r) => {
            AddGameResultsToLastHit(dg.myBets[0].gameValue.result);
            if (!onlyChangeOnHit || (onlyChangeOnHit && r.profitAmount > 0)) {
                ColorBasedOnHitHouse();
            }
            UpdateBetHistory(r);
            let profitAmount = (r.amount * r.odds) - r.amount;
            VaultWin(profitAmount);
            ProvideRecommendedBet();
        });

        function AddGameResultsToLastHit(gameResults) {
            let results = gameResults.split(',');

            if (results.length < 10) {
                console.log("Invalid game result.");
                return;
            }

            lastHit.sort((a, b) => a.number - b.number);

            for (let i = 0; i < 40; i++) {
                let number = lastHit[i].number.toString();

                if (results.includes(number)) {
                    lastHit[i].gamesSinceLastHit = 0;
                    lastHit[i].numberOfTimesHit += 1;
                } else {
                    lastHit[i].gamesSinceLastHit += 1;
                }
            }
        }

        function ColorBasedOnHitHouse() {
            if ($('#rbColdMap')[0].checked) {
                lastHit.forEach(function(item) {
                    let cellId = 'num' + item.number.toString();
                    let colorValue = Math.min(255, 100 + (item.gamesSinceLastHit * 3));
                    let rgbstring = "rgb(" + colorValue + ", 0, 0)";
                    document.getElementById(cellId).style.backgroundColor = rgbstring;
                });
            } else {
                lastHit.forEach(function(item) {
                    let cellId = 'num' + item.number.toString();
                    let colorValue = Math.min(255, 100 + (item.numberOfTimesHit * 3));
                    let rgbstring = "rgb(0, " + colorValue + ", 0)";
                    document.getElementById(cellId).style.backgroundColor = rgbstring;
                });
            }
        }

        function InitializeLastHitFromHistory() {
            let startingIndex = dg.myBets.length - 1;

            while (startingIndex >= 0) {
                if (dg.myBets[startingIndex] != null) {
                    AddGameResultsToLastHit(dg.myBets[startingIndex].gameValue.result);
                }
                startingIndex -= 1;
                isLastHitInitialized = true;
            }
            ColorBasedOnHitHouse();
        }

        // Variables for game control
        var currentNumGame = 0;
        var baseBet = 0;
        var currentBet = 0;
        var b2bBet = 0;
        var currentLoseStreak = 0;
        var currentLossSinceLastWin = 0;
        var maxLoseStreak = 0;
        var isStopRequested = false;
        var useHottestForAlternate = false;
        var stopLossAmount = 0;

        function Stop() {
            if (isStopRequested) {
                $('#stopButton').text('Stop');
                isStopRequested = false;
                PlayOneGame();
            } else {
                isStopRequested = true;
                $('#stopButton').text('Resume');
            }
        }

        function PlaceSingleBet() {
            // Function to place a single bet
            dg.bet(currentBet);
        }

        function toggleOnlyChangeOnHit() {
            onlyChangeOnHit = $('#onlyChangeOnHit').is(':checked');
        }

        async function StartGames() {
            $('#stopButton').text('Stop');
            isStopRequested = false;
            startingBalance = ss.wallet.dict[ss.wallet.current].amount;
            baseBet = parseFloat($('#baseBet').val()) || dg.amount;
            baseBet = GetBaseBet();
            currentBet = baseBet;
            currentNumGame = 0;
            currentLoseStreak = 0;
            currentLossSinceLastWin = 0;
            await PlayOneGame();
        }

        function GetBaseBet() {
            let percentageValue = parseFloat($('#baseBetPercentage').val());
            if (percentageValue > 0) {
                let currentBalance = ss.wallet.dict[ss.wallet.current].amount;
                return currentBalance * (percentageValue / 100.0);
            } else {
                return baseBet;
            }
        }

        function GetNetProfit() {
            let netProfit = ss.wallet.dict[ss.wallet.current].amount - startingBalance;
            return netProfit.toFixed(8);
        }

        function GameTypeChanged() {
            let gameType = $('#kenoGameType').val();
            if (gameType == "pick") {
                $('#manualInput').show();
                $('#numbersToPick').hide();
            } else {
                $('#manualInput').hide();
                $('#numbersToPick').show();
            }
        }

        function handleResetCheckbox(checkboxId, textboxId) {
            if ($('#' + checkboxId).is(':checked')) {
                $('#' + textboxId).val("");
                $('#' + textboxId).attr('disabled', 'disabled');
            } else {
                $('#' + textboxId).removeAttr('disabled');
            }
        }

        function selectKingOfHill() {
            selectedKingOfHill = $('#kingOfHill').val();
        }

        async function PlayOneGame() {
            if (!isStopRequested && (currentNumGame < parseInt($('#numberOfGames').val()) || parseInt($('#numberOfGames').val()) == 0)) {
                let numberToChoose = parseInt($('#numOfNums').val());
                let gameType = $('#kenoGameType').val();

                // Select numbers based on King of the Hill selection
                let selectionPool = getSelectionPool(selectedKingOfHill);

                if (gameType != 'random') {
                    dg.clearSelect();
                }

                let coldest = lastHit.slice();
                let hottest = lastHit.slice();
                let maxLossesBefore = parseInt($('#maxLossesBeforeSkip').val());
                coldest.sort((a, b) => b.gamesSinceLastHit - a.gamesSinceLastHit);
                hottest.sort((a, b) => b.numberOfTimesHit - a.numberOfTimesHit);

                switch (gameType) {
                    case "coldest":
                        SelectNumbersFromPool(coldest, numberToChoose, selectionPool);
                        break;
                    case "hottest":
                        SelectNumbersFromPool(hottest, numberToChoose, selectionPool);
                        break;
                    case "both":
                        SelectNumbersFromPool(coldest, numberToChoose, selectionPool);
                        SelectNumbersFromPool(hottest, numberToChoose, selectionPool);
                        break;
                    case "random":
                        if (LastBetIsWin() || currentNumGame == 0) {
                            dg.clearSelect();
                            let selectedNums = getRandomNumbers(numberToChoose, selectionPool);
                            selectedNums.forEach((item) => { dg.addItem(item); });
                        }
                        break;
                    case "alternate":
                        if (useHottestForAlternate) {
                            SelectNumbersFromPool(hottest, numberToChoose, selectionPool);
                        } else {
                            SelectNumbersFromPool(coldest, numberToChoose, selectionPool);
                        }
                        break;
                    case "pick":
                        let manualInputNumbers = $('#manualInputNumbers').val().split(',').map(Number);
                        SelectNumbers(manualInputNumbers, manualInputNumbers.length);
                        break;
                    default:
                        break;
                }

                try {
                    if (b2bBet > 0) {
                        await dg.bet(b2bBet);
                    } else {
                        await dg.bet(currentBet);
                    }
                    currentNumGame += 1;
                    await HandleGameResults();
                    UpdateUI();
                    PlayOneGame();
                } catch (error) {
                    console.error("Error during betting:", error);
                    isStopRequested = true;
                }
            }
        }

        function getSelectionPool(section) {
            let pool = [];
            switch (section) {
                case 'full':
                    pool = [...Array(40).keys()].map(i => i + 1);
                    break;
                case 'topHalf':
                    pool = [...Array(20).keys()].map(i => i + 1);
                    break;
                case 'bottomHalf':
                    pool = [...Array(20).keys()].map(i => i + 21);
                    break;
                case 'left':
                    pool = [...Array(8).keys()].reduce((acc, row) => {
                        return acc.concat([row * 5 + 1, row * 5 + 2]);
                    }, []);
                    break;
                case 'right':
                    pool = [...Array(8).keys()].reduce((acc, row) => {
                        return acc.concat([row * 5 + 4, row * 5 + 5]);
                    }, []);
                    break;
                // Add other cases for specific sections
                case 'auto':
                    // Implement logic for auto sector
                    pool = getAutoSector();
                    break;
                default:
                    pool = [...Array(40).keys()].map(i => i + 1);
                    break;
            }
            return pool;
        }

        function getAutoSector() {
            // Logic to automatically select the hottest or coldest sections
            // For simplicity, selecting the top 10 hottest numbers
            let sortedNumbers = lastHit.slice();
            if ($('#rbHotMap').is(':checked')) {
                sortedNumbers.sort((a, b) => b.numberOfTimesHit - a.numberOfTimesHit);
            } else {
                sortedNumbers.sort((a, b) => b.gamesSinceLastHit - a.gamesSinceLastHit);
            }
            return sortedNumbers.slice(0, 10).map(item => item.number);
        }

        function getRandomNumbers(count, pool) {
            let selectedNums = new Set();
            while (selectedNums.size < count) {
                let randomNum = pool[Math.floor(Math.random() * pool.length)];
                selectedNums.add(randomNum);
            }
            return Array.from(selectedNums);
        }

        function LastBetIsWin() {
            let lastGame = dg.myBets[0];
            return (lastGame.profitAmount > 0);
        }

        var b2b = false;
        async function HandleGameResults() {
            let lastGame = dg.myBets[0];
            stopLossAmount = parseFloat($('#stopLossCoinAmount').val());

            if (lastGame.profitAmount > 0) {
                useHottestForAlternate = !useHottestForAlternate;
                currentLossSinceLastWin = 0;
                if ($('#resetOnWin').is(':checked')) {
                    currentBet = GetBaseBet();
                    dg.setAmount(currentBet);
                } else {
                    let multiplier = parseFloat($('#onWinMultiplier').val()) || 1;
                    currentBet *= multiplier;
                }
                currentLoseStreak = 0;
                if (!b2b && $('#useb2b').is(':checked')) {
                    b2b = true;
                    b2bBet = lastGame.profitAmount;
                    dg.setAmount(b2bBet);
                    return;
                }
            } else if (lastGame.profitAmount < 0) {
                currentLoseStreak++;
                currentLossSinceLastWin += currentBet;
                if (currentLoseStreak > maxLoseStreak) {
                    maxLoseStreak = currentLoseStreak;
                }
                if ($('#resetOnLose').is(':checked')) {
                    currentBet = GetBaseBet();
                } else {
                    let multiplier = parseFloat($('#onLoseMultiplier').val()) || 1;
                    currentBet *= multiplier;
                }
            }

            if (currentLossSinceLastWin >= stopLossAmount) {
                if ($('#stopLossResetFromBase').is(':checked')) {
                    currentBet = GetBaseBet();
                } else {
                    isStopRequested = true;
                }
            }
            b2b = false;
            dg.setAmount(currentBet);
        }

        function UpdateUI() {
            $('#lblGameNumber').text(currentNumGame);
            $('#lblNetProfit').text(GetNetProfit());
            $('#lblCurrentLose').text(currentLoseStreak);
            $('#lblBiggestLoseStreak').text(maxLoseStreak);
        }

        function SelectNumbers(numbersArray, numberToSelect) {
            for (let i = 0; i < numberToSelect; i++) {
                let number = numbersArray[i];
                if (number) {
                    dg.addItem(number);
                }
            }
        }

        function SelectNumbersFromPool(numbersArray, numberToSelect, pool) {
            let selectedNumbers = numbersArray.filter(item => pool.includes(item.number || item)).slice(0, numberToSelect);
            dg.clearSelect();
            selectedNumbers.forEach(item => {
                dg.addItem(item.number || item);
            });
        }

        function VaultWin(profitAmount) {
            let threshold = parseFloat($('#autovaultThreshold').val());
            if (profitAmount >= threshold) {
                // Logic to transfer profit to vault
                console.log(`Autovaulting ${profitAmount} coins.`);
                // Implement actual vault logic here
            }
        }

        function ProvideRecommendedBet() {
            // Logic to analyze recent game data and provide bet recommendation
            // For simplicity, showing the top hottest number
            let hottestNumber = lastHit.reduce((prev, current) => {
                return (prev.numberOfTimesHit > current.numberOfTimesHit) ? prev : current;
            });
            $('#recommendedBet').text(`Consider betting on number ${hottestNumber.number}`);
        }

        function UpdateBetHistory(result) {
            let profit = result.profitAmount;
            let amount = result.amount;
            let odds = result.odds;
            let gameNumber = currentNumGame;
            let resultText = profit > 0 ? 'Win' : 'Lose';

            let rowHtml = `
                <tr>
                    <td>${gameNumber}</td>
                    <td>${amount}</td>
                    <td>${(amount * odds).toFixed(2)}</td>
                    <td>${resultText}</td>
                </tr>
            `;

            $('#betHistoryTable tbody').prepend(rowHtml);
        }

        function toggleBetHistory() {
            $('#betHistoryContent').toggle();
        }

        $(document).ready(function() {
            SetGameObject();
            InitializeLastHitVariable();
            InitializeLastHitFromHistory();
            GameTypeChanged();
            selectKingOfHill();
        });
    }
})();