/* 1024游戏样式表 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #776e65;
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 900px;
    width: 100%;
    padding: 20px;
}

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

.game-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.game-board {
    flex: 1;
}

.game-sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

h1 {
    font-size: 80px;
    font-weight: bold;
    color: #edc22e;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #edc22e, #f1b500, #edc22e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% 200%;
    animation: textShine 3s ease-in-out infinite;
}

@keyframes textShine {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.score-panel h3, .game-controls h3 {
    font-size: 24px;
    color: #ff6b6b;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.score-panel, .game-controls {
    background: linear-gradient(145deg, #ffd166, #ff9e6d);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 3px solid #ff9e6d;
    backdrop-filter: blur(5px);
}

.score-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.score-box {
    background: linear-gradient(135deg, #ff9e6d, #ff6b6b);
    padding: 15px 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    border: 3px solid #ffd166;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.score-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.score-box:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.score-label {
    display: block;
    font-size: 16px;
    color: #fff;
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.score {
    display: block;
    font-size: 28px;
    font-weight: bold;
    color: #ffd166;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-board .game-container {
    background: linear-gradient(145deg, #bbada0, #a6978b);
    border-radius: 15px;
    padding: 25px;
    position: relative;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.game-controls .game-intro {
    text-align: center;
    margin-top: 15px;
    color: #ff6b6b;
}

.game-controls .game-intro p {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.new-game-btn {
    background: linear-gradient(135deg, #ff6b6b, #ff9e6d);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border: 3px solid #ffd166;
    position: relative;
    overflow: hidden;
    width: 100%;
    margin-bottom: 15px;
}

.new-game-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.new-game-btn:hover {
    background: linear-gradient(135deg, #ff9e6d, #ff6b6b);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.new-game-btn:hover::before {
    left: 100%;
}

.new-game-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.grid-container {
    position: relative;
}

#game-canvas {
    width: 450px;
    height: 450px;
    background: #bbada0;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(238, 228, 218, 0.73);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: 6px;
    z-index: 100;
}

.game-over h2 {
    font-size: 40px;
    color: #776e65;
    margin-bottom: 20px;
}

.instructions-toggle {
    margin-top: 20px;
    text-align: center;
}

.toggle-btn {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-btn:hover {
    background: #7c6b5a;
    transform: translateY(-2px);
}

.instructions {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    color: #776e65;
    margin-bottom: 10px;
}

.instructions ul {
    list-style-position: inside;
    padding-left: 10px;
}

.instructions li {
    margin-bottom: 5px;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .game-sidebar {
        width: 100%;
        order: -1;
    }
    
    .score-container {
        flex-direction: row;
        justify-content: space-around;
    }
}

@media (max-width: 520px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 60px;
    }
    
    #game-canvas {
        width: 350px;
        height: 350px;
    }
    
    .score-panel h3, .game-controls h3 {
        font-size: 20px;
    }
    
    .new-game-btn {
        padding: 14px 24px;
        font-size: 16px;
    }
}

@media (max-width: 400px) {
    #game-canvas {
        width: 300px;
        height: 300px;
    }
    
    .score-panel, .game-controls {
        padding: 20px;
    }
    
    .score-box {
        padding: 12px 16px;
    }
}

/* 动画效果 */
@keyframes appear {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

.cell.new {
    animation: appear 0.2s ease-in-out;
}

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