@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: linear-gradient(135deg, #0f172a, #1e293b);
    --surface: rgba(15, 23, 42, 0.72);
    --surface-2: #1e293b;
    --border: 1px solid rgba(255, 255, 255, 0.08);
    --accent: #7dd3fc;
    --accent-2: #312c85;
    --danger: #dc2626;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --focus: rgba(125, 211, 252, 0.6);
    --radius: 14px;
}

* {
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior: none;
}

*:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

[hidden] { display: none !important; }

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: #fca5a5; }

/* =================================================================== */
/* Landing pages                                                        */
/* =================================================================== */

.page-landing {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    backdrop-filter: blur(8px);
    text-align: center;
}

.card .logo {
    width: 56px;
    height: 64px;
    margin-bottom: 0.75rem;
}

.card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 600;
}

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

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

form label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--muted);
}

form input {
    background: var(--surface-2);
    color: var(--text);
    border: var(--border);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--accent);
    color: #0b1120;
    border: 0;
    border-radius: 10px;
    padding: 0.95rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.2s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }

/* =================================================================== */
/* App / room                                                           */
/* =================================================================== */

.page-app {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stage {
    flex: 1;
    position: relative;
    display: flex;
    min-height: 0;
}

.remotes {
    flex: 1;
    display: grid;
    gap: 6px;
    padding: 6px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    grid-auto-rows: 1fr;
    min-height: 0;
    overflow: hidden;
}

.tile {
    position: relative;
    background: #0b1120;
    border: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.tile .name {
    position: absolute;
    left: 10px;
    bottom: 10px;
    background: rgba(0, 0, 0, 0.55);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.tile .badges {
    position: absolute;
    right: 10px;
    top: 10px;
    display: flex;
    gap: 6px;
}

.tile .badge {
    background: rgba(0, 0, 0, 0.55);
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile .badge.muted { background: var(--danger); }
.tile .avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
}

.local-wrap {
    position: absolute;
    right: 10px;
    bottom: calc(120px + env(safe-area-inset-bottom, 0));
    width: 140px;
    aspect-ratio: 4 / 3;
    background: #000;
    border: var(--border);
    border-radius: 12px;
    overflow: hidden;
    z-index: 5;
}

.local-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* --- Controls --- */

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    background: rgba(11, 17, 32, 0.92);
    border-top: var(--border);
    flex-wrap: wrap;
}

.big-btn {
    background: var(--surface-2);
    color: var(--text);
    border: var(--border);
    border-radius: 18px;
    min-width: 92px;
    min-height: 84px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.08s ease;
}
.big-btn:active { transform: scale(0.97); }
.big-btn.active { background: var(--accent); color: #0b1120; }
.big-btn.danger { background: var(--danger); color: #fff; }

.icon-btn {
    background: var(--surface-2);
    color: var(--text);
    border: var(--border);
    border-radius: 50%;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn.leave { background: var(--danger); color: #fff; }

/* --- Overlay (waiting, ended) --- */

.overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 20;
}

.overlay-content {
    text-align: center;
    max-width: 420px;
}

.overlay-content .logo {
    width: 56px;
    height: 64px;
    margin-bottom: 1rem;
    animation: pulse 2.5s ease-in-out infinite;
}

.overlay-content h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.overlay-link {
    display: inline-block;
    margin-top: 1.25rem;
    padding: 0.7rem 1.25rem;
    background: var(--accent);
    color: #0b1120;
    border-radius: 10px;
    font-weight: 600;
}

@keyframes pulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; transform: scale(1.05); }
}

/* --- Audio unlock banner --- */

.audio-unlock {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #0b1120;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    z-index: 30;
    animation: pulse 2s ease-in-out infinite;
}

/* --- Settings modal --- */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 30;
}

.modal-body {
    width: 100%;
    max-width: 420px;
    background: var(--surface-2);
    border: var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body h3 {
    margin: 0;
}

.modal-body select {
    width: 100%;
    background: #0b1120;
    color: var(--text);
    border: var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    font-size: 1rem;
}

/* --- Mobile tweaks --- */

@media (max-width: 520px) {
    .big-btn {
        min-width: 76px;
        min-height: 76px;
        padding: 8px 10px;
    }
    .big-btn svg { width: 28px; height: 28px; }
    .local-wrap {
        width: 100px;
        bottom: calc(110px + env(safe-area-inset-bottom, 0));
    }
}
