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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow-x: hidden;
}

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

/* 头部区域 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.title-section {
    flex: 1;
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
    letter-spacing: -2px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
}

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

.score-box {
    background: rgba(255, 255, 255, 0.2);
    padding: 12px 16px;
    border-radius: 12px;
    text-align: center;
    min-width: 70px;
    backdrop-filter: blur(10px);
}

.score-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.btn-new {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-new:active {
    transform: scale(0.95);
}

.btn-sound {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    flex: 0 0 auto;
    padding: 14px;
}

.btn-sound:active {
    transform: scale(0.95);
}

/* 游戏容器 */
.game-container {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.grid-container {
    display: grid;
    gap: 15px;
    margin-bottom: 15px;
}

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

.grid-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    position: relative;
}

/* 方块容器 */
.tile-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    z-index: 2;
}

.tile {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

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

.tile-merged {
    animation: pulse 0.3s ease-in-out;
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* 方块颜色 */
.tile-2 { background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%); color: #776e65; }
.tile-4 { background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%); color: #776e65; }
.tile-8 { background: linear-gradient(135deg, #fab1a0 0%, #ff7675 100%); color: #fff; }
.tile-16 { background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%); color: #fff; }
.tile-32 { background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%); color: #fff; }
.tile-64 { background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%); color: #fff; }
.tile-128 { background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%); color: #fff; font-size: 1.8rem; }
.tile-256 { background: linear-gradient(135deg, #fab1a0 0%, #ff7675 100%); color: #fff; font-size: 1.8rem; }
.tile-512 { background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%); color: #fff; font-size: 1.8rem; }
.tile-1024 { background: linear-gradient(135deg, #ffeaa7 0%, #f39c12 100%); color: #fff; font-size: 1.5rem; }
.tile-2048 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: #fff; font-size: 1.5rem; }
.tile-super { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; font-size: 1.3rem; }

/* 游戏结束消息 */
.game-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 100;
    animation: fade-in 0.3s ease-in-out;
}

.game-message.show {
    display: flex;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.message-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slide-up 0.3s ease-in-out;
}

@keyframes slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.message-title {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
    font-weight: 800;
}

.message-score {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 25px;
}

.btn-retry {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 40px;
}

.btn-retry:active {
    transform: scale(0.95);
}

/* 说明 */
.instructions {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* 响应式调整 */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 15px;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .score-box {
        min-width: 60px;
        padding: 10px 12px;
    }

    .score-value {
        font-size: 1.3rem;
    }

    .tile {
        font-size: 1.8rem;
    }

    .tile-128, .tile-256, .tile-512 {
        font-size: 1.5rem;
    }

    .tile-1024, .tile-2048 {
        font-size: 1.2rem;
    }

    .tile-super {
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .game-title {
        font-size: 2rem;
    }

    .tile {
        font-size: 1.5rem;
    }

    .tile-128, .tile-256, .tile-512 {
        font-size: 1.3rem;
    }

    .tile-1024, .tile-2048 {
        font-size: 1rem;
    }

    .tile-super {
        font-size: 0.9rem;
    }
}
