* {
    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%高度（减少三分之一） */
    position: relative;
    min-height: 0;
    max-height: 40vh; /* 限制最大高度，防止在小屏幕上占用过多空间 */
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    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: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    animation: pulse 1.5s infinite;
}

@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.moved {
    position: relative; /* 相对定位 - 移动到在线人数旁边 */
    top: 0;
    left: 0;
    transform: none;
    margin: 0;
    animation: moveToHeader 0.5s ease-out forwards; /* 添加移动动画 */
}

@keyframes moveToHeader {
    0% {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        z-index: 100; /* 确保在最顶层移动 */
    }
    100% {
        position: relative;
        top: 0;
        left: 0;
        transform: scale(1);
        opacity: 1;
    }
}

.volume-btn-container {
    display: inline-block;
}

.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%;
    }
    
    .chat-section {
        flex: 1;
    }
}

/* 响应式设计 */
@media (min-width: 768px) {
    .live-container {
        flex-direction: row;
    }
    
    .video-section {
        width: 70%;
        height: 100vh;
    }
    
    .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;
}
