/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    max-width: 500px;
    width: 100%;
    background: rgba(250, 248, 239, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(10px);
    position: relative;
}

.game-title {
    color: #f9f6f2;
    background: #bbada0;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    display: inline-block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* 游戏信息栏 */
.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    background: rgba(187, 173, 160, 0.3);
    padding: 15px;
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    background: #bbada0;
    padding: 10px 15px;
    border-radius: 8px;
    color: white;
    min-width: 80px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.info-label {
    font-size: 0.8em;
    opacity: 0.9;
    margin-bottom: 5px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1.8em;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 游戏容器 */
.game-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    background: rgba(187, 173, 160, 0.8);
    border-radius: 10px;
    padding: 15px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 游戏棋盘 */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 15px;
    background: #bbada0;
    padding: 15px;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* 游戏格子 */
.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 8px;
    font-size: 2em;
    font-weight: bold;
    color: #776e65;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 不同数值的方块样式 */
.tile-2 {
    background: #eee4da;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.tile-4 {
    background: #ede0c8;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.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;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.1429);
    font-size: 1.8em;
}

.tile-256 {
    background: #edcc61;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3174), inset 0 0 0 1px rgba(255, 255, 255, 0.1905);
    font-size: 1.8em;
}

.tile-512 {
    background: #edc850;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3968), inset 0 0 0 1px rgba(255, 255, 255, 0.2381);
    font-size: 1.8em;
}

.tile-1024 {
    background: #edc53f;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4762), inset 0 0 0 1px rgba(255, 255, 255, 0.2857);
    font-size: 1.5em;
}

.tile-2048 {
    background: #edc22e;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5556), inset 0 0 0 1px rgba(255, 255, 255, 0.3333);
    font-size: 1.5em;
}

/* 更大的数字样式 */
.tile-4096,
.tile-8192,
.tile-16384 {
    background: #3c3a32;
    color: #f9f6f2;
    font-size: 1.2em;
}

/* 合并动画 */
.tile-new {
    animation: appear 0.2s ease-in-out;
}

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

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

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

/* 控制按钮 */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #8f7a66, #9f8b77);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(143, 122, 102, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #776e65, #8f857a);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(119, 110, 101, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #f65e3b, #ff7e5f);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(246, 94, 59, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #2ecc71, #34d97f);
    color: white;
}

.btn-success:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

.btn:active {
    transform: translateY(-1px);
}

/* 游戏说明 */
.game-instructions {
    text-align: left;
    background: rgba(248, 249, 250, 0.8);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.game-instructions h3 {
    color: #8f7a66;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-align: center;
}

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

.game-instructions li {
    margin-bottom: 12px;
    padding-left: 30px;
    position: relative;
    line-height: 1.6;
    font-size: 1em;
    color: #555;
}

.game-instructions li:before {
    content: "▶";
    color: #8f7a66;
    font-weight: bold;
    position: absolute;
    left: 0;
    font-size: 1.2em;
    line-height: 1;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #faf8ef;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #8f7a66;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: #776e65;
}

.modal-content button {
    margin-top: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .game-title {
        font-size: 2em;
        padding: 12px 20px;
    }
    
    .game-board {
        gap: 10px;
        padding: 10px;
    }
    
    .tile {
        font-size: 1.5em;
    }
    
    .tile-128,
    .tile-256,
    .tile-512 {
        font-size: 1.3em;
    }
    
    .tile-1024,
    .tile-2048 {
        font-size: 1.1em;
    }
    
    .tile-4096,
    .tile-8192,
    .tile-16384 {
        font-size: 1em;
    }
    
    .btn {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .game-title {
        font-size: 1.8em;
    }
    
    .game-info {
        flex-direction: column;
        align-items: center;
    }
    
    .info-item {
        width: 100%;
        max-width: 200px;
    }
    
    .game-board {
        gap: 8px;
        padding: 8px;
    }
    
    .tile {
        font-size: 1.2em;
    }
    
    .control-buttons {
        gap: 10px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 80px;
    }
    
    .game-instructions {
        padding: 15px;
    }
    
    .game-instructions li {
        padding-left: 25px;
        font-size: 0.9em;
    }
}