body {
    font-family: Arial, Helvetica, sans-serif;
    text-align: center;
    background-color: #fdf6e3;
}

hr {
    width: 500px;
}

.game-container {
    position: relative;
    display: flex;
}

.board-center-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
}

#board {
    width: 400px;
    height: 400px;
    background-color: #8c8c85;
    border: 6px solid #403f3e;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
}

.tile {
    width: 90px;
    height: 90px;
    border: 5px solid #403f3e;
    font-size: 40px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease-in, background-color 0.2s ease-in;
}

#rules-popup {
    display: none;
    position: fixed;
    top: 100px;
    right: 30px;
    background: #fff;
    border: 2px solid #ccc;
    padding: 20px;
    z-index: 999;
    max-width: 300px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

#rules-popup ul {
    text-align: left;
    padding-left: 20px;
    margin: 10px 0;
}

#rules-popup li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.rules-content h3 {
    margin-top: 0;
}

#rules-btn {
    position: fixed;
    top: 20px;
    right: 80px;
    padding: 8px 14px;
    font-size: 16px;
    background-color: #ffc107;
    color: #333;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, transform 0.2s;
}

#rules-btn:hover {
    background-color: #ffb300;
    transform: scale(1.05);
}

#newHSPopup {
    position: fixed;
    top: 100px;
    right: 20px;
    background-color: #ff6f61;
    color: #000;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 25px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    display: none;
    margin-right: 100px;
    z-index: 999;
    animation: fadeOut 5s forwards;
}

@keyframes fadeOut {
    0% {opacity: 1;}
    60% {opacity: 1;}
    100% {opacity: 0; display: none;}
}

#game-over {
    display: none;
    position: absolute;
    top: 50%;
    right: 12%;
    transform: translateY(-50%);
    background-color: #333;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    font-family: sans-serif;
    z-index: 1000;
    animation: fadeInScale 0.5s ease forwards;
}

#game-over h2 {
    color: #f8f9fa;
    margin-bottom: 20px;
    font-size: 32px;
}

#game-over button { /* invisible in te start */
    padding: 10px 20px;
    font-size: 18px;
    background-color: #ffcc80;
    border: none;
    border-radius: 8px;
    cursor: pointer; /* changes the cursor to hand pointer*/
    transition: background-color 0.3s ease;
}

#game-over button:hover {
    background-color: #ffb74d;
}

#playerName {
    color: black;
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 16px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
}

#playerName:focus {
    border-color: #888;
}

.leaderboard-container {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 20px;
    margin-left: 70px;
    background-color: #403f3e;
    color: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    width: 300px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    font-family: 'Segoe UI', sans-serif;
}

.leaderboard h3 {
    margin: 0 0 10px 0;
    color: #f8f9fa;
    font-size: 20px;
}

#leaderboardList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboardList li {
    background-color: #ffffff;
    color: black;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    font-size: 16px;
}

#reset-highscore-btn {
    bottom: 20px;
    right: 20px;
    position: fixed;
    padding: 10px 15px;
    color: white;
    background-color: #f44336;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

#reset-highscore-btn:hover {
    background-color: #d32f2f;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

#muteBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgb(99, 91, 91);
    border: none;
    font-size: 28px;
    cursor: pointer;
    z-index: 1000;
    color: #333;
}

#muteBtn:hover {
    transform: scale(1.1);
}

.x2 { background-color: #a26769; color: #f8f9fa; }
.x4 { background-color: #b78859; color: #f8f9fa; }
.x8 { background-color: #9db458; color: #f8f9fa; }
.x16 { background-color: #da8b60; color: #f8f9fa; }
.x32 { background-color: #b5838d; color: #f8f9fa; }
.x64 { background-color: #6d597a; color: #f8f9fa; }
.x128 { background-color: #588157; color: #f8f9fa; }
.x256 { background-color: #355070; color: #f8f9fa; }
.x512 { background-color: #8f5f3f; color: #f8f9fa; }
.x1024 { background-color: #8d99ae; color: #f8f9fa; font-size: 38px; }
.x2048 { background-color: #c4b7a6; color: #2f2f2f; font-size: 38px; }
.x4096 { background-color: #5e503f; color: #f8f9fa; font-size: 37px; }
.x8192 { background-color: #2b2d42; color: #f8f9fa; font-size: 37px; }

@media (max-width: 768px) {
    .game-container {
        margin-top: 20px;
        flex-direction: column;
        align-items: center;
    }

    .board-center-wrapper {
        position: static;
        transform: none;
        margin-bottom: 20px;
    }

    .leaderboard-container {
        margin-left: 0;
        width: 90%;
        margin-bottom: 20px;
        max-width: 350px;
    }

    #rules-popup {
        position: absolute;
        top: 300px;
        left: 50%;
        transform: translateX(-50%);
    }

    #newHSPopup {
        top: 200px;
    }

    hr {
        width: 80%;
    }
    
    #rules-btn {
        position: static;
    }

    #reset-highscore-btn {
        position: static;
    }
}
