* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-wrapper {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.game-header p {
    color: #666;
    font-size: 1.1em;
}

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

.score-container {
    display: flex;
    gap: 10px;
}

.score-box {
    background: #bbada0;
    padding: 10px 20px;
    border-radius: 8px;
    text-align: center;
    min-width: 80px;
}

.score-label {
    display: block;
    color: #eee4da;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.score-value {
    display: block;
    color: white;
    font-size: 24px;
    font-weight: bold;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #8f7a66;
    color: white;
}

.btn-primary:hover {
    background: #9f8b77;
    transform: translateY(-2px);
}

.game-board {
    background: #bbada0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    position: relative;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.grid-cell {
    width: 80px;
    height: 80px;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 6px;
}

.tile-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
}

.tile {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    transition: all 0.15s ease-in-out;
    animation: appear 0.2s ease-in-out;
}

@keyframes appear {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

/* 不同数字的颜色 */
.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: 28px; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 28px; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 28px; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 24px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 24px; }
.tile-super { background: #3c3a32; color: #f9f6f2; font-size: 20px; }

.game-message {
    text-align: center;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    min-height: 50px;
}

.game-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.game-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.game-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.game-instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.game-instructions h3 {
    color: #333;
    margin-bottom: 15px;
}

.game-instructions ul {
    list-style: none;
    padding-left: 0;
}

.game-instructions li {
    color: #666;
    margin-bottom: 8px;
    padding-left: 25px;
    position: relative;
}

.game-instructions li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #8f7a66;
    font-weight: bold;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .game-wrapper {
        padding: 20px;
    }

    .game-header h1 {
        font-size: 2em;
    }

    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .score-container {
        justify-content: center;
    }

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

    .tile {
        font-size: 24px;
    }

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

    .tile-1024,
    .tile-2048 {
        font-size: 16px;
    }

    .tile-super {
        font-size: 14px;
    }
}
