:root {
    --bg-dark: #000000;
    --bg-panel: #111111;
    --fg-main: #ffffff;
    --fg-muted: #888888;
    --border-color: #333333;
    --primary: #ffffff;
    --primary-text: #000000;
    --danger: #ff4d4f;
    /* Keep slight color for danger but muted */
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--fg-main);
    font-family: var(--font-family);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Join Screen */
#join-screen {
    display: none;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#join-screen.active {
    display: flex;
}

.glass-panel {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.glass-panel h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--fg-main);
    letter-spacing: -0.05rem;
}

.glass-panel p {
    color: var(--fg-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--bg-dark);
    border-radius: var(--radius);
    padding: 0.5rem 0.8rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.input-group:focus-within {
    border-color: var(--fg-muted);
}

.input-group label {
    font-size: 0.75rem;
    color: var(--fg-muted);
    margin-right: 1rem;
    white-space: nowrap;
    text-transform: uppercase;
    font-weight: 600;
}

.input-group input {
    background: transparent;
    border: none;
    color: var(--fg-main);
    font-family: var(--font-family);
    font-size: 0.95rem;
    flex: 1;
    outline: none;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
    color: var(--fg-main);
    background: #222;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

button {
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.15s ease;
}

button:active {
    transform: translateY(1px);
}

/* Vercel Style Primary Button: White BG, Black Text */
.primary-btn {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}

.primary-btn:hover {
    background: #e6e6e6;
    /* Slight dim */
}

/* Vercel Style Secondary Button: Black BG, White Text, Gray Border */
.secondary-btn {
    background: var(--bg-dark);
    color: var(--fg-main);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background: #111;
    border-color: var(--fg-muted);
}

/* Video Interface */
#video-screen {
    display: none;
    flex-direction: column;
    height: 100%;
}

#video-screen.active {
    display: flex;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    letter-spacing: -0.03rem;
}

#role-badge {
    font-size: 0.6rem;
    background: var(--fg-main);
    color: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05rem;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #111;
    border: 1px solid var(--border-color);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.text-btn {
    background: transparent;
    border: none;
    color: var(--fg-main);
    font-size: 0.8rem;
    padding: 0;
    margin-left: 0.5rem;
    cursor: pointer;
}

.text-btn:hover {
    text-decoration: underline;
    color: #ccc;
}

/* Video Grid */
.video-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    overflow-y: auto;
    /* Hide Scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.video-grid::-webkit-scrollbar {
    display: none;
}

.video-card {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    aspect-ratio: 16/9;
    /* Clean sharp border instead of glow */
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 1200px;
    max-height: calc(100vh - 180px);
}

.video-grid:has(.video-card:nth-child(2)) .video-card {
    max-width: 48%;
}

.video-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* transform: scaleX(-1);  Removed mirror effect by user request */
}

.video-card.screen-share video {
    transform: none;
    object-fit: contain;
}

.name-tag {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: #000;
    border: 1px solid var(--border-color);
    color: var(--fg-main);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Controls */
.controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    padding: 1.5rem;
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    /* Vercel uses circles for icons often, or rounded rects. Keeping circles for classic video feel but minimal */
    background: var(--bg-panel);
    color: var(--fg-main);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.control-btn:hover {
    background: #222;
    border-color: var(--fg-muted);
}

.control-btn.active {
    background: var(--fg-main);
    color: var(--bg-dark);
    border-color: var(--fg-main);
}

.control-btn.active:hover {
    background: #e0e0e0;
}

.control-btn.danger {
    background: rgba(255, 77, 79, 0.1);
    color: var(--danger);
    border-color: rgba(255, 77, 79, 0.3);
}

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

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

/* Status Badge */
.status-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    color: var(--fg-main);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    z-index: 100;
    text-align: center;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    letter-spacing: 0.05rem;
}

.status-badge.connected {
    display: none;
}

.status-badge.checking {
    border-color: #888;
    color: #888;
}

.status-badge.failed {
    border-color: var(--danger);
    color: var(--danger);
}

/* OBS Mode - Clean Feed */
body.obs-mode {
    background: transparent;
}

body.obs-mode .app-header,
body.obs-mode .controls-bar,
body.obs-mode #join-screen {
    display: none !important;
}

body.obs-mode #video-screen {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: transparent;
}

body.obs-mode .video-grid {
    padding: 0;
    gap: 0;
}

body.obs-mode .video-card {
    border-radius: 0;
    border: none;
    box-shadow: none;
}


.title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}


#toast-message {
    padding: 10px 20px;
    color: #fff;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05rem;
}

@media (max-width: 768px) {
    .glass-panel {
        padding: 1.5rem;
        width: 95%;
    }

    #video-screen {
        height: 100dvh;
        position: relative;
    }

    .app-header {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .room-info {
        max-width: 50%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .controls-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 0.8rem;
        gap: 0.5rem;
        flex-wrap: wrap;
        z-index: 1000;
        border-top: 1px solid #222;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(10px);
    }

    /* Ensure content doesn't get hidden behind fixed footer */
    .video-grid {
        padding: 0.5rem;
        padding-bottom: 90px;
    }

    .control-btn {
        width: 40px;
        height: 40px;
    }

    #join-screen.active {
        justify-content: center;
        padding-bottom: 20%;
        /* visual lift for mobile keyboards */
    }
}