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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

/* 游戏容器 */
.game-container {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 100vh;
    overflow-y: auto;
}

/* 玩家信息 */
.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
}

.red-player .player-avatar {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
}

.black-player .player-avatar {
    background: linear-gradient(135deg, #4a4a4a, #333);
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.player-status {
    font-size: 12px;
    color: #888;
}

.player-status.active {
    color: #4CAF50;
    font-weight: 500;
}

/* 棋盘容器 */
.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0d9b5;
    border-radius: 8px;
    padding: 8px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

#chessBoard {
    display: block;
    touch-action: none;
}

/* 控制按钮 */
.control-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 100px;
}

.btn:active {
    transform: scale(0.95);
}

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

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    flex: none;
}

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

/* 聊天区域 */
.chat-section {
    background: #f5f5f5;
    border-radius: 8px;
    overflow: visible;
    position: relative;
    z-index: 10;
}

.chat-header {
    padding: 10px 12px;
    background: #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.chat-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 10px;
}

.chat-content.collapsed + .chat-header .chat-toggle-icon,
.chat-header:has(+ .chat-content.collapsed) .chat-toggle-icon {
    transform: rotate(-90deg);
}

.chat-content {
    max-height: 300px;
    overflow: visible;
    transition: max-height 0.3s ease;
}

.chat-content.collapsed {
    max-height: 0;
}

.chat-messages {
    height: 100px;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    max-width: 80%;
}

.chat-message.red {
    background: #ffebee;
    align-self: flex-start;
}

.chat-message.black {
    background: #e8e8e8;
    align-self: flex-end;
}

.chat-message .sender {
    font-weight: 600;
    margin-right: 4px;
}

.chat-message .emoji {
    font-size: 20px;
}

/* 表情栏 */
.emoji-bar {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    border-top: 1px solid #ddd;
    overflow-x: auto;
}

.emoji-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emoji-btn:active {
    transform: scale(1.1);
    background: #f0f0f0;
}

/* 聊天输入 */
.chat-input-area {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid #ddd;
    min-height: 44px;
    background: white;
    position: relative;
    z-index: 1;
}

#chatInput {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
}

#chatInput:focus {
    border-color: #667eea;
}

/* 观战区域 */
.spectator-section {
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

.spectator-header {
    padding: 8px 12px;
    background: #e8e8e8;
    font-weight: 600;
    font-size: 12px;
}

.spectator-list {
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.spectator-item {
    background: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    color: #666;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    min-width: 280px;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    margin-bottom: 12px;
    color: #333;
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
}

/* 提示高亮 */
.hint-highlight {
    animation: pulse 1s infinite;
}

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

/* 响应式调整 */
@media (max-height: 700px) {
    .game-container {
        padding: 8px;
        gap: 6px;
    }

    .player-info {
        padding: 6px 10px;
    }

    .player-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .chat-messages {
        height: 60px;
    }
}

@media (min-width: 768px) {
    .game-container {
        max-width: 450px;
    }
}

/* 在线状态栏 */
.online-status-bar {
    background: #e8f5e9;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    font-size: 12px;
    color: #2e7d32;
    font-weight: 600;
}

/* 在线模式弹窗样式 */
.online-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.divider {
    text-align: center;
    color: #999;
    font-size: 14px;
}

.room-id-display {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.room-id-display input {
    flex: 1;
    padding: 10px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    font-family: monospace;
}

.room-status {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin: 12px 0;
}

.modal-body h3 {
    margin-bottom: 16px;
    color: #333;
}

#joinRoomInput {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

#joinRoomInput:focus {
    border-color: #667eea;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
