* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    background: #faf8ef;
    color: #776e65;
    font-family: "Trebuchet MS", Arial, sans-serif;
    text-align: center;
}

main {
    width: min(100%, 500px);
    margin: 0 auto;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

h1 {
    margin: 0;
    color: #776e65;
    font-size: clamp(56px, 16vw, 80px);
    line-height: 0.9;
}

.score-box {
    min-width: 86px;
    padding: 8px 12px;
    border-radius: 4px;
    background: #bbada0;
    color: #f9f6f2;
    text-transform: uppercase;
}

.score-box span,
.score-box strong {
    display: block;
}

.score-box span {
    font-size: 12px;
    font-weight: bold;
}

.score-box strong {
    font-size: 24px;
}

.instructions {
    margin: 0 0 18px;
    font-size: 15px;
}

#board {
    width: min(92vw, 500px);
    aspect-ratio: 1;
    padding: clamp(5px, 1.5vw, 10px);
    background-color: #cdc1b5;
    border: clamp(4px, 1.5vw, 6px) solid #bbada0;

    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    touch-action: none;
    user-select: none;
}

.tile {
    width: 25%;
    height: 25%;
    border: clamp(3px, 1vw, 5px) solid #bbada0;

    font-size: clamp(22px, 9vw, 40px);
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}


/** colored tiles **/

.x2{
    background-color: #eee4da;
    color: #727371;
}


.x4{
    background-color: #ece0ca;
    color: #727371;
}


.x8 {
    background-color: #f4b17a;
    color: white;
}

.x16{
    background-color: #f59575;
    color: white;
}

.x32{
    background-color: #f57c5f;
    color: white;
}

.x64{
    background-color: #f65d3b;
    color: white;
}

.x128{
    background-color: #edce71;
    color: white;
}

.x256{
    background-color: #edcc63;
    color: white;
}

.x512{
    background-color: #edc651;
    color: white;
}

.x1024{
    background-color: #eec744;
    color: white;
}

.x2048{
    background-color: #ecc230;
    color: white;
}

.x4096 {
    background-color: #fe3d3d;
    color: white;
}

.x8192 {
    background-color: #ff2020;
    color: white;
}

@media (min-width: 520px) {
    .tile {
        font-size: 40px;
    }
}