/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* 背景动画 */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(252, 70, 107, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(99, 179, 237, 0.3) 0%, transparent 50%);
    animation: backgroundMove 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes backgroundMove {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

/* 毛玻璃效果 */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

/* 头部样式 */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.avatar-container:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.avatar-icon {
    width: 32px;
    height: 32px;
    fill: var(--text-primary);
}

.username {
    font-size: 0.9rem;
    font-weight: 500;
}

.logout-btn {
    padding: 0.5rem;
    background: rgba(245, 101, 101, 0.2);
    border: 1px solid rgba(245, 101, 101, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(245, 101, 101, 0.3);
    transform: scale(1.05);
}

.logout-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--text-primary);
    display: block;
}

.stats-info {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    border-radius: 50px;
    border: 1px solid var(--glass-border);
}

.stat-item {
    font-size: 0.85rem;
    font-weight: 500;
}

/* 主容器 */
.main-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    padding-top: 5rem;
}

.logo-container {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    letter-spacing: 4px;
}

/* 菜单网格 */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    width: 100%;
    animation: fadeInUp 0.8s ease;
}

.menu-btn {
    padding: 2rem 1.5rem;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    overflow: hidden;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.menu-btn:active {
    transform: translateY(-4px) scale(0.98);
}

.menu-icon {
    width: 48px;
    height: 48px;
    fill: var(--text-primary);
}

.menu-text {
    font-size: 1.2rem;
    font-weight: 600;
}

.menu-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* 游戏界面 */
.game-container {
    min-height: 100vh;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.game-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    padding: 0.8rem 1.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-4px);
}

.back-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.game-info {
    flex: 1;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
}

/* 棋盘容器 */
.game-board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.player-info {
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.player-black {
    border-left: 4px solid #2d3748;
}

.player-white {
    border-left: 4px solid #f7fafc;
}

.player-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--glass-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--glass-border);
}

.chess-piece {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    position: relative;
}

.chess-piece.black {
    background: radial-gradient(circle at 30% 30%, #4a5568, #1a202c);
    box-shadow: 
        inset -2px -2px 4px rgba(255, 255, 255, 0.1),
        inset 2px 2px 4px rgba(0, 0, 0, 0.5),
        0 4px 8px rgba(0, 0, 0, 0.3);
}

.chess-piece.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #e2e8f0);
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.1),
        inset 2px 2px 4px rgba(255, 255, 255, 0.8),
        0 4px 8px rgba(0, 0, 0, 0.2);
}

.chess-piece::after {
    content: '';
    position: absolute;
    top: 20%;
    left: 20%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.6), transparent);
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.player-time {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--warning-color);
}

/* 棋盘 */
.game-board {
    border-radius: 16px;
    cursor: pointer;
    touch-action: none;
}

/* 游戏控制 */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-btn {
    padding: 0.8rem 1.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.control-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
}

.control-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 聊天容器 */
.chat-container {
    max-width: 600px;
    margin: 0 auto;
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages {
    height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
}

.chat-message {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
    word-wrap: break-word;
}

.chat-message.system {
    background: rgba(237, 137, 54, 0.2);
    text-align: center;
    font-style: italic;
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.chat-send-btn {
    padding: 0.8rem 1.2rem;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--text-primary);
    display: block;
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    z-index: 1000;
    display: none;
    animation: modalSlideIn 0.3s ease forwards;
}

.modal.active {
    display: block;
}

@keyframes modalSlideIn {
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    padding: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.modal-close svg {
    width: 24px;
    height: 24px;
    fill: var(--text-primary);
    display: block;
}

.modal-body {
    padding: 1.5rem;
}

/* 认证表单 */
.auth-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.8rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-input {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

.form-submit {
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* AI难度选择 */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.difficulty-btn {
    padding: 1.5rem;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(8px);
    border-color: var(--primary-color);
}

.difficulty-icon {
    font-size: 2.5rem;
}

.difficulty-name {
    font-size: 1.3rem;
    font-weight: 600;
    flex: 1;
}

.difficulty-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .game-subtitle {
        font-size: 1rem;
    }
    
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .menu-btn {
        padding: 1.5rem 1rem;
    }
    
    .menu-icon {
        width: 36px;
        height: 36px;
    }
    
    .menu-text {
        font-size: 1rem;
    }
    
    .game-board-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .player-info {
        width: 100%;
        max-width: 400px;
    }
    
    .game-controls {
        gap: 0.5rem;
    }
    
    .control-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .stats-info {
        display: none;
    }
}

@media (max-width: 480px) {
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .control-btn span {
        display: none;
    }
    
    .control-btn {
        padding: 0.8rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
