.container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
    font-family: Arial, sans-serif;
    padding: 10px;
    box-sizing: border-box;
}

h1 {
    font-size: 32px;
    color: #776e65;
    margin: 10px 0;
    user-select: none;
}

.score-container {
    background-color: #bbada0;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    display: inline-block;
    margin-bottom: 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background-color: #bbada0;
    padding: 10px;
    border-radius: 6px;
    margin: 0 auto;
    width: min(90vw, 400px);
    box-sizing: border-box;
    aspect-ratio: 1;
}

.cell {
    width: 100%;
    background-color: #cdc1b4;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #776e65;
    user-select: none;
    position: relative;
    aspect-ratio: 1;
    transition: transform 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.cell span {
    position: absolute;
    font-size: min(8vw, 36px);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease-in-out;
}

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

@keyframes merge {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.cell.new-tile {
    animation: appear 0.2s ease-in-out;
}

.cell.merge {
    animation: merge 0.2s ease-in-out;
}

.cell.moving {
    z-index: 2;
}

.tile-2 {
    background-color: #eee4da;
}

.tile-4 {
    background-color: #ede0c8;
}

.tile-8 {
    background-color: #f2b179;
    color: white;
}

.tile-16 {
    background-color: #f59563;
    color: white;
}

.tile-32 {
    background-color: #f67c5f;
    color: white;
}

.tile-64 {
    background-color: #f65e3b;
    color: white;
}

.tile-128 {
    background-color: #edcf72;
    color: white;
}

.tile-256 {
    background-color: #edcc61;
    color: white;
}

.tile-512 {
    background-color: #edc850;
    color: white;
}

.tile-1024 {
    background-color: #edc53f;
    color: white;
}

.tile-2048 {
    background-color: #edc22e;
    color: white;
}

.instructions {
    margin: 10px 0;
    color: #776e65;
    font-size: 14px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none;
    }
}

@media (max-width: 480px) {
    .score-container {
        font-size: 14px;
        padding: 8px 16px;
    }
    
    .instructions {
        font-size: 12px;
        padding: 0 10px;
    }
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

.game-over > div {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.game-over p {
    font-size: 36px;
    color: #776e65;
    margin: 10px 0;
}

button {
    background-color: #8f7a66;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 18px;
    cursor: pointer;
    margin-top: 20px;
}

button:hover {
    background-color: #9f8b77;
}