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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #312e2b;
    margin-top: 40px;
}

#main {
    display: flex;
    position: relative;
    width: 640px;
    height: 640px;
    flex-wrap: wrap;
}

#a8 {
    border-radius: 4px 0 0 0;
}
#h8 {
    border-radius: 0 4px 0 0;
}
#a1 {
    border-radius: 0 0 0 4px;
}
#h1 {
    border-radius: 0 0 4px 0;
}

#main.reversed {
    flex-wrap: wrap-reverse;
    flex-direction: row-reverse;
}

#main.reversed #h1 {
    border-radius: 4px 0 0 0;
}
#main.reversed #a1 {
    border-radius: 0 4px 0 0;
}
#main.reversed #h8 {
    border-radius: 0 0 0 4px;
}
#main.reversed #a8 {
    border-radius: 0 0 4px 0;
}
/* pieces actions */
.piece-box {
    width: 80px;
    height: 80px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.piece-box.white-box {
    background-color: #eeeed2;
}
.piece-box.black-box {
    background-color: #769656;
} 
.piece {
    z-index: 3;
    width: 80px;
    height: 80px;
}
.piece-box.piece-hover {
    border: 2px solid rgb(248, 233, 24);
}
.piece-box.piece-clicked {
    background-color: #dfe239;
}
.piece-box.piece-contextmenu.white-box {
    background-color: rgb(235, 97, 80);
}
.piece-box.piece-contextmenu.black-box {
    background-color: rgb(235, 97, 80);
    opacity: 0.8;
}
.piece-box.piece-premove,
.piece-box.piece-attack {
    cursor: pointer;
}
.piece-box.piece-premove::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    background-color: rgba(0, 0, 0, .15);
}
.piece-box.piece-attack::after {
    content: "";
    z-index: 1;
    position: absolute;
    border-radius: 50%;
    width: 75px;
    height: 75px;
    background-color: rgba(0, 0, 0, .15);
}
.piece-box.piece-attack::before {
    content: "";
    z-index: 2;
    position: absolute;
    border-radius: 50%;
    width: 58px;
    height: 58px;
}
.piece-box.piece-startmove {
    background-color: #fffe7a;
}
.piece-box.piece-endmove {
    background-color: #f1ff62;
}
/* before and after */
.piece-box.white-box::before {
    background-color: #eeeed2;
}
.piece-box.black-box::before {
    background-color: #769656;
}
.piece-box.piece-startmove.white-box::before,
.piece-box.piece-startmove.black-box::before {
    background-color: #fffe7a;
}
.piece-box.piece-endmove.white-box::before,
.piece-box.piece-endmove.black-box::before {
    background-color: #f1ff62;
}

.check-king {
    background-color: #F29E4C !important;
}

.winner-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 9;
}

.winner-backdrop.hidden {
    display: none;
}
.winner {
    /* background-color: #A4036F; */
    position: absolute;
    left: 50%;
    top: 50%;
    width: 200px;
    margin-left: -100px;
    height: 50px;
    margin-top: -25px;
    z-index: 10;
    background-color: orange;
    border-radius: 10px;
    box-shadow: 3px 3px 10px rgb(0 0 0 / 45%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: #312e2b;
    font-family: "Noto Sans";
    text-transform: uppercase;
}

.piece-box.piece-pointer,
.pointer {
    cursor: pointer;
}

/* ============================  */
.left-panel {
    position: absolute;
    display: flex;
    left: -20px;
    flex-direction: column;
}

.bottom-panel {
    position: absolute;
    display: flex;
    bottom: -25px;
}

.upgrade {
    position: absolute;
    background-color: white;
    top: 0;
    width: 80px;
    height: 350px;
    border-radius: 4px;
    box-shadow: 3px 3px 10px rgb(0 0 0 / 45%);
    z-index: 4;
}

.upgrade.hidden {
    display: none;
}

.img-container {
    height: 80px;
}

.close-upgrade {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    font-family: Arial;
    font-size: 14px;
    font-weight: 700;
    color: gray;
}

.number {
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
}

.letter {
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
}

#actions {
    display: flex;
    flex-direction: column;
    margin: 10px 20px;
    align-self: flex-start;
}

.action-button {
    border: none;
    width: 100px;
    height: 40px;
    background-color: #769656;
    color: white;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
    font-family: 'Noto Sans', sans-serif;
    border-radius: 4px;
    cursor: pointer;
}

.action-button.disabled {
    opacity: 0.5;
    cursor: default;
}
.action-button.disabled:hover {
    background-color: #769656;
}
.action-button:hover {
    background-color: #567636;
}

@media only screen and (max-width: 770px), (max-height: 700px) {
    body {
        margin-top: 20px;
    }
    #main {
        width: 320px;
        height: 320px;
    }
    .piece-box {
        width: 40px;
        height: 40px;
    }
    .number {
        height: 40px;
    }
    .letter {
        width: 40px;
    }
    .piece {
        width: 40px;
        height: 40px;
    }
    .piece-box.piece-premove::after {
        width: 10px;
        height: 10px;
    }
    .piece-box.piece-attack::after {
        width: 35px;
        height: 35px;
    }
    .piece-box.piece-attack::before {
        width: 28px;
        height: 28px;
    }
    .upgrade {
        width: 40px;
        height: 180px;
    }
    .img-container {
        height: 40px;
    }
    .close-upgrade {
        height: 20px;
        font-size: 11px;
    }
    body {
        flex-direction: column;
    }
    #actions {
        width: 100%;
        margin: 40px 0;
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    #actions > button {
        margin: 0 10px
    }
}
