* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }
body, html {
    height: 100%; width: 100%;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #000; color: #e0e0e0;
    overflow: hidden; position: fixed;
}

/* LOGIN SCREEN */
.auth-container {
    height: 100%; width: 100%;
    display: flex; justify-content: center; align-items: center;
    background: linear-gradient(135deg, #1e1e1e 0%, #121212 100%);
    padding: 20px; position: absolute; top: 0; left: 0; z-index: 100;
}
.auth-box { background: #1e1e1e; padding: 30px; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); width: 100%; max-width: 450px; text-align: center; }
.auth-box h1 { margin-bottom: 25px; color: #fff; font-size: 24px; }
.input-group { text-align: left; margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #aaa; }
.auth-box input { width: 100%; padding: 12px; background: #2c2c2c; border: 1px solid #333; border-radius: 6px; color: #fff; font-size: 16px; }
.auth-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.action-block { border: 1px solid #333; padding: 15px; border-radius: 8px; background: #181818; }
.action-block h3 { font-size: 15px; margin-bottom: 8px; color: #aaa; }
.action-block input { margin-bottom: 8px; padding: 10px; font-size: 14px; }
.divider { color: #555; margin: 2px 0; font-weight: bold; font-size: 12px; }
button { padding: 12px 20px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: 0.2s; font-size: 14px; }
.btn-create { background-color: #2e7d32; color: white; width: 100%; }
.btn-create:hover { background-color: #388e3c; }
.btn-join { background-color: #1976d2; color: white; width: 100%; }
.btn-join:hover { background-color: #1e88e5; }

/* MAIN LAYOUT */
.main-room-container { height: 100%; width: 100%; display: flex; flex-direction: column; position: relative; }

/* AREA VIDEO */
.video-section {
    width: 100%; background-color: #000; position: relative;
    padding-top: 56.25%; flex-shrink: 0; z-index: 10;
}
.video-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
video { width: 100%; height: 100%; display: block; object-fit: contain; }

/* AREA KONTEN */
.content-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; background-color: #121212; position: relative; }

/* Info Bar (DIPERBAIKI) */
.room-info-bar { padding: 10px 15px; border-bottom: 1px solid #2c2c2c; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-shrink: 0; }
.info-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.info-text h2 { font-size: 15px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #aaa; }
.truncate-id { display: inline-block; max-width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; font-family: monospace; }
.online-status { color: #4caf50; font-weight: bold; white-space: nowrap; }
.global-controls { display: flex; gap: 5px; flex-shrink: 0; }
.global-controls button { padding: 6px 10px; font-size: 12px; border-radius: 4px; white-space: nowrap; }
#fullscreen-btn { background-color: #444; color: white; }
.btn-leave { background-color: #c62828; color: white; }

/* TOMBOL COPY */
.btn-copy { background: #333; color: #fff; border: 1px solid #555; border-radius: 4px; padding: 3px 6px; font-size: 11px; cursor: pointer; transition: 0.2s; white-space: nowrap; flex-shrink: 0; }
.btn-copy:hover { background: #444; }
.btn-copy:active { background: #555; }

.host-controls-panel { padding: 8px 15px; background-color: #181818; border-bottom: 1px solid #2c2c2c; display: flex; gap: 8px; flex-shrink: 0; }
.host-controls-panel input { flex: 1; padding: 8px; background: #2c2c2c; border: 1px solid #333; border-radius: 4px; color: #fff; font-size: 14px; }
.host-controls-panel button { background-color: #f57c00; color: white; padding: 8px 12px; font-size: 12px; }

/* AREA CHAT */
.chat-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 150px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.chat-input-bar { padding: 8px 10px; border-top: 1px solid #2c2c2c; display: flex; gap: 8px; background-color: #121212; padding-bottom: calc(8px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.chat-input-bar input { flex: 1; padding: 10px 15px; background: #2c2c2c; border: 1px solid #333; border-radius: 20px; color: #fff; font-size: 16px; }
.chat-input-bar button { background-color: #1976d2; color: white; border-radius: 20px; padding: 0 15px; }

.chat-msg { font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.chat-msg .user { font-weight: bold; color: #90caf9; margin-right: 4px; }
.sys-msg { font-size: 11px; color: #777; font-style: italic; text-align: center; margin: 2px 0; }

/* FULLSCREEN & DANMAKU OVERLAY */
.danmaku-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 5; display: none; }
.danmaku-container.active { display: block; }
.danmaku-msg { position: absolute; white-space: nowrap; color: white; font-size: 20px; font-weight: bold; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; animation: danmaku linear; will-change: transform; }
@keyframes danmaku { from { transform: translateX(100vw); } to { transform: translateX(-100%); } }

/* FULLSCREEN UI CONTROLS */
.fs-controls-overlay {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 15px; padding-bottom: calc(15px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%); z-index: 15;
    display: flex; flex-direction: column; gap: 10px; pointer-events: none;
    transition: opacity 0.3s ease; opacity: 1;
}
.fs-controls-overlay.fade-out { opacity: 0; pointer-events: none !important; }
.fs-controls-overlay * { pointer-events: auto; }

.fs-buttons-group { display: flex; gap: 10px; align-self: flex-end; }
.fs-btn { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.4); border-radius: 4px; padding: 6px 12px; font-size: 12px; }
.fs-btn:active { background: rgba(255,255,255,0.4); }

.fs-chat-input-bar { width: 100%; display: flex; gap: 8px; transition: opacity 0.3s; }
.fs-chat-input-bar.hidden { opacity: 0; pointer-events: none; height: 0; overflow: hidden; margin: 0; }
.fs-chat-input-bar input { flex: 1; padding: 10px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; color: #fff; font-size: 14px; }
.fs-chat-input-bar button { background-color: #1976d2; color: white; border-radius: 4px; padding: 0 15px; font-size: 12px; }

/* DESKTOP LAYOUT */
@media (min-width: 768px) {
    .main-room-container { flex-direction: row; }
    .video-section { flex: 1; padding-top: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
    .video-wrapper { position: relative; width: 100%; height: auto; max-height: 100%; aspect-ratio: 16/9; }
    .content-section { width: 320px; border-left: 1px solid #2c2c2c; flex: none; }
    .info-text h2 { font-size: 18px; }
}
