* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 屏幕管理 */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    padding: 20px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    letter-spacing: 2px;
    animation: slideDown 0.6s ease;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    animation: slideDown 0.8s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 模式选择界面 */
.mode-selection {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex: 1;
    padding: 40px 20px;
    animation: fadeIn 0.8s ease;
}

.mode-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 280px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.mode-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}

.mode-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.mode-card h3 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 15px;
}

.mode-card p {
    color: #666;
    font-size: 1rem;
    margin-bottom: 30px;
}

/* 在线模式界面 */
.online-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    animation: fadeIn 0.8s ease;
}

.player-name-input {
    margin-bottom: 30px;
}

.player-name-input input {
    width: 300px;
    max-width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid white;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    text-align: center;
    transition: all 0.3s ease;
}

.player-name-input input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* 房间列表 */
.room-list-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.room-list-container h2 {
    color: #333;
    margin-bottom: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.room-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.room-item {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.room-item:hover {
    border-color: #667eea;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.room-info {
    flex: 1;
}

.room-id {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.room-player {
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
}

.no-rooms {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 1rem;
}

/* 等待屏幕 */
.waiting-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 40px 20px;
    animation: fadeIn 0.8s ease;
}

.room-code-display {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-width: 300px;
}

.room-code-display p {
    color: #666;
    margin-bottom: 15px;
    font-size: 1rem;
}

.room-code {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
    letter-spacing: 10px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
}

.btn-small {
    padding: 8px 20px !important;
    font-size: 0.9rem !important;
}

.waiting-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.waiting-spinner p {
    color: white;
    font-size: 1.2rem;
    margin-top: 20px;
}

/* 准备屏幕 */
.ready-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 40px 20px;
    animation: fadeIn 0.8s ease;
}

.players-ready {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    display: flex;
    align-items: center;
    gap: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-width: 400px;
}

.player-ready-item {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.player-ready-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
}

.player-ready-status {
    font-size: 0.95rem;
    padding: 6px 12px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #999;
}

.player-ready-status.ready {
    background: #4caf50;
    color: white;
}

.vs-divider {
    color: #667eea;
    font-weight: bold;
    font-size: 1.2rem;
}

.ready-buttons {
    display: flex;
    gap: 15px;
}

.ready-buttons .btn {
    width: 150px;
    margin: 0;
}

/* 游戏主区域 */
.game-wrapper {
    display: flex;
    gap: 20px;
    animation: fadeIn 0.8s ease;
    flex: 1;
    overflow: hidden;
}

/* 信息栏 */
.info-panel {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    max-height: 700px;
    padding-right: 10px;
}

.info-panel::-webkit-scrollbar {
    width: 6px;
}

.info-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.info-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.info-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.info-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.info-card h3 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* 玩家信息 */
.player-info, .player-info-online {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 10px 0;
}

.player, .player-online {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.player-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.player-indicator.black {
    background: linear-gradient(135deg, #333 0%, #000 100%);
}

.player-indicator.white {
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    border: 1px solid #ccc;
}

.player-text {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
}

.player-label {
    font-weight: bold;
    color: #333;
}

.player-role {
    font-size: 0.8rem;
    color: #999;
}

.vs-text {
    color: #667eea;
    font-weight: bold;
    font-size: 0.9rem;
}

/* 房间ID显示 */
.room-id-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

/* 状态显示 */
.status-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-box {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    font-size: 0.9rem;
}

.status-label {
    color: #555;
    font-weight: 500;
}

.status-value {
    color: #667eea;
    font-weight: bold;
}

/* 难度选择按钮 */
.difficulty-buttons {
    display: flex;
    gap: 8px;
}

.difficulty-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.difficulty-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

/* 按钮 */
.btn {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245, 87, 108, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-info:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 172, 254, 0.4);
}

/* 统计信息 */
.stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.stat-item span:last-child {
    color: #667eea;
    font-weight: bold;
}

/* 棋盘容器 */
.board-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 640px;
}

#gameBoard, #aiGameBoard, #onlineGameBoard {
    cursor: crosshair;
    display: block;
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    border-radius: 15px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    image-rendering: crisp-edges;
}

.overlay-info {
    position: absolute;
    pointer-events: none;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.5);
}

/* 记录栏 */
.record-panel {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    max-height: 700px;
    padding-right: 10px;
}

.record-panel::-webkit-scrollbar {
    width: 6px;
}

.record-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.record-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.record-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.record-card h3 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* 棋谱列表 */
.moves-list {
    max-height: 250px;
    overflow-y: auto;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    padding: 10px;
}

.moves-list::-webkit-scrollbar {
    width: 4px;
}

.moves-list::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.moves-placeholder {
    text-align: center;
    color: #999;
    padding: 20px;
    font-size: 0.9rem;
}

.move-item {
    padding: 6px 8px;
    margin-bottom: 4px;
    background: white;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.move-index {
    color: #999;
    min-width: 25px;
}

.move-piece {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.move-piece.black {
    background: #333;
}

.move-piece.white {
    background: white;
    border: 1px solid #ccc;
}

.move-coord {
    color: #667eea;
    font-weight: bold;
}

/* 游戏规则 */
.rules {
    list-style: none;
    font-size: 0.85rem;
    color: #555;
}

.rules li {
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

.rules li:before {
    content: "✓ ";
    color: #667eea;
    font-weight: bold;
    margin-right: 5px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.modal-content h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons .btn {
    flex: 1;
    margin: 0;
}

/* 操作按钮容器 */
.action-buttons {
    display: flex;
    gap: 15px;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
}

.action-buttons .btn {
    margin: 0;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .game-wrapper {
        flex-direction: column;
    }

    .info-panel, .record-panel {
        width: 100%;
        max-height: none;
    }

    .board-container {
        min-width: auto;
    }

    .mode-selection {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .game-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    #gameBoard, #aiGameBoard, #onlineGameBoard {
        width: 100%;
        height: auto;
    }

    .board-container {
        padding: 15px;
    }

    .mode-card {
        min-width: auto;
        width: 100%;
    }

    .players-ready {
        min-width: auto;
        width: 100%;
    }
}

/* 返回按钮 */
.back-btn {
    margin: 20px auto;
    max-width: 200px;
    display: block;
}
