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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #A1887F 0%, #795548 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

/* 扁平化设计 - 主容器 */
.game-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 扁平化设计 - 游戏头部 */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 10px;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.game-subtitle {
    font-size: 1.125rem;
    opacity: 0.8;
    font-weight: 400;
}

/* 扁平化设计 - 难度选择 */
.difficulty-selector {
    margin-bottom: 25px;
    text-align: center;
}

.difficulty-selector h3 {
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 500;
    opacity: 0.9;
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 20px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 120px;
    border: 2px solid transparent;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.difficulty-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.difficulty-btn span {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.difficulty-btn div {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.difficulty-btn small {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* 游戏统计 */
.game-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    opacity: 0.8;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 扁平化设计 - 游戏板 */
.game-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.game-board {
    width: 400px;
    height: 400px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    padding: 15px;
    display: grid;
    gap: 10px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.game-board.size-3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.game-board.size-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.game-board.size-5 {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
}

/* 拼图块 */
.puzzle-tile {
    background: linear-gradient(135deg, #8D6E63, #6D4C41);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.puzzle-tile:hover {
    background: linear-gradient(135deg, #A1887F, #8D6E63);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.puzzle-tile.empty {
    background: transparent;
    box-shadow: none;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    cursor: default;
}

.puzzle-tile.empty:hover {
    transform: none;
    background: transparent;
    box-shadow: none;
}

.puzzle-tile.correct {
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    animation: correctPulse 0.5s ease;
}

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

/* 移动动画 */
.puzzle-tile.moving {
    transition: all 0.2s ease-out;
}

/* 扁平化设计 - 游戏控制 */
.game-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: #6D4C41;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(109, 76, 65, 0.3);
    min-width: 120px;
}

.btn:hover {
    background: #5D4037;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(109, 76, 65, 0.4);
}

.btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.15);
}

.start-btn {
    background: #4CAF50;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.start-btn:hover {
    background: #45a049;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

/* 扁平化设计 - 弹窗 */
.victory-popup, .help-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.victory-popup.show, .help-popup.show {
    display: flex;
}

.popup-content {
    background: linear-gradient(135deg, #A1887F 0%, #795548 100%);
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    max-height: 80vh;
    overflow-y: auto;
}

.popup-content h2 {
    font-size: 2rem;
    margin-bottom: 25px;
    font-weight: 300;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* 胜利统计 */
.victory-stats {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-display {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(20px);
}

.stat-icon {
    font-size: 2rem;
    width: 50px;
    text-align: center;
}

.stat-display .stat-label {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.stat-display .stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

/* 星级评分 */
.star-rating {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.star {
    font-size: 2rem;
    transition: all 0.3s ease;
    opacity: 0.3;
}

.star.active {
    opacity: 1;
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    animation: starGlow 1.5s infinite alternate;
}

@keyframes starGlow {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

.popup-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 帮助弹窗特殊样式 */
.help-content {
    text-align: left;
}

.help-content h2 {
    text-align: center;
}

.help-section {
    margin-bottom: 25px;
}

.help-section h3 {
    color: #FFD700;
    margin-bottom: 12px;
    font-size: 1.125rem;
    font-weight: 600;
}

.help-section p {
    margin-bottom: 12px;
    opacity: 0.9;
    line-height: 1.5;
}

.help-section ul {
    margin-left: 20px;
    opacity: 0.9;
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.4;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .difficulty-buttons {
        flex-direction: column;
        align-items: center;
        max-width: 200px;
        margin: 0 auto;
    }
    
    .difficulty-btn {
        width: 100%;
        min-width: 180px;
    }
    
    .game-board {
        width: 350px;
        height: 350px;
        padding: 12px;
    }
    
    .puzzle-tile {
        font-size: 1.5rem;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        min-width: 200px;
    }
    
    .popup-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .popup-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .game-board {
        width: 300px;
        height: 300px;
        padding: 10px;
    }
    
    .puzzle-tile {
        font-size: 1.25rem;
    }
    
    .game-stats {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}