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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: white;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* 横屏提示 */
.rotate-tip {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    color: #333;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 20px;
}

.rotate-icon {
    font-size: 60px;
    animation: rotate 2s ease infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
    100% { transform: rotate(0deg); }
}

.rotate-sub {
    font-size: 14px;
    opacity: 0.8;
}

@media (orientation: portrait) {
    .rotate-tip { display: flex; }
    #app { display: none; }
}

/* 登录界面 */
.login-view {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: white;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 25px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    width: 380px;
    max-width: 100%;
    border: 1px solid #e8e8e8;
}

.logo {
    text-align: center;
    margin-bottom: 15px;
}

.logo-icon {
    font-size: 40px;
    margin-bottom: 5px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo h1 {
    font-size: 20px;
    color: #333;
    font-weight: 600;
}

.tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #e8e8e8;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: #999;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #333;
    border-bottom: 2px solid #333;
}

.form-panel {
    display: none;
}

.form-panel.active {
    display: block;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.3s;
    background: #fafafa;
    margin-bottom: 10px;
}

input:focus, select:focus {
    outline: none;
    border-color: #999;
    background: white;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

input.valid {
    border-color: #4CAF50;
    background: #f5fff5;
}

input.invalid {
    border-color: #f44336;
    background: #fff5f5;
}

.checkbox-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    gap: 8px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #666;
    cursor: pointer;
}

.checkbox-label input {
    width: 14px;
    height: 14px;
    margin: 0;
}

.checkbox-label a {
    color: #666;
    text-decoration: none;
}

.btn {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: white;
    color: #333;
    margin-top: 8px;
    transition: all 0.3s;
}

.btn-primary {
    background: #333;
    color: white;
    border: none;
}

.btn-primary:hover {
    background: #555;
}

.input-hint {
    font-size: 11px;
    margin-top: -8px;
    margin-bottom: 8px;
    text-align: left;
}

.input-hint.valid {
    color: #4CAF50;
}

.input-hint.invalid {
    color: #f44336;
}

.password-hint {
    font-size: 10px;
    color: #999;
    margin-bottom: 8px;
    text-align: left;
}

/* 大厅界面 - 通体白色 */
#lobbyView {
    display: none;
    flex-direction: column;
    height: 100%;
    background: white;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #e8e8e8;
}

.stats-row {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}

.stat-icon {
    font-size: 14px;
}

.stat-item strong {
    color: #333;
    font-size: 14px;
    margin-left: 4px;
}

.settings-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    color: #666;
}

.settings-icon:hover {
    background: #f0f0f0;
}

.lobby-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.hero-section {
    text-align: center;
    margin-bottom: 30px;
}

.hero-section h2 {
    color: #4CAF50;
    font-size: 28px;
    margin-bottom: 6px;
    font-weight: 600;
}

.hero-section p {
    color: #999;
    font-size: 13px;
}

/* 两个按钮一样大 */
.match-section {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 380px;
}

.match-btn {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    background: white;
    color: #333;
    min-width: 140px;
}

.match-btn.primary {
    background: #333;
    color: white;
    border: none;
}

.match-btn.secondary {
    background: white;
    border: 1px solid #ddd;
}

.match-btn:active {
    transform: scale(0.98);
}

.feature-section {
    display: flex;
    gap: 15px;
    width: 100%;
    max-width: 380px;
}

.feature-btn {
    flex: 1;
    padding: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s;
    color: #666;
}

.feature-btn:hover {
    background: #f8f9fa;
    border-color: #999;
}

/* 游戏界面 */
#gameView {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 400;
    flex-direction: column;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #eee;
}

.exit-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: #f44336;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 20px;
}

.game-timers {
    display: flex;
    gap: 20px;
}

.timer-item {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    background: #f5f5f5;
    padding: 5px 12px;
    border-radius: 20px;
}

.timer-item span {
    color: #f44336;
    font-size: 16px;
}

.game-board {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

#gomokuCanvas {
    background: #f5e6c8;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: min(65vw, 65vh);
    height: min(65vw, 65vh);
    cursor: pointer;
}

.game-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding: 15px;
}

.action-btn {
    padding: 8px 24px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.action-btn.surrender {
    color: #ff9800;
    border-color: #ff9800;
}

.action-btn.draw {
    color: #2196f3;
    border-color: #2196f3;
}

/* 结算界面 */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.result-card {
    background: white;
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    width: 260px;
    max-width: 85%;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.result-card h2 {
    margin-bottom: 12px;
    font-size: 20px;
    color: #333;
}

.result-card p {
    margin-bottom: 15px;
    color: #666;
    font-size: 13px;
}

.result-btn {
    padding: 8px 20px;
    background: #333;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 13px;
    cursor: pointer;
}

/* 侧边栏 - 加宽 */
.sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100%;
    background: white;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08);
    transition: right 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 18px;
    color: #333;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* 聊天消息区域 */
.chat-messages {
    height: 450px;
    overflow-y: auto;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 12px;
    font-size: 14px;
    word-break: break-word;
}

.chat-message .chat-name {
    font-weight: 600;
    color: #333;
    margin-right: 8px;
    font-size: 13px;
}

.chat-message .chat-time {
    font-size: 10px;
    color: #999;
    margin-left: 8px;
}

.chat-message.self {
    background: #e3f2fd;
    text-align: right;
}

.chat-bubble {
    max-width: 100%;
}

.chat-text {
    font-size: 14px;
    line-height: 1.4;
}

/* 输入区域 */
.chat-input-area {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    margin: 0;
}

.chat-input-area button {
    padding: 10px 20px;
    background: #333;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
}

/* 好友搜索 */
.friend-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.friend-search input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 25px;
}

.friend-search button {
    padding: 10px 18px;
    background: #333;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #999;
    margin: 15px 0 10px;
    padding-left: 4px;
}

.friend-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #f8f9fa;
    border-radius: 12px;
}

.friend-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.friend-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-online {
    background: #4caf50;
}

.status-offline {
    background: #ccc;
}

.friend-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.friend-actions {
    display: flex;
    gap: 8px;
}

.friend-actions button {
    padding: 5px 12px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 15px;
    cursor: pointer;
    background: white;
}

.friend-actions .invite-btn {
    background: #f0f0f0;
}

.friend-actions .chat-btn {
    background: #f0f0f0;
}

.friend-actions .delete-btn {
    background: #fff0f0;
    border-color: #f44336;
    color: #f44336;
}

.pending-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #fff8e1;
    border-radius: 12px;
    margin-bottom: 8px;
}

.pending-actions {
    display: flex;
    gap: 8px;
}

.accept-btn {
    padding: 4px 12px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
}

.reject-btn {
    padding: 4px 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
}

/* 私聊侧边栏 */
.private-chat {
    width: 420px;
}

.private-chat .chat-messages {
    height: 480px;
}

/* 设置页面 */
.settings-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 300;
    display: none;
    flex-direction: column;
    overflow-y: auto;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 18px;
    background: white;
    border-bottom: 1px solid #e8e8e8;
}

.back-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #333;
}

.settings-header h3 {
    font-size: 18px;
    color: #333;
}

.settings-content {
    padding: 16px;
}

.settings-group {
    background: #f8f9fa;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-group h4 {
    margin-bottom: 12px;
    color: #333;
    font-size: 15px;
}

.profile-info {
    margin-bottom: 12px;
}

.profile-info p {
    margin: 5px 0;
    font-size: 13px;
    color: #333;
}

.info-label {
    color: #999;
    width: 65px;
    display: inline-block;
    font-size: 12px;
}

.settings-group label {
    display: block;
    margin: 10px 0 5px;
    font-size: 12px;
    color: #666;
}

.settings-group input,
.settings-group select,
.settings-group textarea {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 5px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.settings-btn {
    width: 100%;
    padding: 10px;
    background: #333;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
}

.settings-btn.danger {
    background: #f44336;
}

.policy-links {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.policy-links a {
    color: #666;
    text-decoration: none;
    font-size: 12px;
}

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

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 16px;
    width: 300px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    margin-bottom: 12px;
    color: #333;
    font-size: 18px;
}

.modal-content p {
    margin-bottom: 12px;
    color: #666;
    font-size: 12px;
}

.modal-content input {
    width: 100%;
    padding: 8px;
    margin: 6px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.difficulty-btn {
    width: 100%;
    padding: 10px;
    margin: 6px 0;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.difficulty-btn:hover {
    background: #e8e8e8;
}

.cancel-btn {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.delete-confirm {
    width: 100%;
    padding: 10px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 8px;
}

.delete-cancel {
    width: 100%;
    padding: 10px;
    background: #ccc;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 6px;
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 199;
    display: none;
}

/* 排行榜表格 */
#rankList table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#rankList th, #rankList td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

#rankList th {
    background: #f5f5f5;
}

/* 响应式 */
@media (max-width: 600px) {
    .login-card {
        padding: 20px 15px;
        width: 340px;
    }
    
    .logo-icon {
        font-size: 36px;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    
    .checkbox-line {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-row {
        gap: 12px;
    }
    
    .stat-item {
        font-size: 11px;
    }
    
    .sidebar {
        width: 320px;
        right: -340px;
    }
    
    .private-chat {
        width: 340px;
    }
    
    .match-section {
        max-width: 320px;
        gap: 12px;
    }
    
    .match-btn {
        padding: 12px 16px;
        font-size: 14px;
        min-width: 120px;
    }
    
    .feature-section {
        max-width: 320px;
        gap: 12px;
    }
    
    .feature-btn {
        padding: 10px;
        font-size: 12px;
    }
}

/* 快速匹配和人机对战按钮 - 一样大 */
.match-section {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    width: 100%;
    max-width: 420px;
}

.match-btn {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    background: white;
    color: #333;
    min-width: 150px;
}

/* 公共频道和好友列表按钮 - 一样大 */
.feature-section {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 420px;
}

.feature-btn {
    flex: 1;
    padding: 14px 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    color: #666;
    min-width: 150px;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .match-section {
        max-width: 340px;
        gap: 12px;
    }
    .match-btn {
        padding: 12px 16px;
        font-size: 14px;
        min-width: 130px;
    }
    .feature-section {
        max-width: 340px;
        gap: 12px;
    }
    .feature-btn {
        padding: 12px 16px;
        font-size: 14px;
        min-width: 130px;
    }
}

/* 匹配等待界面 */
.matching-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
}

.matching-card {
    background: white;
    border-radius: 24px;
    padding: 40px 30px;
    text-align: center;
    width: 320px;
    max-width: 85%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease;
}

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

.matching-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid #f0f0f0;
    border-top-color: #4CAF50;
    border-right-color: #2196f3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.matching-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.matching-timer {
    background: #f5f5f5;
    border-radius: 16px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.timer-label {
    display: block;
    font-size: 12px;
    color: #999;
    margin-bottom: 5px;
}

.timer-value {
    font-size: 48px;
    font-weight: bold;
    color: #f44336;
    font-family: monospace;
}

.timer-unit {
    font-size: 16px;
    color: #999;
    margin-left: 5px;
}

.matching-tip {
    font-size: 12px;
    color: #999;
    margin-bottom: 25px;
}

.cancel-match-btn {
    width: 100%;
    padding: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 30px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    color: #666;
}

.cancel-match-btn:hover {
    background: #ffebee;
    border-color: #f44336;
    color: #f44336;
}

/* 匹配失败弹窗 */
.match-fail-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.match-fail-tip {
    font-size: 12px;
    color: #999;
}

.match-fail-btn {
    width: 100%;
    padding: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 15px;
}
