/* 数字华容道游戏样式 */

.main-content {
    max-width: 800px;
    margin: 30px auto;
    padding: 20px;
    min-height: calc(100vh - 80px);
}

.page-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.page-header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* 游戏控制面板 */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
    flex-wrap: wrap;
    gap: 15px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.control-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.control-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

/* 游戏状态显示 */
.game-stats {
    display: flex;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    flex-wrap: wrap;
    gap: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.stat-item i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

#gameStatus {
    color: var(--primary-color);
    font-weight: 600;
}

/* 游戏区域 */
.game-area {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.puzzle-board {
    display: grid;
    gap: 4px;
    background: var(--border-color);
    padding: 8px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.puzzle-board.size-3 {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
}

.puzzle-board.size-4 {
    grid-template-columns: repeat(4, 70px);
    grid-template-rows: repeat(4, 70px);
}

.puzzle-tile {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.puzzle-tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.puzzle-tile.moveable {
    background: linear-gradient(135deg, #42e695 0%, #3bb2b8 100%);
    animation: pulse 1.5s infinite;
}

.puzzle-tile.moving {
    transform: scale(0.95);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.puzzle-tile.empty {
    background: transparent;
    cursor: default;
}

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

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 移动动画 */
.puzzle-tile.slide-animation {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 游戏说明 */
.game-instructions {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
}

.game-instructions h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-instructions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.game-instructions li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-primary);
    line-height: 1.5;
}

.game-instructions li::before {
    content: "•";
    color: var(--primary-color);
    font-size: 1.2rem;
    position: absolute;
    left: 0;
    top: 8px;
}

/* 最佳记录 */
.best-scores {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 30px;
}

.best-scores h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--background-color);
    border-radius: 8px;
    color: var(--text-primary);
}

.score-row span:first-child {
    font-weight: 600;
}

.score-row span:last-child {
    color: var(--primary-color);
    font-weight: 500;
}

/* 胜利弹窗 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg, #ffffff);
    padding: 0;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.3s ease;
    border: 1px solid var(--border-color, #e0e0e0);
}

/* 确保弹窗内容在明暗主题下都有正确的背景色 */
.light-mode .modal-content {
    background: #ffffff;
}

.dark-mode .modal-content {
    background: #2d3748;
    color: #ffffff;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header .close {
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.modal-header .close:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 30px;
    text-align: center;
}

.win-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    gap: 20px;
}

.win-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.win-stat i {
    color: var(--primary-color);
    font-size: 2rem;
}

.win-stat span {
    color: var(--text-primary);
    font-weight: 500;
}

.new-record {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    color: #333;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    margin-bottom: 20px;
    animation: sparkle 1s ease-in-out infinite alternate;
}

.win-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.win-actions .btn {
    background: var(--primary-color, #007bff) !important;
    border: none !important;
    color: white !important;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.win-actions .btn:hover {
    background: var(--primary-hover, #0056b3) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.win-actions .btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        transform: scale(0.8) translateY(-20px); 
        opacity: 0;
    }
    to { 
        transform: scale(1) translateY(0); 
        opacity: 1;
    }
}

@keyframes sparkle {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        padding: 10px;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        justify-content: space-between;
    }
    
    .control-buttons {
        justify-content: center;
    }
    
    .game-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .puzzle-board.size-3 {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
    }
    
    .puzzle-board.size-4 {
        grid-template-columns: repeat(4, 60px);
        grid-template-rows: repeat(4, 60px);
    }
    
    .puzzle-tile {
        font-size: 1.5rem;
    }
    
    .win-stats {
        flex-direction: column;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .puzzle-board.size-3 {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 60px);
    }
    
    .puzzle-board.size-4 {
        grid-template-columns: repeat(4, 50px);
        grid-template-rows: repeat(4, 50px);
    }
    
    .puzzle-tile {
        font-size: 1.2rem;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}