/* ─── Modern Unified Lobby — Shared Design System ─────────────
   All activity lobbies (AuraQuest, MatchMind, Jigsaw,
   SketchSolve, InsightWall, InteractiveSheet) use this
   unified design for a consistent, modern look.
   ─────────────────────────────────────────────────────────── */

/* ─── Base Overlay ─── */
.lobby-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(145deg, #0b1120 0%, #121d31 50%, #0d1528 100%);
    z-index: 400000;
    color: #fff;
    display: flex;
    flex-direction: column;
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
}

.lobby-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 26px 36px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    gap: 20px;
    min-height: 0;
}

/* ─── Header ─── */
.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.lobby-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.lobby-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.lobby-icon-box::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    border-radius: inherit;
}

.lobby-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin: 0;
    line-height: 1.2;
}

.lobby-subtitle {
    margin: 2px 0 0;
    opacity: 0.4;
    font-size: 0.78rem;
    font-weight: 600;
}

.lobby-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lobby-header-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.5);
}

.lobby-header-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: scale(1.05);
}

.lobby-header-btn.danger {
    background: rgba(239,68,68,0.08);
    color: #ef4444;
    border-color: rgba(239,68,68,0.15);
}

.lobby-header-btn.danger:hover {
    background: rgba(239,68,68,0.18);
}

.lobby-header-btn.music-active {
    color: var(--lobby-accent, #10b981);
}

.lobby-volume-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.03);
    padding: 2px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    height: 34px;
}

.lobby-volume-wrap .lobby-header-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 0.8rem;
    background: transparent;
    border: none;
}

.lobby-volume-slider {
    width: 54px;
    height: 3px;
    cursor: pointer;
    accent-color: var(--lobby-accent, #10b981);
    background: transparent;
}

/* ─── Main Body ─── */
.lobby-body {
    flex: 1;
    display: flex;
    gap: 28px;
    overflow: hidden;
    min-height: 0;
}

/* ─── Left Panel ─── */
.lobby-left {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lobby-card {
    background: rgba(255,255,255,0.03);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.lobby-qr-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 24px 24px;
    text-align: center;
    min-height: 200px;
}

.lobby-instruction-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.35;
    margin-bottom: 4px;
}

.lobby-join-heading {
    font-size: 1.2rem;
    margin: 0 0 2px;
    font-weight: 700;
}

.lobby-join-hint {
    opacity: 0.45;
    font-size: 0.8rem;
    margin: 0 0 20px;
    font-weight: 500;
}

.lobby-join-hint span {
    font-weight: 700;
}

.lobby-qr-box {
    background: #fff;
    padding: 14px;
    border-radius: 18px;
    margin-bottom: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.45);
    min-width: 190px;
    min-height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.lobby-qr-box:hover {
    transform: scale(1.03);
    box-shadow: 0 18px 56px rgba(0,0,0,0.5) !important;
}

.lobby-code-box {
    padding: 16px 24px 18px;
    text-align: center;
    position: relative;
    width: 100%;
}

.lobby-code-label {
    font-size: 0.65rem;
    font-weight: 800;
    opacity: 0.4;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.lobby-code-value {
    font-size: 2.8rem;
    font-weight: 950;
    letter-spacing: 8px;
    line-height: 1;
    color: var(--lobby-accent, #6366f1);
}

.lobby-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.06);
    border: none;
    color: rgba(255,255,255,0.35);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lobby-copy-btn:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

.lobby-url-display {
    margin-top: 12px;
    background: rgba(99,102,241,0.04);
    border-radius: 10px;
    padding: 8px 14px;
    max-width: 100%;
    font-weight: 500;
    opacity: 0.35;
    font-size: 0.68rem;
    word-break: break-all;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ─── Right Panel ─── */
.lobby-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    gap: 16px;
}

/* ─── Controls Bar ─── */
.lobby-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
}

.lobby-count {
    font-size: 0.95rem;
    font-weight: 700;
    opacity: 0.8;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lobby-count-num {
    font-weight: 950;
    font-size: 1.2rem;
    color: var(--lobby-accent, #6366f1);
    min-width: 24px;
    display: inline-block;
    text-align: center;
}

.lobby-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.lobby-btn {
    padding: 10px 22px;
    font-size: 0.82rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Outfit', sans-serif;
    position: relative;
}

.lobby-btn:active {
    transform: scale(0.96);
}

.lobby-btn-start {
    background: linear-gradient(135deg, var(--lobby-accent, #10b981), var(--lobby-accent-dark, #059669));
    color: #fff;
    box-shadow: 0 4px 18px rgba(var(--lobby-accent-rgb, 16,185,129), 0.35);
}

.lobby-btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(var(--lobby-accent-rgb, 16,185,129), 0.45);
}

.lobby-btn-stop {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.15);
    color: #ef4444;
}

.lobby-btn-stop:hover {
    background: rgba(239,68,68,0.15);
}

.lobby-btn-secondary {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    font-size: 0.78rem;
    padding: 10px 18px;
}

.lobby-btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* ─── Student Area ─── */
.lobby-students-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 8px;
    min-height: 0;
}

.lobby-students-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    overflow-y: auto;
    padding: 6px 2px;
}

/* Student tag */
.lobby-student-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    transition: all 0.2s ease;
    animation: lobbyFadeIn 0.3s ease;
    position: relative;
    min-width: 0;
}

.lobby-student-tag:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
    transform: translateY(-1px);
}

.lobby-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.lobby-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

.lobby-badge {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(255,255,255,0.06);
    opacity: 0.7;
}

.lobby-kick-btn {
    background: none;
    border: none;
    color: rgba(239,68,68,0.3);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.65rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0;
}

.lobby-student-tag:hover .lobby-kick-btn {
    opacity: 1;
}

.lobby-kick-btn:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.12);
}

.lobby-alert-btn {
    background: none;
    border: none;
    color: rgba(251,191,36,0.3);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.65rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0;
    margin-left: 2px;
}

.lobby-student-tag:hover .lobby-alert-btn {
    opacity: 1;
}

.lobby-alert-btn:hover {
    color: #fbbf24;
    background: rgba(251,191,36,0.12);
}

.lobby-alert-btn:active {
    color: #f59e0b;
    background: rgba(251,191,36,0.2);
    animation: lobbyAlertPulse 0.3s ease;
}

@keyframes lobbyAlertPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes lobbyFadeIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Absent List ─── */
.lobby-absent-box {
    flex-shrink: 0;
    background: rgba(239,68,68,0.04);
    border: 1px solid rgba(239,68,68,0.1);
    border-radius: 14px;
    padding: 12px 16px;
    max-height: 110px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.lobby-absent-box:empty {
    display: none;
}

/* ─── Settings Bar ─── */
.lobby-settings {
    flex-shrink: 0;
    background: rgba(255,255,255,0.02);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
}

.lobby-settings-inner {
    display: flex;
    align-items: stretch;
}

.lobby-settings-label {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-right: 1px solid rgba(255,255,255,0.04);
    min-width: 120px;
    flex-shrink: 0;
    background: rgba(var(--lobby-accent-rgb, 99,102,241), 0.04);
}

.lobby-settings-icon {
    font-size: 0.9rem;
    color: var(--lobby-accent, #818cf8);
}

.lobby-settings-label-text {
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
}

.lobby-settings-label-desc {
    font-size: 0.58rem;
    opacity: 0.35;
    font-weight: 600;
}

.lobby-settings-controls {
    flex: 1;
    padding: 14px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    align-items: center;
}

.lobby-settings-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    opacity: 0.75;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.lobby-settings-controls label:hover {
    opacity: 1;
}

.lobby-settings-controls input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--lobby-accent, #6366f1);
}

.lobby-settings-controls select {
    background: rgba(255,255,255,0.06);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s;
}

.lobby-settings-controls select:hover {
    border-color: rgba(var(--lobby-accent-rgb, 99,102,241), 0.3);
}

.lobby-settings-controls select option {
    background: #1e293b;
    color: #fff;
}

.lobby-settings-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.06);
    flex-shrink: 0;
}

/* ─── Custom Setting Blocks Inside Settings ─── */
.lobby-settings-block {
    flex-shrink: 0;
    padding: 0;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    overflow: hidden;
}

.lobby-settings-block-inner {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    gap: 12px;
}

/* ─── QR Enlarge Modal ─── */
.lobby-qr-enlarge-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    cursor: pointer;
}

.lobby-qr-enlarge-overlay.show {
    opacity: 1;
}

.lobby-qr-enlarge-box {
    background: #fff;
    padding: 30px;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
    text-align: center;
    animation: lobbyQrZoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90vw;
    max-height: 90vh;
}

.lobby-qr-enlarge-box .qr-enlarge-title {
    color: #0f172a;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 14px;
    letter-spacing: -0.3px;
}

.lobby-qr-enlarge-box .qr-enlarge-code {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 950;
    letter-spacing: 5px;
    margin-top: 6px;
}

.lobby-qr-enlarge-box .qr-enlarge-hint {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-top: 8px;
}

@keyframes lobbyQrZoomIn {
    from { opacity: 0; transform: scale(0.6); }
    to { opacity: 1; transform: scale(1); }
}

/* ─── Floating QR ─── */
.lobby-floating-qr {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200001;
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lobby-floating-qr .floating-qr-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(15,23,42,0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    transition: all 0.2s ease;
}

.lobby-floating-qr .floating-qr-btn:hover {
    background: var(--lobby-accent, #6366f1);
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(var(--lobby-accent-rgb, 99,102,241), 0.4);
}

.lobby-floating-qr .floating-qr-panel {
    display: none;
    background: #fff;
    padding: 12px;
    border-radius: 18px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    margin-right: 12px;
    animation: lobbyQrSlideIn 0.25s ease;
}

.lobby-floating-qr.expanded .floating-qr-panel {
    display: block;
}

.lobby-floating-qr .floating-qr-code-text {
    text-align: center;
    color: #0f172a;
    font-family: 'Outfit', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
}

.lobby-floating-qr .floating-qr-code-val {
    text-align: center;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 950;
    letter-spacing: 3px;
}

@keyframes lobbyQrSlideIn {
    from { opacity: 0; transform: translateX(20px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ─── Scrollbar overrides for lobby ─── */
.lobby-students-grid::-webkit-scrollbar,
.lobby-absent-box::-webkit-scrollbar {
    width: 4px;
}

.lobby-students-grid::-webkit-scrollbar-track,
.lobby-absent-box::-webkit-scrollbar-track {
    background: transparent;
}

.lobby-students-grid::-webkit-scrollbar-thumb,
.lobby-absent-box::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.lobby-students-grid::-webkit-scrollbar-thumb:hover,
.lobby-absent-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* ─── Responsive ─── */
@media (max-width: 960px) {
    .lobby-inner {
        padding: 20px 20px;
    }
    .lobby-body {
        flex-direction: column;
    }
    .lobby-left {
        width: 100%;
        flex-direction: row;
        flex-shrink: 0;
    }
    .lobby-qr-card {
        flex: 1;
        min-height: auto;
        padding: 20px;
    }
    .lobby-code-box {
        padding: 14px 18px;
    }
    .lobby-code-value {
        font-size: 2rem;
        letter-spacing: 5px;
    }
    .lobby-qr-box {
        min-width: 140px;
        min-height: 140px;
        margin-bottom: 14px;
    }
    .lobby-settings-inner {
        flex-direction: column;
    }
    .lobby-settings-label {
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        min-width: auto;
        padding: 12px 18px;
    }
    .lobby-settings-controls {
        padding: 12px 18px;
    }
    .lobby-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 640px) {
    .lobby-left {
        flex-direction: column;
    }
    .lobby-header-left .lobby-title {
        font-size: 1.1rem;
    }
    .lobby-header-actions {
        gap: 4px;
    }
    .lobby-header-btn {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }
    .lobby-volume-wrap {
        padding: 2px 6px;
    }
    .lobby-volume-slider {
        width: 40px;
    }
}
