:root {
    --bg-color: #faf8ef;
    --grid-bg: #bbada0;
    --cell-bg: rgba(238, 228, 218, 0.35);
    --text-dark: #776e65;
    --text-light: #f9f6f2;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.container {
    width: 500px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 80px;
    font-weight: bold;
    margin: 0;
}

.score-container {
    background: #bbada0;
    padding: 15px 25px;
    font-size: 25px;
    line-height: 25px;
    font-weight: bold;
    border-radius: 3px;
    color: white;
    text-align: center;
}

.score-label {
    font-size: 13px;
    color: #eee4da;
}

.game-intro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.game-explanation {
    margin: 0;
}

#restart-button {
    background: #8f7a66;
    border-radius: 3px;
    padding: 0 20px;
    text-decoration: none;
    color: #f9f6f2;
    height: 40px;
    line-height: 42px;
    cursor: pointer;
    border: none;
    font-weight: bold;
}

@media screen and (max-width: 520px) {
    .container {
        width: 320px;
    }

    .title {
        font-size: 40px;
    }

    #game-container {
        width: 320px;
        height: 320px;
        padding: 10px;
    }

    #grid-container {
        grid-gap: 10px;
    }

    .grid-cell, .tile {
        width: 67.5px;
        height: 67.5px;
    }

    .tile {
        font-size: 35px;
        top: 0;
        left: 0;
    }

    .tile-128, .tile-256, .tile-512 { font-size: 25px; }
    .tile-1024, .tile-2048 { font-size: 20px; }

    .score-container {
        padding: 10px 15px;
    }
}

#game-container {
    position: relative;
    padding: 15px;
    cursor: default;
    background: #bbada0;
    border-radius: 6px;
    width: 500px;
    height: 500px;
    box-sizing: border-box;
}

#grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    grid-gap: 15px;
    width: 100%;
    height: 100%;
}

.grid-cell {
    width: 106.25px;
    height: 106.25px;
    border-radius: 3px;
    background: var(--cell-bg);
}

#tile-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    z-index: 2;
}

.tile {
    position: absolute;
    width: 106.25px;
    height: 106.25px;
    border-radius: 3px;
    background: #eee4da;
    text-align: center;
    font-weight: bold;
    z-index: 10;
    font-size: 55px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 100ms ease-in-out;
    transition-property: transform, top, left;
    animation: appear 200ms ease-in-out;
}

@keyframes appear {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.tile-2 { background: #eee4da; color: #776e65; }
.tile-4 { background: #ede0c8; color: #776e65; }
.tile-8 { background: #f2b179; color: #f9f6f2; }
.tile-16 { background: #f59563; color: #f9f6f2; }
.tile-32 { background: #f67c5f; color: #f9f6f2; }
.tile-64 { background: #f65e3b; color: #f9f6f2; }
.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 45px; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 45px; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 45px; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 35px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 35px; }

#game-message {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(238, 228, 218, 0.73);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#game-message.hidden {
    display: none;
}

#game-message p {
    font-size: 60px;
    font-weight: bold;
    height: 60px;
    line-height: 60px;
    margin-top: 222px;
}

.lower {
    display: block;
    margin-top: 59px;
}

.retry-button {
    background: #8f7a66;
    border-radius: 3px;
    padding: 0 20px;
    text-decoration: none;
    color: #f9f6f2;
    height: 40px;
    line-height: 42px;
    cursor: pointer;
    border: none;
    font-weight: bold;
}
