:root {
    --bg: #0b1020;
    --surface: #141b2f;
    --surface-2: #1b2440;
    --text: #eef2ff;
    --muted: #9aa6c2;
    --primary: #4f7cff;
    --primary-hover: #3d68e8;
    --danger: #ef4444;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1a2450 0%, var(--bg) 45%);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 20px 80px;
}

.hero {
    margin-bottom: 28px;
}

.eyebrow {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1, h2 {
    margin: 0 0 12px;
}

.subtitle {
    color: var(--muted);
    margin: 0;
}

.card {
    background: rgba(20, 27, 47, 0.92);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

label {
    display: block;
    margin-bottom: 16px;
    font-size: 0.95rem;
    color: var(--muted);
}

input {
    width: 100%;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
}

select {
    width: 100%;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-hover);
}

.btn.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.copy-row {
    display: flex;
    gap: 10px;
}

.copy-row input {
    flex: 1;
}

.error {
    color: #fca5a5;
    margin-top: 12px;
}

.hidden {
    display: none !important;
}

.room-page {
    min-height: 100vh;
}

.lobby {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.lobby-card {
    width: min(520px, 100%);
    background: rgba(20, 27, 47, 0.95);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
}

#preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 14px;
    object-fit: cover;
    margin: 16px 0;
}

.lobby-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.call {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 16, 32, 0.85);
}

.participants {
    color: var(--muted);
}

.call-body {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    padding: 24px;
}

.participant-panel {
    background: rgba(20, 27, 47, 0.92);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    height: fit-content;
}

.participant-panel h3 {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.participant-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.participant-item:last-child {
    border-bottom: none;
}

.participant-item.self .participant-name {
    color: var(--primary);
}

.participant-name {
    flex: 1;
    font-size: 0.92rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
}

.status-dot.online {
    background: #22c55e;
}

.status-dot.offline {
    background: #f59e0b;
}

.badge {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(79, 124, 255, 0.18);
    color: #b9c9ff;
}

.lobby-panel {
    margin-bottom: 16px;
}

.reconnect-banner {
    background: rgba(79, 124, 255, 0.12);
    border: 1px solid rgba(79, 124, 255, 0.35);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.connection-status {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 4px 0 0;
}

.connection-status.connected {
    color: #86efac;
}

.connection-status.disconnected {
    color: #fca5a5;
}

@media (max-width: 900px) {
    .call-body {
        grid-template-columns: 1fr;
    }

    .participant-panel {
        order: 2;
    }
}

.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 900px) {
    .video-grid {
        grid-template-columns: 3fr 1fr;
        align-items: stretch;
    }
}

.remote-videos {
    display: grid;
    gap: 12px;
    min-height: 280px;
    grid-template-columns: 1fr;
    align-content: start;
}

.remote-videos.count-2 {
    grid-template-columns: repeat(2, 1fr);
}

.remote-videos.count-3,
.remote-videos.count-4 {
    grid-template-columns: repeat(2, 1fr);
}

.remote-videos.count-5,
.remote-videos.count-6 {
    grid-template-columns: repeat(3, 1fr);
}

.remote-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    margin: 0;
    padding: 24px;
    border-radius: 18px;
    border: 1px dashed var(--border);
    color: var(--muted);
    text-align: center;
    grid-column: 1 / -1;
}

.remote-empty.hidden {
    display: none;
}

.remote-videos .video-tile {
    min-height: 200px;
    aspect-ratio: 16 / 10;
}

.video-grid .video-tile.local {
    min-height: 200px;
}

@media (max-width: 899px) {
    .remote-videos.count-5,
    .remote-videos.count-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.video-tile {
    position: relative;
    background: #000;
    border-radius: 18px;
    overflow: hidden;
    min-height: 280px;
    border: 1px solid var(--border);
}

.video-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.video-label {
    position: absolute;
    left: 14px;
    bottom: 14px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 0.85rem;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border);
    background: rgba(11, 16, 32, 0.9);
}

.control-btn {
    min-width: 110px;
    padding: 12px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}

.control-btn.danger {
    background: var(--danger);
    border-color: var(--danger);
}
