/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 页面切换 */
.page {
    display: none;
    flex: 1;
    animation: fadeIn 0.5s ease-in-out;
}

.page.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.title {
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
    background: linear-gradient(45deg, #fff, #f0f8ff, #fff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.9);
    font-weight: 300;
}

/* 首页菜单 */
.menu {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 60px;
}

.menu-btn {
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: 20px;
    padding: 30px;
    width: 300px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 20px;
    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.4), transparent);
    transition: left 0.5s;
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.menu-btn:active {
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 3rem;
    flex-shrink: 0;
}

.btn-text h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.btn-text p {
    font-size: 1rem;
    color: #666;
    line-height: 1.4;
}

.create-btn:hover {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.create-btn:hover .btn-text h3,
.create-btn:hover .btn-text p {
    color: white;
}

.join-btn:hover {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.join-btn:hover .btn-text h3,
.join-btn:hover .btn-text p {
    color: white;
}

/* 返回按钮 */
.back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.back-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateX(-5px);
}

/* 创建房间页面 */
.room-info {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
}

.room-code-display {
    margin-bottom: 40px;
}

.room-code-display h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
}

.room-code {
    font-size: 3rem;
    font-weight: 700;
    color: #2196F3;
    background: linear-gradient(135deg, #f0f8ff 0%, #e3f2fd 100%);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    letter-spacing: 5px;
    border: 3px dashed #2196F3;
    position: relative;
    overflow: hidden;
    animation: glow 2s ease-in-out infinite alternate;
}

.room-code::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(33, 150, 243, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes glow {
    from { box-shadow: 0 0 10px rgba(33, 150, 243, 0.3); }
    to { box-shadow: 0 0 20px rgba(33, 150, 243, 0.6); }
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.copy-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

/* 等待区域 */
.waiting-area {
    border-top: 2px solid #eee;
    padding-top: 30px;
}

.player-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.player {
    text-align: center;
    padding: 20px;
    border-radius: 15px;
    min-width: 150px;
}

.red-player {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
}

.black-player {
    background: linear-gradient(135deg, #4a4a4a, #2c2c2c);
    color: white;
}

.player-avatar {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.player-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.player-status {
    font-size: 0.9rem;
    padding: 5px 15px;
    border-radius: 15px;
    display: inline-block;
}

.player-status.ready {
    background: #4CAF50;
    color: white;
}

.player-status.waiting {
    background: #ff9800;
    color: white;
}

.vs-divider {
    font-size: 2rem;
    font-weight: 700;
    color: #666;
}

.waiting-message {
    font-size: 1.1rem;
    color: #666;
    font-style: italic;
}

/* 进入房间页面 */
.join-form {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 500px;
    margin: 0 auto;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.input-group input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.5rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    text-align: center;
    letter-spacing: 3px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.join-room-btn {
    width: 100%;
    background: #2196F3;
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.join-room-btn:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.error-message {
    color: #f44336;
    text-align: center;
    font-size: 1rem;
    margin-top: 15px;
    padding: 10px;
    background: #ffebee;
    border-radius: 5px;
    display: none;
}

/* 游戏页面 */
.game-header {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.game-info {
    display: flex;
    gap: 30px;
    align-items: center;
}

.room-info-small {
    font-size: 1.1rem;
    color: #666;
}

.current-player {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

/* 游戏棋盘 */
.game-board-container {
    display: flex;
    gap: 20px;
    flex: 1;
}

.board-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.chess-board {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, #f5f5dc 0%, #e6e6d4 100%);
    border: 3px solid #8b4513;
    border-radius: 10px;
    position: relative;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
    padding: 10px;
    box-shadow: 
        0 0 20px rgba(0,0,0,0.3),
        inset 0 0 20px rgba(255,255,255,0.1);
}

.chess-board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, transparent 0%, rgba(139, 69, 19, 0.1) 50%, transparent 100%),
        linear-gradient(0deg, transparent 0%, rgba(139, 69, 19, 0.1) 50%, transparent 100%);
    pointer-events: none;
    border-radius: 7px;
}

.chess-square {
    background: linear-gradient(135deg, #f5f5dc 0%, #e6e6d4 100%);
    border: 1px solid #8b4513;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 1;
}

.chess-square:nth-child(odd) {
    background: linear-gradient(135deg, #e6e6d4 0%, #d4d4c4 100%);
}

.chess-square:hover {
    background: #fffacd;
    transform: scale(1.05);
}

.chess-square.selected {
    background: linear-gradient(135deg, #ffeb3b 0%, #ffc107 100%);
    box-shadow: 0 0 15px rgba(255, 235, 59, 0.8);
    transform: scale(1.05);
    z-index: 2;
}

.chess-square.possible-move {
    background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

.chess-square.possible-move::after {
    content: '';
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #4caf50 0%, #2e7d32 100%);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.chess-piece {
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.chess-piece:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

/* 游戏侧边栏 */
.game-sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.player-panel {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.player {
    margin-bottom: 15px;
}

.player:last-child {
    margin-bottom: 0;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.player-avatar {
    font-size: 2rem;
}

.player-details {
    flex: 1;
}

.player-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.player-time {
    font-size: 0.9rem;
    color: #666;
}

.player-status {
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 10px;
    text-align: center;
}

.red-player-panel .player-status {
    background: #ffebee;
    color: #c62828;
}

.black-player-panel .player-status {
    background: #f3e5f5;
    color: #7b1fa2;
}

.game-log {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    flex: 1;
}

.game-log h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1rem;
}

.log-content {
    max-height: 200px;
    overflow-y: auto;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    color: #666;
}

.log-entry:last-child {
    border-bottom: none;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 消息提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: #4caf50;
}

.toast.error {
    background: #f44336;
}

.toast.info {
    background: #2196f3;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .menu {
        flex-direction: column;
        align-items: center;
    }
    
    .menu-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .game-board-container {
        flex-direction: column;
    }
    
    .chess-board {
        width: 350px;
        height: 350px;
    }
    
    .game-sidebar {
        width: 100%;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .chess-board {
        width: 300px;
        height: 300px;
    }
    
    .chess-piece {
        font-size: 1.5rem;
    }
    
    .room-code {
        font-size: 2rem;
        letter-spacing: 3px;
    }
}
