* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除点击高亮 */
    -webkit-touch-callout: none; /* 禁止长按弹出菜单 */
    -webkit-user-select: none; /* 禁止选中文本 */
    -webkit-text-size-adjust: 100%; /* 防止iOS Safari字体变化 */
}

html {
    height: 100%;
    overflow: hidden;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #000;
    color: #fff;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

.live-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    overflow: hidden; /* 防止内容溢出 */
    min-height: 400px; /* 设置最小高度 */
}

/* 视频播放区域（包含视频 + 回放控制条） */
.video-section {
    flex: 0 0 33.33%; /* 固定视频区域占33.33%高度（减少三分之一） */
    display: flex;
    flex-direction: column; /* video-wrapper 和 replay-bar 垂直排列 */
    position: relative;
    min-height: 0;
    max-height: 50vh; /* 稍微增加最大高度以容纳回放控制条 */
    overflow: hidden;
}

.video-wrapper {
    position: relative;
    width: 100%;
    flex: 1; /* 占据 video-section 的主要空间 */
    min-height: 0; /* 允许收缩以给 replay-bar 腾出空间 */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

.main-video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 改回contain以正确显示视频比例，不拉伸变形 */
    outline: none;
    background-color: #000; /* 确保视频背景为黑色 */
}

/* 隐藏视频默认控件 */
.main-video::-webkit-media-controls {
    display: none !important;
}

.live-indicator {
    position: absolute;
    top: 15px;
    left: 15px;
    background: linear-gradient(45deg, #ff4757, #ff3838);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    animation: pulse 1.5s infinite;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-indicator .current-time {
    font-size: 11px;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* 聊天区域 */
.chat-section {
    flex: 1; /* 使用flex: 1来自动填充剩余空间 */
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #333;
    position: relative;
    z-index: 10;
    /* 为老年人优化字体大小 */
    font-size: 16px;
    min-height: 0; /* 确保内部内容可以滚动 */
    overflow: hidden; /* 防止溢出 */
}

.chat-header {
    padding: 10px 15px;
    background-color: #2c2c2c;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: bold;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.online-count {
    font-size: 12px;
    color: #aaa;
}

.volume-btn {
    background: rgba(0, 0, 0, 0.7); /* 添加半透明黑色背景 */
    border: 2px solid #ffffff; /* 白色边框 */
    border-radius: 50%;
    width: 50px; /* 增大按钮 */
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 20px; /* 增大图标 */
    transition: all 0.3s ease;
    position: absolute; /* 绝对定位 - 默认在视频区域中心 */
    top: 50%; /* 垂直居中 */
    left: 50%; /* 水平居中 */
    transform: translate(-50%, -50%); /* 精确居中 */
    z-index: 25; /* 确保在其他元素之上 */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); /* 添加阴影 */
    backdrop-filter: blur(2px); /* 添加模糊效果 */
}

/* 当按钮移动到在线人数旁边时的样式 - 使用缩放+淡出淡入效果 */
.volume-btn.teleporting {
    animation: teleportEffect 0.5s ease-out forwards;
}

@keyframes teleportEffect {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(var(--target-x, -50%), var(--target-y, -50%)) scale(0.1);
        opacity: 0;
    }
    100% {
        transform: translate(var(--target-x, 0), var(--target-y, 0)) scale(1);
        opacity: 1;
    }
}

/* 移动后的按钮样式 */
.volume-btn.moved {
    position: relative; /* 相对定位 - 移动到在线人数旁边 */
    top: 0;
    left: 0;
    transform: none;
    margin: 0;
    /* 移动后不再有特殊动画 */
}

.volume-btn-container {
    display: inline-block;
}

/* 音量按钮 - 直接在聊天头部显示（内联模式） */
.volume-btn-inline {
    background: none;
    border: none;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #aaa;
    font-size: 16px;
    padding: 2px 6px;
    transition: all 0.3s ease;
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    margin: 0;
    line-height: 1;
}

.volume-btn-inline:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.volume-btn-inline.active {
    color: #3498db;
}

.volume-btn:hover {
    background: rgba(52, 152, 219, 0.9); /* 悬停时显示蓝色背景 */
    border-color: #3498db;
    transform: translate(-50%, -50%) scale(1.1); /* 悬停时稍微放大 */
}

.volume-btn.moved:hover {
    transform: scale(1.1); /* 移动后的按钮悬停效果 */
}

.volume-btn.active {
    background: rgba(52, 152, 219, 0.9);
    border-color: #3498db;
}

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    max-height: calc(100% - 60px); /* 使用百分比，相对于父容器 */
    min-height: 0; /* 确保可以收缩 */
}

.message-item {
    margin-bottom: 8px;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 16px; /* 为老年人增大字体 */
    line-height: 1.5;
}

.user-message {
    background-color: #3498db;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.bot-message {
    background-color: #2ecc71;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    color: #000;
    font-weight: bold;
}

.system-message {
    background-color: #9b59b6;
    align-self: center;
    text-align: center;
    font-size: 16px; /* 统一使用大字体 */
    color: white;
}

.message-user {
    font-weight: bold;
    margin-right: 5px;
    font-size: 16px; /* 统一使用大字体 */
}

.message-content {
    word-break: break-word;
}

.chat-input-area {
    padding: 10px 15px;
    display: flex;
    gap: 10px;
    background-color: #2c2c2c;
    border-top: 1px solid #333;
    flex-shrink: 0; /* 防止输入区域被压缩 */
    position: relative; /* 确保定位正确 */
    box-sizing: border-box; /* 确保padding不会增加总高度 */
    min-height: 60px; /* 设置最小高度 */
    max-height: 80px; /* 限制最大高度 */
    flex-wrap: wrap; /* 允许换行以防止溢出 */
    align-items: center; /* 垂直居中对齐 */
}

#messageInput {
    flex: 1;
    padding: 10px 15px; /* 减少内边距 */
    border: none;
    border-radius: 20px; /* 减少圆角 */
    background-color: #3a3a3a;
    color: white;
    font-size: 16px; /* 统一使用大字体 */
    outline: none;
    max-height: 40px; /* 限制输入框高度 */
    box-sizing: border-box; /* 确保padding不会增加总高度 */
    min-width: 100px; /* 设置最小宽度以确保可用性 */
    flex-grow: 1; /* 允许增长 */
}

.send-btn, .like-btn {
    padding: 8px 12px; /* 进一步减少按钮大小 */
    border: none;
    border-radius: 20px; /* 减少圆角 */
    background-color: #3498db;
    color: white;
    cursor: pointer;
    font-size: 16px; /* 统一使用大字体 */
    transition: background-color 0.3s;
    min-width: 60px; /* 进一步减少最小宽度 */
    max-height: 40px; /* 限制按钮高度 */
    box-sizing: border-box; /* 确保padding不会增加总高度 */
    flex-shrink: 0; /* 防止按钮被压缩 */
}

.like-btn {
    background-color: #e74c3c;
}

.send-btn:hover {
    background-color: #2980b9;
}

.like-btn:hover {
    background-color: #c0392b;
}

/* 横屏适配 */
@media screen and (orientation: landscape) {
    body, html {
        height: 100%;
        width: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }
    
    .live-container {
        flex-direction: column;
        height: 100vh;
        width: 100vw;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 999;
    }
    
    .video-section {
        position: fixed !important; /* 强制固定定位 */
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        z-index: 1000 !important; /* 确保在最顶层 */
        flex: none !important; /* 不受flex属性影响 */
    }
    
    .chat-section {
        display: none !important; /* 强制隐藏聊天区域 */
    }
    
    /* 确保视频元素也全屏 */
    .video-wrapper, .main-video, .cover-image-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        z-index: 998 !important;
    }
    
    /* 在横屏模式下，静音按钮在垂直左右中心 */
    .volume-btn {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 1001 !important; /* 确保在视频上方 */
    }
    
    /* 确保移动后的音量按钮也可见 */
    .volume-btn.moved {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 1001 !important;
    }
    
    /* 确保直播中标识在横屏时也可见 */
    .live-indicator {
        position: fixed !important;
        top: 20px !important;
        left: 20px !important;
        z-index: 1002 !important; /* 比按钮更高层级 */
    }
}

/* 竖屏适配 */
@media screen and (orientation: portrait) {
    .live-container {
        flex-direction: column;
    }
    
    .video-section {
        flex: 0 0 33.33%;
        display: flex;
        flex-direction: column; /* 保持 video-wrapper + replay-bar 垂直排列 */
    }
    
    .chat-section {
        flex: 1;
    }
}

/* 响应式设计 */
@media (min-width: 768px) {
    .live-container {
        flex-direction: row;
    }
    
    .video-section {
        width: 70%;
        height: 100vh;
        display: flex;
        flex-direction: column; /* 保持 video-wrapper + replay-bar 垂直排列 */
    }
    
    .chat-section {
        width: 30%;
        height: 100vh;
        position: fixed;
        right: 0;
        top: 0;
    }
}

/* 移动端适配：输入框聚焦时调整布局 */
@media screen and (max-height: 700px) {
    .chat-section {
        flex: 1; /* 继续使用flex: 1来自动填充 */
    }
    
    .message-list {
        flex: 1;
        max-height: calc(100% - 60px);
    }
}

@media screen and (max-height: 600px) {
    .chat-section {
        flex: 1; /* 继续使用flex: 1来自动填充 */
    }
    
    .message-list {
        flex: 1;
        max-height: calc(100% - 60px);
    }
    
    .chat-input-area {
        padding: 5px 10px;
        min-height: 50px;
        max-height: 60px;
    }
    
    #messageInput {
        padding: 8px 12px;
        font-size: 14px;
        max-height: 35px;
    }
    
    .send-btn, .like-btn {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 60px;
        max-height: 35px;
    }
}

/* 输入框聚焦时的样式调整 */
body.keyboard-open .chat-section {
    height: 50vh !important;
}

body.keyboard-open .message-list {
    flex: 1;
}

/* 滚动条样式 */
.message-list::-webkit-scrollbar {
    width: 6px;
}

.message-list::-webkit-scrollbar-track {
    background: #2c2c2c;
}

.message-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* 解除静音覆盖层 */
.unmute-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    backdrop-filter: blur(2px);
    gap: 20px;
}

.play-instructions {
    text-align: center;
    color: white;
}

.play-instructions p {
    margin: 10px 0;
    font-size: 18px;
    font-weight: bold;
}

#unmuteButton {
    padding: 15px 25px;
    font-size: 16px;
    background: linear-gradient(45deg, #3498db, #2ecc71);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

#unmuteButton:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

#unmuteButton:active {
    transform: scale(0.98);
}

/* 当视频播放器聚焦时的样式 */
.main-video:focus {
    outline: 2px solid #3498db;
}

.cover-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #000; /* 确保封面图背景为黑色 */
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ========== 回放功能样式（底部控制条） ========== */

/* 回放按钮 - 位于视频区域右下角（旧样式，保留兼容） */
.replay-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    color: #fff;
    font-size: 13px;
    padding: 5px 10px;
    cursor: pointer;
    z-index: 16;
    transition: all 0.25s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.replay-btn:hover,
.replay-btn:active {
    background: rgba(52, 152, 219, 0.8);
    border-color: #3498db;
}

.replay-btn.active {
    background: rgba(231, 76, 60, 0.8);
    border-color: #e74c3c;
}

/* 回放按钮 - 内联样式（位于 chat-header 的"直播间"标题后面） */
.replay-btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    padding: 2px 6px;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.2s ease;
    line-height: 1.2;
}

.replay-btn-inline:hover,
.replay-btn-inline:active {
    background: rgba(52, 152, 219, 0.7);
    border-color: #3498db;
}

.replay-btn-inline.active {
    background: rgba(231, 76, 60, 0.75);
    border-color: #e74c3c;
}

/* 克隆视频样式（用于回放模式） */
.replay-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    outline: none;
    background-color: #000;
    position: absolute;
    top: 0;
    left: 0;
}

/* ===== 回放控制条 - 在视频区域下方，完全独立 ===== */
.replay-bar {
    /* 作为 video-section 的 flex 子元素，在 video-wrapper 下方 */
    flex-shrink: 0; /* 不被压缩 */
    background: #1a1a1a;
    padding: 10px 15px;
    border-top: 1px solid #333;
    animation: replayBarSlideUp 0.3s ease;
    overflow: hidden;
}

/* 回放控制条显示时的样式 */
.replay-bar[style*="display: flex"],
.replay-bar[style*="display:block"] {
    display: block !important;
}

@keyframes replayBarSlideUp {
    from { 
        opacity: 0;
        max-height: 0;
        padding: 0 15px;
    }
    to { 
        opacity: 1;
        max-height: 80px;
        padding: 10px 15px;
    }
}

/* 控制条主体 */
.replay-bar-main {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 进度行：时间 + 进度条 + 时间 */
.replay-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.replay-time {
    color: #ddd;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    min-width: 38px;
    text-align: center;
    flex-shrink: 0;
}

.replay-max-time {
    color: #5bc0de;
}

/* 进度条包装器 */
.replay-progress-wrap {
    flex: 1;
}

/* 进度轨道 */
.replay-track {
    position: relative;
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 7px;
    cursor: pointer;
    /* 增大触摸区域 */
    padding: 4px 0;
}

/* 已缓冲/已播放部分 */
.replay-buffered {
    position: absolute;
    left: 0;
    top: 4px;
    height: 6px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 3px;
    width: 0%;
    pointer-events: none;
    transition: width 0.08s linear;
}

/* 拖拽滑块（圆点） */
.replay-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    left: 0%;
    transition: left 0.08s linear;
    pointer-events: none;
}

/* 按钮行 */
.replay-btn-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

/* 控制按钮统一样式 */
.rb-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    color: #eee;
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rb-btn:hover,
.rb-btn:active {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.4);
}

.rb-play-btn {
    background: rgba(46, 204, 113, 0.7) !important;
    border-color: rgba(46, 204, 113, 0.8) !important;
    font-size: 14px !important;
    padding: 5px 14px !important;
}

.rb-play-btn:hover,
.rb-play-btn:active {
    background: rgba(39, 174, 96, 0.9) !important;
}

.rb-live-btn {
    background: rgba(231, 76, 60, 0.7) !important;
    border-color: rgba(231, 76, 60, 0.8) !important;
}

.rb-live-btn:hover,
.rb-live-btn:active {
    background: rgba(192, 57, 43, 0.9) !important;
}

.rb-close-btn {
    background: none !important;
    border: none !important;
    font-size: 13px !important;
    padding: 4px 6px !important;
    color: #999;
}

.rb-close-btn:hover,
.rb-close-btn:active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1) !important;
}

/* 横屏模式适配 */
@media screen and (orientation: landscape) {
    .replay-btn {
        position: fixed !important;
        bottom: 15px !important;
        right: 15px !important;
        z-index: 1002 !important;
    }
    
    /* 横屏时隐藏回放控制条（因为chat-section已隐藏，控制条无处安放） */
    .replay-bar {
        display: none !important;
    }
}

/* ========== 微信环境提示遮罩层（强制全屏黑屏） ========== */
.wechat-tip-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;  /* 纯黑色背景，完全遮挡 */
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: wechatTipFadeIn 0.3s ease;
}

/* 右上角大箭头容器 */
.wechat-arrow-container {
    position: absolute;
    top: 30px;
    right: 20px;
    z-index: 10;
}

.wechat-big-arrow {
    font-size: 80px;
    color: #fff;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.8),
        0 4px 15px rgba(0, 0, 0, 0.5);
    animation: wechatArrowBounce 1.5s infinite;
    line-height: 1;
}

/* 提示内容区域（居中偏下） */
.wechat-tip-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 24px;
    padding: 35px 28px;
    max-width: 340px;
    width: 88%;
    text-align: center;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 40px;  /* 给右上角箭头留空间 */
}

/* 警告图标 */
.wechat-warning-icon {
    font-size: 56px;
    margin-bottom: 18px;
    animation: wechatWarningShake 2s infinite;
}

/* 标题 */
.wechat-tip-content h2 {
    color: #fff;
    font-size: 22px;
    margin-bottom: 25px;
    font-weight: bold;
    letter-spacing: 1px;
}

/* 步骤列表 */
.wechat-step-list {
    text-align: left;
    margin-bottom: 22px;
}

.wechat-step {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    line-height: 1.5;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-radius: 50%;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
}

.wechat-step strong {
    color: #ffd700;
    font-weight: bold;
}

/* 底部提示文字 */
.wechat-note {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== 动画效果 ===== */
@keyframes wechatTipFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes wechatArrowBounce {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate(-8px, -12px) rotate(-10deg) scale(1.05);
    }
    50% {
        transform: translate(-15px, -6px) rotate(-5deg) scale(1);
    }
    75% {
        transform: translate(-8px, -12px) rotate(-10deg) scale(1.05);
    }
}

@keyframes wechatWarningShake {
    0%, 80%, 100% {
        transform: rotate(0deg);
    }
    10%, 30% {
        transform: rotate(-8deg);
    }
    20%, 40% {
        transform: rotate(8deg);
    }
}
