body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    flex-direction:column;
    margin: 0;
    background:linear-gradient(45deg,#011e2c,#012529);
    overflow:hidden;
    }

.home-page {
    text-align: center;
    background: linear-gradient(135deg, #00795E, #012D33);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width:70%;
    height:50vh;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
}

.home-page h1 {
    color: #EDDA33;
    margin-bottom: 30px;
    font-size: 3rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.home-page button {
    display: block;
    margin: 15px auto;
    padding: 15px 40px;
    font-size: 1.2rem;
    background-color: #F44336;
    color: #f9f6f2;
    font-weight:bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.home-page button:hover {
    background-color: #eb3c10;
    transform: scale(1.05);
    color: black;

}

.game-container {
    text-align: center;
    background-color: #011e2c;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    width:460px;
    margin:25px;
    height:fit-content;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    background-color:#012529;
}

.score, .high-score, .timer {
    background-color: #044c70;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
    margin:5px;
    flex: 1 1 33%;
    min-width: 100px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap:5px;
    background-color: #012D33;
    padding: 10px;
    border-radius: 5px;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1 / 1;
    height:380px;
}

.tile {
    position: relative;
    width: 90%;
    height:90%;
    background-color: #00795E;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    color: #776e65;
    border-radius: 5px;
    transition: all 0.2s ease;
    aspect-ratio: 1 / 1; /* Ensures square shape */
}

.tile-2 { background-color: #eee4da; }
.tile-4 { background-color: #ede0c8; }
.tile-8 { background-color: #f2b179; color: #f9f6f2; }
.tile-16 { background-color: #f59563; color: #f9f6f2; }
.tile-32 { background-color: #f67c5f; color: #f9f6f2; }
.tile-64 { background-color: #f65e3b; color: #f9f6f2; }
.tile-128 { background-color: #edcf72; color: #f9f6f2; }
.tile-256 { background-color: #edcc61; color: #f9f6f2; }
.tile-512 { background-color: #edc850; color: #f9f6f2; }
.tile-1024 { background-color: #edc53f; color: #f9f6f2; }
.tile-2048 { background-color: #edc22e; color: #f9f6f2; }

button {
    margin-top: 15px;
    padding: 12px 30px;
    font-size: 1.1rem;
    background-color: #8f7a66;
    color: #f9f6f2;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #9f8b77;
}

.game-over, .game-won {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: 10px;
}

.game-over p, .game-won p {
    margin: 0;
}

.game-over button, .game-won button {
    margin-top: 20px;
    background-color: #f65e3b;
    padding: 12px 30px;
    font-size: 1.1rem;
}

.game-over button:hover, .game-won button:hover {
    background-color: #f67c5f;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .home-page {
        padding: 20px;
        width: 80%;
    }

    .home-page h1 {
        font-size: 2rem;
    }

    .home-page button {
        padding: 12px 30px;
        font-size: 1rem;
    }

    .game-container {
        padding: 10px;
        width: 95%;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .score, .high-score, .timer {
        font-size: 1rem;
        padding: 6px 10px;
        margin: 3px 0;
    }

    .grid {
        grid-gap: 5px;
        padding: 5px;
    }

    .tile {
        font-size: 1.5rem;
        font-weight:bold;
    }

    button {
        padding: 10px 25px;
        font-size: 1rem;
    }

    .game-over, .game-won {
        font-size: 1.2rem;
    }

    .game-over button, .game-won button {
        padding: 10px 25px;
        font-size: 1rem;
    }
}