Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>2048 Game</title>
        <link rel="stylesheet" href="coding/css/normalize.css">
        <link rel="stylesheet" href="2048.css">
    </head>
    <body>
        <a href="https://www.facebook.com/omar.keshk.7121" target="_blank"><div class='me'>Made by: Omar Keshk</div></a>
        <table>
            <tr class="row" id=" row1">
                <td class="box" id="box1"></td>
                <td class="box" id="box2"></td>
                <td class="box" id="box3"></td>
                <td class="box" id="box4"></td>
            </tr>
            <tr class="row" id="row2">
                <td class="box" id="box5"></td>
                <td class="box" id="box6"></td>
                <td class="box" id="box7"></td>
                <td class="box" id="box8"></td>
            </tr>     
            <tr class="row" id="row3">
                <td class="box" id="box9"></td>
                <td class="box" id="box10"></td>
                <td class="box" id="box11"></td>
                <td class="box" id="box12"></td>
            </tr>
            <tr class="row" id="row4">
                <td class="box" id="box13"></td>
                <td class="box" id="box14"></td>
                <td class="box" id="box15"></td>
                <td class="box" id="box16"></td>
            </tr>
        </table>
        <div class="restart" onclick="restart()">restart</div>
        <script src="2048.js"></script>
    </body>
</html>

              
            
!

CSS

              
                table:first-of-type{
    background-color: #B4A295;
    height: 400px;
    width: 400px;
    padding: 10px;
    margin: auto;
    border-radius: 15px;
}
td{
    width: 80px;
    height: 80px;
    color: #FBFCF7;
    font-family: Arial, Helvetica, sans-serif;
    border-radius: 10px;
    border: 5px solid #B4A295;
    margin: 10px;
    background-color: #C9BCB3;
    text-align: center;
    font-weight: bolder;
    font-size: 40px;
}
.me{
    padding: 10px;
    border-radius: 5px;
    font-family: Arial, Helvetica, sans-serif;
    color: white;
    border: 1px solid #ccc;
    background-color: orange;
    max-width: 400px;
    margin: 15px auto;
    font-size: 40px;
    text-align: center;
}
a{
    text-decoration: none;
    color: initial;
}
.restart{
    padding: 10px;
    border-radius: 5px;
    font-family: Arial, Helvetica, sans-serif;
    color: white;
    border: 1px solid #ccc;
    background-color: orange;
    max-width: 100px;
    margin: 10px auto;
    font-size: 20px;
    text-align: center;
}
.restart:hover{
    cursor: pointer;
}
              
            
!

JS

              
                var score = 0
    box1 = document.getElementById('box1'),
    box2 = document.getElementById('box2'),
    box3 = document.getElementById('box3'),
    box4 = document.getElementById('box4'),
    box5 = document.getElementById('box5'),
    box6 = document.getElementById('box6'),
    box7 = document.getElementById('box7'),
    box8 = document.getElementById('box8'),
    box9 = document.getElementById('box9'),
    box10 = document.getElementById('box10'),
    box11 = document.getElementById('box11'),
    box12 = document.getElementById('box12'),
    box13 = document.getElementById('box13'),
    box14 = document.getElementById('box14'),
    box15 = document.getElementById('box15'),
    box16 = document.getElementById('box16'),
    box1Filled = false,
    box2Filled = false,
    box3Filled = false,
    box4Filled = false,
    box5Filled = false,
    box6Filled = false,
    box7Filled = false,
    box8Filled = false,
    box9Filled = false,
    box10Filled = false,
    box11Filled = false,
    box12Filled = false,
    box13Filled = false,
    box14Filled = false,
    box15Filled = false,
    box16Filled = false,
    box1Value = 0,
    box2Value = 0,
    box3Value = 0,
    box4Value = 0,
    box5Value = 0,
    box6Value = 0,
    box7Value = 0,
    box8Value = 0,
    box9Value = 0,
    box10Value = 0,
    box11Value = 0,
    box12Value = 0,
    box13Value = 0,
    box14Value = 0,
    box15Value = 0,
    box16Value = 0;

window.onkeyup = click;

function newBox(){
    if(box1Filled == false ||
        box2Filled == false ||
        box3Filled == false ||
        box4Filled == false ||
        box5Filled == false ||
        box6Filled == false ||
        box7Filled == false ||
        box8Filled == false ||
        box9Filled == false ||
        box10Filled == false ||
        box11Filled == false ||
        box12Filled == false ||
        box13Filled == false ||
        box14Filled == false ||
        box15Filled == false ||
        box16Filled == false){
            setTimeout(function(){
                var num =  Math.floor((Math.random() * 10) + 1);
                var chosen = Math.floor((Math.random() * 16) + 1);
                if(num == 10){
                    num = 4
                }else{
                    num = 2
                }
                switch(chosen){
                    case 1:
                        if(box1Filled == true){
                            newBox()
                        }else{
                            box1Filled = true
                            box1Value = num
                            check()
                        }
                    break;
                    case 2:
                        if(box2Filled == true){
                            newBox()
                        }else{
                            box2Filled = true
                            box2Value = num
                            check()
                        }
                    break;
                    case 3:
                        if(box3Filled == true){
                            newBox()
                        }else{
                            box3Value = num
                            box3Filled = true
                            check()
                        }
                    break;
                    case 4:
                        if(box4Filled == true){
                            newBox()
                        }else{
                            box4Value = num
                            box4Filled = true
                            check()
                        }
                    break;
                    case 5:
                        if(box5Filled == true){
                            newBox()
                        }else{
                            box5Filled = true
                            box5Value = num
                            check()
                        }
                    break;
                    case 6:
                        if(box6Filled == true){
                            newBox()
                        }else{
                            box6Filled = true
                            box6Value = num
                            check()
                        }
                    break;
                    case 7:
                        if(box7Filled == true){
                            newBox()
                        }else{
                            box7Filled = true
                            box7Value = num
                            check()
                        }
                    break;
                    case 8:
                        if(box8Filled == true){
                            newBox()
                        }else{
                            box8Filled = true
                            box8Value = num
                            check()
                        }
                    break;
                    case 9:
                        if(box9Filled == true){
                            newBox()
                        }else{
                            box9Filled = true
                            box9Value = num
                            check()
                        }
                    break;
                    case 10:
                        if(box10Filled == true){
                            newBox()
                        }else{
                            box10Filled = true
                            box10Value = num
                            check()
                        }
                    break;
                    case 11:
                        if(box11Filled == true){
                            newBox()
                        }else{
                            box11Filled = true
                            box11Value = num
                            check()
                        }
                    break;
                    case 12:
                        if(box12Filled == true){
                            newBox()
                        }else{
                            box12Filled = true
                            box12Value = num
                            check()
                        }
                    break;
                    case 13:
                        if(box13Filled == true){
                            newBox()
                        }else{
                            box13Filled = true
                            box13Value = num
                            check()
                        }
                    break;
                    case 14:
                        if(box14Filled == true){
                            newBox()
                        }else{
                            box14Filled = true
                            box14Value = num
                            check()
                        }
                    break;
                    case 15:
                        if(box15Filled == true){
                            newBox()
                        }else{
                            box15Filled = true
                            box15Value = num
                            check()
                        }
                    break;
                    case 16:
                        if(box16Filled == true){
                            newBox()
                        }else{
                            box16Filled = true
                            box16Value = num
                            check()
                        }
                    break;
                }
            },50) 
    }
    
}
(function(){
    var startingBox = Math.floor((Math.random() * 16) + 1);
    var num = Math.floor((Math.random() * 10) + 1);
    if(num == 10){
        num = 4
    }else{
        num = 2
    }
    switch(startingBox){
        case 1:
        box1Filled = true
        box1Value = num
        check()
        break;
        
        case 2:
        box2Filled = true
        box2Value = num
        check()
        break;
        
        case 3:
        box3Filled = true
        box3Value = num
        check()
        break;
        
        case 4:
        box4Filled = true
        box4Value = num
        check()
        break;
        
        case 5:
        box5Filled = true
        box5Value = num
        check()
        break;
        
        case 6:
        box6Filled = true
        box6Value = num
        check()
        break;
        
        case 7:
        box7Filled = true
        box7Value = num
        check()
        break;
        
        case 8:
        box8Filled = true
        box8Value = num
        check()
        break;
        
        case 9:
        box9Filled = true
        box9Value = num
        check()
        break;
        
        case 10:
        box10Filled = true
        box10Value = num
        check()
        break;
        
        case 11:
        box11Filled = true
        box11Value = num
        check()
        break;
        
        case 12:
        box12Filled = true
        box12Value = num
        check()
        break;
        
        case 13:
        box13Filled = true
        box13Value = num
        check()
        break;
        
        case 14:
        box14Filled = true
        box14Value = num
        check()
        break;
        
        case 15:
        box15Filled = true
        box15Value = num
        check()
        break;
        
        case 16:
        box16Filled = true
        box16Value = num
        check()
        break;       
    }
})()

function click(){
    if(window.event.keyCode == '37'){
        left()
    }
    if(window.event.keyCode == '38'){
        up()
    }
    if(window.event.keyCode == '39'){
        right()
    }
    if(window.event.keyCode == '40'){
        down()
    }
}
function right(){
    newBox()
    if(box4Filled == false){
        if(box3Filled == false){
            if(box2Filled == true){
                box2Filled = false
                box3Filled = true
                box3Value = box2Value
                box2Value = 0
                box2.innerText = ''
                check()
                setTimeout(function(){
                    box3Filled = false
                    box4Filled = true
                    box4Value = box3Value
                    box3Value = 0
                    box3.innerText = ''
                    check()
                },40)
                if(box1Filled == true){
                    box1Filled = false
                    box2Filled = true
                    box2Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box3Filled == false){
                            box2Filled = false
                            box3Filled = true
                            box3Value = box2Value
                            box2Value = 0
                            box2.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box4Filled == false){
                                    box3Filled = false
                                    box4Filled = true
                                    box4Value = box3Value
                                    box3Value = 0
                                    box3.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box2Filled == false){
                if(box1Filled == true){
                    box1Filled = false
                    box2Filled = true
                    box2Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box3Filled == false){
                            box2Filled = false
                            box3Filled = true
                            box3Value = box2Value
                            box2Value = 0
                            box2.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box4Filled == false){
                                    box3Filled = false
                                    box4Filled = true
                                    box4Value = box3Value
                                    box3Value = 0
                                    box3.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box3Filled == true){
            box3Filled = false
            box4Filled = true
            box4Value = box3Value
            box3Value = 0
            box3.innerText = ''
            check()
            if(box2Filled == true){
                box2Filled = false
                box3Filled = true
                box3Value = box2Value
                box2Value = 0
                box2.innerText = ''
                check()
            }
        }
    }
    if(box4Filled == true){
        if(box3Filled == false){
            if(box2Filled == true){
                box2Filled = false
                box3Filled = true
                box3Value = box2Value
                box2Value = 0
                box2.innerText = ''
                check()
                setTimeout(function(){
                    if(box3Value == box4Value){
                        box3Filled = false
                        box4Filled = true
                        box4Value = box4Value * 2
                        box3Value = 0
                        box3.innerText = ''
                        check()
                    }
                },39)
                if(box1Filled == true){
                    box1Filled = false
                    box2Filled = true
                    box2Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box2Value == box3Value){
                            box2Filled = false
                            box3Filled = true
                            box3Value = box3Value * 2
                            box2Value = 0
                            box2.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box2Filled == false){
                if(box1Filled == true){
                    box1Filled = false
                    box2Filled = true
                    box2Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box3Filled == false){
                            box2Filled = false
                            box3Filled = true
                            box3Value = box2Value
                            box2Value = 0
                            box2.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box3Value == box4Value){
                                    box3Filled = false
                                    box4Filled = true
                                    box4Value = box4Value * 2
                                    box3Value = 0
                                    box3.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box3Filled == true){
            if(box3Value == box4Value){
                box3Filled = false
                box4Filled = true
                box4Value = box4Value * 2
                box3Value = 0
                box3.innerText = ''
                check()
            }
            if(box2Filled == false){
                if(box1Filled == true){
                    box1Filled = false
                    box2Filled = true
                    box2Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box3Filled == false){
                            box2Filled = false
                            box3Filled = true
                            box3Value = box2Value
                            box2Value = 0
                            box2.innerText = ''
                            check()
                        }
                        else if(box3Filled == true){
                            if(box3Value == box2Value){
                                box2Filled = false
                                box3Filled = true
                                box3Value = box3Value * 2
                                box2Value = 0
                                box2.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box3Value == box4Value){
                                box3Filled = false
                                box4Filled = true
                                box4Value = box4Value * 2
                                box3Value = 0
                                box3.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box2Filled == true){
                if(box2Value == box3Value){
                    box2Filled = false
                    box3Filled = true
                    box3Value = box3Value * 2
                    box2Value = 0
                    box2.innerText = ''
                    check()   
                }
                    if(box3Filled == false){
                        box2Filled = false
                        box3Filled = true
                        box3Value = box2Value
                        box2Value = 0
                        box2.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box4Filled == true){
                                if(box3Value == box4Value){
                                    box3Filled = false
                                    box4Filled = true
                                    box4Value = box4Value * 2
                                    box3Value = 0
                                    box3.innerText = ''
                                    check()
                                }
                            }
                            else if(box4Filled == false){
                                box3Filled = false
                                box4Filled = true
                                box4Value = box3Value
                                box3Value = 0
                                box3.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box2Filled == true && box1Filled == true){
                        if(box1Value == box2Value){
                            box1Filled = false
                            box2Filled = true
                            box2Value = box2Value * 2
                            box1Value = 0
                            box1.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box8Filled == false){
        if(box7Filled == false){
            if(box6Filled == true){
                box6Filled = false
                box7Filled = true
                box7Value = box6Value
                box6Value = 0
                box6.innerText = ''
                check()
                setTimeout(function(){
                    box7Filled = false
                    box8Filled = true
                    box8Value = box7Value
                    box7Value = 0
                    box7.innerText = ''
                    check()
                },40)
                if(box5Filled == true){
                    box5Filled = false
                    box6Filled = true
                    box6Value = box5Value
                    box5Value = 0
                    box5.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box6Filled = false
                            box7Filled = true
                            box7Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box8Filled == false){
                                    box7Filled = false
                                    box8Filled = true
                                    box8Value = box7Value
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box6Filled == false){
                if(box5Filled == true){
                    box5Filled = false
                    box6Filled = true
                    box6Value = box5Value
                    box5Value = 0
                    box5.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box6Filled = false
                            box7Filled = true
                            box7Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box8Filled == false){
                                    box7Filled = false
                                    box8Filled = true
                                    box8Value = box7Value
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box7Filled == true){
            box7Filled = false
            box8Filled = true
            box8Value = box7Value
            box7Value = 0
            box7.innerText = ''
            check()
            if(box6Filled == true){
                box6Filled = false
                box7Filled = true
                box7Value = box6Value
                box6Value = 0
                box6.innerText = ''
                check()
            }
        }
    }
    if(box8Filled == true){
        if(box7Filled == false){
            if(box6Filled == true){
                box6Filled = false
                box7Filled = true
                box7Value = box6Value
                box6Value = 0
                box6.innerText = ''
                check()
                setTimeout(function(){
                    if(box7Value == box8Value){
                        box7Filled = false
                        box8Filled = true
                        box8Value = box8Value * 2
                        box7Value = 0
                        box7.innerText = ''
                        check()
                    }
                },39)
                if(box5Filled == true){
                    box5Filled = false
                    box6Filled = true
                    box6Value = box5Value
                    box5Value = 0
                    box5.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Value == box7Value){
                            box6Filled = false
                            box7Filled = true
                            box7Value = box7Value * 2
                            box6Value = 0
                            box6.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box6Filled == false){
                if(box5Filled == true){
                    box5Filled = false
                    box6Filled = true
                    box6Value = box5Value
                    box5Value = 0
                    box5.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box6Filled = false
                            box7Filled = true
                            box7Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box7Value == box8Value){
                                    box7Filled = false
                                    box8Filled = true
                                    box8Value = box8Value * 2
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box7Filled == true){
            if(box7Value == box8Value){
                box7Filled = false
                box8Filled = true
                box8Value = box8Value * 2
                box7Value = 0
                box7.innerText = ''
                check()
            }
            if(box6Filled == false){
                if(box5Filled == true){
                    box5Filled = false
                    box6Filled = true
                    box6Value = box5Value
                    box5Value = 0
                    box5.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box6Filled = false
                            box7Filled = true
                            box7Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                        }
                        else if(box7Filled == true){
                            if(box7Value == box6Value){
                                box6Filled = false
                                box7Filled = true
                                box7Value = box7Value * 2
                                box6Value = 0
                                box6.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box7Value == box8Value){
                                box7Filled = false
                                box8Filled = true
                                box8Value = box8Value * 2
                                box7Value = 0
                                box7.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box6Filled == true){
                if(box6Value == box7Value){
                    box6Filled = false
                    box7Filled = true
                    box7Value = box7Value * 2
                    box6Value = 0
                    box6.innerText = ''
                    check()   
                }
                    if(box7Filled == false){
                        box6Filled = false
                        box7Filled = true
                        box7Value = box6Value
                        box6Value = 0
                        box6.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box8Filled == true){
                                if(box7Value == box8Value){
                                    box7Filled = false
                                    box8Filled = true
                                    box8Value = box8Value * 2
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            }
                            else if(box8Filled == false){
                                box7Filled = false
                                box8Filled = true
                                box8Value = box7Value
                                box7Value = 0
                                box7.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box6Filled == true && box5Filled == true){
                        if(box5Value == box6Value){
                            box5Filled = false
                            box6Filled = true
                            box6Value = box6Value * 2
                            box5Value = 0
                            box5.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box12Filled == false){
        if(box11Filled == false){
            if(box10Filled == true){
                box10Filled = false
                box11Filled = true
                box11Value = box10Value
                box10Value = 0
                box10.innerText = ''
                check()
                setTimeout(function(){
                    box11Filled = false
                    box12Filled = true
                    box12Value = box11Value
                    box11Value = 0
                    box11.innerText = ''
                    check()
                },40)
                if(box9Filled == true){
                    box9Filled = false
                    box10Filled = true
                    box10Value = box9Value
                    box9Value = 0
                    box9.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box10Filled = false
                            box11Filled = true
                            box11Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box12Filled == false){
                                    box11Filled = false
                                    box12Filled = true
                                    box12Value = box11Value
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box10Filled == false){
                if(box9Filled == true){
                    box9Filled = false
                    box10Filled = true
                    box10Value = box9Value
                    box9Value = 0
                    box9.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box10Filled = false
                            box11Filled = true
                            box11Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box12Filled == false){
                                    box11Filled = false
                                    box12Filled = true
                                    box12Value = box11Value
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box11Filled == true){
            box11Filled = false
            box12Filled = true
            box12Value = box11Value
            box11Value = 0
            box11.innerText = ''
            check()
            if(box10Filled == true){
                box10Filled = false
                box11Filled = true
                box11Value = box10Value
                box10Value = 0
                box10.innerText = ''
                check()
            }
        }
    }
    if(box12Filled == true){
        if(box11Filled == false){
            if(box10Filled == true){
                box10Filled = false
                box11Filled = true
                box11Value = box10Value
                box10Value = 0
                box10.innerText = ''
                check()
                setTimeout(function(){
                    if(box11Value == box12Value){
                        box11Filled = false
                        box12Filled = true
                        box12Value = box12Value * 2
                        box11Value = 0
                        box11.innerText = ''
                        check()
                    }
                },39)
                if(box9Filled == true){
                    box9Filled = false
                    box10Filled = true
                    box10Value = box9Value
                    box9Value = 0
                    box9.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Value == box11Value){
                            box10Filled = false
                            box11Filled = true
                            box11Value = box11Value * 2
                            box10Value = 0
                            box10.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box10Filled == false){
                if(box9Filled == true){
                    box9Filled = false
                    box10Filled = true
                    box10Value = box9Value
                    box9Value = 0
                    box9.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box10Filled = false
                            box11Filled = true
                            box11Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box11Value == box12Value){
                                    box11Filled = false
                                    box12Filled = true
                                    box12Value = box12Value * 2
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box11Filled == true){
            if(box11Value == box12Value){
                box11Filled = false
                box12Filled = true
                box12Value = box12Value * 2
                box11Value = 0
                box11.innerText = ''
                check()
            }
            if(box10Filled == false){
                if(box9Filled == true){
                    box9Filled = false
                    box10Filled = true
                    box10Value = box9Value
                    box9Value = 0
                    box9.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box10Filled = false
                            box11Filled = true
                            box11Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                        }
                        else if(box11Filled == true){
                            if(box11Value == box10Value){
                                box10Filled = false
                                box11Filled = true
                                box11Value = box11Value * 2
                                box10Value = 0
                                box10.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box11Value == box12Value){
                                box11Filled = false
                                box12Filled = true
                                box12Value = box12Value * 2
                                box11Value = 0
                                box11.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box10Filled == true){
                if(box10Value == box11Value){
                    box10Filled = false
                    box11Filled = true
                    box11Value = box11Value * 2
                    box10Value = 0
                    box10.innerText = ''
                    check()   
                }
                    if(box11Filled == false){
                        box10Filled = false
                        box11Filled = true
                        box11Value = box10Value
                        box10Value = 0
                        box10.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box12Filled == true){
                                if(box11Value == box12Value){
                                    box11Filled = false
                                    box12Filled = true
                                    box12Value = box12Value * 2
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            }
                            else if(box12Filled == false){
                                box11Filled = false
                                box12Filled = true
                                box12Value = box11Value
                                box11Value = 0
                                box11.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box10Filled == true && box9Filled == true){
                        if(box9Value == box10Value){
                            box9Filled = false
                            box10Filled = true
                            box10Value = box10Value * 2
                            box9Value = 0
                            box9.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box16Filled == false){
        if(box15Filled == false){
            if(box14Filled == true){
                box14Filled = false
                box15Filled = true
                box15Value = box14Value
                box14Value = 0
                box14.innerText = ''
                check()
                setTimeout(function(){
                    box15Filled = false
                    box16Filled = true
                    box16Value = box15Value
                    box15Value = 0
                    box15.innerText = ''
                    check()
                },40)
                if(box13Filled == true){
                    box13Filled = false
                    box14Filled = true
                    box14Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box15Filled == false){
                            box14Filled = false
                            box15Filled = true
                            box15Value = box14Value
                            box14Value = 0
                            box14.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box16Filled == false){
                                    box15Filled = false
                                    box16Filled = true
                                    box16Value = box15Value
                                    box15Value = 0
                                    box15.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box14Filled == false){
                if(box13Filled == true){
                    box13Filled = false
                    box14Filled = true
                    box14Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box15Filled == false){
                            box14Filled = false
                            box15Filled = true
                            box15Value = box14Value
                            box14Value = 0
                            box14.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box16Filled == false){
                                    box15Filled = false
                                    box16Filled = true
                                    box16Value = box15Value
                                    box15Value = 0
                                    box15.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box15Filled == true){
            box15Filled = false
            box16Filled = true
            box16Value = box15Value
            box15Value = 0
            box15.innerText = ''
            check()
            if(box14Filled == true){
                box14Filled = false
                box15Filled = true
                box15Value = box14Value
                box14Value = 0
                box14.innerText = ''
                check()
            }
        }
    }
    if(box16Filled == true){
        if(box15Filled == false){
            if(box14Filled == true){
                box14Filled = false
                box15Filled = true
                box15Value = box14Value
                box14Value = 0
                box14.innerText = ''
                check()
                setTimeout(function(){
                    if(box15Value == box16Value){
                        box15Filled = false
                        box16Filled = true
                        box16Value = box16Value * 2
                        box15Value = 0
                        box15.innerText = ''
                        check()
                    }
                },39)
                if(box13Filled == true){
                    box13Filled = false
                    box14Filled = true
                    box14Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box14Value == box15Value){
                            box14Filled = false
                            box15Filled = true
                            box15Value = box15Value * 2
                            box14Value = 0
                            box14.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box14Filled == false){
                if(box13Filled == true){
                    box13Filled = false
                    box14Filled = true
                    box14Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box15Filled == false){
                            box14Filled = false
                            box15Filled = true
                            box15Value = box14Value
                            box14Value = 0
                            box14.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box15Value == box16Value){
                                    box15Filled = false
                                    box16Filled = true
                                    box16Value = box16Value * 2
                                    box15Value = 0
                                    box15.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box15Filled == true){
            if(box15Value == box16Value){
                box15Filled = false
                box16Filled = true
                box16Value = box16Value * 2
                box15Value = 0
                box15.innerText = ''
                check()
            }
            if(box14Filled == false){
                if(box13Filled == true){
                    box13Filled = false
                    box14Filled = true
                    box14Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box15Filled == false){
                            box14Filled = false
                            box15Filled = true
                            box15Value = box14Value
                            box14Value = 0
                            box14.innerText = ''
                            check()
                        }
                        else if(box15Filled == true){
                            if(box15Value == box14Value){
                                box14Filled = false
                                box15Filled = true
                                box15Value = box15Value * 2
                                box14Value = 0
                                box14.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box15Value == box16Value){
                                box15Filled = false
                                box16Filled = true
                                box16Value = box16Value * 2
                                box15Value = 0
                                box15.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box14Filled == true){
                if(box14Value == box15Value){
                    box14Filled = false
                    box15Filled = true
                    box15Value = box15Value * 2
                    box14Value = 0
                    box14.innerText = ''
                    check()   
                }
                    if(box15Filled == false){
                        box14Filled = false
                        box15Filled = true
                        box15Value = box14Value
                        box14Value = 0
                        box14.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box16Filled == true){
                                if(box15Value == box16Value){
                                    box15Filled = false
                                    box16Filled = true
                                    box16Value = box16Value * 2
                                    box15Value = 0
                                    box15.innerText = ''
                                    check()
                                }
                            }
                            else if(box16Filled == false){
                                box15Filled = false
                                box16Filled = true
                                box16Value = box15Value
                                box15Value = 0
                                box15.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box14Filled == true && box13Filled == true){
                        if(box13Value == box14Value){
                            box13Filled = false
                            box14Filled = true
                            box14Value = box14Value * 2
                            box13Value = 0
                            box13.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
}

function down(){
    newBox()
    if(box16Filled == false){
        if(box12Filled == false){
            if(box8Filled == true){
                box8Filled = false
                box12Filled = true
                box12Value = box8Value
                box8Value = 0
                box8.innerText = ''
                check()
                setTimeout(function(){
                    box12Filled = false
                    box16Filled = true
                    box16Value = box12Value
                    box12Value = 0
                    box12.innerText = ''
                    check()
                },40)
                if(box4Filled == true){
                    box4Filled = false
                    box8Filled = true
                    box8Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box12Filled == false){
                            box8Filled = false
                            box12Filled = true
                            box12Value = box8Value
                            box8Value = 0
                            box8.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box16Filled == false){
                                    box12Filled = false
                                    box16Filled = true
                                    box16Value = box12Value
                                    box12Value = 0
                                    box12.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box8Filled == false){
                if(box4Filled == true){
                    box4Filled = false
                    box8Filled = true
                    box8Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box12Filled == false){
                            box8Filled = false
                            box12Filled = true
                            box12Value = box8Value
                            box8Value = 0
                            box8.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box16Filled == false){
                                    box12Filled = false
                                    box16Filled = true
                                    box16Value = box12Value
                                    box12Value = 0
                                    box12.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box12Filled == true){
            box12Filled = false
            box16Filled = true
            box16Value = box12Value
            box12Value = 0
            box12.innerText = ''
            check()
            if(box8Filled == true){
                box8Filled = false
                box12Filled = true
                box12Value = box8Value
                box8Value = 0
                box8.innerText = ''
                check()
            }
        }
    }
    if(box16Filled == true){
        if(box12Filled == false){
            if(box8Filled == true){
                box8Filled = false
                box12Filled = true
                box12Value = box8Value
                box8Value = 0
                box8.innerText = ''
                check()
                setTimeout(function(){
                    if(box12Value == box16Value){
                        box12Filled = false
                        box16Filled = true
                        box16Value = box16Value * 2
                        box12Value = 0
                        box12.innerText = ''
                        check()
                    }
                },39)
                if(box4Filled == true){
                    box4Filled = false
                    box8Filled = true
                    box8Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box8Value == box12Value){
                            box8Filled = false
                            box12Filled = true
                            box12Value = box12Value * 2
                            box8Value = 0
                            box8.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box8Filled == false){
                if(box4Filled == true){
                    box4Filled = false
                    box8Filled = true
                    box8Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box12Filled == false){
                            box8Filled = false
                            box12Filled = true
                            box12Value = box8Value
                            box8Value = 0
                            box8.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box12Value == box16Value){
                                    box12Filled = false
                                    box16Filled = true
                                    box16Value = box16Value * 2
                                    box12Value = 0
                                    box12.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box12Filled == true){
            if(box12Value == box16Value){
                box12Filled = false
                box16Filled = true
                box16Value = box16Value * 2
                box12Value = 0
                box12.innerText = ''
                check()
            }
            if(box8Filled == false){
                if(box4Filled == true){
                    box4Filled = false
                    box8Filled = true
                    box8Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box12Filled == false){
                            box8Filled = false
                            box12Filled = true
                            box12Value = box8Value
                            box8Value = 0
                            box8.innerText = ''
                            check()
                        }
                        else if(box12Filled == true){
                            if(box12Value == box8Value){
                                box8Filled = false
                                box12Filled = true
                                box12Value = box12Value * 2
                                box8Value = 0
                                box8.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box12Value == box16Value){
                                box12Filled = false
                                box16Filled = true
                                box16Value = box16Value * 2
                                box12Value = 0
                                box12.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box8Filled == true){
                if(box8Value == box12Value){
                    box8Filled = false
                    box12Filled = true
                    box12Value = box12Value * 2
                    box8Value = 0
                    box8.innerText = ''
                    check()   
                }
                    if(box12Filled == false){
                        box8Filled = false
                        box12Filled = true
                        box12Value = box8Value
                        box8Value = 0
                        box8.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box16Filled == true){
                                if(box12Value == box16Value){
                                    box12Filled = false
                                    box16Filled = true
                                    box16Value = box16Value * 2
                                    box12Value = 0
                                    box12.innerText = ''
                                    check()
                                }
                            }
                            else if(box16Filled == false){
                                box12Filled = false
                                box16Filled = true
                                box16Value = box12Value
                                box12Value = 0
                                box12.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box8Filled == true && box4Filled == true){
                        if(box4Value == box8Value){
                            box4Filled = false
                            box8Filled = true
                            box8Value = box8Value * 2
                            box4Value = 0
                            box4.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box15Filled == false){
        if(box11Filled == false){
            if(box7Filled == true){
                box7Filled = false
                box11Filled = true
                box11Value = box7Value
                box7Value = 0
                box7.innerText = ''
                check()
                setTimeout(function(){
                    box11Filled = false
                    box15Filled = true
                    box15Value = box11Value
                    box11Value = 0
                    box11.innerText = ''
                    check()
                },40)
                if(box3Filled == true){
                    box3Filled = false
                    box7Filled = true
                    box7Value = box3Value
                    box3Value = 0
                    box3.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box7Filled = false
                            box11Filled = true
                            box11Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box15Filled == false){
                                    box11Filled = false
                                    box15Filled = true
                                    box15Value = box11Value
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box7Filled == false){
                if(box3Filled == true){
                    box3Filled = false
                    box7Filled = true
                    box7Value = box3Value
                    box3Value = 0
                    box3.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box7Filled = false
                            box11Filled = true
                            box11Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box15Filled == false){
                                    box11Filled = false
                                    box15Filled = true
                                    box15Value = box11Value
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box11Filled == true){
            box11Filled = false
            box15Filled = true
            box15Value = box11Value
            box11Value = 0
            box11.innerText = ''
            check()
            if(box7Filled == true){
                box7Filled = false
                box11Filled = true
                box11Value = box7Value
                box7Value = 0
                box7.innerText = ''
                check()
            }
        }
    }
    if(box15Filled == true){
        if(box11Filled == false){
            if(box7Filled == true){
                box7Filled = false
                box11Filled = true
                box11Value = box7Value
                box7Value = 0
                box7.innerText = ''
                check()
                setTimeout(function(){
                    if(box11Value == box15Value){
                        box11Filled = false
                        box15Filled = true
                        box15Value = box15Value * 2
                        box11Value = 0
                        box11.innerText = ''
                        check()
                    }
                },39)
                if(box3Filled == true){
                    box3Filled = false
                    box7Filled = true
                    box7Value = box3Value
                    box3Value = 0
                    box3.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Value == box11Value){
                            box7Filled = false
                            box11Filled = true
                            box11Value = box11Value * 2
                            box7Value = 0
                            box7.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box7Filled == false){
                if(box3Filled == true){
                    box3Filled = false
                    box7Filled = true
                    box7Value = box3Value
                    box3Value = 0
                    box3.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box7Filled = false
                            box11Filled = true
                            box11Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box11Value == box15Value){
                                    box11Filled = false
                                    box15Filled = true
                                    box15Value = box15Value * 2
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box11Filled == true){
            if(box11Value == box15Value){
                box11Filled = false
                box15Filled = true
                box15Value = box15Value * 2
                box11Value = 0
                box11.innerText = ''
                check()
            }
            if(box7Filled == false){
                if(box3Filled == true){
                    box3Filled = false
                    box7Filled = true
                    box7Value = box3Value
                    box3Value = 0
                    box3.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Filled == false){
                            box7Filled = false
                            box11Filled = true
                            box11Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                        }
                        else if(box11Filled == true){
                            if(box11Value == box7Value){
                                box7Filled = false
                                box11Filled = true
                                box11Value = box11Value * 2
                                box7Value = 0
                                box7.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box11Value == box15Value){
                                box11Filled = false
                                box15Filled = true
                                box15Value = box15Value * 2
                                box11Value = 0
                                box11.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box7Filled == true){
                if(box7Value == box11Value){
                    box7Filled = false
                    box11Filled = true
                    box11Value = box11Value * 2
                    box7Value = 0
                    box7.innerText = ''
                    check()   
                }
                    if(box11Filled == false){
                        box7Filled = false
                        box11Filled = true
                        box11Value = box7Value
                        box7Value = 0
                        box7.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box15Filled == true){
                                if(box11Value == box15Value){
                                    box11Filled = false
                                    box15Filled = true
                                    box15Value = box15Value * 2
                                    box11Value = 0
                                    box11.innerText = ''
                                    check()
                                }
                            }
                            else if(box15Filled == false){
                                box11Filled = false
                                box15Filled = true
                                box15Value = box11Value
                                box11Value = 0
                                box11.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box7Filled == true && box3Filled == true){
                        if(box3Value == box7Value){
                            box3Filled = false
                            box7Filled = true
                            box7Value = box7Value * 2
                            box3Value = 0
                            box3.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box14Filled == false){
        if(box10Filled == false){
            if(box6Filled == true){
                box6Filled = false
                box10Filled = true
                box10Value = box6Value
                box6Value = 0
                box6.innerText = ''
                check()
                setTimeout(function(){
                    box10Filled = false
                    box14Filled = true
                    box14Value = box10Value
                    box10Value = 0
                    box10.innerText = ''
                    check()
                },40)
                if(box2Filled == true){
                    box2Filled = false
                    box6Filled = true
                    box6Value = box2Value
                    box2Value = 0
                    box2.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box6Filled = false
                            box10Filled = true
                            box10Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box14Filled == false){
                                    box10Filled = false
                                    box14Filled = true
                                    box14Value = box10Value
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box6Filled == false){
                if(box2Filled == true){
                    box2Filled = false
                    box6Filled = true
                    box6Value = box2Value
                    box2Value = 0
                    box2.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box6Filled = false
                            box10Filled = true
                            box10Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box14Filled == false){
                                    box10Filled = false
                                    box14Filled = true
                                    box14Value = box10Value
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box10Filled == true){
            box10Filled = false
            box14Filled = true
            box14Value = box10Value
            box10Value = 0
            box10.innerText = ''
            check()
            if(box6Filled == true){
                box6Filled = false
                box10Filled = true
                box10Value = box6Value
                box6Value = 0
                box6.innerText = ''
                check()
            }
        }
    }
    if(box14Filled == true){
        if(box10Filled == false){
            if(box6Filled == true){
                box6Filled = false
                box10Filled = true
                box10Value = box6Value
                box6Value = 0
                box6.innerText = ''
                check()
                setTimeout(function(){
                    if(box10Value == box14Value){
                        box10Filled = false
                        box14Filled = true
                        box14Value = box14Value * 2
                        box10Value = 0
                        box10.innerText = ''
                        check()
                    }
                },39)
                if(box2Filled == true){
                    box2Filled = false
                    box6Filled = true
                    box6Value = box2Value
                    box2Value = 0
                    box2.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Value == box10Value){
                            box6Filled = false
                            box10Filled = true
                            box10Value = box10Value * 2
                            box6Value = 0
                            box6.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box6Filled == false){
                if(box2Filled == true){
                    box2Filled = false
                    box6Filled = true
                    box6Value = box2Value
                    box2Value = 0
                    box2.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box6Filled = false
                            box10Filled = true
                            box10Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box10Value == box14Value){
                                    box10Filled = false
                                    box14Filled = true
                                    box14Value = box14Value * 2
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box10Filled == true){
            if(box10Value == box14Value){
                box10Filled = false
                box14Filled = true
                box14Value = box14Value * 2
                box10Value = 0
                box10.innerText = ''
                check()
            }
            if(box6Filled == false){
                if(box2Filled == true){
                    box2Filled = false
                    box6Filled = true
                    box6Value = box2Value
                    box2Value = 0
                    box2.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box6Filled = false
                            box10Filled = true
                            box10Value = box6Value
                            box6Value = 0
                            box6.innerText = ''
                            check()
                        }
                        else if(box10Filled == true){
                            if(box10Value == box6Value){
                                box6Filled = false
                                box10Filled = true
                                box10Value = box10Value * 2
                                box6Value = 0
                                box6.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box10Value == box14Value){
                                box10Filled = false
                                box14Filled = true
                                box14Value = box14Value * 2
                                box10Value = 0
                                box10.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box6Filled == true){
                if(box6Value == box10Value){
                    box6Filled = false
                    box10Filled = true
                    box10Value = box10Value * 2
                    box6Value = 0
                    box6.innerText = ''
                    check()   
                }
                    if(box10Filled == false){
                        box6Filled = false
                        box10Filled = true
                        box10Value = box6Value
                        box6Value = 0
                        box6.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box14Filled == true){
                                if(box10Value == box14Value){
                                    box10Filled = false
                                    box14Filled = true
                                    box14Value = box14Value * 2
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            }
                            else if(box14Filled == false){
                                box10Filled = false
                                box14Filled = true
                                box14Value = box10Value
                                box10Value = 0
                                box10.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box6Filled == true && box2Filled == true){
                        if(box2Value == box6Value){
                            box2Filled = false
                            box6Filled = true
                            box6Value = box6Value * 2
                            box2Value = 0
                            box2.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box13Filled == false){
        if(box9Filled == false){
            if(box5Filled == true){
                box5Filled = false
                box9Filled = true
                box9Value = box5Value
                box5Value = 0
                box5.innerText = ''
                check()
                setTimeout(function(){
                    box9Filled = false
                    box13Filled = true
                    box13Value = box9Value
                    box9Value = 0
                    box9.innerText = ''
                    check()
                },40)
                if(box1Filled == true){
                    box1Filled = false
                    box5Filled = true
                    box5Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box9Filled == false){
                            box5Filled = false
                            box9Filled = true
                            box9Value = box5Value
                            box5Value = 0
                            box5.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box13Filled == false){
                                    box9Filled = false
                                    box13Filled = true
                                    box13Value = box9Value
                                    box9Value = 0
                                    box9.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box5Filled == false){
                if(box1Filled == true){
                    box1Filled = false
                    box5Filled = true
                    box5Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box9Filled == false){
                            box5Filled = false
                            box9Filled = true
                            box9Value = box5Value
                            box5Value = 0
                            box5.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box13Filled == false){
                                    box9Filled = false
                                    box13Filled = true
                                    box13Value = box9Value
                                    box9Value = 0
                                    box9.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box9Filled == true){
            box9Filled = false
            box13Filled = true
            box13Value = box9Value
            box9Value = 0
            box9.innerText = ''
            check()
            if(box5Filled == true){
                box5Filled = false
                box9Filled = true
                box9Value = box5Value
                box5Value = 0
                box5.innerText = ''
                check()
            }
        }
    }
    if(box13Filled == true){
        if(box9Filled == false){
            if(box5Filled == true){
                box5Filled = false
                box9Filled = true
                box9Value = box5Value
                box5Value = 0
                box5.innerText = ''
                check()
                setTimeout(function(){
                    if(box9Value == box13Value){
                        box9Filled = false
                        box13Filled = true
                        box13Value = box13Value * 2
                        box9Value = 0
                        box9.innerText = ''
                        check()
                    }
                },39)
                if(box1Filled == true){
                    box1Filled = false
                    box5Filled = true
                    box5Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box5Value == box9Value){
                            box5Filled = false
                            box9Filled = true
                            box9Value = box9Value * 2
                            box5Value = 0
                            box5.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box5Filled == false){
                if(box1Filled == true){
                    box1Filled = false
                    box5Filled = true
                    box5Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box9Filled == false){
                            box5Filled = false
                            box9Filled = true
                            box9Value = box5Value
                            box5Value = 0
                            box5.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box9Value == box13Value){
                                    box9Filled = false
                                    box13Filled = true
                                    box13Value = box13Value * 2
                                    box9Value = 0
                                    box9.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box9Filled == true){
            if(box9Value == box13Value){
                box9Filled = false
                box13Filled = true
                box13Value = box13Value * 2
                box9Value = 0
                box9.innerText = ''
                check()
            }
            if(box5Filled == false){
                if(box1Filled == true){
                    box1Filled = false
                    box5Filled = true
                    box5Value = box1Value
                    box1Value = 0
                    box1.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box9Filled == false){
                            box5Filled = false
                            box9Filled = true
                            box9Value = box5Value
                            box5Value = 0
                            box5.innerText = ''
                            check()
                        }
                        else if(box9Filled == true){
                            if(box9Value == box5Value){
                                box5Filled = false
                                box9Filled = true
                                box9Value = box9Value * 2
                                box5Value = 0
                                box5.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box9Value == box13Value){
                                box9Filled = false
                                box13Filled = true
                                box13Value = box13Value * 2
                                box9Value = 0
                                box9.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box5Filled == true){
                if(box5Value == box9Value){
                    box5Filled = false
                    box9Filled = true
                    box9Value = box9Value * 2
                    box5Value = 0
                    box5.innerText = ''
                    check()   
                }
                    if(box9Filled == false){
                        box5Filled = false
                        box9Filled = true
                        box9Value = box5Value
                        box5Value = 0
                        box5.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box13Filled == true){
                                if(box9Value == box13Value){
                                    box9Filled = false
                                    box13Filled = true
                                    box13Value = box13Value * 2
                                    box9Value = 0
                                    box9.innerText = ''
                                    check()
                                }
                            }
                            else if(box13Filled == false){
                                box9Filled = false
                                box13Filled = true
                                box13Value = box9Value
                                box9Value = 0
                                box9.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box5Filled == true && box1Filled == true){
                        if(box1Value == box5Value){
                            box1Filled = false
                            box5Filled = true
                            box5Value = box5Value * 2
                            box1Value = 0
                            box1.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
}

function left(){
    newBox()
    if(box13Filled == false){
        if(box14Filled == false){
            if(box15Filled == true){
                box15Filled = false
                box14Filled = true
                box14Value = box15Value
                box15Value = 0
                box15.innerText = ''
                check()
                setTimeout(function(){
                    box14Filled = false
                    box13Filled = true
                    box13Value = box14Value
                    box14Value = 0
                    box14.innerText = ''
                    check()
                },40)
                if(box16Filled == true){
                    box16Filled = false
                    box15Filled = true
                    box15Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box14Filled == false){
                            box15Filled = false
                            box14Filled = true
                            box14Value = box15Value
                            box15Value = 0
                            box15.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box13Filled == false){
                                    box14Filled = false
                                    box13Filled = true
                                    box13Value = box14Value
                                    box14Value = 0
                                    box14.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box15Filled == false){
                if(box16Filled == true){
                    box16Filled = false
                    box15Filled = true
                    box15Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box14Filled == false){
                            box15Filled = false
                            box14Filled = true
                            box14Value = box15Value
                            box15Value = 0
                            box15.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box13Filled == false){
                                    box14Filled = false
                                    box13Filled = true
                                    box13Value = box14Value
                                    box14Value = 0
                                    box14.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box14Filled == true){
            box14Filled = false
            box13Filled = true
            box13Value = box14Value
            box14Value = 0
            box14.innerText = ''
            check()
            if(box15Filled == true){
                box15Filled = false
                box14Filled = true
                box14Value = box15Value
                box15Value = 0
                box15.innerText = ''
                check()
            }
        }
    }
    if(box13Filled == true){
        if(box14Filled == false){
            if(box15Filled == true){
                box15Filled = false
                box14Filled = true
                box14Value = box15Value
                box15Value = 0
                box15.innerText = ''
                check()
                setTimeout(function(){
                    if(box14Value == box13Value){
                        box14Filled = false
                        box13Filled = true
                        box13Value = box13Value * 2
                        box14Value = 0
                        box14.innerText = ''
                        check()
                    }
                },39)
                if(box16Filled == true){
                    box16Filled = false
                    box15Filled = true
                    box15Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box15Value == box14Value){
                            box15Filled = false
                            box14Filled = true
                            box14Value = box14Value * 2
                            box15Value = 0
                            box15.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box15Filled == false){
                if(box16Filled == true){
                    box16Filled = false
                    box15Filled = true
                    box15Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box14Filled == false){
                            box15Filled = false
                            box14Filled = true
                            box14Value = box15Value
                            box15Value = 0
                            box15.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box14Value == box13Value){
                                    box14Filled = false
                                    box13Filled = true
                                    box13Value = box13Value * 2
                                    box14Value = 0
                                    box14.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box14Filled == true){
            if(box14Value == box13Value){
                box14Filled = false
                box13Filled = true
                box13Value = box13Value * 2
                box14Value = 0
                box14.innerText = ''
                check()
            }
            if(box15Filled == false){
                if(box16Filled == true){
                    box16Filled = false
                    box15Filled = true
                    box15Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box14Filled == false){
                            box15Filled = false
                            box14Filled = true
                            box14Value = box15Value
                            box15Value = 0
                            box15.innerText = ''
                            check()
                        }
                        else if(box14Filled == true){
                            if(box14Value == box15Value){
                                box15Filled = false
                                box14Filled = true
                                box14Value = box14Value * 2
                                box15Value = 0
                                box15.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box14Value == box13Value){
                                box14Filled = false
                                box13Filled = true
                                box13Value = box13Value * 2
                                box14Value = 0
                                box14.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box15Filled == true){
                if(box15Value == box14Value){
                    box15Filled = false
                    box14Filled = true
                    box14Value = box14Value * 2
                    box15Value = 0
                    box15.innerText = ''
                    check()   
                }
                    if(box14Filled == false){
                        box15Filled = false
                        box14Filled = true
                        box14Value = box15Value
                        box15Value = 0
                        box15.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box13Filled == true){
                                if(box14Value == box13Value){
                                    box14Filled = false
                                    box13Filled = true
                                    box13Value = box13Value * 2
                                    box14Value = 0
                                    box14.innerText = ''
                                    check()
                                }
                            }
                            else if(box13Filled == false){
                                box14Filled = false
                                box13Filled = true
                                box13Value = box14Value
                                box14Value = 0
                                box14.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box15Filled == true && box16Filled == true){
                        if(box16Value == box15Value){
                            box16Filled = false
                            box15Filled = true
                            box15Value = box15Value * 2
                            box16Value = 0
                            box16.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box9Filled == false){
        if(box10Filled == false){
            if(box11Filled == true){
                box11Filled = false
                box10Filled = true
                box10Value = box11Value
                box11Value = 0
                box11.innerText = ''
                check()
                setTimeout(function(){
                    box10Filled = false
                    box9Filled = true
                    box9Value = box10Value
                    box10Value = 0
                    box10.innerText = ''
                    check()
                },40)
                if(box12Filled == true){
                    box12Filled = false
                    box11Filled = true
                    box11Value = box12Value
                    box12Value = 0
                    box12.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box11Filled = false
                            box10Filled = true
                            box10Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box9Filled == false){
                                    box10Filled = false
                                    box9Filled = true
                                    box9Value = box10Value
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box11Filled == false){
                if(box12Filled == true){
                    box12Filled = false
                    box11Filled = true
                    box11Value = box12Value
                    box12Value = 0
                    box12.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box11Filled = false
                            box10Filled = true
                            box10Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box9Filled == false){
                                    box10Filled = false
                                    box9Filled = true
                                    box9Value = box10Value
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box10Filled == true){
            box10Filled = false
            box9Filled = true
            box9Value = box10Value
            box10Value = 0
            box10.innerText = ''
            check()
            if(box11Filled == true){
                box11Filled = false
                box10Filled = true
                box10Value = box11Value
                box11Value = 0
                box11.innerText = ''
                check()
            }
        }
    }
    if(box9Filled == true){
        if(box10Filled == false){
            if(box11Filled == true){
                box11Filled = false
                box10Filled = true
                box10Value = box11Value
                box11Value = 0
                box11.innerText = ''
                check()
                setTimeout(function(){
                    if(box10Value == box9Value){
                        box10Filled = false
                        box9Filled = true
                        box9Value = box9Value * 2
                        box10Value = 0
                        box10.innerText = ''
                        check()
                    }
                },39)
                if(box12Filled == true){
                    box12Filled = false
                    box11Filled = true
                    box11Value = box12Value
                    box12Value = 0
                    box12.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Value == box10Value){
                            box11Filled = false
                            box10Filled = true
                            box10Value = box10Value * 2
                            box11Value = 0
                            box11.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box11Filled == false){
                if(box12Filled == true){
                    box12Filled = false
                    box11Filled = true
                    box11Value = box12Value
                    box12Value = 0
                    box12.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box11Filled = false
                            box10Filled = true
                            box10Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box10Value == box9Value){
                                    box10Filled = false
                                    box9Filled = true
                                    box9Value = box9Value * 2
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box10Filled == true){
            if(box10Value == box9Value){
                box10Filled = false
                box9Filled = true
                box9Value = box9Value * 2
                box10Value = 0
                box10.innerText = ''
                check()
            }
            if(box11Filled == false){
                if(box12Filled == true){
                    box12Filled = false
                    box11Filled = true
                    box11Value = box12Value
                    box12Value = 0
                    box12.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Filled == false){
                            box11Filled = false
                            box10Filled = true
                            box10Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                        }
                        else if(box10Filled == true){
                            if(box10Value == box11Value){
                                box11Filled = false
                                box10Filled = true
                                box10Value = box10Value * 2
                                box11Value = 0
                                box11.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box10Value == box9Value){
                                box10Filled = false
                                box9Filled = true
                                box9Value = box9Value * 2
                                box10Value = 0
                                box10.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box11Filled == true){
                if(box11Value == box10Value){
                    box11Filled = false
                    box10Filled = true
                    box10Value = box10Value * 2
                    box11Value = 0
                    box11.innerText = ''
                    check()   
                }
                    if(box10Filled == false){
                        box11Filled = false
                        box10Filled = true
                        box10Value = box11Value
                        box11Value = 0
                        box11.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box9Filled == true){
                                if(box10Value == box9Value){
                                    box10Filled = false
                                    box9Filled = true
                                    box9Value = box9Value * 2
                                    box10Value = 0
                                    box10.innerText = ''
                                    check()
                                }
                            }
                            else if(box9Filled == false){
                                box10Filled = false
                                box9Filled = true
                                box9Value = box10Value
                                box10Value = 0
                                box10.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box11Filled == true && box12Filled == true){
                        if(box12Value == box11Value){
                            box12Filled = false
                            box11Filled = true
                            box11Value = box11Value * 2
                            box12Value = 0
                            box12.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box5Filled == false){
        if(box6Filled == false){
            if(box7Filled == true){
                box7Filled = false
                box6Filled = true
                box6Value = box7Value
                box7Value = 0
                box7.innerText = ''
                check()
                setTimeout(function(){
                    box6Filled = false
                    box5Filled = true
                    box5Value = box6Value
                    box6Value = 0
                    box6.innerText = ''
                    check()
                },40)
                if(box8Filled == true){
                    box8Filled = false
                    box7Filled = true
                    box7Value = box8Value
                    box8Value = 0
                    box8.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box7Filled = false
                            box6Filled = true
                            box6Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box5Filled == false){
                                    box6Filled = false
                                    box5Filled = true
                                    box5Value = box6Value
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box7Filled == false){
                if(box8Filled == true){
                    box8Filled = false
                    box7Filled = true
                    box7Value = box8Value
                    box8Value = 0
                    box8.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box7Filled = false
                            box6Filled = true
                            box6Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box5Filled == false){
                                    box6Filled = false
                                    box5Filled = true
                                    box5Value = box6Value
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box6Filled == true){
            box6Filled = false
            box5Filled = true
            box5Value = box6Value
            box6Value = 0
            box6.innerText = ''
            check()
            if(box7Filled == true){
                box7Filled = false
                box6Filled = true
                box6Value = box7Value
                box7Value = 0
                box7.innerText = ''
                check()
            }
        }
    }
    if(box5Filled == true){
        if(box6Filled == false){
            if(box7Filled == true){
                box7Filled = false
                box6Filled = true
                box6Value = box7Value
                box7Value = 0
                box7.innerText = ''
                check()
                setTimeout(function(){
                    if(box6Value == box5Value){
                        box6Filled = false
                        box5Filled = true
                        box5Value = box5Value * 2
                        box6Value = 0
                        box6.innerText = ''
                        check()
                    }
                },39)
                if(box8Filled == true){
                    box8Filled = false
                    box7Filled = true
                    box7Value = box8Value
                    box8Value = 0
                    box8.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Value == box6Value){
                            box7Filled = false
                            box6Filled = true
                            box6Value = box6Value * 2
                            box7Value = 0
                            box7.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box7Filled == false){
                if(box8Filled == true){
                    box8Filled = false
                    box7Filled = true
                    box7Value = box8Value
                    box8Value = 0
                    box8.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box7Filled = false
                            box6Filled = true
                            box6Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box6Value == box5Value){
                                    box6Filled = false
                                    box5Filled = true
                                    box5Value = box5Value * 2
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box6Filled == true){
            if(box6Value == box5Value){
                box6Filled = false
                box5Filled = true
                box5Value = box5Value * 2
                box6Value = 0
                box6.innerText = ''
                check()
            }
            if(box7Filled == false){
                if(box8Filled == true){
                    box8Filled = false
                    box7Filled = true
                    box7Value = box8Value
                    box8Value = 0
                    box8.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box7Filled = false
                            box6Filled = true
                            box6Value = box7Value
                            box7Value = 0
                            box7.innerText = ''
                            check()
                        }
                        else if(box6Filled == true){
                            if(box6Value == box7Value){
                                box7Filled = false
                                box6Filled = true
                                box6Value = box6Value * 2
                                box7Value = 0
                                box7.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box6Value == box5Value){
                                box6Filled = false
                                box5Filled = true
                                box5Value = box5Value * 2
                                box6Value = 0
                                box6.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box7Filled == true){
                if(box7Value == box6Value){
                    box7Filled = false
                    box6Filled = true
                    box6Value = box6Value * 2
                    box7Value = 0
                    box7.innerText = ''
                    check()   
                }
                    if(box6Filled == false){
                        box7Filled = false
                        box6Filled = true
                        box6Value = box7Value
                        box7Value = 0
                        box7.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box5Filled == true){
                                if(box6Value == box5Value){
                                    box6Filled = false
                                    box5Filled = true
                                    box5Value = box5Value * 2
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            }
                            else if(box5Filled == false){
                                box6Filled = false
                                box5Filled = true
                                box5Value = box6Value
                                box6Value = 0
                                box6.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box7Filled == true && box8Filled == true){
                        if(box8Value == box7Value){
                            box8Filled = false
                            box7Filled = true
                            box7Value = box7Value * 2
                            box8Value = 0
                            box8.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box1Filled == false){
        if(box2Filled == false){
            if(box3Filled == true){
                box3Filled = false
                box2Filled = true
                box2Value = box3Value
                box3Value = 0
                box3.innerText = ''
                check()
                setTimeout(function(){
                    box2Filled = false
                    box1Filled = true
                    box1Value = box2Value
                    box2Value = 0
                    box2.innerText = ''
                    check()
                },40)
                if(box4Filled == true){
                    box4Filled = false
                    box3Filled = true
                    box3Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box2Filled == false){
                            box3Filled = false
                            box2Filled = true
                            box2Value = box3Value
                            box3Value = 0
                            box3.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box1Filled == false){
                                    box2Filled = false
                                    box1Filled = true
                                    box1Value = box2Value
                                    box2Value = 0
                                    box2.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box3Filled == false){
                if(box4Filled == true){
                    box4Filled = false
                    box3Filled = true
                    box3Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box2Filled == false){
                            box3Filled = false
                            box2Filled = true
                            box2Value = box3Value
                            box3Value = 0
                            box3.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box1Filled == false){
                                    box2Filled = false
                                    box1Filled = true
                                    box1Value = box2Value
                                    box2Value = 0
                                    box2.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box2Filled == true){
            box2Filled = false
            box1Filled = true
            box1Value = box2Value
            box2Value = 0
            box2.innerText = ''
            check()
            if(box3Filled == true){
                box3Filled = false
                box2Filled = true
                box2Value = box3Value
                box3Value = 0
                box3.innerText = ''
                check()
            }
        }
    }
    if(box1Filled == true){
        if(box2Filled == false){
            if(box3Filled == true){
                box3Filled = false
                box2Filled = true
                box2Value = box3Value
                box3Value = 0
                box3.innerText = ''
                check()
                setTimeout(function(){
                    if(box2Value == box1Value){
                        box2Filled = false
                        box1Filled = true
                        box1Value = box1Value * 2
                        box2Value = 0
                        box2.innerText = ''
                        check()
                    }
                },39)
                if(box4Filled == true){
                    box4Filled = false
                    box3Filled = true
                    box3Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box3Value == box2Value){
                            box3Filled = false
                            box2Filled = true
                            box2Value = box2Value * 2
                            box3Value = 0
                            box3.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box3Filled == false){
                if(box4Filled == true){
                    box4Filled = false
                    box3Filled = true
                    box3Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box2Filled == false){
                            box3Filled = false
                            box2Filled = true
                            box2Value = box3Value
                            box3Value = 0
                            box3.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box2Value == box1Value){
                                    box2Filled = false
                                    box1Filled = true
                                    box1Value = box1Value * 2
                                    box2Value = 0
                                    box2.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box2Filled == true){
            if(box2Value == box1Value){
                box2Filled = false
                box1Filled = true
                box1Value = box1Value * 2
                box2Value = 0
                box2.innerText = ''
                check()
            }
            if(box3Filled == false){
                if(box4Filled == true){
                    box4Filled = false
                    box3Filled = true
                    box3Value = box4Value
                    box4Value = 0
                    box4.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box2Filled == false){
                            box3Filled = false
                            box2Filled = true
                            box2Value = box3Value
                            box3Value = 0
                            box3.innerText = ''
                            check()
                        }
                        else if(box2Filled == true){
                            if(box2Value == box3Value){
                                box3Filled = false
                                box2Filled = true
                                box2Value = box2Value * 2
                                box3Value = 0
                                box3.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box2Value == box1Value){
                                box2Filled = false
                                box1Filled = true
                                box1Value = box1Value * 2
                                box2Value = 0
                                box2.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box3Filled == true){
                if(box3Value == box2Value){
                    box3Filled = false
                    box2Filled = true
                    box2Value = box2Value * 2
                    box3Value = 0
                    box3.innerText = ''
                    check()   
                }
                    if(box2Filled == false){
                        box3Filled = false
                        box2Filled = true
                        box2Value = box3Value
                        box3Value = 0
                        box3.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box1Filled == true){
                                if(box2Value == box1Value){
                                    box2Filled = false
                                    box1Filled = true
                                    box1Value = box1Value * 2
                                    box2Value = 0
                                    box2.innerText = ''
                                    check()
                                }
                            }
                            else if(box1Filled == false){
                                box2Filled = false
                                box1Filled = true
                                box1Value = box2Value
                                box2Value = 0
                                box2.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box3Filled == true && box4Filled == true){
                        if(box4Value == box3Value){
                            box4Filled = false
                            box3Filled = true
                            box3Value = box3Value * 2
                            box4Value = 0
                            box4.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
}

function up(){
    newBox()
    if(box1Filled == false){
        if(box5Filled == false){
            if(box9Filled == true){
                box9Filled = false
                box5Filled = true
                box5Value = box9Value
                box9Value = 0
                box9.innerText = ''
                check()
                setTimeout(function(){
                    box5Filled = false
                    box1Filled = true
                    box1Value = box5Value
                    box5Value = 0
                    box5.innerText = ''
                    check()
                },40)
                if(box13Filled == true){
                    box13Filled = false
                    box9Filled = true
                    box9Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box5Filled == false){
                            box9Filled = false
                            box5Filled = true
                            box5Value = box9Value
                            box9Value = 0
                            box9.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box1Filled == false){
                                    box5Filled = false
                                    box1Filled = true
                                    box1Value = box5Value
                                    box5Value = 0
                                    box5.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box9Filled == false){
                if(box13Filled == true){
                    box13Filled = false
                    box9Filled = true
                    box9Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box5Filled == false){
                            box9Filled = false
                            box5Filled = true
                            box5Value = box9Value
                            box9Value = 0
                            box9.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box1Filled == false){
                                    box5Filled = false
                                    box1Filled = true
                                    box1Value = box5Value
                                    box5Value = 0
                                    box5.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box5Filled == true){
            box5Filled = false
            box1Filled = true
            box1Value = box5Value
            box5Value = 0
            box5.innerText = ''
            check()
            if(box9Filled == true){
                box9Filled = false
                box5Filled = true
                box5Value = box9Value
                box9Value = 0
                box9.innerText = ''
                check()
            }
        }
    }
    if(box1Filled == true){
        if(box5Filled == false){
            if(box9Filled == true){
                box9Filled = false
                box5Filled = true
                box5Value = box9Value
                box9Value = 0
                box9.innerText = ''
                check()
                setTimeout(function(){
                    if(box5Value == box1Value){
                        box5Filled = false
                        box1Filled = true
                        box1Value = box1Value * 2
                        box5Value = 0
                        box5.innerText = ''
                        check()
                    }
                },39)
                if(box13Filled == true){
                    box13Filled = false
                    box9Filled = true
                    box9Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box9Value == box5Value){
                            box9Filled = false
                            box5Filled = true
                            box5Value = box5Value * 2
                            box9Value = 0
                            box9.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box9Filled == false){
                if(box13Filled == true){
                    box13Filled = false
                    box9Filled = true
                    box9Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box5Filled == false){
                            box9Filled = false
                            box5Filled = true
                            box5Value = box9Value
                            box9Value = 0
                            box9.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box5Value == box1Value){
                                    box5Filled = false
                                    box1Filled = true
                                    box1Value = box1Value * 2
                                    box5Value = 0
                                    box5.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box5Filled == true){
            if(box5Value == box1Value){
                box5Filled = false
                box1Filled = true
                box1Value = box1Value * 2
                box5Value = 0
                box5.innerText = ''
                check()
            }
            if(box9Filled == false){
                if(box13Filled == true){
                    box13Filled = false
                    box9Filled = true
                    box9Value = box13Value
                    box13Value = 0
                    box13.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box5Filled == false){
                            box9Filled = false
                            box5Filled = true
                            box5Value = box9Value
                            box9Value = 0
                            box9.innerText = ''
                            check()
                        }
                        else if(box5Filled == true){
                            if(box5Value == box9Value){
                                box9Filled = false
                                box5Filled = true
                                box5Value = box5Value * 2
                                box9Value = 0
                                box9.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box5Value == box1Value){
                                box5Filled = false
                                box1Filled = true
                                box1Value = box1Value * 2
                                box5Value = 0
                                box5.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box9Filled == true){
                if(box9Value == box5Value){
                    box9Filled = false
                    box5Filled = true
                    box5Value = box5Value * 2
                    box9Value = 0
                    box9.innerText = ''
                    check()   
                }
                    if(box5Filled == false){
                        box9Filled = false
                        box5Filled = true
                        box5Value = box9Value
                        box9Value = 0
                        box9.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box1Filled == true){
                                if(box5Value == box1Value){
                                    box5Filled = false
                                    box1Filled = true
                                    box1Value = box1Value * 2
                                    box5Value = 0
                                    box5.innerText = ''
                                    check()
                                }
                            }
                            else if(box1Filled == false){
                                box5Filled = false
                                box1Filled = true
                                box1Value = box5Value
                                box5Value = 0
                                box5.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box9Filled == true && box13Filled == true){
                        if(box13Value == box9Value){
                            box13Filled = false
                            box9Filled = true
                            box9Value = box9Value * 2
                            box13Value = 0
                            box13.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box2Filled == false){
        if(box6Filled == false){
            if(box10Filled == true){
                box10Filled = false
                box6Filled = true
                box6Value = box10Value
                box10Value = 0
                box10.innerText = ''
                check()
                setTimeout(function(){
                    box6Filled = false
                    box2Filled = true
                    box2Value = box6Value
                    box6Value = 0
                    box6.innerText = ''
                    check()
                },40)
                if(box14Filled == true){
                    box14Filled = false
                    box10Filled = true
                    box10Value = box14Value
                    box14Value = 0
                    box14.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box10Filled = false
                            box6Filled = true
                            box6Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box2Filled == false){
                                    box6Filled = false
                                    box2Filled = true
                                    box2Value = box6Value
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box10Filled == false){
                if(box14Filled == true){
                    box14Filled = false
                    box10Filled = true
                    box10Value = box14Value
                    box14Value = 0
                    box14.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box10Filled = false
                            box6Filled = true
                            box6Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box2Filled == false){
                                    box6Filled = false
                                    box2Filled = true
                                    box2Value = box6Value
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box6Filled == true){
            box6Filled = false
            box2Filled = true
            box2Value = box6Value
            box6Value = 0
            box6.innerText = ''
            check()
            if(box10Filled == true){
                box10Filled = false
                box6Filled = true
                box6Value = box10Value
                box10Value = 0
                box10.innerText = ''
                check()
            }
        }
    }
    if(box2Filled == true){
        if(box6Filled == false){
            if(box10Filled == true){
                box10Filled = false
                box6Filled = true
                box6Value = box10Value
                box10Value = 0
                box10.innerText = ''
                check()
                setTimeout(function(){
                    if(box6Value == box2Value){
                        box6Filled = false
                        box2Filled = true
                        box2Value = box2Value * 2
                        box6Value = 0
                        box6.innerText = ''
                        check()
                    }
                },39)
                if(box14Filled == true){
                    box14Filled = false
                    box10Filled = true
                    box10Value = box14Value
                    box14Value = 0
                    box14.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box10Value == box6Value){
                            box10Filled = false
                            box6Filled = true
                            box6Value = box6Value * 2
                            box10Value = 0
                            box10.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box10Filled == false){
                if(box14Filled == true){
                    box14Filled = false
                    box10Filled = true
                    box10Value = box14Value
                    box14Value = 0
                    box14.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box10Filled = false
                            box6Filled = true
                            box6Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box6Value == box2Value){
                                    box6Filled = false
                                    box2Filled = true
                                    box2Value = box2Value * 2
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box6Filled == true){
            if(box6Value == box2Value){
                box6Filled = false
                box2Filled = true
                box2Value = box2Value * 2
                box6Value = 0
                box6.innerText = ''
                check()
            }
            if(box10Filled == false){
                if(box14Filled == true){
                    box14Filled = false
                    box10Filled = true
                    box10Value = box14Value
                    box14Value = 0
                    box14.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box6Filled == false){
                            box10Filled = false
                            box6Filled = true
                            box6Value = box10Value
                            box10Value = 0
                            box10.innerText = ''
                            check()
                        }
                        else if(box6Filled == true){
                            if(box6Value == box10Value){
                                box10Filled = false
                                box6Filled = true
                                box6Value = box6Value * 2
                                box10Value = 0
                                box10.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box6Value == box2Value){
                                box6Filled = false
                                box2Filled = true
                                box2Value = box2Value * 2
                                box6Value = 0
                                box6.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box10Filled == true){
                if(box10Value == box6Value){
                    box10Filled = false
                    box6Filled = true
                    box6Value = box6Value * 2
                    box10Value = 0
                    box10.innerText = ''
                    check()   
                }
                    if(box6Filled == false){
                        box10Filled = false
                        box6Filled = true
                        box6Value = box10Value
                        box10Value = 0
                        box10.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box2Filled == true){
                                if(box6Value == box2Value){
                                    box6Filled = false
                                    box2Filled = true
                                    box2Value = box2Value * 2
                                    box6Value = 0
                                    box6.innerText = ''
                                    check()
                                }
                            }
                            else if(box2Filled == false){
                                box6Filled = false
                                box2Filled = true
                                box2Value = box6Value
                                box6Value = 0
                                box6.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box10Filled == true && box14Filled == true){
                        if(box14Value == box10Value){
                            box14Filled = false
                            box10Filled = true
                            box10Value = box10Value * 2
                            box14Value = 0
                            box14.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box3Filled == false){
        if(box7Filled == false){
            if(box11Filled == true){
                box11Filled = false
                box7Filled = true
                box7Value = box11Value
                box11Value = 0
                box11.innerText = ''
                check()
                setTimeout(function(){
                    box7Filled = false
                    box3Filled = true
                    box3Value = box7Value
                    box7Value = 0
                    box7.innerText = ''
                    check()
                },40)
                if(box15Filled == true){
                    box15Filled = false
                    box11Filled = true
                    box11Value = box15Value
                    box15Value = 0
                    box15.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box11Filled = false
                            box7Filled = true
                            box7Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box3Filled == false){
                                    box7Filled = false
                                    box3Filled = true
                                    box3Value = box7Value
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box11Filled == false){
                if(box15Filled == true){
                    box15Filled = false
                    box11Filled = true
                    box11Value = box15Value
                    box15Value = 0
                    box15.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box11Filled = false
                            box7Filled = true
                            box7Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box3Filled == false){
                                    box7Filled = false
                                    box3Filled = true
                                    box3Value = box7Value
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box7Filled == true){
            box7Filled = false
            box3Filled = true
            box3Value = box7Value
            box7Value = 0
            box7.innerText = ''
            check()
            if(box11Filled == true){
                box11Filled = false
                box7Filled = true
                box7Value = box11Value
                box11Value = 0
                box11.innerText = ''
                check()
            }
        }
    }
    if(box3Filled == true){
        if(box7Filled == false){
            if(box11Filled == true){
                box11Filled = false
                box7Filled = true
                box7Value = box11Value
                box11Value = 0
                box11.innerText = ''
                check()
                setTimeout(function(){
                    if(box7Value == box3Value){
                        box7Filled = false
                        box3Filled = true
                        box3Value = box3Value * 2
                        box7Value = 0
                        box7.innerText = ''
                        check()
                    }
                },39)
                if(box15Filled == true){
                    box15Filled = false
                    box11Filled = true
                    box11Value = box15Value
                    box15Value = 0
                    box15.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box11Value == box7Value){
                            box11Filled = false
                            box7Filled = true
                            box7Value = box7Value * 2
                            box11Value = 0
                            box11.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box11Filled == false){
                if(box15Filled == true){
                    box15Filled = false
                    box11Filled = true
                    box11Value = box15Value
                    box15Value = 0
                    box15.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box11Filled = false
                            box7Filled = true
                            box7Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box7Value == box3Value){
                                    box7Filled = false
                                    box3Filled = true
                                    box3Value = box3Value * 2
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box7Filled == true){
            if(box7Value == box3Value){
                box7Filled = false
                box3Filled = true
                box3Value = box3Value * 2
                box7Value = 0
                box7.innerText = ''
                check()
            }
            if(box11Filled == false){
                if(box15Filled == true){
                    box15Filled = false
                    box11Filled = true
                    box11Value = box15Value
                    box15Value = 0
                    box15.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box7Filled == false){
                            box11Filled = false
                            box7Filled = true
                            box7Value = box11Value
                            box11Value = 0
                            box11.innerText = ''
                            check()
                        }
                        else if(box7Filled == true){
                            if(box7Value == box11Value){
                                box11Filled = false
                                box7Filled = true
                                box7Value = box7Value * 2
                                box11Value = 0
                                box11.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box7Value == box3Value){
                                box7Filled = false
                                box3Filled = true
                                box3Value = box3Value * 2
                                box7Value = 0
                                box7.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box11Filled == true){
                if(box11Value == box7Value){
                    box11Filled = false
                    box7Filled = true
                    box7Value = box7Value * 2
                    box11Value = 0
                    box11.innerText = ''
                    check()   
                }
                    if(box7Filled == false){
                        box11Filled = false
                        box7Filled = true
                        box7Value = box11Value
                        box11Value = 0
                        box11.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box3Filled == true){
                                if(box7Value == box3Value){
                                    box7Filled = false
                                    box3Filled = true
                                    box3Value = box3Value * 2
                                    box7Value = 0
                                    box7.innerText = ''
                                    check()
                                }
                            }
                            else if(box3Filled == false){
                                box7Filled = false
                                box3Filled = true
                                box3Value = box7Value
                                box7Value = 0
                                box7.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box11Filled == true && box15Filled == true){
                        if(box15Value == box11Value){
                            box15Filled = false
                            box11Filled = true
                            box11Value = box11Value * 2
                            box15Value = 0
                            box15.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    if(box4Filled == false){
        if(box8Filled == false){
            if(box12Filled == true){
                box12Filled = false
                box8Filled = true
                box8Value = box12Value
                box12Value = 0
                box12.innerText = ''
                check()
                setTimeout(function(){
                    box8Filled = false
                    box4Filled = true
                    box4Value = box8Value
                    box8Value = 0
                    box8.innerText = ''
                    check()
                },40)
                if(box16Filled == true){
                    box16Filled = false
                    box12Filled = true
                    box12Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box8Filled == false){
                            box12Filled = false
                            box8Filled = true
                            box8Value = box12Value
                            box12Value = 0
                            box12.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box4Filled == false){
                                    box8Filled = false
                                    box4Filled = true
                                    box4Value = box8Value
                                    box8Value = 0
                                    box8.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
            else if(box12Filled == false){
                if(box16Filled == true){
                    box16Filled = false
                    box12Filled = true
                    box12Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box8Filled == false){
                            box12Filled = false
                            box8Filled = true
                            box8Value = box12Value
                            box12Value = 0
                            box12.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box4Filled == false){
                                    box8Filled = false
                                    box4Filled = true
                                    box4Value = box8Value
                                    box8Value = 0
                                    box8.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box8Filled == true){
            box8Filled = false
            box4Filled = true
            box4Value = box8Value
            box8Value = 0
            box8.innerText = ''
            check()
            if(box12Filled == true){
                box12Filled = false
                box8Filled = true
                box8Value = box12Value
                box12Value = 0
                box12.innerText = ''
                check()
            }
        }
    }
    if(box4Filled == true){
        if(box8Filled == false){
            if(box12Filled == true){
                box12Filled = false
                box8Filled = true
                box8Value = box12Value
                box12Value = 0
                box12.innerText = ''
                check()
                setTimeout(function(){
                    if(box8Value == box4Value){
                        box8Filled = false
                        box4Filled = true
                        box4Value = box4Value * 2
                        box8Value = 0
                        box8.innerText = ''
                        check()
                    }
                },39)
                if(box16Filled == true){
                    box16Filled = false
                    box12Filled = true
                    box12Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box12Value == box8Value){
                            box12Filled = false
                            box8Filled = true
                            box8Value = box8Value * 2
                            box12Value = 0
                            box12.innerText = ''
                            check()
                        }
                    },40)
                }
            }
            else if(box12Filled == false){
                if(box16Filled == true){
                    box16Filled = false
                    box12Filled = true
                    box12Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box8Filled == false){
                            box12Filled = false
                            box8Filled = true
                            box8Value = box12Value
                            box12Value = 0
                            box12.innerText = ''
                            check()
                            setTimeout(function(){
                                if(box8Value == box4Value){
                                    box8Filled = false
                                    box4Filled = true
                                    box4Value = box4Value * 2
                                    box8Value = 0
                                    box8.innerText = ''
                                    check()
                                }
                            },40)
                        }
                    },40)
                }
            }
        }
        else if(box8Filled == true){
            if(box8Value == box4Value){
                box8Filled = false
                box4Filled = true
                box4Value = box4Value * 2
                box8Value = 0
                box8.innerText = ''
                check()
            }
            if(box12Filled == false){
                if(box16Filled == true){
                    box16Filled = false
                    box12Filled = true
                    box12Value = box16Value
                    box16Value = 0
                    box16.innerText = ''
                    check()
                    setTimeout(function(){
                        if(box8Filled == false){
                            box12Filled = false
                            box8Filled = true
                            box8Value = box12Value
                            box12Value = 0
                            box12.innerText = ''
                            check()
                        }
                        else if(box8Filled == true){
                            if(box8Value == box12Value){
                                box12Filled = false
                                box8Filled = true
                                box8Value = box8Value * 2
                                box12Value = 0
                                box12.innerText = ''
                                check()
                            }
                        }
                        setTimeout(function(){
                            if(box8Value == box4Value){
                                box8Filled = false
                                box4Filled = true
                                box4Value = box4Value * 2
                                box8Value = 0
                                box8.innerText = ''
                                check()
                            }
                        },40)
                    },40)
                }
            }
            else if(box12Filled == true){
                if(box12Value == box8Value){
                    box12Filled = false
                    box8Filled = true
                    box8Value = box8Value * 2
                    box12Value = 0
                    box12.innerText = ''
                    check()   
                }
                    if(box8Filled == false){
                        box12Filled = false
                        box8Filled = true
                        box8Value = box12Value
                        box12Value = 0
                        box12.innerText = ''
                        check()
                        setTimeout(function(){
                            if(box4Filled == true){
                                if(box8Value == box4Value){
                                    box8Filled = false
                                    box4Filled = true
                                    box4Value = box4Value * 2
                                    box8Value = 0
                                    box8.innerText = ''
                                    check()
                                }
                            }
                            else if(box4Filled == false){
                                box8Filled = false
                                box4Filled = true
                                box4Value = box8Value
                                box8Value = 0
                                box8.innerText = ''
                                check()
                            }
                        },40)
                    }
                    if(box12Filled == true && box16Filled == true){
                        if(box16Value == box12Value){
                            box16Filled = false
                            box12Filled = true
                            box12Value = box12Value * 2
                            box16Value = 0
                            box16.innerText = ''
                            check() 
                        }
                    }
            }
        }
    }
    

}
function check(){
    if(box1Filled == false){
        box1.style.backgroundColor = '#C9BCB3'
        box1.style.innerText = ''
    }
    if(box2Filled == false){
        box2.style.backgroundColor = '#C9BCB3'
        box2.style.innerText = ''
    }
    if(box3Filled == false){
        box3.style.backgroundColor = '#C9BCB3'
        box3.style.innerText = ''
    }
    if(box4Filled == false){
        box4.style.backgroundColor = '#C9BCB3'
        box4.style.innerText = ''
    }
    if(box5Filled == false){
        box5.style.backgroundColor = '#C9BCB3'
        box5.style.innerText = ''
    }
    if(box6Filled == false){
        box6.style.backgroundColor = '#C9BCB3'
        box6.style.innerText = ''
    }
    if(box7Filled == false){
        box7.style.backgroundColor = '#C9BCB3'
        box7.style.innerText = ''
    }
    if(box8Filled == false){
        box8.style.backgroundColor = '#C9BCB3'
        box8.style.innerText = ''
    }
    if(box9Filled == false){
        box9.style.backgroundColor = '#C9BCB3'
        box9.style.innerText = ''
    }
    if(box10Filled == false){
        box10.style.backgroundColor = '#C9BCB3'
        box10.style.innerText = ''
    }
    if(box11Filled == false){
        box11.style.backgroundColor = '#C9BCB3'
        box11.style.innerText = ''
    }
    if(box12Filled == false){
        box12.style.backgroundColor = '#C9BCB3'
        box12.style.innerText = ''
    }
    if(box13Filled == false){
        box13.style.backgroundColor = '#C9BCB3'
        box13.style.innerText = ''
    }
    if(box14Filled == false){
        box14.style.backgroundColor = '#C9BCB3'
        box14.style.innerText = ''
    }
    if(box15Filled == false){
        box15.style.backgroundColor = '#C9BCB3'
        box15.style.innerText = ''
    }
    if(box16Filled == false){
        box16.style.backgroundColor = '#C9BCB3'
        box16.style.innerText = ''
    }
    if(box1Filled == true){
        if(box1Value == 0){
            box1.innerText = ''
            box1.style.color = '#766D64'
            box1.style.backgroundColor = '#EFE5D8'
        }
        if(box1Value == 2){
            box1.innerText = '2'
            box1.style.color = '#766D64'
            box1.style.backgroundColor = '#EFE5D8'
        }
        if(box1Value == 4){
            box1.innerText = '4'
            box1.style.color = '#766D64'
            box1.style.backgroundColor = '#CFC9BB'
        }
        if(box1Value == 8){
            box1.innerText = '8'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#EDAC78'
        }
        if(box1Value == 16){
            box1.innerText = '16'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#F1905F'
        }
        if(box1Value == 32){
            box1.innerText = '32'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#F57B5D'
        }
        if(box1Value == 64){
            box1.innerText = '64'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#EA5A38'
        }
        if(box1Value == 128){
            box1.innerText = '128'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#E8C86E'
        }
        if(box1Value == 256){
            box1.innerText = '256'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#F2D04B'
        }
        if(box1Value == 512){
            box1.innerText = '512'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#E5C24D'
        }
        if(box1Value == 1024){
            box1.innerText = '1024'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#E3BA14'
        }
        if(box1Value == 2048){
            box1.innerText = '2048'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#ECC402'
        }
        if(box1Value == 4096){
            box1.innerText = '4096'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = '#60D992'
        }
        if(box1Value == 8192){
            box1.innerText = '8192'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = 'red'
        }
        if(box1Value == 16384){
            box1.innerText = '16384'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = 'red'
        }
        if(box1Value == 32768){
            box1.innerText = '32768'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = 'red'
        }
        if(box1Value == 65536){
            box1.innerText = '65536'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = 'red'
        }
        if(box1Value == 131072){
            box1.innerText = '131072'
            box1.style.color = '#FBFCF7'
            box1.style.backgroundColor = 'red'
        }
    }
    if(box2Filled == true){
        if(box2Value == 2){
            box2.innerText = '2'
            box2.style.color = '#766D64'
            box2.style.backgroundColor = '#EFE5D8'
        }
        if(box2Value == 4){
            box2.innerText = '4'
            box2.style.color = '#766D64'
            box2.style.backgroundColor = '#CFC9BB'
        }
        if(box2Value == 8){
            box2.innerText = '8'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#EDAC78'
        }
        if(box2Value == 16){
            box2.innerText = '16'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#F1905F'
        }
        if(box2Value == 32){
            box2.innerText = '32'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#F57B5D'
        }
        if(box2Value == 64){
            box2.innerText = '64'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#EA5A38'
        }
        if(box2Value == 128){
            box2.innerText = '128'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#E8C86E'
        }
        if(box2Value == 256){
            box2.innerText = '256'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#F2D04B'
        }
        if(box2Value == 512){
            box2.innerText = '512'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#E5C24D'
        }
        if(box2Value == 1024){
            box2.innerText = '1024'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#E3BA14'
        }
        if(box2Value == 2048){
            box2.innerText = '2048'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#ECC402'
        }
        if(box2Value == 4096){
            box2.innerText = '4096'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = '#60D992'
        }
        if(box2Value == 8192){
            box2.innerText = '8192'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = 'red'
        }
        if(box2Value == 16384){
            box2.innerText = '16384'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = 'red'
        }
        if(box2Value == 32768){
            box2.innerText = '32768'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = 'red'
        }
        if(box2Value == 65536){
            box2.innerText = '65536'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = 'red'
        }
        if(box2Value == 131072){
            box2.innerText = '131072'
            box2.style.color = '#FBFCF7'
            box2.style.backgroundColor = 'red'
        }
    }
    if(box3Filled == true){
        if(box3Value == 2){
            box3.innerText = '2'
            box3.style.color = '#766D64'
            box3.style.backgroundColor = '#EFE5D8'
        }
        if(box3Value == 4){
            box3.innerText = '4'
            box3.style.color = '#766D64'
            box3.style.backgroundColor = '#CFC9BB'
        }
        if(box3Value == 8){
            box3.innerText = '8'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#EDAC78'
        }
        if(box3Value == 16){
            box3.innerText = '16'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#F1905F'
        }
        if(box3Value == 32){
            box3.innerText = '32'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#F57B5D'
        }
        if(box3Value == 64){
            box3.innerText = '64'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#EA5A38'
        }
        if(box3Value == 128){
            box3.innerText = '128'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#E8C86E'
        }
        if(box3Value == 256){
            box3.innerText = '256'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#F2D04B'
        }
        if(box3Value == 512){
            box3.innerText = '512'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#E5C24D'
        }
        if(box3Value == 1024){
            box3.innerText = '1024'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#E3BA14'
        }
        if(box3Value == 2048){
            box3.innerText = '2048'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#ECC402'
        }
        if(box3Value == 4096){
            box3.innerText = '4096'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = '#60D992'
        }
        if(box3Value == 8192){
            box3.innerText = '8192'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = 'red'
        }
        if(box3Value == 16384){
            box3.innerText = '16384'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = 'red'
        }
        if(box3Value == 32768){
            box3.innerText = '32768'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = 'red'
        }
        if(box3Value == 65536){
            box3.innerText = '65536'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = 'red'
        }
        if(box3Value == 131072){
            box3.innerText = '131072'
            box3.style.color = '#FBFCF7'
            box3.style.backgroundColor = 'red'
        }
    }
    if(box4Filled == true){
        if(box4Value == 2){
            box4.innerText = '2'
            box4.style.color = '#766D64'
            box4.style.backgroundColor = '#EFE5D8'
        }
        if(box4Value == 4){
            box4.innerText = '4'
            box4.style.color = '#766D64'
            box4.style.backgroundColor = '#CFC9BB'
        }
        if(box4Value == 8){
            box4.innerText = '8'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#EDAC78'
        }
        if(box4Value == 16){
            box4.innerText = '16'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#F1905F'
        }
        if(box4Value == 32){
            box4.innerText = '32'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#F57B5D'
        }
        if(box4Value == 64){
            box4.innerText = '64'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#EA5A38'
        }
        if(box4Value == 128){
            box4.innerText = '128'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#E8C86E'
        }
        if(box4Value == 256){
            box4.innerText = '256'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#F2D04B'
        }
        if(box4Value == 512){
            box4.innerText = '512'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#E5C24D'
        }
        if(box4Value == 1024){
            box4.innerText = '1024'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#E3BA14'
        }
        if(box4Value == 2048){
            box4.innerText = '2048'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#ECC402'
        }
        if(box4Value == 4096){
            box4.innerText = '4096'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = '#60D992'
        }
        if(box4Value == 8192){
            box4.innerText = '8192'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = 'red'
        }
        if(box4Value == 16384){
            box4.innerText = '16384'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = 'red'
        }
        if(box4Value == 32768){
            box4.innerText = '32768'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = 'red'
        }
        if(box4Value == 65536){
            box4.innerText = '65536'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = 'red'
        }
        if(box4Value == 131072){
            box4.innerText = '131072'
            box4.style.color = '#FBFCF7'
            box4.style.backgroundColor = 'red'
        }
    }
    if(box5Filled == true){
        if(box5Value == 2){
            box5.innerText = '2'
            box5.style.color = '#766D64'
            box5.style.backgroundColor = '#EFE5D8'
        }
        if(box5Value == 4){
            box5.innerText = '4'
            box5.style.color = '#766D64'
            box5.style.backgroundColor = '#CFC9BB'
        }
        if(box5Value == 8){
            box5.innerText = '8'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#EDAC78'
        }
        if(box5Value == 16){
            box5.innerText = '16'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#F1905F'
        }
        if(box5Value == 32){
            box5.innerText = '32'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#F57B5D'
        }
        if(box5Value == 64){
            box5.innerText = '64'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#EA5A38'
        }
        if(box5Value == 128){
            box5.innerText = '128'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#E8C86E'
        }
        if(box5Value == 256){
            box5.innerText = '256'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#F2D04B'
        }
        if(box5Value == 512){
            box5.innerText = '512'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#E5C24D'
        }
        if(box5Value == 1024){
            box5.innerText = '1024'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#E3BA14'
        }
        if(box5Value == 2048){
            box5.innerText = '2048'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#ECC402'
        }
        if(box5Value == 4096){
            box5.innerText = '4096'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = '#60D992'
        }
        if(box5Value == 8192){
            box5.innerText = '8192'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = 'red'
        }
        if(box5Value == 16384){
            box5.innerText = '16384'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = 'red'
        }
        if(box5Value == 32768){
            box5.innerText = '32768'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = 'red'
        }
        if(box5Value == 65536){
            box5.innerText = '65536'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = 'red'
        }
        if(box5Value == 131072){
            box5.innerText = '131072'
            box5.style.color = '#FBFCF7'
            box5.style.backgroundColor = 'red'
        }
    }
    if(box6Filled == true){
        if(box6Value == 2){
            box6.innerText = '2'
            box6.style.color = '#766D64'
            box6.style.backgroundColor = '#EFE5D8'
        }
        if(box6Value == 4){
            box6.innerText = '4'
            box6.style.color = '#766D64'
            box6.style.backgroundColor = '#CFC9BB'
        }
        if(box6Value == 8){
            box6.innerText = '8'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#EDAC78'
        }
        if(box6Value == 16){
            box6.innerText = '16'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#F1905F'
        }
        if(box6Value == 32){
            box6.innerText = '32'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#F57B5D'
        }
        if(box6Value == 64){
            box6.innerText = '64'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#EA5A38'
        }
        if(box6Value == 128){
            box6.innerText = '128'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#E8C86E'
        }
        if(box6Value == 256){
            box6.innerText = '256'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#F2D04B'
        }
        if(box6Value == 512){
            box6.innerText = '512'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#E5C24D'
        }
        if(box6Value == 1024){
            box6.innerText = '1024'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#E3BA14'
        }
        if(box6Value == 2048){
            box6.innerText = '2048'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#ECC402'
        }
        if(box6Value == 4096){
            box6.innerText = '4096'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = '#60D992'
        }
        if(box6Value == 8192){
            box6.innerText = '8192'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = 'red'
        }
        if(box6Value == 16384){
            box6.innerText = '16384'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = 'red'
        }
        if(box6Value == 32768){
            box6.innerText = '32768'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = 'red'
        }
        if(box6Value == 65536){
            box6.innerText = '65536'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = 'red'
        }
        if(box6Value == 131072){
            box6.innerText = '131072'
            box6.style.color = '#FBFCF7'
            box6.style.backgroundColor = 'red'
        }
    }
    if(box7Filled == true){
        if(box7Value == 2){
            box7.innerText = '2'
            box7.style.color = '#766D64'
            box7.style.backgroundColor = '#EFE5D8'
        }
        if(box7Value == 4){
            box7.innerText = '4'
            box7.style.color = '#766D64'
            box7.style.backgroundColor = '#CFC9BB'
        }
        if(box7Value == 8){
            box7.innerText = '8'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#EDAC78'
        }
        if(box7Value == 16){
            box7.innerText = '16'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#F1905F'
        }
        if(box7Value == 32){
            box7.innerText = '32'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#F57B5D'
        }
        if(box7Value == 64){
            box7.innerText = '64'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#EA5A38'
        }
        if(box7Value == 128){
            box7.innerText = '128'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#E8C86E'
        }
        if(box7Value == 256){
            box7.innerText = '256'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#F2D04B'
        }
        if(box7Value == 512){
            box7.innerText = '512'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#E5C24D'
        }
        if(box7Value == 1024){
            box7.innerText = '1024'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#E3BA14'
        }
        if(box7Value == 2048){
            box7.innerText = '2048'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#ECC402'
        }
        if(box7Value == 4096){
            box7.innerText = '4096'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = '#60D992'
        }
        if(box7Value == 8192){
            box7.innerText = '8192'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = 'red'
        }
        if(box7Value == 16384){
            box7.innerText = '16384'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = 'red'
        }
        if(box7Value == 32768){
            box7.innerText = '32768'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = 'red'
        }
        if(box7Value == 65536){
            box7.innerText = '65536'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = 'red'
        }
        if(box7Value == 131072){
            box7.innerText = '131072'
            box7.style.color = '#FBFCF7'
            box7.style.backgroundColor = 'red'
        }
    }
    if(box8Filled == true){
        if(box8Value == 2){
            box8.innerText = '2'
            box8.style.color = '#766D64'
            box8.style.backgroundColor = '#EFE5D8'
        }
        if(box8Value == 4){
            box8.innerText = '4'
            box8.style.color = '#766D64'
            box8.style.backgroundColor = '#CFC9BB'
        }
        if(box8Value == 8){
            box8.innerText = '8'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#EDAC78'
        }
        if(box8Value == 16){
            box8.innerText = '16'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#F1905F'
        }
        if(box8Value == 32){
            box8.innerText = '32'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#F57B5D'
        }
        if(box8Value == 64){
            box8.innerText = '64'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#EA5A38'
        }
        if(box8Value == 128){
            box8.innerText = '128'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#E8C86E'
        }
        if(box8Value == 256){
            box8.innerText = '256'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#F2D04B'
        }
        if(box8Value == 512){
            box8.innerText = '512'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#E5C24D'
        }
        if(box8Value == 1024){
            box8.innerText = '1024'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#E3BA14'
        }
        if(box8Value == 2048){
            box8.innerText = '2048'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#ECC402'
        }
        if(box8Value == 4096){
            box8.innerText = '4096'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = '#60D992'
        }
        if(box8Value == 8192){
            box8.innerText = '8192'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = 'red'
        }
        if(box8Value == 16384){
            box8.innerText = '16384'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = 'red'
        }
        if(box8Value == 32768){
            box8.innerText = '32768'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = 'red'
        }
        if(box8Value == 65536){
            box8.innerText = '65536'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = 'red'
        }
        if(box8Value == 131072){
            box8.innerText = '131072'
            box8.style.color = '#FBFCF7'
            box8.style.backgroundColor = 'red'
        }
    }
    if(box9Filled == true){
        if(box9Value == 2){
            box9.innerText = '2'
            box9.style.color = '#766D64'
            box9.style.backgroundColor = '#EFE5D8'
        }
        if(box9Value == 4){
            box9.innerText = '4'
            box9.style.color = '#766D64'
            box9.style.backgroundColor = '#CFC9BB'
        }
        if(box9Value == 8){
            box9.innerText = '8'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#EDAC78'
        }
        if(box9Value == 16){
            box9.innerText = '16'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#F1905F'
        }
        if(box9Value == 32){
            box9.innerText = '32'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#F57B5D'
        }
        if(box9Value == 64){
            box9.innerText = '64'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#EA5A38'
        }
        if(box9Value == 128){
            box9.innerText = '128'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#E8C86E'
        }
        if(box9Value == 256){
            box9.innerText = '256'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#F2D04B'
        }
        if(box9Value == 512){
            box9.innerText = '512'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#E5C24D'
        }
        if(box9Value == 1024){
            box9.innerText = '1024'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#E3BA14'
        }
        if(box9Value == 2048){
            box9.innerText = '2048'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#ECC402'
        }
        if(box9Value == 4096){
            box9.innerText = '4096'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = '#60D992'
        }
        if(box9Value == 8192){
            box9.innerText = '8192'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = 'red'
        }
        if(box9Value == 16384){
            box9.innerText = '16384'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = 'red'
        }
        if(box9Value == 32768){
            box9.innerText = '32768'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = 'red'
        }
        if(box9Value == 65536){
            box9.innerText = '65536'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = 'red'
        }
        if(box9Value == 131072){
            box9.innerText = '131072'
            box9.style.color = '#FBFCF7'
            box9.style.backgroundColor = 'red'
        }
    }
    if(box10Filled == true){
        if(box10Value == 2){
            box10.innerText = '2'
            box10.style.color = '#766D64'
            box10.style.backgroundColor = '#EFE5D8'
        }
        if(box10Value == 4){
            box10.innerText = '4'
            box10.style.color = '#766D64'
            box10.style.backgroundColor = '#CFC9BB'
        }
        if(box10Value == 8){
            box10.innerText = '8'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#EDAC78'
        }
        if(box10Value == 16){
            box10.innerText = '16'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#F1905F'
        }
        if(box10Value == 32){
            box10.innerText = '32'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#F57B5D'
        }
        if(box10Value == 64){
            box10.innerText = '64'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#EA5A38'
        }
        if(box10Value == 128){
            box10.innerText = '128'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#E8C86E'
        }
        if(box10Value == 256){
            box10.innerText = '256'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#F2D04B'
        }
        if(box10Value == 512){
            box10.innerText = '512'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#E5C24D'
        }
        if(box10Value == 1024){
            box10.innerText = '1024'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#E3BA14'
        }
        if(box10Value == 2048){
            box10.innerText = '2048'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#ECC402'
        }
        if(box10Value == 4096){
            box10.innerText = '4096'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = '#60D992'
        }
        if(box10Value == 8192){
            box10.innerText = '8192'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = 'red'
        }
        if(box10Value == 16384){
            box10.innerText = '16384'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = 'red'
        }
        if(box10Value == 32768){
            box10.innerText = '32768'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = 'red'
        }
        if(box10Value == 65536){
            box10.innerText = '65536'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = 'red'
        }
        if(box10Value == 131072){
            box10.innerText = '131072'
            box10.style.color = '#FBFCF7'
            box10.style.backgroundColor = 'red'
        }
    }
    if(box11Filled == true){
        if(box11Value == 2){
            box11.innerText = '2'
            box11.style.color = '#766D64'
            box11.style.backgroundColor = '#EFE5D8'
        }
        if(box11Value == 4){
            box11.innerText = '4'
            box11.style.color = '#766D64'
            box11.style.backgroundColor = '#CFC9BB'
        }
        if(box11Value == 8){
            box11.innerText = '8'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#EDAC78'
        }
        if(box11Value == 16){
            box11.innerText = '16'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#F1905F'
        }
        if(box11Value == 32){
            box11.innerText = '32'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#F57B5D'
        }
        if(box11Value == 64){
            box11.innerText = '64'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#EA5A38'
        }
        if(box11Value == 128){
            box11.innerText = '128'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#E8C86E'
        }
        if(box11Value == 256){
            box11.innerText = '256'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#F2D04B'
        }
        if(box11Value == 512){
            box11.innerText = '512'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#E5C24D'
        }
        if(box11Value == 1024){
            box11.innerText = '1024'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#E3BA14'
        }
        if(box11Value == 2048){
            box11.innerText = '2048'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#ECC402'
        }
        if(box11Value == 4096){
            box11.innerText = '4096'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = '#60D992'
        }
        if(box11Value == 8192){
            box11.innerText = '8192'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = 'red'
        }
        if(box11Value == 16384){
            box11.innerText = '16384'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = 'red'
        }
        if(box11Value == 32768){
            box11.innerText = '32768'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = 'red'
        }
        if(box11Value == 65536){
            box11.innerText = '65536'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = 'red'
        }
        if(box11Value == 131072){
            box11.innerText = '131072'
            box11.style.color = '#FBFCF7'
            box11.style.backgroundColor = 'red'
        }
    }
    if(box12Filled == true){
        if(box12Value == 2){
            box12.innerText = '2'
            box12.style.color = '#766D64'
            box12.style.backgroundColor = '#EFE5D8'
        }
        if(box12Value == 4){
            box12.innerText = '4'
            box12.style.color = '#766D64'
            box12.style.backgroundColor = '#CFC9BB'
        }
        if(box12Value == 8){
            box12.innerText = '8'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#EDAC78'
        }
        if(box12Value == 16){
            box12.innerText = '16'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#F1905F'
        }
        if(box12Value == 32){
            box12.innerText = '32'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#F57B5D'
        }
        if(box12Value == 64){
            box12.innerText = '64'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#EA5A38'
        }
        if(box12Value == 128){
            box12.innerText = '128'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#E8C86E'
        }
        if(box12Value == 256){
            box12.innerText = '256'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#F2D04B'
        }
        if(box12Value == 512){
            box12.innerText = '512'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#E5C24D'
        }
        if(box12Value == 1024){
            box12.innerText = '1024'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#E3BA14'
        }
        if(box12Value == 2048){
            box12.innerText = '2048'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#ECC402'
        }
        if(box12Value == 4096){
            box12.innerText = '4096'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = '#60D992'
        }
        if(box12Value == 8192){
            box12.innerText = '8192'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = 'red'
        }
        if(box12Value == 16384){
            box12.innerText = '16384'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = 'red'
        }
        if(box12Value == 32768){
            box12.innerText = '32768'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = 'red'
        }
        if(box12Value == 65536){
            box12.innerText = '65536'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = 'red'
        }
        if(box12Value == 131072){
            box12.innerText = '131072'
            box12.style.color = '#FBFCF7'
            box12.style.backgroundColor = 'red'
        }
    }
    if(box13Filled == true){
        if(box13Value == 2){
            box13.innerText = '2'
            box13.style.color = '#766D64'
            box13.style.backgroundColor = '#EFE5D8'
        }
        if(box13Value == 4){
            box13.innerText = '4'
            box13.style.color = '#766D64'
            box13.style.backgroundColor = '#CFC9BB'
        }
        if(box13Value == 8){
            box13.innerText = '8'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#EDAC78'
        }
        if(box13Value == 16){
            box13.innerText = '16'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#F1905F'
        }
        if(box13Value == 32){
            box13.innerText = '32'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#F57B5D'
        }
        if(box13Value == 64){
            box13.innerText = '64'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#EA5A38'
        }
        if(box13Value == 128){
            box13.innerText = '128'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#E8C86E'
        }
        if(box13Value == 256){
            box13.innerText = '256'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#F2D04B'
        }
        if(box13Value == 512){
            box13.innerText = '512'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#E5C24D'
        }
        if(box13Value == 1024){
            box13.innerText = '1024'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#E3BA14'
        }
        if(box13Value == 2048){
            box13.innerText = '2048'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#ECC402'
        }
        if(box13Value == 4096){
            box13.innerText = '4096'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = '#60D992'
        }
        if(box13Value == 8192){
            box13.innerText = '8192'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = 'red'
        }
        if(box13Value == 16384){
            box13.innerText = '16384'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = 'red'
        }
        if(box13Value == 32768){
            box13.innerText = '32768'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = 'red'
        }
        if(box13Value == 65536){
            box13.innerText = '65536'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = 'red'
        }
        if(box13Value == 131072){
            box13.innerText = '131072'
            box13.style.color = '#FBFCF7'
            box13.style.backgroundColor = 'red'
        }
    }
    if(box14Filled == true){
        if(box14Value == 2){
            box14.innerText = '2'
            box14.style.color = '#766D64'
            box14.style.backgroundColor = '#EFE5D8'
        }
        if(box14Value == 4){
            box14.innerText = '4'
            box14.style.color = '#766D64'
            box14.style.backgroundColor = '#CFC9BB'
        }
        if(box14Value == 8){
            box14.innerText = '8'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#EDAC78'
        }
        if(box14Value == 16){
            box14.innerText = '16'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#F1905F'
        }
        if(box14Value == 32){
            box14.innerText = '32'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#F57B5D'
        }
        if(box14Value == 64){
            box14.innerText = '64'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#EA5A38'
        }
        if(box14Value == 128){
            box14.innerText = '128'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#E8C86E'
        }
        if(box14Value == 256){
            box14.innerText = '256'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#F2D04B'
        }
        if(box14Value == 512){
            box14.innerText = '512'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#E5C24D'
        }
        if(box14Value == 1024){
            box14.innerText = '1024'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#E3BA14'
        }
        if(box14Value == 2048){
            box14.innerText = '2048'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#ECC402'
        }
        if(box14Value == 4096){
            box14.innerText = '4096'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = '#60D992'
        }
        if(box14Value == 8192){
            box14.innerText = '8192'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = 'red'
        }
        if(box14Value == 16384){
            box14.innerText = '16384'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = 'red'
        }
        if(box14Value == 32768){
            box14.innerText = '32768'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = 'red'
        }
        if(box14Value == 65536){
            box14.innerText = '65536'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = 'red'
        }
        if(box14Value == 131072){
            box14.innerText = '131072'
            box14.style.color = '#FBFCF7'
            box14.style.backgroundColor = 'red'
        }
    }
    if(box15Filled == true){
        if(box15Value == 2){
            box15.innerText = '2'
            box15.style.color = '#766D64'
            box15.style.backgroundColor = '#EFE5D8'
        }
        if(box15Value == 4){
            box15.innerText = '4'
            box15.style.color = '#766D64'
            box15.style.backgroundColor = '#CFC9BB'
        }
        if(box15Value == 8){
            box15.innerText = '8'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#EDAC78'
        }
        if(box15Value == 16){
            box15.innerText = '16'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#F1905F'
        }
        if(box15Value == 32){
            box15.innerText = '32'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#F57B5D'
        }
        if(box15Value == 64){
            box15.innerText = '64'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#EA5A38'
        }
        if(box15Value == 128){
            box15.innerText = '128'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#E8C86E'
        }
        if(box15Value == 256){
            box15.innerText = '256'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#F2D04B'
        }
        if(box15Value == 512){
            box15.innerText = '512'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#E5C24D'
        }
        if(box15Value == 1024){
            box15.innerText = '1024'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#E3BA14'
        }
        if(box15Value == 2048){
            box15.innerText = '2048'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#ECC402'
        }
        if(box15Value == 4096){
            box15.innerText = '4096'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = '#60D992'
        }
        if(box15Value == 8192){
            box15.innerText = '8192'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = 'red'
        }
        if(box15Value == 16384){
            box15.innerText = '16384'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = 'red'
        }
        if(box15Value == 32768){
            box15.innerText = '32768'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = 'red'
        }
        if(box15Value == 65536){
            box15.innerText = '65536'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = 'red'
        }
        if(box15Value == 131072){
            box15.innerText = '131072'
            box15.style.color = '#FBFCF7'
            box15.style.backgroundColor = 'red'
        }
    }
    if(box16Filled == true){
        if(box16Value == 2){
            box16.innerText = '2'
            box16.style.color = '#766D64'
            box16.style.backgroundColor = '#EFE5D8'
        }
        if(box16Value == 4){
            box16.innerText = '4'
            box16.style.color = '#766D64'
            box16.style.backgroundColor = '#CFC9BB'
        }
        if(box16Value == 8){
            box16.innerText = '8'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#EDAC78'
        }
        if(box16Value == 16){
            box16.innerText = '16'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#F1905F'
        }
        if(box16Value == 32){
            box16.innerText = '32'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#F57B5D'
        }
        if(box16Value == 64){
            box16.innerText = '64'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#EA5A38'
        }
        if(box16Value == 128){
            box16.innerText = '128'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#E8C86E'
        }
        if(box16Value == 256){
            box16.innerText = '256'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#F2D04B'
        }
        if(box16Value == 512){
            box16.innerText = '512'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#E5C24D'
        }
        if(box16Value == 1024){
            box16.innerText = '1024'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#E3BA14'
        }
        if(box16Value == 2048){
            box16.innerText = '2048'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#ECC402'
        }
        if(box16Value == 4096){
            box16.innerText = '4096'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = '#60D992'
        }
        if(box16Value == 8192){
            box16.innerText = '8192'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = 'red'
        }
        if(box16Value == 16384){
            box16.innerText = '16384'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = 'red'
        }
        if(box16Value == 32768){
            box16.innerText = '32768'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = 'red'
        }
        if(box16Value == 65536){
            box16.innerText = '65536'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = 'red'
        }
        if(box16Value == 131072){
            box16.innerText = '131072'
            box16.style.color = '#FBFCF7'
            box16.style.backgroundColor = 'red'
        }
    }
                                                            
}
function restart(){
    box1Filled = false
    box2Filled = false
    box3Filled = false
    box4Filled = false
    box5Filled = false
    box6Filled = false
    box7Filled = false
    box8Filled = false
    box9Filled = false
    box10Filled = false
    box11Filled = false
    box12Filled = false
    box13Filled = false
    box14Filled = false
    box15Filled = false
    box16Filled = false
    box1Value = 0
    box2Value = 0
    box3Value = 0
    box4Value = 0
    box5Value = 0
    box6Value = 0
    box7Value = 0
    box8Value = 0
    box9Value = 0
    box10Value = 0
    box11Value = 0
    box12Value = 0
    box13Value = 0
    box14Value = 0
    box15Value = 0
    box16Value = 0
    box1.innerText = ''
    box2.innerText = ''
    box3.innerText = ''
    box4.innerText = ''
    box5.innerText = ''
    box6.innerText = ''
    box7.innerText = ''
    box8.innerText = ''
    box9.innerText = ''
    box10.innerText = ''
    box11.innerText = ''
    box12.innerText = ''
    box13.innerText = ''
    box14.innerText = ''
    box15.innerText = ''
    box16.innerText = ''

    check()
    newBox()
}
              
            
!
999px

Console