/**
 * Stage Containers — Unified Circle-Based Interface
 * Унифицированный интерфейс кружочков для desktop и mobile
 */

/* === Stage Background === */
.stage-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-image: url('/assets/images/theater/stage.png');
    background-size: cover;
    background-position: center;
    filter: brightness(0.75) blur(2px);
    transition: filter 0.3s ease;
}

.stage-active:hover .stage-background {
    filter: brightness(0.85) blur(1px);
}

@media (min-width: 769px) {
    .stage-background {
        background-image: url('/assets/images/theater/stage-desktop.jpg');
    }
}

/* ===== UNIFIED STAGE OVERLAY ===== */
.stage-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
}

/* === Video Circles (centered above text) === */
.video-circles {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 24px;
    z-index: 50;
    pointer-events: none;
}

.video-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    flex-shrink: 0;
}

/* Partner circle: left in centered row */
.video-circle--partner {
    /* No positioning needed - flex handles it */
}

/* Self circle: right in centered row */
.video-circle--self {
    /* No positioning needed - flex handles it */
}

.video-circle:hover {
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.5);
}

.video-circle:active {
    transform: scale(0.95);
}

.video-circle video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-circle--self video {
    transform: scaleX(-1);
}

/* Zoomed circle (click to enlarge) — positioned in top-left of text area */
.video-circle.zoomed {
    position: absolute;
    top: 200px; /* Below circles row, at start of text */
    left: calc(50% - 380px); /* Left edge of text container */
    transform: none;
    width: min(320px, 40vw);
    height: min(320px, 40vw);
    max-width: 320px;
    max-height: 320px;
    z-index: 60;
    border-color: var(--accent-gold, #d4af37);
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7);
    pointer-events: auto;
}

/* Both circles zoom to same position (top-left corner) */
.video-circle--partner.zoomed,
.video-circle--self.zoomed {
    /* Same position - left corner of text area */
}

/* Legacy: Hide circle when fullscreen mode (backward compat) */
.video-circle.expanded {
    opacity: 0;
    pointer-events: none;
}

/* Circle visibility based on mode is handled via JS (setStageMode) */

/* === Fullscreen Layer === */
.fullscreen-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px; /* above controls */
    z-index: 1;
    pointer-events: none; /* Пропускать клики к кружкам */
}

.fullscreen-layer > * {
    pointer-events: auto; /* Интерактивные элементы внутри */
}

.fullscreen-text,
.fullscreen-partner,
.fullscreen-self {
    position: absolute;
    inset: 0;
    display: none;
}

/* Partner video: ALWAYS rendered (for audio), hidden via visibility when not active */
.fullscreen-partner {
    display: block !important;
    visibility: hidden;
    pointer-events: none;
    z-index: -1;
}

/* Mode visibility rules */
.fullscreen-layer[data-mode="text"] .fullscreen-text { display: flex; }
.fullscreen-layer[data-mode="partner"] .fullscreen-partner {
    display: block;
    visibility: visible;
    pointer-events: auto;
    z-index: auto;
}
.fullscreen-layer[data-mode="self"] .fullscreen-self { display: block; }

/* Partner/Self fullscreen videos */
.fullscreen-partner video,
.fullscreen-self video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.fullscreen-self video {
    transform: scaleX(-1);
}

/* Text fullscreen view */
.fullscreen-text {
    flex-direction: column;
    align-items: center;
    padding: 180px 60px 20px; /* top padding for centered video circles */
    overflow: hidden;
}

.text-viewport {
    flex: 1;
    max-width: 800px;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.text-viewport::-webkit-scrollbar {
    width: 6px;
}

.text-viewport::-webkit-scrollbar-track {
    background: transparent;
}

.text-viewport::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.text-lines {
    width: 100%;
}

.text-line {
    padding: 12px 16px;
    font-size: 1.15em;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.75);
    transition: color 0.3s ease, opacity 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    /* Прозрачный фон, text-shadow для читаемости */
    background: transparent;
    text-shadow: 0 0 10px rgba(0, 0, 0, 1), 0 2px 6px rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    margin-bottom: 8px;
}

.text-line.current {
    color: rgba(255, 255, 255, 1);
    font-weight: 500;
    border-left: 4px solid var(--accent-primary, #6366f1);
    padding-left: 16px;
    /* Фон + свечение только у активной */
    background: rgba(10, 10, 20, 0.88);
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.35);
    text-shadow: none;
}

.text-line.past {
    opacity: 0.55;
}

.text-line.future {
    opacity: 0.75;
}

.text-line-speaker {
    font-weight: 600;
    margin-right: 8px;
}

.text-line-speaker[data-role="role1"] {
    color: #ff6b9d;
}

.text-line-speaker[data-role="role2"] {
    color: #4ecdc4;
}

.text-line-content {
    display: inline;
}

.text-line-header {
    font-weight: 700;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    white-space: pre-line;
}

/* Автор и название пьесы — крупнее на 50% */
.text-line-header.play-author,
.text-line-header.play-title {
    font-size: 1.35em;
}

.text-line-direction {
    font-style: italic;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875em;
}

.text-line-end {
    text-align: center;
    font-size: 1.5em;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: rgba(255, 255, 255, 0.8);
    padding: 2em 0;
    border-left: none !important;
    padding-left: 0 !important;
}

.text-line-end.current {
    color: var(--accent-primary);
}

/* Navigation side panel (right) — positioned near text edge */
.text-nav-side {
    position: absolute;
    right: calc(50% - 450px); /* near right edge of 800px text container */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 10;
}

.text-nav-btn {
    width: 50px;
    height: 50px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.text-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.text-nav-btn:active {
    transform: scale(0.95);
}

/* Font size controls - right corner above text */
.text-controls-header {
    position: absolute;
    top: 170px;
    right: calc(50% - 420px); /* align with text container edge */
    display: flex;
    gap: 6px;
    z-index: 55;
}

.text-fontsize-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.text-fontsize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Text Progress Bar - left corner above text */
.text-progress-bar {
    position: absolute;
    top: 170px;
    left: calc(50% - 420px); /* align with text container edge */
    background: rgba(0, 0, 0, 0.75);
    padding: 8px 16px;
    border-radius: 16px;
    z-index: 55;
    backdrop-filter: blur(4px);
}

.text-progress {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
}

/* Viewers in progress bar */
.text-progress-viewers {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.text-progress-viewers .viewers-divider {
    color: rgba(255, 255, 255, 0.3);
    margin-right: 4px;
}

.text-progress-viewers .viewers-icon {
    font-size: 16px;
}

.text-progress-viewers .viewers-count {
    color: #ffd700;
    font-size: 16px;
    font-weight: 700;
}

.text-progress-viewers .viewers-label {
    color: #ffd700;
    font-size: 14px;
    font-weight: 600;
}

/* === Viewers Badge (above controls) === */
.viewers-badge {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: #fff;
    z-index: 20;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.viewers-badge-text {
    white-space: nowrap;
}

.viewers-badge #viewers-number {
    color: var(--accent-gold, #d4af37);
    font-weight: 600;
}

.broadcast-status-dot {
    width: 8px;
    height: 8px;
    background: #ff4444;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* === Background Replacement Menu === */
.bg-menu {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(10, 10, 20, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.bg-menu-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bg-menu-section {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 12px 0 6px 0;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bg-preset-btn {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
}

.bg-preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.bg-preset-btn:active {
    transform: translateX(2px);
}

.bg-preset-btn.bg-preset-active {
    background: rgba(99, 102, 241, 0.3);
    border: 1px solid rgba(99, 102, 241, 0.5);
}

.bg-upload-btn {
    cursor: pointer;
}

.bg-loading {
    text-align: center;
    padding: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    animation: bg-loading-pulse 1.5s infinite;
}

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

@media (max-width: 768px) {
    .bg-menu {
        width: 220px;
        max-height: 50vh;
        padding: 12px;
    }

    .bg-preset-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* === Mobile Adaptations === */
@media (max-width: 768px) {
    /* Smaller circles on mobile */
    .mode-circle {
        width: 56px;
        height: 56px;
    }

    .mode-circle--partner {
        top: 12px;
        left: 12px;
    }

    .mode-circle--self,
    .mode-circle--text {
        bottom: 90px;
        right: 12px;
    }

    .circle-text-preview .circle-speaker {
        font-size: 8px;
        max-width: 54px;
    }

    .circle-text-preview .circle-line {
        font-size: 7px;
        max-height: 32px;
    }

    /* Hide unified stage-overlay on mobile (use legacy mobile-stage-overlay) */
    .stage-overlay {
        display: none;
    }

    /* Text adjustments for smaller screens */
    .fullscreen-text {
        padding: 100px 20px 20px;
    }

    .text-line {
        font-size: 1em;
        padding: 10px 14px;
    }

    .text-nav-side {
        right: 16px;
    }

    .text-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .text-controls-header {
        right: 16px;
        top: 100px;
    }

    .text-progress-bar {
        left: 16px;
        top: 100px;
    }
}

/* ===== Mobile Stage Overlay (Simplified) ===== */
.mobile-stage-overlay {
    display: none;
}

@media (max-width: 768px) {
    /* Show only when active */
    .mobile-stage-overlay.active {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
        background: #0a0a14;
    }

    /* Stage background image */
    .mobile-stage-background {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: url('/assets/images/theater/stage-mobile.jpg');
        background-size: cover;
        background-position: center;
        filter: brightness(0.5) blur(2px);
        z-index: 0;
    }

    /* Two circles row: Partner + Self */
    .mobile-circles-row {
        position: absolute;
        top: 16px;
        left: 0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        gap: 16px;
        z-index: 50;
        padding: 0 16px;
    }

    /* Video circles (partner & self) — normal state */
    .mobile-circle--partner,
    .mobile-circle--self {
        width: 100px;
        height: 100px;
        border-radius: 50%;
        overflow: hidden;
        border: 3px solid rgba(255, 255, 255, 0.4);
        background: rgba(0, 0, 0, 0.6);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
        flex-shrink: 0;
        cursor: pointer;
        transition: all 0.3s ease;
        z-index: 50;
    }

    /* Zoomed video circle (click to enlarge) */
    .mobile-circle--partner.zoomed,
    .mobile-circle--self.zoomed {
        width: min(240px, 60vw);
        height: min(240px, 60vw);
        border: 4px solid var(--accent-gold, #d4af37);
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
        z-index: 100;
    }

    /* Minimized video circle (when other is zoomed) */
    .mobile-circle--partner.minimized,
    .mobile-circle--self.minimized {
        width: 60px;
        height: 60px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        opacity: 0.8;
    }

    .mobile-circle--partner video,
    .mobile-circle--self video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        pointer-events: auto;
        cursor: pointer;
    }

    /* Mirror self video */
    .mobile-circle--self video {
        transform: scaleX(-1);
    }

    /* Text area */
    .mobile-text-area {
        position: absolute;
        top: 130px;
        left: 0;
        right: 0;
        bottom: 90px;
        overflow-y: auto;
        padding: 16px;
        z-index: 10;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-text-content {
        font-size: 18px;
        line-height: 1.6;
        color: #e0e0e0;
    }

    /* Progress bar */
    .mobile-text-progress-bar {
        position: absolute;
        top: 120px;
        left: 16px;
        background: rgba(0, 0, 0, 0.75);
        padding: 4px 10px;
        border-radius: 10px;
        z-index: 40;
        backdrop-filter: blur(4px);
    }

    .mobile-text-progress {
        color: rgba(255, 255, 255, 0.8);
        font-size: 12px;
        font-weight: 500;
    }

    /* Viewers badge */
    .mobile-viewers-badge {
        position: absolute;
        top: 120px;
        right: 16px;
        background: rgba(0, 0, 0, 0.75);
        padding: 4px 10px;
        border-radius: 10px;
        font-size: 12px;
        color: var(--accent-gold, #d4af37);
        z-index: 40;
        backdrop-filter: blur(4px);
    }

    /* Controls */
    .mobile-controls {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 90px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 32px;
        background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
        padding-bottom: env(safe-area-inset-bottom, 0);
        z-index: 60;
    }

    .mobile-control-btn {
        width: 56px;
        height: 56px;
        border: none;
        background: rgba(255, 255, 255, 0.15);
        color: white;
        border-radius: 50%;
        font-size: 24px;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .mobile-control-btn:active {
        transform: scale(0.95);
    }

    .mobile-control-btn.muted {
        background: #c0392b;
    }

    .mobile-control-btn.active {
        background: #27ae60;
    }

    .mobile-control-btn--danger {
        background: #c0392b;
    }

    /* Hide desktop elements when mobile overlay is active */
    .stage-active:has(.mobile-stage-overlay.active) > .stage-overlay,
    .stage-active:has(.mobile-stage-overlay.active) > .viewers-badge,
    .stage-active:has(.mobile-stage-overlay.active) > .stage-controls,
    .stage-active:has(.mobile-stage-overlay.active) > .stage-background {
        display: none !important;
    }
}

/* === Mobile Tabs === */
.mobile-tabs {
    display: flex;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 300;
}

.mobile-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.mobile-tab.active {
    color: var(--accent-gold, #d4af37);
    border-bottom-color: var(--accent-gold, #d4af37);
}

/* === Mobile Tab Content === */
.mobile-tab-content {
    display: none;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.mobile-tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* === Mobile Stage Tab (3-Mode System: Text / Partner / Self) === */
#mobile-tab-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #0a0a14;
}

/* === Fullscreen Layer (contains all 3 fullscreen views) === */
.mobile-fullscreen-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px; /* above controls */
    z-index: 1;
}

/* Fullscreen Text Mode */
.mobile-fullscreen-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    padding-top: 80px; /* space for circles */
}

/* Fullscreen Partner Video */
.mobile-fullscreen-partner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    background: #111;
}

.mobile-fullscreen-partner video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fullscreen Self Video */
.mobile-fullscreen-self {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    background: #111;
}

.mobile-fullscreen-self video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror */
}

/* Mode visibility rules */
#mobile-tab-stage[data-mode="text"] .mobile-fullscreen-text { display: flex; }
#mobile-tab-stage[data-mode="partner"] .mobile-fullscreen-partner { display: block; }
#mobile-tab-stage[data-mode="self"] .mobile-fullscreen-self { display: block; }

/* === Mode Circles (top switchers) === */
.mobile-mode-circles {
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 16px;
    z-index: 50;
    padding: 0 16px;
}

.mobile-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.mobile-circle:active {
    transform: scale(0.95);
}

.mobile-circle.active {
    border-color: var(--accent-gold, #d4af37);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

/* Zoomed mobile circle (click to enlarge 250%) */
.mobile-circle.zoomed {
    width: 160px;
    height: 160px;
    z-index: 100;
    border-color: var(--accent-gold, #d4af37);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.mobile-circle video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-circle--self video {
    transform: scaleX(-1); /* Mirror */
}

/* Text preview in circle */
.mobile-circle--text {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.9);
}

.circle-text-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    text-align: center;
    overflow: hidden;
}

.circle-text-preview .circle-speaker {
    font-size: 8px;
    font-weight: 600;
    color: var(--accent-gold, #d4af37);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 54px;
}

.circle-text-preview .circle-line {
    font-size: 7px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.2;
    max-height: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Circle visibility based on mode */
#mobile-tab-stage[data-mode="text"] .mobile-circle--text { display: none; }
#mobile-tab-stage[data-mode="text"] .mobile-circle--partner { display: block; }
#mobile-tab-stage[data-mode="text"] .mobile-circle--self { display: block; }

#mobile-tab-stage[data-mode="partner"] .mobile-circle--text { display: flex; }
#mobile-tab-stage[data-mode="partner"] .mobile-circle--partner { display: none; }
#mobile-tab-stage[data-mode="partner"] .mobile-circle--self { display: block; }

#mobile-tab-stage[data-mode="self"] .mobile-circle--text { display: flex; }
#mobile-tab-stage[data-mode="self"] .mobile-circle--partner { display: block; }
#mobile-tab-stage[data-mode="self"] .mobile-circle--self { display: none; }

/* === Mobile Text Content (fullscreen mode) === */
.mobile-text-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    font-size: 18px;
    line-height: 1.6;
    color: #e0e0e0;
    -webkit-overflow-scrolling: touch;
}

/* Text progress bar */
.mobile-text-progress-bar {
    position: absolute;
    top: 80px;
    left: 16px;
    background: rgba(0, 0, 0, 0.75);
    padding: 6px 12px;
    border-radius: 12px;
    z-index: 40;
    backdrop-filter: blur(4px);
}

.mobile-text-progress {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
}

/* Mobile viewers in progress bar */
.mobile-progress-viewers {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.mobile-progress-viewers .mobile-viewers-divider {
    color: rgba(255, 255, 255, 0.3);
    margin-right: 2px;
}

.mobile-progress-viewers .mobile-viewers-icon {
    font-size: 12px;
}

.mobile-progress-viewers .mobile-viewers-count {
    color: #ffd700;
    font-size: 13px;
    font-weight: 700;
}

.mobile-progress-viewers .mobile-viewers-label {
    color: #ffd700;
    font-size: 11px;
    font-weight: 600;
}

/* === Controls (always on top) === */
.mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 60;
}

/* Mobile Stage Buttons (unified size) */
.mobile-stage-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 56px;
    height: 56px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mobile-stage-btn-icon {
    font-size: 22px;
    line-height: 1;
}

.mobile-stage-btn-text {
    font-size: 9px;
    font-weight: 500;
    color: #fff;
}

.mobile-stage-btn:active {
    transform: scale(0.95);
}

/* Mic ON state (green) — initial + active class */
.mobile-stage-btn--mic-on,
.mobile-stage-btn.active {
    background: #27ae60;
}

.mobile-stage-btn--mic-on:active,
.mobile-stage-btn.active:active {
    background: #2ecc71;
}

/* Mic muted state (red) — overrides green */
.mobile-stage-btn.muted {
    background: #c0392b;
}

.mobile-stage-btn--red {
    background: #c0392b;
}

.mobile-stage-btn--red:active {
    background: #a33;
}

.mobile-stage-btn--green {
    background: #27ae60;
}

.mobile-stage-btn--green:active {
    background: #2ecc71;
}

/* Legacy mobile-control-btn (keep for compatibility) */
.mobile-control-btn {
    width: 56px;
    height: 56px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mobile-control-btn:active {
    transform: scale(0.95);
}

.mobile-control-btn.muted {
    background: #c0392b;
}

.mobile-control-btn.active {
    background: #27ae60;
}

.mobile-control-btn--danger {
    background: #c0392b;
}

.mobile-control-btn--danger:active {
    background: #a33;
}

/* === Leave Door Button (mobile) === */
.mobile-controls .leave-door-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.mobile-controls .leave-door-btn .leave-door-icon {
    font-size: 22px;
    transition: filter 0.3s ease;
}

.mobile-controls .leave-door-btn .leave-door-text {
    font-size: 9px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.mobile-controls .leave-door-btn .leave-door-confirm {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Red state (initial) */
.mobile-controls .leave-door-btn--red {
    background: #c0392b;
}

.mobile-controls .leave-door-btn--red:active {
    background: #a33;
}

.mobile-controls .leave-door-btn--red .leave-door-icon {
    filter: hue-rotate(90deg) saturate(1.5);
}

.mobile-controls .leave-door-btn--red .leave-door-text {
    color: #fff;
}

/* Green state (confirmation) */
.mobile-controls .leave-door-btn--green {
    background: #27ae60;
}

.mobile-controls .leave-door-btn--green:active {
    background: #219a52;
}

.mobile-controls .leave-door-btn--green .leave-door-icon {
    filter: hue-rotate(90deg) saturate(1.5);
}

.mobile-controls .leave-door-btn--green .leave-door-text {
    color: #fff;
}

.mobile-controls .leave-door-btn--green .leave-door-confirm {
    color: #4ade80;
    opacity: 1;
}

/* === Viewers Badge (mobile) === */
.mobile-viewers-badge {
    position: absolute;
    top: 80px;
    right: 16px;
    background: rgba(0, 0, 0, 0.75);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: white;
    z-index: 40;
    backdrop-filter: blur(4px);
}

.mobile-viewers-badge #mobile-viewers-count {
    color: var(--accent-gold, #d4af37);
    font-weight: 600;
}

/* === Mobile Settings Tab === */
#mobile-tab-settings {
    padding: 16px;
    overflow-y: auto;
    background: #0d0d15;
}

.mobile-settings-section {
    margin-bottom: 24px;
}

.mobile-settings-section h4 {
    color: var(--accent-gold, #d4af37);
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-viewers-list {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    min-height: 60px;
}

.mobile-empty-state {
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    text-align: center;
    padding: 16px;
}

.mobile-settings-btn {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-settings-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.mobile-settings-btn--small {
    width: auto;
    padding: 8px 16px;
}

.mobile-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-size: 14px;
}

.mobile-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
}

.mobile-toggle.active {
    background: var(--accent-gold, #d4af37);
    color: #000;
}

.mobile-toggle.active .toggle-label::before {
    content: '✓ ';
}

.mobile-fontsize-controls {
    display: flex;
    gap: 8px;
}

.mobile-fontsize-btn {
    width: 40px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.mobile-fontsize-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.mobile-range {
    width: 120px;
    accent-color: var(--accent-gold, #d4af37);
}

