/* @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Inter:wght@300;400;500;600&family=Merriweather:ital,wght@0,300;0,400;0,700;1,300&family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;600;700&display=swap'); */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Noto+Serif+SC:wght@400;600&display=swap');
/* ==================== Variables & Reset ==================== */

/* 防止滚动到边界时触发浏览器地址栏 */
html, body {
    overscroll-behavior: none;
}

.chat-messages {
    overscroll-behavior: contain;
}
:root {
    --bg-main: #121418;
    --bg-secondary: #1b2026;
    --bg-tertiary: #232a34;
    
    --accent-primary: #d4af37;
    --accent-secondary: #7289da;
    --accent-danger: #e05d5d;
    --accent-success: #4aa879;
    
    --text-main: #e0e0e0;
    --text-muted: #949ba4;
    --text-highlight: #ffffff;
    
    --border-color: #2f3640;
    --border-hover: #d4af37;

    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    
    /* 英文字体在前，中文字体在后，浏览器自动选择 */
    --font-heading: 'Cinzel', 'Noto Serif SC', serif;
    --font-body: 'Noto Serif SC', serif;
    --font-reading: 'Merriweather', 'Noto Serif SC', serif;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(212, 175, 55, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(114, 137, 218, 0.05) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: #3e4654; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #566070; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-highlight);
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* ==================== 神秘光晕效果 ==================== */
.mystic-text {
    font-family: 'Noto Serif SC', var(--font-reading);
    color: #e8dcc4 !important;  /* 加 !important */
    text-shadow: 
        0 0 10px rgba(212, 175, 55, 0.5),
        0 0 30px rgba(212, 175, 55, 0.3),
        0 0 50px rgba(212, 175, 55, 0.1);
    letter-spacing: 4px;
    font-style: italic;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    gap: 8px;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

.btn-primary {
    background: linear-gradient(135deg, #3a4352 0%, #2a303b 100%);
    border: 1px solid var(--border-color);
    color: var(--text-highlight);
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.btn-primary:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.btn-success {
    background: rgba(74, 168, 121, 0.15);
    border: 1px solid var(--accent-success);
    color: #6fcfa3;
}
.btn-success:hover:not(:disabled) { background: rgba(74, 168, 121, 0.25); }

.btn-danger {
    background: rgba(224, 93, 93, 0.15);
    border: 1px solid var(--accent-danger);
    color: #ff8f8f;
}
.btn-danger:hover:not(:disabled) { background: rgba(224, 93, 93, 0.25); }

.btn-small { padding: 6px 12px; font-size: 12px; border-radius: 4px; }
.btn-block { width: 100%; display: flex; margin-bottom: 12px; }

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
    padding: 4px;
    border-radius: 4px;
}
.btn-icon:hover { color: var(--accent-primary); background: rgba(255,255,255,0.05); }

/* ==================== Forms ==================== */
input, select, textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    transition: all 0.2s ease;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-secondary);
    background: rgba(0, 0, 0, 0.3);
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* 控制面板内的 label 使用标题字体，与 h3 统一 */
.control-section .form-group label {
    font-family: var(--font-heading);
}

/* ==================== Login Page ==================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at center, #1e232e 0%, #0b0c0f 100%);
}

.login-box {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
}

.login-box h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.avatar-item {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.avatar-item:hover { transform: scale(1.1); }
.avatar-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.error-message {
    color: var(--accent-danger);
    font-size: 13px;
    text-align: center;
    margin-top: 15px;
    min-height: 20px;
}

/* ==================== Lobby ==================== */
.lobby-container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; }

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.lobby-header h1 { font-size: 2.5rem; }

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-secondary);
    padding: 8px 20px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}
.user-info span#userAvatar { font-size: 1.5rem; }
.user-info span#userName { font-weight: 600; color: var(--text-highlight); }

.lobby-actions { margin-bottom: 30px; display: flex; gap: 15px; }

.room-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.room-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 25px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}
.room-card:hover {
    transform: translateY(-5px);
    border-color: var(--text-muted);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.room-status {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: absolute;
    top: 20px; right: 25px;
}
.room-card .status-waiting { color: var(--accent-success); }
.room-card .status-playing { color: var(--accent-primary); }
.room-card .status-paused { color: var(--accent-danger); }
.room-card .status-inactive { color: #6b7280; }

/* 不活跃房间样式 */
.room-card.room-inactive {
    opacity: 0.6;
    border-color: #3e4654;
}
.room-card.room-inactive:hover {
    opacity: 0.8;
    border-color: #4e5664;
}
.room-card.room-inactive h3 {
    color: var(--text-muted);
}

.room-card h3 { margin-bottom: 15px; font-size: 1.2rem; padding-right: 80px; }

.room-info { margin-bottom: 20px; flex-grow: 1; }
.room-info div {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.room-info div::before { content: '•'; color: var(--border-color); }

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    background: rgba(0,0,0,0.1);
}

/* ==================== Room Layout ==================== */
.room-container {
    display: flex;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

.player-sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.room-header-mini {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
}
.room-header-mini h2 {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-meta {
    font-size: 12px;
    color: var(--accent-primary);
    margin-top: 4px;
    font-family: var(--font-heading);
}

.player-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.player-sidebar h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 15px;
    padding-left: 5px;
}

.player-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.player-item.player-me {
    background: rgba(114, 137, 218, 0.1);
    border-color: rgba(114, 137, 218, 0.3);
}

.player-avatar {
    font-size: 1.4rem;
    margin-right: 12px;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

.player-info { flex: 1; overflow: hidden; }
.player-name { font-size: 13px; font-weight: 600; color: var(--text-highlight); }
.player-character {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

/* ==================== Chat Area ==================== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

.chat-messages {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
}

.message {
    display: flex;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.3s ease-out;
}

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

.message-avatar {
    width: 48px; height: 48px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.message.message-ai .message-avatar {
    border-color: var(--accent-primary);
    background: rgba(212, 175, 55, 0.1);
}

.message-content { flex: 1; min-width: 0; }

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
    flex-wrap: wrap;
}

.message-name {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 1rem;
}

.message-character {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.message-text {
    font-family: var(--font-reading);
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.8;
    white-space: pre-wrap;
}

.quoted-text {
    color: #e8c56c;
    font-weight: 400;
}

.message-ai .message-text { color: #e6e6fa; }
.message-ai .message-name {
    background: linear-gradient(90deg, var(--accent-primary), #fff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ==================== AI Message Controls ==================== */
.ai-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.ai-control-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-control-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}
.ai-control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.ai-control-btn svg { width: 14px; height: 14px; }

/* Version Navigation */
.version-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.version-nav button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 10px;
    transition: color 0.2s;
}
.version-nav button:hover:not(:disabled) { color: var(--accent-primary); }
.version-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
.version-nav span { min-width: 40px; text-align: center; }

/* ==================== Input Area ==================== */
.chat-input-area {
    padding: 20px 40px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.input-wrapper {
    flex: 1;
    position: relative;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}
.input-wrapper:focus-within { border-color: var(--accent-secondary); }

.input-wrapper textarea {
    background: transparent;
    border: none;
    box-shadow: none;
    resize: none;
    min-height: 50px;
    padding: 12px 16px;
    padding-right: 40px;
}
.input-wrapper textarea:focus { background: transparent; box-shadow: none; }

.visibility-icon {
    position: absolute;
    bottom: 10px; right: 10px;
    opacity: 0.5;
}
.visibility-icon:hover { opacity: 1; }

/* ==================== Control Panel ==================== */
.control-panel {
    width: 240px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    z-index: 10;
}

.control-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

/* Character Action Bar */
.character-action-bar {
    background: rgba(42, 48, 60, 0.9);
    margin: 20px;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    text-align: center;
    backdrop-filter: blur(5px);
}

.character-action-bar p {
    font-family: var(--font-heading);
}

.btn-create-character {
    background: linear-gradient(135deg, #3a4352 0%, #2a303b 100%);
    border: 1px solid var(--border-color);
    color: var(--text-highlight);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-create-character:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
}

/* ==================== Player Status Panel ==================== */
.player-status-panel {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 10px;
}

.player-status-panel h4 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 12px;
}
.status-row:last-child { border-bottom: none; }

.status-label { color: var(--text-muted); }
.status-value { color: var(--text-main); font-weight: 500; }

.status-value.status-healthy { color: var(--accent-success); }
.status-value.status-injured { color: #ffc107; }
.status-value.status-critical { color: var(--accent-danger); }

.status-value.mental-stable { color: var(--accent-success); }
.status-value.mental-stressed { color: #ffc107; }
.status-value.mental-unstable { color: var(--accent-danger); }

/* ==================== Player Status Badges ==================== */
.player-status-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    text-transform: uppercase;
    font-weight: 700;
}
.status-pending { background: rgba(255, 193, 7, 0.15); color: #ffc107; border: 1px solid rgba(255,193,7,0.3); }
.status-ready { background: rgba(76, 175, 80, 0.15); color: #4caf50; border: 1px solid rgba(76,175,80,0.3); }
.status-spectator { background: rgba(158, 158, 158, 0.15); color: #9e9e9e; border: 1px solid rgba(158,158,158,0.3); }

.btn-view-character {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 2px 6px;
    margin-left: 5px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
}
.btn-view-character:hover {
    border-color: var(--text-highlight);
    color: var(--text-highlight);
}

/* ==================== Modals ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.modal.show { display: flex !important; }

.modal-content, .character-modal {
    background: #1a202c;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    position: relative;
    display: flex;
    flex-direction: column;
}

.character-modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
}
.character-modal.show { display: flex; }

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h2 { font-size: 1.4rem; margin: 0; color: var(--text-highlight); }

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: 70vh;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    display: flex;
    gap: 15px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Character Display */
.character-display {
    background: #151921;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.character-display h3 {
    color: var(--accent-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.character-info-row {
    display: flex;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}
.character-info-label { color: var(--text-muted); width: 100px; font-weight: 600; }

.character-background {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    font-family: var(--font-reading);
    line-height: 1.7;
    color: var(--text-main);
    font-style: italic;
}

/* ==================== Tables Modal ==================== */
.tables-modal {
    max-width: 800px;
    max-height: 80vh;
}

.tables-modal .modal-body {
    overflow-y: auto;
}

.table-section {
    margin-bottom: 25px;
}
.table-section h4 {
    color: var(--accent-primary);
    margin-bottom: 10px;
    font-size: 14px;
}

.game-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.game-table th, .game-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.game-table th {
    background: rgba(0,0,0,0.3);
    color: var(--accent-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.game-table tr:hover { background: rgba(255,255,255,0.02); }
.game-table td { color: var(--text-main); }

/* Markdown 表格（消息内） */
.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 10px 0;
}

.md-table th,
.md-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.md-table th {
    background: rgba(0,0,0,0.3);
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 12px;
}

.md-table td {
    color: var(--text-main);
}

.md-table tr:hover td {
    background: rgba(255,255,255,0.02);
}
/* ==================== Confirm Dialog ==================== */
.confirm-dialog {
    max-width: 400px;
}
.confirm-dialog .modal-body {
    text-align: center;
    padding: 30px;
}
.confirm-dialog .modal-body p {
    color: var(--text-main);
    margin-bottom: 10px;
}
.confirm-dialog .modal-body .warning {
    color: var(--accent-danger);
    font-size: 13px;
}
.confirm-dialog .modal-footer {
    justify-content: center;
}

/* ==================== AI Thinking Animation ==================== */
.ai-thinking-bubble { opacity: 0.8; }
.thinking-dots span {
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    margin: 0 2px;
    animation: pulse 1.4s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { transform: scale(0.5); opacity: 0.5; }
    50% { transform: scale(1); opacity: 1; }
}

/* ==================== Message Text Formatting ==================== */
.story-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 25px 0;
    opacity: 0.6;
}

/* 场景标记 ***文字 （Claude常用格式）*/
.scene-marker {
    display: block;
    color: var(--accent-primary);
    font-weight: 600;
    margin: 20px 0 10px 0;
    padding-left: 12px;
    border-left: 3px solid var(--accent-primary);
    font-family: var(--font-heading);
}

/* 引用块 > 文字 */
.story-quote {
    display: block;
    margin: 12px 0;
    padding: 10px 16px;
    border-left: 3px solid var(--accent-secondary);
    background: rgba(114, 137, 218, 0.08);
    color: var(--text-main);
    font-style: italic;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* 一级标题 */
.message-text h1 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 1.4em;
    color: var(--text-highlight);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 8px;
}

/* 二级标题 */
.message-text h2 {
    margin-top: 22px;
    margin-bottom: 10px;
    font-size: 1.2em;
    color: var(--text-highlight);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.message-text h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: var(--text-highlight);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    display: inline-block;
}

.message-text em { font-style: italic; color: var(--text-muted); }

.list-item {
    padding-left: 20px;
    position: relative;
    margin-bottom: 6px;
    line-height: 1.5;
    color: var(--text-main);
}

.list-item.indent {
    margin-left: 20px;
}

.list-item:not(.number-item)::before {
    content: "•";
    position: absolute;
    left: 5px;
    color: var(--accent-primary);
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1;
    top: 2px;
}

.number-item { padding-left: 5px; }
.number-item .list-num { color: var(--accent-primary); font-weight: bold; }

/* ==================== Non-Owner Mode ==================== */
/* 桌面端非房主：隐藏控制面板 */
body.non-owner .control-panel { 
    display: none; 
}
body.non-owner .chat-area { 
    margin-right: 0; 
}

/* ==================== Desktop Settings Button (非房主专用) ==================== */
.desktop-settings-btn {
    display: none;  /* 默认隐藏，由 JS 控制 */
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.desktop-settings-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

/* 桌面端非房主抽屉样式 */
@media (min-width: 901px) {
    /* 桌面端：非房主的控制面板作为抽屉使用 */
    body.non-owner .control-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        z-index: 1002;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        display: flex !important;
        flex-direction: column;
    }
    
    body.non-owner .control-panel.desktop-drawer-open {
        transform: translateX(0);
    }
    
    /* 桌面端遮罩层默认不显示，抽屉打开时显示 */
    .drawer-overlay.show {
        display: block;
        opacity: 1;
    }
}

/* ==================== Mobile Header ==================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0 8px;
}

.mobile-menu-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.05);
}

.mobile-menu-btn:active {
    background: rgba(255,255,255,0.1);
}

.mobile-header-title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    pointer-events: none;
}

.mobile-header-title #mobileRoomName {
    font-family: var(--font-heading);
    font-size: 14px;
    color: var(--text-highlight);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-header-title .mobile-round {
    font-size: 11px;
    color: var(--accent-primary);
}

/* ==================== Drawer Overlay ==================== */
.drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-overlay.show {
    display: block;
    opacity: 1;
}

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
    /* 移动端隐藏桌面端设置按钮 */
    .desktop-settings-btn {
        display: none !important;
    }
    
    /* 显示移动端导航栏 */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    /* 主容器适配 */
    .room-container {
        flex-direction: column;
        padding-top: 56px;
    }
    
    /* 左侧抽屉 */
    .player-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1002;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding-top: 0;
    }
    
    .player-sidebar.drawer-open {
        transform: translateX(0);
    }
    
    /* 右侧抽屉 */
    .control-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1002;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        display: flex !important;
        flex-direction: column;
    }
    
    .control-panel.drawer-open {
        transform: translateX(0);
    }
    
    /* 非房主也要能看到抽屉（如果打开的话） */
    body.non-owner .control-panel {
        display: flex !important;
    }
    
    /* 聊天区域全宽 */
    .chat-area {
        margin: 0;
        height: calc(100vh - 56px);
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .chat-messages {
        flex: 1;
        padding: 15px;
        padding-bottom: 15px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chat-input-area {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
        z-index: 100;
    }
    
    /* 移动端消息优化 */
    .message {
        gap: 12px;
        max-width: 100%;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .message-name {
        font-size: 0.9rem;
    }
    
    .message-text {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    /* AI消息控制按钮适配 */
    .message-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .ai-controls {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    .lobby-header { flex-direction: column; gap: 20px; text-align: center; }
    .lobby-header h1 { font-size: 1.8rem; }
    .room-list { grid-template-columns: 1fr; }
    .login-box { padding: 25px; }
    
    /* 更小屏幕的抽屉宽度 */
    .player-sidebar,
    .control-panel {
        width: 260px;
    }
    
    .mobile-header-title #mobileRoomName {
        max-width: 140px;
        font-size: 13px;
    }
    
    /* 进一步优化消息 */
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 10px;
        padding-bottom: 10px;
    }
}