* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    overflow-x: hidden;
}

/* 模式选择界面 */
.mode-select-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.mode-select-container.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.mode-select-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s ease;
    max-width: 90%;
    width: 400px;
}

.mode-select-content h1 {
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.mode-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.mode-btn:active {
    transform: translateY(-1px);
}

/* 返回按钮 */
.back-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
    margin-left: 15px;
}

.back-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

/* 游戏容器 */
.game-container-inner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    perspective: 1000px;
}

/* 双人模式游戏区域 */
.two-player-area {
    margin-top: 20px;
}

.players-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.player-game {
    background: #f7fafc;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 300px;
    max-width: 400px;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.player-header h3 {
    color: #4a5568;
    margin: 0;
}

.player-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    font-weight: bold;
    color: #4a5568;
}

.player-timer, .player-moves {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 单人模式游戏区域 */
.single-game-area {
    margin-top: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .players-container {
        flex-direction: column;
        align-items: center;
    }
    
    .player-game {
        width: 100%;
        max-width: none;
    }
    
    .player-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .player-stats {
        justify-content: center;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .players-container {
        gap: 15px;
    }
    
    .player-game {
        padding: 10px;
    }
    
    .player-header {
        margin-bottom: 10px;
    }
}

/* 调整header布局 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
}

header h1 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-weight: bold;
    color: #4a5568;
    font-size: 14px;
}

.setting-group select,
.setting-group input[type="number"] {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: all 0.3s ease;
    outline: none;
}

.setting-group select:focus,
.setting-group input[type="number"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-group input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.setting-group input[type="color"]:hover {
    transform: scale(1.1);
}

.start-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #4a5568;
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    perspective: 1000px;
}

.board {
    display: grid;
    gap: 5px;
    background: #e2e8f0;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

/* 3阶 */
.board[data-level="3"] {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
}

/* 4阶 */
.board[data-level="4"] {
    grid-template-columns: repeat(4, 70px);
    grid-template-rows: repeat(4, 70px);
}

/* 5阶 */
.board[data-level="5"] {
    grid-template-columns: repeat(5, 60px);
    grid-template-rows: repeat(5, 60px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .board[data-level="3"] {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
    }
    
    .board[data-level="4"] {
        grid-template-columns: repeat(4, 60px);
        grid-template-rows: repeat(4, 60px);
    }
    
    .board[data-level="5"] {
        grid-template-columns: repeat(5, 50px);
        grid-template-rows: repeat(5, 50px);
    }
    
    .settings {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-group {
        justify-content: space-between;
    }
    
    header h1 {
        font-size: 2em;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .board[data-level="3"] {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 60px);
    }
    
    .board[data-level="4"] {
        grid-template-columns: repeat(4, 50px);
        grid-template-rows: repeat(4, 50px);
    }
    
    .board[data-level="5"] {
        grid-template-columns: repeat(5, 45px);
        grid-template-rows: repeat(5, 45px);
    }
    
    .container {
        padding: 10px;
        max-height: 100vh;
    }
    
    header h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .game-info {
        margin-bottom: 10px;
        font-size: 16px;
    }
}

.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform-style: preserve-3d;
    position: relative;
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.tile.empty {
    background: transparent;
    box-shadow: none;
    cursor: default;
}

.tile.empty:hover {
    transform: none;
}

/* 棋子颜色2 */
.tile.color2 {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

/* 3阶棋子大小 */
.board[data-level="3"] .tile {
    font-size: 28px;
}

/* 5阶棋子大小 */
.board[data-level="5"] .tile {
    font-size: 18px;
}

.player-info {
    margin: 15px 0;
    padding: 10px;
    background: #f7fafc;
    border-radius: 10px;
    display: inline-block;
    margin: 0 10px;
}

.player-info h3 {
    color: #4a5568;
    margin-bottom: 5px;
}

.player-timer {
    font-weight: bold;
    color: #667eea;
}

/* 弹窗样式 */
.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);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    max-width: 90%;
    width: 400px;
}

.modal-content h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    color: #718096;
    margin-bottom: 25px;
    font-size: 16px;
}

.restart-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

/* 倒计时弹窗样式 */
#countdown-modal {
    z-index: 1100; /* 高于其他弹窗 */
    background: transparent; /* 透明背景 */
    backdrop-filter: none; /* 去掉模糊效果 */
}

.countdown-content {
    text-align: center;
    background: transparent; /* 透明背景 */
    padding: 0;
    border-radius: 0;
    box-shadow: none; /* 去掉阴影 */
    animation: none;
    max-width: 100%;
    width: auto;
}

.countdown-number {
    font-size: 150px; /* 更大的字体 */
    font-weight: bold;
    color: white;
    margin: 0;
    animation: countdownPulse 1s ease-in-out infinite;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5), /* 深色阴影，增加可读性 */
                 0 0 20px rgba(102, 126, 234, 0.8); /* 发光效果 */
    line-height: 1;
}

.countdown-text {
    display: none; /* 隐藏提示文字 */
}

/* 倒计时动画 */
@keyframes countdownPulse {
    0%, 100% {
        transform: scale(1);
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5),
                     0 0 20px rgba(102, 126, 234, 0.8);
    }
    50% {
        transform: scale(1.2);
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5),
                     0 0 30px rgba(102, 126, 234, 1);
    }
}

/* 获胜动画 */
.win-animation {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    background: radial-gradient(circle, #4CAF50 0%, #45a049 100%);
    border-radius: 50%;
    animation: winPulse 1s ease-in-out infinite alternate;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 40px;
}

/* 玩家2获胜时的颜色 */
.win-animation.player2 {
    background: radial-gradient(circle, #2196F3 0%, #1976D2 100%);
}

/* 玩家1获胜时的颜色 */
.win-animation.player1 {
    background: radial-gradient(circle, #4CAF50 0%, #45a049 100%);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes winPulse {
    from {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
    }
    to {
        transform: scale(1.1);
        box-shadow: 0 0 40px rgba(76, 175, 80, 0.8);
    }
}

/* 棋子移动动画 */
.tile.moving {
    transition: transform 0.2s ease;
}

/* 游戏完成时的闪烁效果 */
.board.completed .tile:not(.empty) {
    animation: flash 0.6s ease-in-out 3;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 滚动条样式 */
.container::-webkit-scrollbar {
    width: 8px;
}

.container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}