/* 像素2048 - 8位复古风格 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

@font-face {
    font-family: 'PixelFont';
    src: local('Courier New');
}

body {
    font-family: 'PixelFont', 'Courier New', monospace;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
}

.container {
    max-width: 500px;
    width: 100%;
    text-align: center;
}

/* 标题区域 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
}

.title {
    font-size: 2.5em;
    color: #ffd700;
    text-shadow: 
        3px 3px 0 #ff6b35,
        -1px -1px 0 #ff6b35,
        1px -1px 0 #ff6b35,
        -1px 1px 0 #ff6b35;
    letter-spacing: 2px;
    font-weight: bold;
}

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

.score-box {
    background: #2d2d44;
    border: 3px solid #4a4a6a;
    padding: 8px 15px;
    border-radius: 8px;
    box-shadow: 
        inset 0 -3px 0 rgba(0,0,0,0.3),
        0 3px 0 #1a1a2e;
}

.score-label {
    font-size: 0.7em;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 1.3em;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* 游戏说明 */
.game-info {
    margin-bottom: 15px;
    color: #8892b0;
    font-size: 0.9em;
}

/* 游戏容器 */
.game-container {
    position: relative;
    background: #2d2d44;
    border: 5px solid #4a4a6a;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 
        inset 0 -5px 0 rgba(0,0,0,0.3),
        0 10px 30px rgba(0,0,0,0.5);
    touch-action: none;
    user-select: none;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    position: relative;
    z-index: 1;
}

.grid-cell {
    aspect-ratio: 1;
    background: #1a1a2e;
    border-radius: 8px;
    border: 2px solid #2d2d44;
}

.tiles-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 2;
}

/* 方块样式 */
.tile {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    font-weight: bold;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    transition: all 0.15s ease-in-out;
    border: 3px solid rgba(0,0,0,0.2);
    box-shadow: 
        inset 0 -3px 0 rgba(0,0,0,0.2),
        0 3px 0 rgba(0,0,0,0.2);
}

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

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

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

@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        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;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3);
}
.tile-256 { 
    background: #edcc61; 
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4);
}
.tile-512 { 
    background: #edc850; 
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5);
}
.tile-1024 { 
    background: #edc53f; 
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.6);
}
.tile-2048 { 
    background: #edc22e; 
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.8);
    animation: glow 1s ease-in-out infinite alternate;
}
.tile-super { 
    background: #3c3a32; 
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(60, 58, 50, 0.5);
}

@keyframes glow {
    from {
        box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.8);
    }
    to {
        box-shadow: 0 0 50px 20px rgba(243, 215, 116, 1);
    }
}

/* 按钮 */
.new-game-btn, .retry-btn {
    margin-top: 20px;
    padding: 12px 30px;
    font-size: 1.1em;
    font-family: 'PixelFont', 'Courier New', monospace;
    background: linear-gradient(180deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 
        inset 0 -3px 0 rgba(0,0,0,0.3),
        0 5px 0 #2d7a2e,
        0 5px 10px rgba(0,0,0,0.3);
    transition: all 0.1s;
}

.new-game-btn:hover, .retry-btn:hover {
    background: linear-gradient(180deg, #5CBF60 0%, #4CAF50 100%);
    transform: translateY(-2px);
}

.new-game-btn:active, .retry-btn:active {
    transform: translateY(3px);
    box-shadow: 
        inset 0 -1px 0 rgba(0,0,0,0.3),
        0 2px 0 #2d7a2e;
}

/* 游戏结束遮罩 */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    z-index: 100;
    animation: fadeIn 0.3s ease-in-out;
}

.game-over-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-over-content {
    text-align: center;
    color: white;
}

.game-over-content h2 {
    font-size: 2em;
    color: #ff6b6b;
    margin-bottom: 15px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.game-over-content p {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: #ffd700;
}

/* 响应式设计 */
@media (max-width: 500px) {
    .title {
        font-size: 2em;
    }
    
    .score-box {
        padding: 5px 10px;
    }
    
    .score-value {
        font-size: 1.1em;
    }
    
    .game-info {
        font-size: 0.8em;
    }
}

@media (max-width: 360px) {
    .header {
        flex-direction: column;
        gap: 10px;
    }
    
    .title {
        font-size: 1.8em;
    }
}

/* 防止iOS橡皮筋效果 */
body {
    overscroll-behavior: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

.container {
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
