body {
    background-color: #faf8ef;
    display: flex;
    justify-content: center;
    font-family: "Clear Sans", Helvetica, serif;
    overflow: hidden; /* Prevent body scroll */
}

h1 {
    font-size: 80px;
    line-height: 0.7;
    color: #776E65;
    margin: 0;
}

p, h2 {
    margin: 0;
}

.container {
    width: 468px;
    margin-top: 30px;
    outline: none; /* Remove outline for focus */
}

.info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.grid {
    display: flex;
    flex-wrap: wrap;
    width: 456px;
    height: 456px;
    background-color: #BBADA0;
    border: 7px solid #BBADA0;
    border-radius: 6px;
    margin-top: 20px;
    position: relative;
}

.grid div {
    width: 100px;
    height: 100px;
    margin: 7px;
    border-radius: 3px;
    background-color: #EEE4DA;
    color: #AFA192;
    font-weight: bold;
    text-align: center;
    font-size: 60px;
    line-height: 1.6;
    transition: all 0.15s ease-in-out; /* Smooth transition for all properties */
    animation: pop 0.2s ease-in-out; /* Pop animation for new tiles */
}

/* Animation for new tiles */
@keyframes pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Animation for merged tiles */
@keyframes merge {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.grid div.merged {
    animation: merge 0.2s ease-in-out;
}

/* Tile colors */
.grid div[data-value="2"] {
    background-color: #EEE4DA;
    color: #776E65;
}

.grid div[data-value="4"] {
    background-color: #EDE0C8;
    color: #776E65;
}

.grid div[data-value="8"] {
    background-color: #F2B179;
    color: #F9F6F2;
}

.grid div[data-value="16"] {
    background-color: #F59563;
    color: #F9F6F2;
}

.grid div[data-value="32"] {
    background-color: #F67C5F;
    color: #F9F6F2;
}

.grid div[data-value="64"] {
    background-color: #F65E3B;
    color: #F9F6F2;
}

.grid div[data-value="128"] {
    background-color: #EDCF72;
    color: #F9F6F2;
    font-size: 50px;
    line-height: 1.9;
}

.grid div[data-value="256"] {
    background-color: #EDCC61;
    color: #F9F6F2;
    font-size: 50px;
    line-height: 1.9;
}

.grid div[data-value="512"] {
    background-color: #EDC850;
    color: #F9F6F2;
    font-size: 50px;
    line-height: 1.9;
}

.grid div[data-value="1024"] {
    background-color: #EDC53F;
    color: #F9F6F2;
    font-size: 40px;
    line-height: 2.4;
}

.grid div[data-value="2048"] {
    background-color: #EDC22E;
    color: #F9F6F2;
    font-size: 40px;
    line-height: 2.4;
}

.score-container {
    text-align: center;
    width: 70px;
    height: 60px;
    border-radius: 3px;
    background-color: #8f7a66;
    color: #FFF;
}

#score {
    font-size: 30px;
}

.score-title {
    font-size: 16px;
}

/* Focus indicator for game container */
.container:focus {
    outline: 2px solid #8f7a66;
    outline-offset: 4px;
}

/* Instructions */
.instructions {
    text-align: center;
    color: #8f7a66;
    font-size: 14px;
    margin-top: 10px;
}
