* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'SimHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

/* 头部样式 */
.header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    color: #333;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.user-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.user-name {
    font-weight: bold;
    color: #333;
    margin-right: 10px;
}

.logout-btn {
    padding: 8px 15px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: #d32f2f;
}

.game-info {
    flex: 1;
    min-width: 250px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: #f0f0f0;
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.difficulty-selector {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.difficulty-selector label {
    font-weight: bold;
    margin-right: 10px;
}

.difficulty-selector select {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
}

.status {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.status p {
    margin: 10px 0;
    font-size: 18px;
}

.red {
    color: #d32f2f;
    font-weight: bold;
}

.black {
    color: #1a1a1a;
    font-weight: bold;
}

.reset-btn {
    width: 100%;
    padding: 15px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.reset-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.game-board {
    flex: 0 0 auto;
}

#chessBoard {
    border: 3px solid #8b4513;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    background: #f4e4c1;
}

.move-history {
    flex: 1;
    min-width: 250px;
    max-height: 600px;
    overflow-y: auto;
}

.move-history h3 {
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

#moveList {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.move-item {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border-radius: 5px;
    border-left: 3px solid #667eea;
}

.move-item:nth-child(odd) {
    border-left-color: #d32f2f;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-btn {
    width: 100%;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.auth-btn:hover {
    background: #5568d3;
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.auth-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    display: none;
}

.auth-message.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.auth-message.error {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

/* 用户统计样式 */
.user-stats {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    color: white;
}

.user-stats h3 {
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.2em;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
}

.stat-buttons {
    display: flex;
    gap: 10px;
}

.stat-btn {
    flex: 1;
    padding: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.stat-btn:hover {
    background: white;
    color: #667eea;
}

/* 排行榜样式 */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.leaderboard-table th {
    background: #667eea;
    color: white;
    font-weight: bold;
}

.leaderboard-table tr:hover {
    background: #f5f5f5;
}

.rank-medal {
    font-size: 1.5em;
    margin-right: 5px;
}

/* 历史记录样式 */
.history-item {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.history-item.win {
    border-left-color: #4caf50;
}

.history-item.lose {
    border-left-color: #f44336;
}

.history-item.draw {
    border-left-color: #ff9800;
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: bold;
}

.history-details {
    font-size: 0.9em;
    color: #666;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    #chessBoard {
        width: 100%;
        height: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* 联机对战样式 */
.online-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.online-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.online-status {
    margin-top: 10px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    text-align: center;
    font-size: 14px;
}

.online-status.waiting {
    background: #fff3cd;
    color: #856404;
}

.online-status.matched {
    background: #d4edda;
    color: #155724;
}

.online-status.playing {
    background: #d1ecf1;
    color: #0c5460;
}

/* 匹配弹窗样式 */
#matchModal .modal-content {
    max-width: 400px;
    text-align: center;
}

.match-spinner {
    width: 60px;
    height: 60px;
    margin: 30px auto;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.match-status {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin: 20px 0 10px 0;
}

.match-tip {
    font-size: 14px;
    color: #666;
    margin-bottom: 30px;
}

.match-success {
    font-size: 80px;
    color: #28a745;
    margin: 20px 0;
    animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.match-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.match-info p {
    margin: 10px 0;
    font-size: 16px;
}

.match-info span {
    font-weight: bold;
    color: #667eea;
}

.cancel-btn, .start-btn {
    width: 80%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px auto;
}

.cancel-btn {
    background: #dc3545;
    color: white;
}

.cancel-btn:hover {
    background: #c82333;
}

.start-btn {
    background: #28a745;
    color: white;
}

.start-btn:hover {
    background: #218838;
}

/* 登录提示样式 */
.login-prompt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.login-prompt p {
    margin: 8px 0;
}

.login-prompt p:first-child {
    font-size: 18px;
    font-weight: bold;
}
