/* ===== 绿洲市 - 虚拟沙盒游戏样式 ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8edf3;
    --bg-card: #ffffff;
    --accent: #5b8def;
    --accent-hover: #4a7de0;
    --blue: #5b8def;
    --green: #52c41a;
    --orange: #ff9500;
    --purple: #af52de;
    --gold: #f5a623;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #aeaeb2;
    --border: #e0e4ea;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
}

/* ── 滚动头条栏 ── */
.headline-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    display: flex; align-items: center; height: 32px;
    background: rgba(255,255,255,0.3);
    backdrop-filter: blur(4px);
    color: #333; font-size: 13px; padding: 0 12px;
    overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
body.has-headline .main-layout { padding-top: 32px; }
.headline-label {
    flex-shrink: 0; font-weight: bold; margin-right: 16px;
    color: #e67e22; white-space: nowrap;
}
.headline-scroll {
    flex: 1; overflow: hidden; white-space: nowrap;
}
.headline-scroll-inner {
    display: inline-block; animation: marquee 40s linear infinite;
    padding-left: 100%;
}
.headline-item {
    display: inline; margin-right: 60px; white-space: nowrap;
}
@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-80%); }
}
/* 夜间适配 */
[data-theme="dark"] .headline-bar {
    background: rgba(15,15,30,0.75);
    backdrop-filter: blur(4px);
    color: #ccc;
}

/* 夜间主题 */
[data-theme="dark"] {
    --bg-primary: #1a1c2e;
    --bg-secondary: #252740;
    --bg-tertiary: #1e2035;
    --bg-card: #252740;
    --accent: #7b9ff0;
    --accent-hover: #6b8fe0;
    --blue: #7b9ff0;
    --text-primary: #e0e0ec;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a80;
    --border: #353555;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* 背景装饰层 */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 确保所有主要内容在背景之上 */
.main-layout, .chat-bar, .modal-overlay {
    position: relative;
    z-index: 1;
}

input, textarea, .chat-messages, .msg-bubble {
    -webkit-user-select: text;
    user-select: text;
}

/* ===== 顶部栏 ===== */
.top-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.game-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-icon {
    font-size: 24px;
}

.game-title h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #5b8def, #34c759);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.time-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
}

.time-icon {
    font-size: 18px;
}

.speed-badge {
    font-size: 11px;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
}

.player-icon {
    font-size: 20px;
}

.player-role {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.header-controls {
    display: flex;
    gap: 6px;
}

/* ===== 主布局 ===== */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
    background: transparent;
}

/* ===== 地图面板 — v71 隐藏地图，保留后台NPC位置数据 ===== */
.map-panel {
    display: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255,255,255,0.2);
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.npc-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.map-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.map-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 10px;
    background: transparent;
}

.map-container::-webkit-scrollbar { width: 6px; }
.map-container::-webkit-scrollbar-track { background: var(--bg-primary); }
.map-container::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 3px; }

#cityMap {
    display: block;
    border-radius: var(--radius);
}

.map-zoom {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.map-zoom button {
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}
.map-zoom button:hover { background: var(--bg-tertiary); border-color: var(--accent); }

.map-legend {
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.4);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ===== 侧面板 ===== */
.side-panel {
    flex: 1;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.3);
    backdrop-filter: blur(4px);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.panel-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#npcListPanel, #residentListPanel {
    flex: 1 1 auto;
    border-bottom: 1px solid var(--border);
    min-height: 0;
    overflow: hidden;
}

#socialFeedPanel {
    flex: 0 0 auto;
    border-top: 2px solid var(--primary);
    background: rgba(255,255,255,0.98);
    display: flex;
    flex-direction: column;
    z-index: 5;
    position: relative;
    transition: all 0.2s ease;
}

/* 最小化状态：底部窄条 */
#socialFeedPanel.minimized {
    /* 自然高度=标题栏 */
}

/* 展开状态：覆盖整个侧面板 */
#socialFeedPanel:not(.minimized) {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-top: none;
    z-index: 10;
}

#socialFeedPanel .panel-header {
    cursor: pointer;
    padding: 5px 12px;
    font-size: 13px;
    background: linear-gradient(135deg, rgba(255,152,0,0.08), transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
}

#socialFeedPanel .panel-header:hover {
    background: linear-gradient(135deg, rgba(255,152,0,0.15), transparent);
}

.toggle-arrow {
    font-size: 10px;
    color: #999;
    transition: transform 0.2s ease;
}

#socialFeedPanel:not(.minimized) .toggle-arrow {
    transform: rotate(180deg);
}

/* 关闭按钮：始终显示 */
#socialCloseBtn {
    display: inline-block !important;
    cursor: pointer !important;
    font-size: 12px !important;
    color: #4a90d9 !important;
    padding: 2px 8px !important;
    border: 1px solid #4a90d9 !important;
    border-radius: 3px !important;
    background: rgba(74,144,217,0.05) !important;
    margin-left: 8px !important;
    flex-shrink: 0 !important;
}
#socialCloseBtn:hover {
    background: rgba(74,144,217,0.15) !important;
}

/* 社交动态内容区 */
#socialFeed {
    flex: 1;
    overflow-y: auto;
}

#eventPanel {
    flex: 1;
    min-height: 150px;
}

/* ===== 搜索框 ===== */
.search-box {
    padding: 8px 12px;
    flex-shrink: 0;
}

.search-box input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
    -webkit-user-select: text;
    user-select: text;
}

.search-box input:focus {
    border-color: var(--accent);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ===== NPC列表 ===== */
.npc-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
}

/* NPC分类折叠 */
.npc-category {}
.npc-cat-header {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 13px; font-weight: 600; color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin: 4px 0;
    transition: color var(--transition);
}
.npc-cat-header:hover { color: var(--primary); }
.npc-cat-arrow {
    display: inline-block; transition: transform 0.2s;
    font-size: 10px; width: 12px; text-align: center;
}
.npc-cat-header.collapsed .npc-cat-arrow { transform: rotate(-90deg); }
.npc-cat-count { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-left: auto; }
.npc-cat-body { overflow: hidden; transition: max-height 0.3s; }
.npc-cat-header.collapsed + .npc-cat-body { max-height: 0 !important; }
/* 置顶区（玩家+帕西法尔）——无折叠，始终可见 */
.npc-pinned { padding-bottom: 4px; border-bottom: 2px solid var(--border); margin-bottom: 6px; }

.npc-list::-webkit-scrollbar,
.event-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.npc-list::-webkit-scrollbar-thumb,
.event-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.npc-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    margin-bottom: 4px;
    background: transparent;
}

.npc-card:hover {
    background: rgba(255,255,255,0.5);
    border-color: var(--accent);
}

.npc-card.selected {
    background: rgba(91,141,239,0.15);
    border-color: var(--accent);
}

.npc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
    transition: transform 0.15s ease;
}
.npc-avatar:hover {
    transform: scale(2.2);
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* 未读消息红点 */
.unread-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff3b30;
    border: 2px solid #fff;
    z-index: 2;
    animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}
.unread-badge {
    display: inline-block;
    background: #ff3b30;
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}
.has-unread {
    background: rgba(255,59,48,0.06);
    border-left: 3px solid #ff3b30;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.npc-avatar .status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.status-dot.busy { background: var(--accent); }
.status-dot.free { background: var(--green); }
.status-dot.sleeping { background: var(--text-muted); }

.npc-info {
    flex: 1;
    min-width: 0;
}

.npc-name {
    font-size: 14px;
    font-weight: 600;
}

.npc-role-tag {
    font-size: 11px;
    color: var(--text-muted);
}

.npc-activity {
    font-size: 11px;
    color: var(--blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.npc-relation {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

.rel-good { background: rgba(129, 199, 132, 0.2); color: var(--green); }
.rel-neutral { background: rgba(79, 195, 247, 0.2); color: var(--blue); }
.rel-bad { background: rgba(233, 69, 96, 0.2); color: var(--accent); }

/* ===== 事件日志 ===== */
.event-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.event-item {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    border-left: 2px solid var(--border);
    margin-bottom: 4px;
    padding-left: 10px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.event-item.system { border-left-color: var(--gold); }
.event-item.thought { border-left-color: var(--blue); color: var(--text-primary); }
.event-item.interaction { border-left-color: var(--purple); }
.event-item.player { border-left-color: var(--accent); }

.event-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-right: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== 底部聊天栏 ===== */
.chat-bar {
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    transition: height 0.3s ease;
    height: 50px;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.chat-bar.expanded {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 56px;
    height: auto;
    overflow: visible;
    z-index: 400;
}

/* 手机端聊天栏改为底部弹层 */
@media (max-width: 768px) {
    .chat-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 500;
        border-radius: 16px 16px 0 0;
    }
    .chat-bar.expanded {
        height: 85vh;
        top: auto;
        display: flex;
        flex-direction: column;
    }
    .chat-messages {
        max-height: none;
        flex: 1;
    }
    .chat-input-area {
        flex-shrink: 0;
    }
    .chat-input-area input {
        font-size: 16px;
        padding: 12px;
    }
    .chat-input-area button#btnSend {
        padding: 12px;
        font-size: 16px;
    }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    cursor: pointer;
    background: transparent;
    height: 50px;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header:hover {
    background: var(--bg-tertiary);
}

.chat-target {
    font-size: 14px;
    color: var(--text-secondary);
}

.chat-target.active {
    color: var(--text-primary);
    font-weight: 600;
}

.msg-badge {
    background: #ff4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 8px;
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.btn-close-chat {
    opacity: 0;
    transition: opacity var(--transition);
}

.chat-bar.expanded .btn-close-chat {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 聊天消息气泡 */
.msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 85%;
}
.msg.player {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.msg.npc {
    align-self: flex-start;
}
.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    font-size: 14px;
    overflow: hidden;
}
.msg-bubble {
    padding: 8px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.msg.player .msg-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg.npc .msg-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* 系统消息（NPC不在时提示） */
.system-msg {
    text-align: center;
    padding: 10px 0;
}
/* 玩家行为动作消息 - 右对齐 */
.system-msg.action-player {
    align-self: flex-end;
    text-align: right;
    padding: 6px 0;
}
.system-text {
    display: inline-block;
    padding: 6px 16px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 80%;
}

/* NPC主动向玩家打招呼 */
.greeting-msg {
    text-align: center;
    margin: 16px 0 8px 0;
}
.greeting-banner {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(79, 195, 247, 0.12);
    color: #0288d1;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}
.greeting-msg .msg-bubble {
    display: inline-block;
    text-align: left;
    margin: 0 auto;
}

.chat-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.chat-placeholder span {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* 聊天时间分隔线 */
.msg-time-header {
    text-align: center;
    color: #999;
    font-size: 11px;
    padding: 8px 0 4px;
    letter-spacing: 0.5px;
}

/* 单条消息时间 */
.msg-time {
    font-size: 9px;
    color: #aaa;
    text-align: right;
    margin-top: 2px;
    letter-spacing: 0.3px;
}

.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease;
}

.chat-msg.player {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-msg.npc {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-msg .sender {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
}

/* 打字指示器 */
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
    width: 6px; height: 6px; background: #888; border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* TTS 语音播放按钮 */
.btn-tts-play {
    float: right;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
    line-height: 1;
}
.btn-tts-play:hover {
    opacity: 1;
    background: rgba(79, 195, 247, 0.15);
}

/* ── 微信式语音消息气泡 ── */
.voice-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--bubble-npc, #e8f0fe);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    min-width: 60px;
    transition: background 0.15s;
}
.voice-bubble:hover { background: #d0e2fc; }
.voice-bubble .voice-icon {
    font-size: 18px;
    line-height: 1;
    color: #555;
    flex-shrink: 0;
}
.voice-bubble .voice-wave {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 28px;
    flex: 1;
    min-width: 40px;
}
.voice-bubble .voice-wave span {
    display: block;
    width: 3px;
    background: #666;
    border-radius: 2px;
    height: 8px;
    transition: height 0.1s;
}
.voice-bubble .voice-wave span:nth-child(1) { height: 12px; }
.voice-bubble .voice-wave span:nth-child(2) { height: 20px; }
.voice-bubble .voice-wave span:nth-child(3) { height: 14px; }
.voice-bubble .voice-wave span:nth-child(4) { height: 24px; }
.voice-bubble .voice-wave span:nth-child(5) { height: 8px; }
.voice-bubble .voice-dur {
    font-size: 12px;
    color: #888;
    flex-shrink: 0;
    min-width: 24px;
    text-align: right;
}
.voice-bubble.playing .voice-wave span {
    animation: voiceAnim 0.6s ease-in-out infinite alternate;
}
@keyframes voiceAnim {
    0% { transform: scaleY(0.4); }
    100% { transform: scaleY(1.0); }
}
.voice-bubble.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ── 语音转文字（类似微信）── */
.voice-to-text-link {
    display: inline-block;
    font-size: 11px;
    color: #576b95;
    cursor: pointer;
    padding: 2px 4px;
    margin-top: 1px;
    user-select: none;
}
.voice-to-text-link:hover { color: #3a5a8c; }
.voice-to-text-link.active { color: #999; }
/* ── 语音未读红点 ── */
.voice-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #f44;
    border-radius: 50%;
    margin: 0 0 0 6px;
    vertical-align: middle;
    flex-shrink: 0;
}
.voice-unread-dot.read { display: none; }
.voice-text-content {
    display: none;
    padding: 8px 12px;
    margin-top: 2px;
    background: #f0f0f0;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    word-break: break-word;
}
.voice-text-content.show { display: block; }

/* ── 微信式红包气泡 ── */
.red-envelope-msg { margin: 8px 0; }
.red-envelope-msg.sent { display: flex; justify-content: flex-end; }
.red-bubble {
    display: inline-flex; align-items: center; gap: 10px;
    background: linear-gradient(135deg, #fa9d3b, #f56c2d);
    border-radius: 8px; padding: 10px 14px;
    cursor: default; max-width: 240px;
    box-shadow: 0 2px 6px rgba(245,108,45,0.3);
}
.red-bubble.claimed {
    background: linear-gradient(135deg, #ccc, #aaa);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.red-bubble.refunded {
    background: linear-gradient(135deg, #e0e0e0, #bbb);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.red-icon { font-size: 28px; flex-shrink: 0; }
.red-info { color: #fff; min-width: 0; }
.red-title { font-size: 15px; font-weight: 700; }
.red-sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.red-status { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.red-bubble.claimed .red-info { color: #888; }
.red-bubble.claimed .red-icon { opacity: 0.5; }
.red-bubble.refunded .red-info { color: #999; }
.red-bubble.refunded .red-icon { opacity: 0.4; }
/* NPC发来的红包（暖橙色，区别于玩家发的红色） */
.red-envelope-msg.npc-sent .red-bubble {
    background: linear-gradient(135deg, #ff9800, #ff7400);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}
.npc-red-bubble { cursor: pointer; transition: transform 0.15s; }
.npc-red-bubble:hover { transform: scale(1.03); }
.npc-red-bubble.claimed { cursor: default; opacity: 0.7; }
.npc-red-bubble.claimed:hover { transform: none; }

.chat-input-area input {
    flex: none;
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.chat-input-area input:focus {
    border-color: var(--accent);
}

.chat-input-area input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-input-area button#btnSend {
    width: 100%;
    padding: 10px;
    font-size: 15px;
}

/* STT 录音状态（复用btnSend） */
#btnSend.recording {
    background: #ff4757;
    border-color: #ff4757;
    color: white;
    animation: sttPulse 0.8s infinite;
    box-shadow: 0 0 12px rgba(255,71,87,0.5);
}
@keyframes sttPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,71,87,0.3); }
    50% { box-shadow: 0 0 20px rgba(255,71,87,0.6); }
}
/* 语音实时预览 */
.stt-preview {
    padding: 6px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    min-height: 20px;
}

/* ===== 按钮 ===== */
button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all var(--transition);
}

.btn-icon {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-small {
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.btn-small:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-primary {
    background: var(--accent);
    color: white;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

#btnSend {
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

#btnSend:hover {
    background: var(--accent-hover);
}

#btnSend:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ===== 模态弹窗 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 30px;
    max-width: 500px;
    pointer-events: auto;
    position: relative;
    z-index: 1001;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 16px;
}

.help-content {
    text-align: left;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.help-content ul {
    padding-left: 20px;
    margin: 12px 0;
}

.help-content li {
    margin-bottom: 6px;
}

.help-content em {
    color: var(--blue);
}

.modal-content .btn-primary {
    margin-top: 20px;
}

.modal-content input {
    pointer-events: auto;
    -webkit-user-select: auto;
    user-select: auto;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }

    /* 移动端默认隐藏地图，显示居民列表 */
    .map-panel {
        display: none;
        flex: none;
    }
    .map-panel.mobile-show {
        display: flex;
        flex: 1;
        min-height: 0;
    }

    .side-panel {
        width: 100%;
        max-height: none;
        flex: 1;
        overflow-y: auto;
    }
    .side-panel.mobile-hide {
        display: none;
    }

    .map-zoom {
        bottom: 10px;
        right: 10px;
    }
    .map-zoom button {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* 显示切换按钮 */
    .mobile-only {
        display: inline-block !important;
    }

    /* 移动端居民列表更大 */
    .npc-card {
        padding: 12px;
    }
    .npc-avatar {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .npc-name {
        font-size: 15px;
    }
    .npc-role {
        font-size: 12px;
    }

    /* 移动端搜索框更大 */
    .search-box input {
        font-size: 16px;
        padding: 10px 14px;
    }

    /* 聊天栏 — 85vh留出顶部空间 */
    .chat-bar.expanded {
        height: 85vh;
    }
    .chat-messages {
        max-height: none;
    }
    .chat-input-area input {
        font-size: 16px;
    }
}

/* 玩家列表 */
.player-list {
    padding: 4px 8px;
    overflow-y: auto;
}

.player-item {
    border-radius: 4px;
    transition: background var(--transition);
}

.player-item:hover {
    background: var(--bg-tertiary);
}

/* 登录弹窗 */
#loginModal input {
    outline: none;
    transition: border-color var(--transition);
}

#loginModal input:focus {
    border-color: var(--accent);
}

/* ── 打赏系统 ── */
.btn-tip {
    background: transparent;
    color: #e67e22;
    font-size: 18px;
    cursor: pointer;
    padding: 0 8px;
    transition: transform 0.2s;
}
.btn-tip:hover {
    transform: scale(1.2);
}
/* 发红包按钮——统一红色渐变风格 */
#btnPlayerRed, #btnTip {
    background: linear-gradient(135deg, #f5a623, #e67e22);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    width: auto;
    height: auto;
    min-width: 44px;
    line-height: 1.6;
}
.tip-amount-btn {
    background: linear-gradient(135deg, #f5a623, #e67e22);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.tip-amount-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.4);
}
.btn-cancel {
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
}

/* ── 背包系统 ── */
.bp-tab {
    background: #e8eaf6;
    color: #5c6bc0;
    border: 2px solid transparent;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.bp-tab.active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    font-weight: 600;
}
.bp-tab:hover:not(.active) {
    background: #c5cae9;
}
.bp-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
/* ── 行为动作通知 ── */
.action-notification .msg-bubble {
    background: linear-gradient(135deg, rgba(76,175,80,0.1), rgba(139,195,74,0.1));
    border-left: 3px solid #4caf50;
    color: #666;
    font-style: italic;
    font-size: 13px;
    animation: fadeInUp 0.5s ease;
}
/* ── v70 NPC行为描述（靠左，旁白灰底）── */
.npc-action {
    align-self: flex-start;
    padding: 2px 0;
    margin-left: 36px;
}
.npc-action .npc-action-bubble {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-muted);
    max-width: 85%;
    line-height: 1.5;
    word-break: break-word;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
#backpackModal .modal-content {
    padding: 16px 20px;
}
#tipCustomAmount {
    outline: none;
    font-size: 14px;
}
#tipCustomAmount:focus {
    border-color: #e67e22;
}
.npc-money {
    font-size: 11px;
    color: #e67e22;
    font-weight: 600;
}

/* ── 玩家钱包 ── */
.player-wallet {
    flex-shrink: 0; display: flex; align-items: center;
    gap: 6px; margin-left: auto;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px; padding: 2px 10px;
}
.wallet-balance {
    color: #ffd700; font-weight: 700; font-size: 13px;
}
.wallet-coin {
    color: rgba(255, 215, 0, 0.7); font-size: 11px;
}
.btn-signin {
    background: linear-gradient(135deg, #ffd700, #f0a500);
    color: #1a1a2e; border: none;
    padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 700; cursor: pointer;
    transition: all 0.2s; white-space: nowrap;
}
.btn-signin:hover { transform: scale(1.05); }
.btn-signin:disabled {
    background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.4); cursor: default; transform: none;
}

/* 合规底部栏 */
.compliance-footer {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid #e8e8e8;
    display: flex; align-items: center; justify-content: center; gap: 16px;
    padding: 6px 12px; z-index: 1000; font-size: 11px;
}
.footer-text { color: #999; }
.footer-link { color: #667eea; text-decoration: none; cursor: pointer; }
.footer-link:hover { text-decoration: underline; }
/* 底部栏时chatBar留出空间 */
.chat-bar.expanded { padding-bottom: 36px; }

/* 弹窗通用 */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: #fff; border-radius: 12px; padding: 24px;
    max-width: 90vw; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15); text-align: center;
}
.modal-content h4 { margin: 12px 0 6px; font-size: 14px; color: #1a237e; }
.btn-cancel {
    padding: 10px 20px; border: none; border-radius: 8px;
    font-size: 14px; cursor: pointer;
}


/* v83.5: self模式玩家行为靠右 — 蓝色气泡 */
.msg.self-action {
    margin-left: auto !important;
    margin-right: 12px;
    max-width: 75%;
}
.msg.self-action .system-text {
    display: inline-block;
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff;
    padding: 8px 14px;
    border-radius: 14px 4px 14px 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
