:root {
    --primary-color: #8B5CF6;
    --secondary-color: #A78BFA;
    --background: #000000;
    --surface: #0A0A0A;
    --surface-light: #1A1A1A;
    --text-primary: #FFFFFF;
    --text-secondary: #9CA3AF;
    --accent: #C084FC;
    --success: #10B981;
    --border: #1F1F1F;
    --gradient-start: #8B5CF6;
    --gradient-end: #3B82F6;
    --chat-surface: #0F0A14;
    --chat-message-bg: #15101D;
    color-scheme: only light;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    /* Fluid type: 16px up to ~1920 CSS px, grows to 22px on 4K@100% / ultrawide.
       Everything sized in rem follows (replaces the old 2560/3440/3840 media queries). */
    font-size: clamp(16px, calc(8px + 0.42vw), 22px);
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    position: fixed;
    overflow-y: auto;
    /* Prevent iOS pull-to-refresh */
    overscroll-behavior-y: none;
}

/* Page Loader */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.logo-loader {
    margin: 0 auto 1.5rem;
    display: block;
    /* Logo statico - no animation */
}

@keyframes rotate {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1.5rem;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-content p {
    color: #3B83F6;
    font-size: 1rem;
    font-weight: 500;
}

/* Welcome Screen */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    overflow-x: hidden;
    overflow-y: auto;
}

.welcome-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/dots-pattern.webp');
    background-repeat: repeat;
    background-size: auto;
    opacity: 0.7;
    pointer-events: none;
    z-index: 1;
}

.welcome-screen::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 100%;
    background-image: url('assets/blur-overlay.webp');
    background-repeat: no-repeat;
    background-position: center bottom;
    background-size: cover;
    pointer-events: none;
    z-index: 1;
    opacity: 0.6;
}

.welcome-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.welcome-ellipse {
    position: absolute;
    width: min(39rem, 90vw, 90dvh);
    height: min(39rem, 90vw, 90dvh);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -60%);
    z-index: 2;
    pointer-events: none;
    opacity: 1;
}

.welcome-content {
    text-align: center;
    max-width: 37.5rem;
    /* margin:auto centers in the flex parent but lets short screens scroll instead of clipping the top */
    margin: auto;
    padding: clamp(1rem, 5dvh, 3rem) 2rem;
    animation: fadeInUp 0.8s ease;
    position: relative;
    z-index: 2;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.welcome-logo-img {
    max-width: min(100%, 39rem);
    max-height: 38dvh;
    width: auto;
    height: auto;
    margin: 0 auto clamp(1rem, 4dvh, 2.5rem);
    display: block;
    filter: drop-shadow(0 10px 40px rgba(0, 0, 0, 0.5));
    /* animation: float 3s ease-in-out infinite; */ /* Disabled - uncomment to re-enable floating animation */
}

.welcome-title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    font-size: 1.25rem;
    color: #9EA3AE;
    font-weight: 500;
    margin-bottom: 0;
    letter-spacing: -0.02em;
    opacity: 1;
    line-height: 1.1;
}

.welcome-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #8B5CF6, transparent);
    margin: clamp(1rem, 4dvh, 2rem) auto;
    border-radius: 2px;
}

.welcome-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    margin-bottom: clamp(1rem, 4dvh, 2rem);
    line-height: 1.6;
    opacity: 1;
}

.welcome-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    color: #1f1f1f;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.welcome-login-btn:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(255, 255, 255, 0.15);
}

.welcome-login-btn:active {
    transform: translateY(0);
}

.welcome-login-btn svg {
    flex-shrink: 0;
}

.welcome-footer {
    margin-top: clamp(1rem, 4dvh, 2rem);
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.875rem;
    opacity: 1;
}

/* Hide content until loaded */
.container {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.container.loaded {
    opacity: 1;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(180deg, #000000 0%, #0A0A0A 50%, #000000 100%) !important;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    filter: none !important;
}

/* Force override browser dark mode - Samsung specific */
html {
    background: #000000 !important;
    filter: none !important;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: only light !important;
    }
    
    html, body {
        background: #000000 !important;
        filter: none !important;
    }
}

.container {
    max-width: 1600px;
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh; /* Fallback */
    min-height: 100dvh;
    max-height: 100vh; /* Fallback */
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    background: var(--surface);
    padding: 1rem clamp(1rem, 5vw, 2rem);
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    width: 100%;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header-logo {
    height: 2.5rem;
    width: auto;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.user-menu {
    position: relative;
    display: inline-block;
}

.username-display {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface-light);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.username-display:hover {
    background: rgba(139, 92, 246, 0.1);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--surface-light);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    width: 100%;
    min-width: 120px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'Inter', sans-serif;
    text-align: center;
}

.dropdown-item:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    color: #1f1f1f;
    border: 1px solid #dadce0;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.login-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.login-btn svg {
    flex-shrink: 0;
}

.edit-username-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
    opacity: 0.7;
}

.edit-username-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    opacity: 1;
}

/* Username Modal */
.username-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.username-modal.active {
    display: flex;
}

.username-modal-content {
    background: #1a1a1a;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    width: 90%;
}

.username-modal h2 {
    margin: 0 0 1rem;
    color: var(--text-primary);
}

.username-modal input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.username-modal input:focus {
    outline: none;
    border-color: var(--accent);
}

.username-modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.username-modal button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.username-modal button:hover {
    opacity: 0.9;
}

.username-modal .btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.username-modal .btn-save {
    background: linear-gradient(135deg, var(--accent) 0%, #3B82F6 100%);
    color: white;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Player Section */
.player-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 0;
    overflow: hidden;
    justify-content: center;
}

.player-container {
    position: relative;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    width: 100%;
    box-shadow: 
        0 0 0 1px rgba(139, 92, 246, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(139, 92, 246, 0.15);
    flex-shrink: 1;
    min-height: 0;
    transition: box-shadow 0.3s ease;
    max-width: 90%;
    margin: 0 auto;
    contain: layout;
}

.player-container:hover {
    box-shadow: 
        0 0 0 1px rgba(139, 92, 246, 0.4),
        0 12px 48px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(139, 92, 246, 0.25);
}

/* LiveKit Player - Force fill container */
#stream-player video,
#stream-player audio {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Stream sound toggle (top-right of the player) */
.audio-toggle {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 11;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 40px;
    min-width: 40px;
    padding: 0 0.6rem;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: rgba(12, 14, 26, 0.6);
    box-shadow: inset 0 0 0 1px var(--glass-line, rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.audio-toggle[hidden] { display: none; }

.audio-toggle:hover,
.audio-toggle:focus-visible,
.audio-toggle.blocked {
    opacity: 1;
}

/* Playback blocked by the browser (autoplay rules, iPhone Low Power Mode): a big call to action
   in the middle of the player instead of the small corner button (easy to miss on iPad/iPhone,
   test 16/11/2026); the whole video is tappable too (app.js, .needs-tap) */
.audio-toggle.blocked {
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    height: 56px;
    padding: 0 1.4rem 0 1.1rem;
    gap: 0.6rem;
    font-size: 1.05rem;
    white-space: nowrap;
    background: var(--brand-grad, var(--primary-color));
    animation: audioNudge 2s ease-in-out infinite;
}
.audio-toggle.blocked svg { width: 24px; height: 24px; }
.player-container.needs-tap { cursor: pointer; }

.audio-toggle svg { width: 20px; height: 20px; flex-shrink: 0; }
.audio-toggle .icon-sound-off,
.audio-toggle.muted .icon-sound-on { display: none; }
.audio-toggle.muted .icon-sound-off { display: block; }
.audio-toggle-label:empty { display: none; }

/* Video status over the player (bottom centre): reconnecting / "Watch here" */
.stream-notice {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 11;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    max-width: calc(100% - 2rem);
    padding: 0.5rem 0.6rem 0.5rem 1rem;
    border-radius: 999px;
    background: rgba(12, 14, 26, 0.75);
    box-shadow: inset 0 0 0 1px var(--glass-line, rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.stream-notice[hidden],
.stream-notice-action[hidden] { display: none; }

.stream-notice-action {
    flex-shrink: 0;
    height: 32px;
    padding: 0 0.9rem;
    border: none;
    border-radius: 999px;
    background: var(--brand-grad, var(--primary-color));
    color: #fff;
    font: inherit;
    cursor: pointer;
}

@keyframes audioNudge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.6); }
    50%      { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
}

/* Placeholder Image Wrapper */
.placeholder-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 10;
    border-radius: 12px;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.placeholder-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Stream Metrics */
.stream-metrics {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.7rem;
    z-index: 10;
    max-width: calc(100% - 1rem);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .stream-metrics {
        top: 0.25rem;
        right: 0.25rem;
        padding: 0.2rem 0.35rem;
        gap: 0;
        font-size: 0.5rem;
        max-width: auto;
        border-radius: 4px;
        border-width: 0.5px;
        flex-direction: row;
        align-items: center;
    }
    
    /* Hide Local Time and Stream Time on mobile, show only Latency */
    .stream-metrics .metric:not(:first-child) {
        display: none;
    }
    
    .metric {
        gap: 0.25rem;
        flex-direction: row;
        align-items: center;
    }
    
    .metric-label {
        font-size: 0.5rem;
        letter-spacing: 0;
    }
    
    .metric-value {
        font-size: 0.6rem;
        line-height: 1;
    }
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.metric-label {
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.5px;
}

.metric-value {
    color: #A78BFA;
    font-weight: 600;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    line-height: 1.2;
    overflow-wrap: break-word;
}

/* Reactions Overlay */
.reactions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.floating-reaction {
    position: absolute;
    font-size: 2.5rem;
    animation: float-up 3s ease-out forwards;
    pointer-events: none;
}

.emoji-animated-float {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    display: block;
}

@keyframes float-up {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }
    10% {
        transform: translateY(-20px) scale(1);
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-400px) scale(0.5);
        opacity: 0;
    }
}

/* Reactions Bar */
.reactions-bar {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    padding: 0.8rem;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    max-width: 90%;
    margin: 0 auto;
    width: 100%;
}

.reaction-btn {
    background: var(--surface-light);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 55px;
    height: 55px;
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.reaction-btn:hover {
    transform: scale(1.1);
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
}

.reaction-btn:active {
    transform: scale(1.3);
}

/* Custom emoji icons in reaction buttons */
.custom-emoji-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Chat Section */
.chat-section {
    display: flex;
    flex-direction: column;
    background: var(--chat-surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.1);
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    margin-bottom: env(safe-area-inset-bottom, 0px);
    /* Prevent iOS overscroll */
    overscroll-behavior: contain;
}

.chat-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-bottom: 1px solid rgba(139, 92, 246, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.online-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-messages {
    flex: 1;
    padding: 1rem 1.5rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
    /* iOS scroll fixes */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--surface);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--surface-light);
}

/* New Messages Badge */
.new-messages-badge {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.new-messages-badge.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.new-messages-badge:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.new-messages-badge .badge-icon {
    font-size: 1rem;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

/* Chat locked: a strip over the send row only (inside .chat-input-container),
   so the audience keeps reading the messages while sending is off */
.chat-locked-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 0.75rem;
    background: rgba(10, 10, 14, 0.94);
    border-radius: inherit;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
}

.lock-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.lock-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ef4444;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lock-message {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-header {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.message-author {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
    letter-spacing: -0.01em;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.message-content {
    background: var(--chat-message-bg);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    word-wrap: break-word;
    font-size: 0.95rem;
    border: 1px solid rgba(139, 92, 246, 0.08);
    border-left: 3px solid rgba(139, 92, 246, 0.5);
    transition: border-color 0.2s ease;
}

.system-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem;
}

.chat-input-container {
    padding: 1rem clamp(0.75rem, 3vw, 1.5rem);
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(59, 130, 246, 0.03) 100%);
    border-top: 1px solid rgba(139, 92, 246, 0.15);
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.photo-btn {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
    padding: 0;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

.photo-btn:hover {
    background: rgba(139, 92, 246, 0.25);
    transform: scale(1.05);
}

#chat-input {
    flex: 1;
    min-width: 0;
    background: rgba(10, 10, 10, 0.6);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, background 0.2s;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(10, 10, 10, 0.8);
}

.send-btn {
    background: #009CD9;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.8rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #007FB8;
    box-shadow: 0 4px 16px rgba(0, 156, 217, 0.4);
}

.send-btn:active {
    transform: scale(0.98);
}

/* Responsive Design - structural layout lives in the "Layout" section at the end of the file */
@media (max-width: 768px) {
    /* iOS Safari viewport fix */
    .container {
        min-height: 100dvh;
        max-height: 100dvh;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .main-content {
        padding: 1rem;
        gap: 1rem;
        max-width: 100vw;
    }
    
    /* Prevent zoom on input focus */
    #chat-input {
        font-size: 16px;
    }
    
    .chat-input-container {
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
    
    /* Welcome Screen Mobile */
    .welcome-content {
        padding: clamp(1rem, 4dvh, 2rem) 1.5rem;
    }
    
    .welcome-logo {
        width: 80px;
        height: 80px;
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .welcome-subtitle {
        font-size: 1rem;
    }
    
    .welcome-description {
        font-size: 0.9rem;
    }
    
    .welcome-login-btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Landscape mode on mobile devices (iPhone horizontal) */
@media (max-height: 500px) and (orientation: landscape) {
    .main-content {
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .chat-header {
        padding: 0.5rem 0.75rem;
        min-height: 40px;
    }
    
    .chat-header h2 {
        font-size: 0.9rem;
    }
    
    .online-count {
        font-size: 0.75rem;
    }
    
    .chat-messages {
        padding: 0.5rem;
        padding-bottom: 0.5rem;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
    
    .message {
        margin-bottom: 0.25rem;
    }
    
    .message-header {
        margin-bottom: 0.15rem;
    }
    
    .message-author {
        font-size: 0.75rem;
    }
    
    .message-time {
        font-size: 0.65rem;
    }
    
    .message-content {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }
    
    .chat-input-container {
        padding: 0.4rem;
        padding-bottom: 0.4rem;
        gap: 0.4rem;
        min-height: 50px;
        flex-shrink: 0;
    }
    
    #chat-input {
        font-size: 13px;
        padding: 0.4rem 0.6rem;
        min-height: 36px;
    }
    
    .send-btn {
        width: 70px;
        height: 36px;
        font-size: 0.85rem;
        padding: 0 0.5rem;
        flex-shrink: 0;
    }
    
    .photo-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        flex-shrink: 0;
    }
}

.loading-text,
.empty-text,
.error-text {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Custom Emoji in Reactions Bar */
.custom-emoji-btn {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-emoji-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Custom Emoji in Floating Reactions */
.custom-emoji-float {
    width: 3rem;
    height: 3rem;
    object-fit: contain;
}

/* Photo Upload Features */
.photo-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* Popover anchored above the photo button (position set from JS) */
.photo-menu {
    position: absolute;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    padding: 0.35rem;
    background: rgba(12, 14, 26, 0.97);
    border: 1px solid var(--glass-line, rgba(255, 255, 255, 0.08));
    border-radius: 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transform-origin: bottom left;
    animation: photoMenuIn 0.16s ease-out;
}

.photo-menu.closing {
    animation: photoMenuOut 0.15s ease-in forwards;
}

@keyframes photoMenuIn {
    from { opacity: 0; transform: translateY(6px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}

@keyframes photoMenuOut {
    to { opacity: 0; transform: translateY(6px) scale(0.96); }
}

.photo-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.photo-menu-btn:hover,
.photo-menu-btn:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.photo-menu-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 9px;
    background: rgba(139, 92, 246, 0.16);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #C4B5FD;
}

.photo-menu-icon svg {
    width: 18px;
    height: 18px;
}

/* Camera Modal: full-screen viewfinder with a shutter bar */
.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: #000;
    animation: fadeIn 0.2s ease;
}

.camera-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.camera-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1.25rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom));
    background: #000;
}

.camera-slot {
    display: flex;
    justify-content: center;
}

.camera-icon-btn {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

.camera-icon-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.camera-icon-btn svg {
    width: 22px;
    height: 22px;
}

.camera-close {
    position: absolute;
    top: calc(1rem + env(safe-area-inset-top));
    left: 1rem;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.camera-shutter {
    width: 72px;
    height: 72px;
    padding: 0;
    border-radius: 50%;
    border: 4px solid #fff;
    background: var(--brand-grad, var(--primary-color));
    box-shadow: inset 0 0 0 4px #000;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.camera-shutter:active {
    transform: scale(0.92);
}

.camera-modal.flash .camera-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #fff;
    animation: cameraFlash 0.25s ease-out forwards;
}

@keyframes cameraFlash {
    from { opacity: 0.8; }
    to   { opacity: 0; }
}

/* No camera could be opened: message + photo library fallback */
.camera-modal-error {
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(4, 5, 11, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.camera-error {
    width: min(100%, 360px);
    padding: 1.75rem 1.5rem 1.25rem;
    text-align: center;
    background: rgba(12, 14, 26, 0.97);
    border: 1px solid var(--glass-line, rgba(255, 255, 255, 0.08));
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.camera-error-icon {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 0.9rem;
    border-radius: 16px;
    background: rgba(139, 92, 246, 0.16);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #C4B5FD;
}

.camera-error-icon svg { width: 26px; height: 26px; }

.camera-error h3 {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
    font-weight: 650;
    color: #fff;
}

.camera-error p {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--muted-2, #8C92A8);
}

.camera-error-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.camera-error-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, filter 0.15s ease;
}

.camera-error-btn:hover { background: rgba(255, 255, 255, 0.1); }

.camera-error-btn.primary {
    border: 0;
    background: var(--brand-grad, var(--primary-color));
}

.camera-error-btn.primary:hover { filter: brightness(1.1); }

.camera-error-btn.ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted-2, #8C92A8);
}

/* Message Photo Display */
.message-photo-container {
    margin: 0.5rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.message-photo {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

@media (max-width: 768px) {
    .message-photo {
        max-width: 200px;
    }
}

.message-photo:hover {
    transform: scale(1.02);
}

.photo-caption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Lightbox: full-screen photo viewer (close button reuses .camera-icon-btn) */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(4.5rem + env(safe-area-inset-top)) 1rem calc(1.5rem + env(safe-area-inset-bottom));
    background: rgba(4, 5, 11, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: fadeIn 0.2s ease;
}

.lightbox-content {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
}

.lightbox-content img {
    display: block;
    max-width: min(100%, 1100px);
    max-height: calc(100vh - 9rem);
    max-height: calc(100dvh - 9rem);
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
    animation: lightboxIn 0.2s ease-out;
}

@keyframes lightboxIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.lightbox-caption {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #fff;
}

.lightbox-caption[hidden] { display: none; }

.lightbox-author { font-weight: 600; }

.lightbox-time {
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: var(--muted-2, #8C92A8);
}

.lightbox-close {
    position: absolute;
    top: calc(1rem + env(safe-area-inset-top));
    right: 1rem;
}

.uploading-indicator {
    text-align: center;
    padding: 1rem;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Poll Styles */
.poll-message {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.05) 100%) !important;
    border-left: 3px solid #8B5CF6 !important;
    padding: 1rem !important;
}

.poll-question {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.poll-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.poll-option {
    position: relative;
    background: rgba(10, 10, 10, 0.4);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    overflow: hidden;
}

.poll-option:not(.voted):hover {
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.1);
    transform: translateX(2px);
}

.poll-option.voted {
    cursor: default;
}

.poll-option-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.3) 0%, rgba(59, 130, 246, 0.2) 100%);
    transition: width 0.5s ease;
    border-radius: 8px 0 0 8px;
}

.poll-option-content {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.poll-option-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.poll-option-votes {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.poll-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(139, 92, 246, 0.15);
}

/* ==========================================================================
   Layout - player + reactions ("stage") and chat
   Decided by orientation, not width: the page is locked to 100dvh, so the real
   constraint is height. Landscape -> two columns, portrait -> one column.
   The player is always exactly 16:9 and never squeezed.
   ========================================================================== */
:root {
    --chat-w: clamp(300px, 28vw, 440px);
    --reaction-size: 3.45rem;
    --reactions-pad: 0.8rem;
    --reactions-h: calc(var(--reaction-size) + 2 * var(--reactions-pad));
    --stage-gap: 0.8rem;
}

.reaction-btn {
    width: var(--reaction-size);
    height: var(--reaction-size);
}

.reactions-bar {
    padding: var(--reactions-pad);
}

/* Landscape (default): stage | chat */
.main-content {
    grid-template-columns: minmax(0, 1fr) var(--chat-w);
    grid-template-rows: minmax(0, 1fr);
}

.player-section {
    container-type: size;
    justify-content: flex-start;
    gap: var(--stage-gap);
}

/* Largest 16:9 box that fits the stage together with the reactions bar */
.player-container,
.reactions-bar {
    width: min(100cqw, calc((100cqh - var(--reactions-h) - var(--stage-gap)) * 16 / 9));
    max-width: none;
    margin: 0 auto;
}

.player-container {
    flex: none;
}

.chat-section {
    max-height: none;
    min-height: 0;
}

@media (min-width: 2560px) {
    :root { --chat-w: clamp(460px, 20vw, 640px); }
}

/* Short landscape screens (phones sideways) */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --chat-w: clamp(260px, 40vw, 380px);
        --reaction-size: 36px;
        --reactions-pad: 0.3rem;
        --stage-gap: 0.4rem;
    }
    .reactions-bar { gap: 0.4rem; }
    .reaction-btn { font-size: 1.1rem; }
}

/* Portrait: stage on top at full width, chat takes the rest */
@media (orientation: portrait) {
    .main-content {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }

    .player-section {
        container-type: normal;
    }

    .player-container,
    .reactions-bar {
        width: 100%;
    }
}

@media (orientation: portrait) and (max-width: 600px) {
    :root {
        --reaction-size: 44px;
        --reactions-pad: 0.45rem;
        --stage-gap: 0.5rem;
    }
    .main-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    .reactions-bar { gap: 0.5rem; }
    .reaction-btn { font-size: 1.3rem; }

    /* Compact chat chrome so short phones (iPhone SE) still show messages */
    .chat-header { padding: 0.5rem 1rem; }
    .chat-header h2 { font-size: 1rem; }
    .online-count { font-size: 0.8rem; }
    .chat-messages { padding: 0.5rem 0.75rem; }
    .chat-input-container {
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
        gap: 0.5rem;
    }
}

/* Compact page header on phones (portrait and sideways): every pixel goes to video + chat */
@media (orientation: portrait) and (max-width: 600px), (orientation: landscape) and (max-height: 500px) {
    .header {
        padding: 0.5rem 0.75rem;
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
    .header-logo { height: 1.75rem; }
    .username-display {
        font-size: 0.8rem;
        padding: 0.35rem 0.75rem;
        max-width: 55vw;
    }
}

/* Welcome screen on phones held sideways: smaller logo so the login button and footer fit */
@media (orientation: landscape) and (max-height: 500px) {
    .welcome-logo-img { max-height: 28dvh; }
}

/* ==========================================================================
   Restyle 2026 - same elements, event look
   Atmosphere from the welcome screen behind the stage, video as hero,
   floating reaction pill, box-less chat with avatars, pinned poll,
   single blue->violet accent. The welcome screen keeps its own styles.
   ========================================================================== */
:root {
    --font-ui: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Consolas, monospace;
    --stage-bg: #04050B;
    --glass: rgba(14, 16, 30, 0.68);
    --glass-line: rgba(255, 255, 255, 0.08);
    --brand-grad: linear-gradient(135deg, #3B83F6 0%, #8B5CF6 100%);
    --muted-2: #8C92A8;
    --online: #22C55E;
    --player-radius: 20px;
}

.container,
.container button,
.container input {
    font-family: var(--font-ui);
}

/* Atmosphere: same glows as the welcome screen, quieter, plus a fading dot grid */
.container {
    position: relative;
    isolation: isolate;
    background:
        radial-gradient(70vw 60vh at 10% -12%, rgba(59, 131, 246, 0.20), transparent 60%),
        radial-gradient(60vw 70vh at 108% 112%, rgba(139, 92, 246, 0.20), transparent 60%),
        radial-gradient(45vw 30vh at 50% 118%, rgba(236, 72, 153, 0.09), transparent 70%),
        var(--stage-bg);
}
.container::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.2px);
    background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.12) 70%);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.12) 70%);
}

/* Header: transparent, brighter logo, avatar + name */
.header {
    background: transparent;
    border-bottom: 0;
    box-shadow: none;
    padding-block: 0.85rem;
}
.header-logo {
    filter: brightness(1.9) contrast(1.05);
}
.username-display {
    align-items: center;
    gap: 0.6rem;
    background: transparent;
    padding: 0.25rem 0.35rem 0.25rem 0.25rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
}
.username-display:not([style*="none"]) { display: inline-flex !important; }
.username-display:hover { background: rgba(255, 255, 255, 0.06); }
.username-display .user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--brand-grad);
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}
.username-display .user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Video: the hero */
.player-container {
    border-radius: var(--player-radius);
    background: #000;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 16px 60px -28px rgba(59, 131, 246, 0.55),
        0 0 110px -40px rgba(139, 92, 246, 0.55);
}
.player-container:hover {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 16px 60px -28px rgba(59, 131, 246, 0.65),
        0 0 110px -40px rgba(139, 92, 246, 0.65);
}
#stream-player,
#stream-player img,
#stream-player video {
    border-radius: 0 !important;
}

/* Reactions: glass pill UNDER the video, not over its bottom edge (changed 16/11/2026 after the
   iPhone test: the pill covered the bottom of the picture, where captions and speaker names go).
   The stage reserves the whole pill plus a small gap. */
:root { --stage-gap: 0px; --reactions-gap: 0.6rem; }
@media (orientation: portrait) and (max-width: 600px), (orientation: landscape) and (max-height: 500px) {
    :root { --reactions-gap: 0.45rem; }
}
@media (orientation: landscape) {
    .player-container {
        width: min(100cqw, calc((100cqh - var(--reactions-h) - var(--reactions-gap)) * 16 / 9));
    }
}
.reactions-bar {
    width: max-content !important;
    max-width: 100% !important;
    margin: var(--reactions-gap) auto 0 !important;
    position: relative;
    z-index: 15;
    gap: 0.6rem;
    border-radius: 999px;
    background: rgba(12, 14, 26, 0.78);
    border: 1px solid var(--glass-line);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.reaction-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.reaction-btn:hover {
    transform: translateY(-3px);
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.35);
}
.reaction-btn:active { transform: scale(1.18); }
.reaction-btn .custom-emoji-icon {
    width: 62%;
    height: 62%;
    object-fit: contain;
}

/* Chat: glass panel */
.chat-section {
    background: var(--glass);
    border: 1px solid var(--glass-line);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}
.chat-header {
    background: transparent;
    border-bottom: 0;
    padding: 1rem 1.1rem 0.6rem;
}
.chat-header h2 {
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}
.online-count {
    font: 500 0.75rem/1 var(--font-mono);
    color: var(--muted-2);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    gap: 0.45rem;
}
.online-count .status-dot { background: var(--online); width: 7px; height: 7px; }

/* Scroll position is managed in app.js (stick to bottom + compensation on removals),
   identically in every browser: Safari has no scroll anchoring, so it is off everywhere */
.chat-messages { overflow-anchor: none; }

/* Messages: no boxes, initials avatar, name + time on one line */
.chat-messages {
    padding: 0.4rem 1.1rem 0.8rem;
    gap: 0.55rem; /* was 0.8rem: the taller name line (avatar-centred) gives back the space */
}
.message {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr);
    column-gap: 0.65rem;
    row-gap: 0;
}
.message-avatar {
    grid-row: 1 / span 2;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.66rem;
    font-weight: 700;
    color: #fff;
    background: #8B5CF6;
}
/* The name line is as tall as the avatar (line-height = circle size), so the name sits centred on
   the circle; name and time stay on the same baseline (with align-items: center the smaller mono
   time floated above the name's baseline - a visible step, iPhone test 16/11/2026) */
.message-header {
    display: flex;
    align-items: baseline;
    line-height: 1.75rem;
    gap: 0.5rem;
    margin: 0;
}
.message-header + .message-content,
.message-header + * { margin-top: -0.15rem; }
.message-author { font-size: 0.82rem; font-weight: 650; }
.message-time { font: 0.7rem var(--font-mono); color: var(--muted-2); }
.message-content {
    background: none !important;
    border: 0 !important;
    padding: 0.05rem 0 0;
    border-radius: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #E7E9F2;
}
.system-message {
    align-self: center;
    font: 500 0.72rem var(--font-mono);
    font-style: normal;
    color: var(--muted-2);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
}
.message-photo { border-radius: 12px; }

/* Polls (only pinned above the chat; never in the chat flow) */
.poll-message {
    background: linear-gradient(135deg, rgba(59, 131, 246, 0.14), rgba(139, 92, 246, 0.16)) !important;
    border: 1px solid rgba(139, 92, 246, 0.35) !important;
    border-radius: 14px !important;
    padding: 0.85rem !important;
    margin-top: 0.25rem;
}
.poll-question { font-size: 0.95rem; font-weight: 650; line-height: 1.3; margin-bottom: 0.6rem; }
.poll-options { gap: 0.4rem; }
.poll-option {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 9px;
    padding: 0.5rem 0.7rem;
}
.poll-option:hover { border-color: rgba(201, 184, 255, 0.55); }
.poll-option-bar { background: var(--brand-grad); opacity: 0.38; border-radius: 0; }
.poll-option-content { font-size: 0.85rem; }
.poll-option-votes { font: 500 0.75rem var(--font-mono); color: #E4E0F5; }
.poll-footer { font-size: 0.72rem; color: var(--muted-2); border-top: 0; padding-top: 0.5rem; margin-top: 0; text-align: left; }

/* The open poll is pinned above the chat */
.pinned-poll {
    margin: 0 0.85rem 0.35rem;
    flex-shrink: 0;
    max-height: 45%;
    overflow-y: auto;
}
.pinned-poll .poll-message { margin-top: 0; }
.pinned-poll-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font: 600 0.66rem/1 var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #C9B8FF;
    margin-bottom: 0.5rem;
}
.pinned-poll-toggle {
    all: unset;
    cursor: pointer;
    font: 500 0.7rem/1 var(--font-mono);
    letter-spacing: 0.04em;
    color: var(--muted-2);
    padding: 0.2rem 0.3rem;
    border-radius: 6px;
}
.pinned-poll-toggle:focus-visible { outline: 2px solid #8B5CF6; }
.pinned-poll.collapsed .poll-options,
.pinned-poll.collapsed .poll-footer { display: none; }
.pinned-poll.collapsed .poll-question { margin-bottom: 0; }

/* Input: one rounded field with the photo icon inside and a gradient send */
.chat-input-container {
    margin: 0 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    padding: 0.35rem !important;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
}
.chat-input-container:focus-within { border-color: rgba(139, 92, 246, 0.6); }
#chat-input {
    background: transparent;
    border: 0;
    padding: 0.55rem 0.3rem;
}
#chat-input:focus { outline: none; box-shadow: none; }
.photo-btn {
    width: 2.4rem;
    height: 2.4rem;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: var(--muted-2);
}
.photo-btn:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.send-btn {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 10px;
    background: var(--brand-grad);
    display: grid;
    place-items: center;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn svg { display: block; }

.new-messages-badge { background: var(--brand-grad); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45); }

/* Phones held upright: edge-to-edge video, avatar-only user button */
@media (orientation: portrait) and (max-width: 600px) {
    .player-container { --player-radius: 14px; }
    .username-display .user-name { display: none; }
    .username-display { padding: 0.15rem; }
    .chat-section { border-radius: 18px; }
    .chat-header { padding: 0.7rem 0.9rem 0.45rem; }
    .chat-messages { padding: 0.3rem 0.9rem 0.6rem; gap: 0.4rem; } /* was 0.65rem, see .message-header */
    .pinned-poll { margin: 0 0.6rem 0.3rem; max-height: 55%; }
    .pinned-poll .poll-message { padding: 0.7rem !important; }
    .pinned-poll .poll-option { padding: 0.4rem 0.6rem; }
    .pinned-poll .poll-question { font-size: 0.9rem; margin-bottom: 0.45rem; }
    .chat-input-container { margin: 0 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
}
