* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #111111;
    --bg-secondary: #1f1f1f;
    --bg-tertiary: #2a2a2a;
    --bg-hover: #333333;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #777777;
    --accent: #e50914;
    --accent-hover: #f40612;
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* ========== Join Screen ========== */
#join-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
}

.join-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px var(--shadow);
    text-align: center;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.join-card h1 {
    font-size: 32px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
    margin-top: 0;
}

/* ========== Main Screen ========== */
#main-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-id {
    background: var(--bg-tertiary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-icon {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.user-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-count span {
    color: var(--accent);
    font-weight: 700;
}

/* ========== Main Content ========== */
.main-content {
    display: flex;
    flex: 1;
    gap: 0;
    padding: 0;
}

.video-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #000;
}

.video-container {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 300px;
}

#video-player {
    width: 100%;
    max-height: calc(100vh - 220px);
    display: block;
    background: #000;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.overlay-content {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
}

/* ========== Controls ========== */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.controls-left, .controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ctrl-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

#volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.time-display {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    margin-left: 8px;
}

/* ========== Progress Bar ========== */
.progress-container {
    padding: 0 16px 8px;
    background: var(--bg-secondary);
}

#progress-bar {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: height 0.2s;
}

#progress-bar:hover {
    height: 6px;
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(229, 9, 20, 0.5);
}

/* ========== Video URL Section ========== */
.video-url-section {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

#video-url-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

#video-url-input:focus {
    border-color: var(--accent);
}

/* ========== Sidebar ========== */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    height: calc(100vh - 56px);
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
}

.users-panel {
    flex: 0 0 auto;
    max-height: 200px;
    border-bottom: 1px solid var(--border);
}

.chat-panel {
    flex: 1;
    min-height: 0;
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* ========== Users List ========== */
.users-list {
    list-style: none;
    padding: 0 12px;
}

.users-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.users-list li:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Chat ========== */
.chat-messages {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    animation: fadeIn 0.3s ease;
    word-break: break-word;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message .msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.chat-message .msg-user {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.chat-message .msg-time {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-message .msg-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.chat-message.system-msg {
    background: transparent;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

#chat-input:focus {
    border-color: var(--accent);
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    box-shadow: 0 4px 20px var(--shadow);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
    max-width: 300px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .top-bar {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .logo {
        font-size: 16px;
    }

    .main-content {
        flex-direction: column;
    }

    .video-section {
        width: 100%;
    }

    #video-player {
        max-height: 40vh;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .users-panel {
        max-height: 120px;
    }

    .chat-panel {
        min-height: 200px;
    }

    .controls-bar {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .volume-control {
        display: none;
    }

    .time-display {
        font-size: 12px;
    }

    .video-url-section {
        flex-direction: column;
    }

    .join-card {
        padding: 32px 24px;
    }

    .join-card h1 {
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .ctrl-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .controls-left {
        gap: 4px;
    }
}

/* ========== 浮动聊天提示 ========== */
.floating-chat-container {
    position: absolute;
    bottom: 80px; /* 位于自定义控制栏上方 */
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none; /* 防止遮挡视频点击事件 */
    z-index: 10;
    max-width: 80%;
}

.floating-chat-msg {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    backdrop-filter: blur(6px);
    /* 动画：0.3s进入，停留9.7s，0.3s退出，总共10s */
    animation: floatIn 0.3s ease, floatOut 0.3s ease 9.7s forwards;
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
}

.floating-chat-msg .float-user {
    color: #ff4757;
    font-weight: 600;
    flex-shrink: 0;
}

.floating-chat-msg .float-text {
    color: #f1f2f6;
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floatOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
}

/* 移动端适配优化 */
@media (max-width: 768px) {
    .floating-chat-container {
        bottom: 60px;
        right: 12px;
        max-width: 85%;
    }

    .floating-chat-msg {
        font-size: 13px;
        padding: 6px 12px;
    }
}