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

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

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
}

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

h1 {
    font-size: 3rem;
    color: #776e65;
    margin-bottom: 20px;
    font-weight: bold;
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.score-box {
    background: #bbada0;
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
    min-width: 100px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.score-box:hover {
    background: #a89a8c;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.score-label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 5px;
    opacity: 0.8;
}

#score, #best-score {
    font-size: 1.5rem;
    font-weight: bold;
}

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

.game-info p {
    color: #776e65;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

#new-game-btn, #hint-btn {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

#new-game-btn:hover, #hint-btn:hover {
    background: #7f6a56;
    transform: translateY(-2px);
}

#hint-btn.active {
    background: #f65e3b;
    box-shadow: 0 4px 8px rgba(246, 94, 59, 0.3);
}

#auto-btn {
    background: #3cba54;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}
#auto-btn:hover {
    background: #2e8b3c;
    transform: translateY(-2px);
}
#auto-btn.active {
    background: #f65e3b;
    box-shadow: 0 4px 8px rgba(246, 94, 59, 0.3);
}

.hint-container {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: rgba(143, 122, 102, 0.1);
    border-radius: 8px;
}

.hint-levels {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
}

.hint-level {
    background: #edc850;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s;
}

.hint-level:hover {
    background: #edc22e;
}

.hint-level.active {
    background: #f65e3b;
}

.hint-result {
    text-align: center;
    color: #776e65;
    font-weight: bold;
    min-height: 20px;
}

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

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

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

.grid-cell {
    background: rgba(238, 228, 218, 0.35);
    border-radius: 8px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    color: #776e65;
    position: relative;
    transition: all 0.15s ease;
    overflow: hidden;
}

.tile {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: appear 0.3s ease;
    transform-origin: center;
}

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



.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: 1.8rem; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 1.8rem; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 1.8rem; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.5rem; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.5rem; }

.game-over, .win-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-content, .win-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.game-over-content h2, .win-content h2 {
    color: #776e65;
    margin-bottom: 20px;
    font-size: 2rem;
}

.game-over-content p, .win-content p {
    color: #776e65;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

#restart-btn, #continue-btn {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

#restart-btn:hover, #continue-btn:hover {
    background: #7f6a56;
}

.records-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.records-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.records-content h2 {
    color: #776e65;
    margin-bottom: 20px;
    text-align: center;
}
.records-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
.records-content th, .records-content td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #eee;
}
.records-content th {
    background: #f5f5f5;
    font-weight: bold;
    color: #776e65;
}
.records-content button {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    display: block;
    margin: 0 auto;
}
.records-content button:hover {
    background: #7f6a56;
}

.input-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.input-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.input-content h3 {
    color: #776e65;
    margin-bottom: 15px;
}

.input-content p {
    color: #776e65;
    margin-bottom: 20px;
}

.input-content input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.input-content input:focus {
    outline: none;
    border-color: #8f7a66;
}

.input-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.input-buttons button {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.input-buttons button:hover {
    background: #7f6a56;
}

#cancel-record-btn {
    background: #ccc !important;
}

#cancel-record-btn:hover {
    background: #bbb !important;
}

.delete-btn {
    background: #f65e3b;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s;
}

.delete-btn:hover {
    background: #e54d2a;
}



/* 响应式设计 */
@media (max-width: 600px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    .score-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .score-box {
        min-width: 120px;
    }
    
    .grid-container {
        gap: 10px;
    }
    
    .grid-row {
        gap: 10px;
    }
    
    .tile {
        font-size: 1.5rem;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1.3rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 1.1rem;
    }
} 