/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196f3;
    --primary-dark: #1976d2;
    --primary-light: #bbdefb;
    --secondary-color: #ff9800;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --warning-color: #ffc107;
    --info-color: #00bcd4;
    
    --dark-bg: #1a1a2e;
    --dark-surface: #16213e;
    --dark-surface-light: #2d4059;
    --dark-text: #ffffff;
    --dark-text-secondary: #b0b0b0;
    
    --light-bg: #f5f5f5;
    --light-surface: #ffffff;
    --light-surface-dark: #e0e0e0;
    --light-text: #333333;
    --light-text-secondary: #666666;
    
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

html {
    font-size: 16px;
    font-family: 'Noto Sans SC', 'Segoe UI', system-ui, sans-serif;
}

body {
    background: var(--dark-bg);
    color: var(--dark-text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* 加载界面 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity var(--transition-slow);
}

.loading-content {
    text-align: center;
    max-width: 300px;
    padding: 2rem;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-text {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--dark-text-secondary);
}

.loading-progress {
    height: 4px;
    background: var(--dark-surface-light);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    animation: progress 2s ease-in-out infinite;
}

/* 应用容器 */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.app-container.loaded {
    opacity: 1;
}

/* 头部样式 */
.app-header {
    background: var(--dark-surface);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.logo-img {
    height: 36px;
    width: 36px;
    object-fit: contain;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: var(--dark-surface-light);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.status-dot.offline {
    background: var(--danger-color);
}

.status-dot.connecting {
    background: var(--warning-color);
    animation: pulse 1.5s infinite;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--dark-surface-light);
    border-radius: var(--border-radius);
    min-width: 200px;
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-color), var(--info-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
}

.player-details {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--dark-text-secondary);
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* 按钮样式 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    user-select: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

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

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--dark-text-secondary);
    color: var(--dark-text);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-control {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--dark-surface);
    border: 2px solid var(--dark-surface-light);
}

.btn-control:hover {
    background: var(--dark-surface-light);
    border-color: var(--primary-color);
}

.btn-mode {
    background: var(--dark-surface);
    border: 2px solid transparent;
    text-align: left;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
}

.btn-mode.active {
    background: var(--dark-surface-light);
    border-color: var(--primary-color);
}

.mode-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.mode-text {
    flex: 1;
}

/* 主要内容区 */
.app-main {
    flex: 1;
    display: flex;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
}

.sidebar-left, .sidebar-right {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.sidebar-section {
    background: var(--dark-surface);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.sidebar-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark-text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-modes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rooms-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}

.room-item {
    background: var(--dark-surface-light);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.room-item:hover {
    background: var(--dark-surface);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.room-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
}

.room-status.waiting {
    background: var(--warning-color);
    color: #000;
}

.room-status.playing {
    background: var(--success-color);
    color: white;
}

.room-status.finished {
    background: var(--dark-text-secondary);
    color: white;
}

.room-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--dark-text-secondary);
}

/* 游戏状态栏 */
.game-status-bar {
    background: var(--dark-surface);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-label {
    font-size: 0.875rem;
    color: var(--dark-text-secondary);
}

.status-value {
    font-weight: 600;
    font-size: 1rem;
}

/* 棋盘容器 */
.board-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.board-wrapper {
    position: relative;
    background: var(--dark-surface-light);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
}

.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    z-index: 10;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
}

.overlay-content h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.overlay-content p {
    color: var(--dark-text-secondary);
    margin-bottom: 1.5rem;
}

.board-controls {
    display: flex;
    gap: 1rem;
}

/* 玩家信息 */
.players-info {
    display: flex;
    gap: 1rem;
}

.player-card {
    flex: 1;
    background: var(--dark-surface);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.player-card.player-black {
    border-left: 4px solid #333;
}

.player-card.player-white {
    border-left: 4px solid #eee;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.stone-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.stone-preview.black {
    background: radial-gradient(circle at 30% 30%, #666, #000);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.stone-preview.white {
    background: radial-gradient(circle at 30% 30%, #fff, #ccc);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.player-name {
    font-weight: 600;
    font-size: 1rem;
}

.player-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--dark-text-secondary);
    margin-bottom: 0.75rem;
}

.stat {
    display: flex;
    gap: 0.25rem;
}

.stat-value {
    font-weight: 600;
    color: var(--dark-text);
}

.player-timer {
    height: 8px;
    background: var(--dark-surface-light);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: var(--primary-color);
    transition: width 1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* 聊天面板 */
.chat-panel {
    flex: 1;
    background: var(--dark-surface);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chat-header {
    background: var(--dark-surface-light);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chat-title {
    font-size: 1rem;
    font-weight: 600;
}

.chat-actions {
    display: flex;
    gap: 0.25rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    animation: slideIn var(--transition-normal);
}

.message-content {
    background: var(--dark-surface-light);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--primary-color);
}

.system-message .message-content {
    border-left-color: var(--info-color);
}

.message-sender {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.system-message .message-sender {
    color: var(--info-color);
}

.message-text {
    word-break: break-word;
}

.message-time {
    font-size: 0.75rem;
    color: var(--dark-text-secondary);
    margin-top: 0.25rem;
    text-align: right;
}

.chat-input-area {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.75rem 1rem;
    background: var(--dark-surface-light);
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255,255,255,0.2);
    background: var(--dark-bg);
    color: var(--dark-text);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.chat-hint {
    font-size: 0.75rem;
    color: var(--dark-text-secondary);
    margin-top: 0.25rem;
    text-align: center;
}

/* 观战面板 */
.spectator-panel, .leaderboard-panel {
    background: var(--dark-surface);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
}

.badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-weight: 600;
}

.spectator-list, .leaderboard-list {
    max-height: 200px;
    overflow-y: auto;
}

.spectator-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    background: var(--dark-surface-light);
    margin-bottom: 0.25rem;
}

.spectator-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.spectator-name {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 排行榜 */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    background: var(--dark-surface-light);
    margin-bottom: 0.25rem;
    transition: background var(--transition-fast);
}

.leaderboard-item:hover {
    background: var(--dark-surface);
}

.rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    background: var(--dark-surface);
    border-radius: 4px;
}

.rank-1 {
    background: gold;
    color: #000;
}

.rank-2 {
    background: silver;
    color: #000;
}

.rank-3 {
    background: #cd7f32;
    color: #000;
}

.player-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-color), var(--info-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.player-info-sm {
    flex: 1;
    min-width: 0;
}

.player-name-sm {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-rating {
    font-size: 0.75rem;
    color: var(--dark-text-secondary);
}

.score {
    font-weight: 600;
    font-size: 1rem;
}

.select-sm {
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    background: var(--dark-surface-light);
    color: var(--dark-text);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 0.75rem;
    font-family: inherit;
}

.select-sm:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 底部状态栏 */
.app-footer {
    background: var(--dark-surface);
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--dark-text-secondary);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-left, .footer-center, .footer-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-text {
    opacity: 0.8;
}

.footer-value {
    font-weight: 600;
    color: var(--dark-text);
}

/* 空状态 */
.empty-state, .loading-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--dark-text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-text {
    font-size: 0.875rem;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.loading-spinner-sm {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 动画 */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes progress {
    0% { width: 0%; margin-left: 0%; }
    50% { width: 100%; margin-left: 0%; }
    100% { width: 0%; margin-left: 100%; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 响应式调整将在 responsive.css 中处理 */