/* CineSync v4 - Mobile First */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --primary: #e50914;
    --bg: #0a0a0a;
    --bg-card: #141414;
    --surface: #1f1f1f;
    --surface-hover: #2a2a2a;
    --text: #fff;
    --text-muted: #aaa;
    --text-dim: #555;
    --border: #2a2a2a;
    --success: #2ecc71;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    color: inherit;
    min-height: 44px;
    -webkit-appearance: none;
    background: var(--surface);
    border: 1px solid var(--border);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:active { transform: scale(0.96); opacity: 0.9; }

.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }

/* ===== INPUTS ===== */
.input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--text-dim); }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

/* ===== LANDING ===== */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 100px 20px 40px;
    background: radial-gradient(ellipse at top, rgba(229,9,20,0.1) 0%, transparent 60%);
}

.landing-logo { font-size: 40px; font-weight: 800; text-align: center; margin-bottom: 8px; }
.landing-subtitle { text-align: center; color: var(--text-muted); font-size: 15px; margin-bottom: 32px; max-width: 300px; }

.room-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 24px;
}

.room-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 20px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.room-card-icon { font-size: 40px; margin-bottom: 12px; }
.room-card h3 { font-size: 18px; margin-bottom: 6px; }
.room-card p { font-size: 13px; color: var(--text-dim); }

.join-box { width: 100%; max-width: 400px; }
.join-box h3 { font-size: 16px; margin-bottom: 12px; text-align: center; }
.join-inputs { display: flex; gap: 10px; }
.join-inputs .input { text-align: center; font-family: monospace; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.modal h2 { font-size: 22px; margin-bottom: 8px; }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.modal .input { margin-bottom: 16px; }
.modal .btn { width: 100%; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 10001;
    min-width: 280px;
    max-width: 90vw;
    transition: transform 0.3s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.toast-msg { font-size: 13px; color: var(--text-muted); }

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(10,10,10,0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
}
.header-logo { font-size: 22px; font-weight: 800; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 6px; }
.header-logo span { font-size: 26px; }
.header-actions { display: flex; gap: 8px; }

/* ===== ROOM BAR ===== */
.room-bar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 999;
    gap: 10px;
}
.room-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.room-code {
    background: var(--surface);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 13px;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
}
.room-code:active { border-color: var(--primary); }
.online-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.online-dot { width: 7px; height: 7px; background: var(--success); border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.room-actions { display: flex; gap: 8px; }

/* ===== MAIN LAYOUT ===== */
.main-layout { display: flex; flex-direction: column; padding-top: 108px; min-height: 100vh; }

/* ===== VIDEO ===== */
.video-section { background: #000; position: relative; aspect-ratio: 16/9; max-height: 55vh; }
.video-container { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; position: relative; }
.video-wrapper { width: 100%; height: 100%; position: relative; }
.video-wrapper iframe, .video-wrapper video { width: 100%; height: 100%; border: none; display: block; }
.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.9);
    z-index: 10;
    padding: 16px;
    overflow-y: auto;
}
.video-overlay.hidden { display: none !important; }
.start-screen { text-align: center; max-width: 100%; }
.start-screen h2 { font-size: 22px; margin-bottom: 8px; }
.start-screen p { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.source-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.source-tab {
    padding: 8px 14px;
    background: var(--surface);
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.source-tab.active { border-color: var(--primary); color: var(--primary); background: rgba(229,9,20,0.1); }
.input-group { display: flex; gap: 8px; margin-bottom: 12px; }
.input-group .input { flex: 1; }
.sample-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ===== CHAT ===== */
.chat-section { flex: 1; display: flex; flex-direction: column; background: var(--bg); min-height: 280px; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-card); }
.chat-header h3 { font-size: 15px; display: flex; align-items: center; gap: 6px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 180px; max-height: 35vh; }
.message { max-width: 85%; animation: msgIn 0.2s ease; }
@keyframes msgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.message-header { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.message-avatar { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.message-name { font-size: 12px; font-weight: 600; }
.message-time { font-size: 10px; color: var(--text-dim); }
.message-body { background: var(--surface); padding: 8px 12px; border-radius: 14px; border-top-left-radius: 4px; font-size: 14px; line-height: 1.5; word-wrap: break-word; }
.message.own { align-self: flex-end; }
.message.own .message-body { background: var(--primary); border-top-left-radius: 14px; border-top-right-radius: 4px; }
.message.own .message-name { color: var(--primary); }
.message.system { align-self: center; }
.message.system .message-body { background: transparent; color: var(--text-dim); font-size: 12px; text-align: center; padding: 4px; }

.chat-input-area { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; background: var(--bg-card); }
.chat-input { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 10px 16px; color: var(--text); font-size: 14px; outline: none; font-family: inherit; }
.chat-input:focus { border-color: var(--primary); }
.send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.send-btn:active { transform: scale(0.9); }
.emoji-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); border: none; color: var(--text); cursor: pointer; font-size: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.emoji-btn:active { transform: scale(0.9); }
.typing-indicator { display: none; padding: 6px 16px; font-size: 12px; color: var(--text-dim); font-style: italic; background: var(--bg-card); border-top: 1px solid var(--border); }
.typing-indicator.show { display: block; }

/* ===== CHEAT ===== */
.cheat-menu {
    position: absolute;
    top: 48px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 200;
    min-width: 180px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.cheat-menu.show { display: flex; }
.cheat-item { padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.cheat-item:active { background: var(--surface); }
.cheat-item .cheat-icon { font-size: 18px; }

.cheat-effect { position: fixed; inset: 0; pointer-events: none; z-index: 9999; display: none; overflow: hidden; opacity: 0.6; }
.cheat-effect.active { display: block; }
.heart-rain { position: absolute; font-size: 22px; animation: heartFall linear forwards; }
@keyframes heartFall { 0%{transform:translateY(-50px) rotate(0deg);opacity:0.8} 50%{opacity:0.6} 100%{transform:translateY(60vh) rotate(360deg);opacity:0} }

.cheat-popup {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translate(-50%, 0) scale(0);
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    z-index: 10000;
    width: 80%;
    max-width: 280px;
    transition: transform 0.3s cubic-bezier(0.68,-0.55,0.265,1.55);
    opacity: 0.9;
}
.cheat-popup.show { transform: translate(-50%, 0) scale(1); }
.cheat-popup .emoji-big { font-size: 36px; margin-bottom: 8px; display: block; animation: bounce 0.8s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.cheat-popup h3 { font-size: 22px; margin-bottom: 8px; color: var(--primary); }
.cheat-popup p { color: var(--text-muted); margin-bottom: 20px; font-size: 15px; }

.reaction-float { position: fixed; font-size: 36px; animation: floatUp 2.5s ease-out forwards; pointer-events: none; z-index: 9999; }
@keyframes floatUp { 0%{opacity:0.8;transform:translateY(0) scale(1)} 50%{opacity:0.6;transform:translateY(-60px) scale(1.2)} 100%{opacity:0;transform:translateY(-120px) scale(0.5)} }

/* ===== SURPRISE BTN ===== */
.surprise-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ff4757);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(229,9,20,0.4);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: heartbeat 2s infinite;
}
@keyframes heartbeat { 0%,100%{transform:scale(1)} 15%{transform:scale(1.12)} 30%{transform:scale(1)} 45%{transform:scale(1.08)} 60%{transform:scale(1)} }
.surprise-btn:active { transform: scale(0.92); animation: none; }

/* ===== PROGRESS ===== */
.progress-bar { height: 3px; background: var(--surface); }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }

/* ===== SYNC ===== */
.sync-indicator { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,0.7); padding: 6px 12px; border-radius: 20px; font-size: 11px; display: flex; align-items: center; gap: 6px; z-index: 5; backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.1); }
.sync-dot { width: 7px; height: 7px; background: var(--success); border-radius: 50%; }
.sync-dot.syncing { background: #f1c40f; animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ===== RAW GRID ===== */
.raw-section { padding: 16px; background: var(--bg); }
.raw-section h3 { font-size: 16px; margin-bottom: 12px; padding: 0 4px; }
.raw-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.raw-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.raw-card:active { border-color: var(--primary); }
.raw-card-thumb { width: 100%; aspect-ratio: 16/9; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 36px; position: relative; }
.raw-card-thumb::after { content: '▶'; position: absolute; font-size: 28px; color: var(--primary); opacity: 0; transition: var(--transition); background: rgba(0,0,0,0.5); width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.raw-card:active .raw-card-thumb::after { opacity: 1; }
.raw-card-info { padding: 12px; }
.raw-card-info h4 { font-size: 13px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raw-card-info p { font-size: 11px; color: var(--text-dim); }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .room-grid { grid-template-columns: repeat(2, 1fr); max-width: 600px; }
    .raw-grid { grid-template-columns: repeat(3, 1fr); }
    .main-layout { flex-direction: row; padding-top: 56px; }
    .video-section { flex: 1.5; max-height: none; height: calc(100vh - 56px); }
    .chat-section { width: 300px; height: calc(100vh - 56px); }
    .room-bar { top: 56px; }
}
@media (min-width: 1024px) {
    .chat-section { width: 380px; }
    .raw-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== SPINNER ===== */
.spinner { width: 36px; height: 36px; border: 3px solid var(--surface); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-hover); border-radius: 2px; }
