/* 2048 specific styles */
.game-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 0 15px;
}

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

.header-top h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin: 0;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.scores {
    display: flex;
    gap: 10px;
}

.score-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    backdrop-filter: blur(10px);
}

.score-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #a5b4fc;
    letter-spacing: 1px;
}

#scoreDisplay {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

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

.instruction {
    font-size: 0.9rem;
    color: #9ca3af;
    text-align: left;
    margin-bottom: 30px;
}

.board-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
}

.board {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 20, 30, 0.8);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-cell {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    width: 100%;
    height: 100%;
}

.tile-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    pointer-events: none; /* Let touches pass through to board/document container */
    overflow: hidden; /* For safety, though tiles shouldn't leave */
}

.tile {
    position: absolute;
    width: calc(25% - 7.5px); /* (100% - 3*gap) / 4 */
    height: calc(25% - 7.5px);
    background: #e5e7eb;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    transition: transform 0.15s ease-in-out;
    animation: popIn 0.2s ease-out;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Base class for merged tile animation */
.tile-merged {
    animation: popMerge 0.2s ease-out;
}

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

@keyframes popMerge {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Tile Colors based on Value */
.tile-2 { background: #eee4da; color: #776e65; }
.tile-4 { background: #ede0c8; color: #776e65; }
.tile-8 { background: #f2b179; color: #f9f6f2; font-size: 2.2rem; }
.tile-16 { background: #f59563; color: #f9f6f2; font-size: 2.2rem; }
.tile-32 { background: #f67c5f; color: #f9f6f2; font-size: 2.2rem; }
.tile-64 { background: #f65e3b; color: #f9f6f2; font-size: 2.2rem; }
.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 1.8rem; box-shadow: 0 0 15px rgba(237, 207, 114, 0.4); }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 1.8rem; box-shadow: 0 0 20px rgba(237, 204, 97, 0.5); }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 1.8rem; box-shadow: 0 0 25px rgba(237, 200, 80, 0.6); }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.4rem; box-shadow: 0 0 30px rgba(237, 197, 63, 0.7); }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.4rem; box-shadow: 0 0 40px rgba(237, 194, 46, 0.8); }

.game-message {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 15, 0.8);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.5s ease;
}

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

.game-message h2 {
    font-size: 3rem;
    margin-bottom: 20px;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
