/* Fantasy-themed viewer styles based on wireframe */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: url('public/auth.jpg') center/cover no-repeat fixed, rgba(0, 0, 0, 0.4);
    min-height: 100vh;
    width: 100vw;
    padding: 0 20px;
    margin: 0;
    overflow-x: hidden;
}

.container {
    width: calc(100vw - 40px);
    height: 100vh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
}

.header {
  text-align: center;
  font-size: 20px;
  line-height: 1.15;
  font-weight: bold;
  background: linear-gradient(180deg, #f3deb1 0%, #bb8b34 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 12px rgba(252, 215, 136, 0.4);
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

/* Login Section Styles */
.login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 20px;
}

/* Ensure viewer login centers exactly in viewport */
#loginSection {
    min-height: 100vh;
}

.login-form {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #bb8b34;
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 0 30px rgba(187, 139, 52, 0.3);
}

.login-form h2 {
    color: #f3deb1;
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.8em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #f3deb1;
    margin-bottom: 8px;
    font-weight: bold;
}

.login-form input[type="text"],
.login-form input[type="password"],
.login-form input[type="email"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #bb8b34;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #f3deb1;
    font-size: 16px;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus,
.login-form input[type="email"]:focus {
    outline: none;
    border-color: #f3deb1;
    box-shadow: 0 0 10px rgba(243, 222, 177, 0.3);
}

.error-message {
    color: #ff6b6b;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 5px;
    border: 1px solid #ff6b6b;
}

.sample-accounts {
    margin-top: 30px;
    border-top: 1px solid #bb8b34;
    padding-top: 20px;
}

.sample-accounts h3 {
    color: #f3deb1;
    margin-bottom: 15px;
    text-align: center;
}

.accounts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.account-card {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(187, 139, 52, 0.2);
    border: 1px solid #bb8b34;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.account-card:hover {
    background: rgba(187, 139, 52, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(187, 139, 52, 0.3);
}

.account-card .avatar {
    font-size: 24px;
    margin-right: 12px;
}

.account-card .account-info {
    flex: 1;
}

.account-card .account-info strong {
    display: block;
    color: #f3deb1;
    margin-bottom: 2px;
}

.account-card .account-info small {
    color: #bb8b34;
    font-size: 0.9em;
}

.more-accounts {
    text-align: center;
    color: #bb8b34;
    font-style: italic;
    margin-top: 10px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(187, 139, 52, 0.3), rgba(187, 139, 52, 0.5));
    border: 2px solid #bb8b34;
    color: #f3deb1;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(187, 139, 52, 0.5), rgba(187, 139, 52, 0.7));
    box-shadow: 0 0 15px rgba(187, 139, 52, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(187, 139, 52, 0.3);
    color: #f3deb1;
    border: 2px solid #bb8b34;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(187, 139, 52, 0.5);
    transform: translateY(-2px);
}

.accounts-grid {
    display: grid;
    gap: 15px;
}

.account-card {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.account-card:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-2px);
}

.account-card .avatar {
    font-size: 2rem;
    margin-right: 15px;
}

.account-info strong {
    display: block;
    color: #333;
    margin-bottom: 4px;
}

.account-info small {
    color: #666;
    font-family: 'Courier New', monospace;
}

/* Logout button positioned in top right corner */
.logout-top-right {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    background: #6c757d;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.logout-top-right:hover {
    background: #5a6268;
}

.fantasy-container {
    max-width: 95%;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Header styling */
.fantasy-header {
    text-align: center;
    font-size: 30px;
    line-height: 1.15;
    font-weight: bold;
    background: linear-gradient(180deg, #ffffff 0%, #dbdbdb 100%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 12px rgba(252, 215, 136, 0.4);
}

.fantasy-title {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(180deg, #f3deb1 0%, #bb8b34 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2rem;
    color: #b8c5d6;
    font-style: italic;
}

/* Main layout */
.main-layout {
    display: grid;
    grid-template-columns: 75% 25%;
    gap: 30px;
    align-items: stretch;
    height: 100vh;
}

/* Main content area */
.main-content {
    border-radius: 15px;
}

/* Status indicator */
.status-indicator {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 100, 200, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(0, 150, 255, 0.3);
}

.status-text {
    font-size: 1.1rem;
    color: #87ceeb;
}

/* Story viewer (broadcast section) */
.story-viewer {
    margin-bottom: 25px;
}

.story-frame {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#broadcastVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background-color: #000;
    z-index: 1;
}

.story-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #ffd700;
    font-size: 1.3rem;
    z-index: 2;
    pointer-events: none;
}

.loading-text {
    animation: pulse 2s infinite;
}

/* Notifications Overlay */
.notifications-container {
    position: fixed;
    top: 55px; /* tighter margin below logout button without overlap */
    right: 20px; /* align with logout button right margin */
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1002;
    pointer-events: none; /* allow underlying livestream to be interactive */
}

.notifications-header {
    align-self: flex-end;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid #bb8b34;
    color: #f3deb1;
    padding: 3px 5px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto; /* allow clicking the toggle */
}

.mute-toggle-label {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    user-select: none;
}

.notification {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #bb8b34;
    color: #f3deb1;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto; /* allow interaction with the notification itself */
}

.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notification-title {
    font-weight: 700;
    font-size: 14px;
    color: #f3deb1;
}

.notification-close {
    background: transparent;
    border: none;
    color: #f3deb1;
    font-size: 16px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}

.notification-body {
    font-size: 13px;
    color: #e7e1cf;
}

.notification-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.notification-timer {
    font-size: 12px;
    color: #bb8b34;
}

.notification-link {
    color: #ffd36b;
    text-decoration: underline;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Interaction panel (join section) */
.interaction-panel {
    margin-bottom: 25px;
}

.join-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.fantasy-input {
    padding: 12px 20px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-size: 1rem;
    min-width: 250px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.fantasy-input:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.fantasy-input::placeholder {
    color: #b8c5d6;
}

/* Fantasy buttons */
.fantasy-button {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.fantasy-button.primary {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.fantasy-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.fantasy-button.warning {
    background: linear-gradient(45deg, #ff6b35, #ff8c42);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.fantasy-button.danger {
    background: linear-gradient(45deg, #dc143c, #ff1744);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(220, 20, 60, 0.3);
}

.fantasy-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Queue panel */
.queue-panel {
    text-align: center;
    padding: 30px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 15px;
    border: 2px solid rgba(187, 139, 52, 0.3);
    margin-bottom: 25px;
}

.queue-content h3 {
    color: #f3deb1;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.queue-content p {
    color: white;
    margin: 15px 0;
}

.queue-position {
    font-size: 1.3rem;
    color: #ffd700;
    margin: 15px 0;
    font-weight: bold;
}

.mystical-loading {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(187, 139, 52, 0.3);
    border-top: 3px solid #f3deb1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Private audience (video section) */
.private-audience {
    display: none;
}

.audience-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(50, 205, 50, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(50, 205, 50, 0.3);
}

.audience-info strong {
    color: #98fb98;
    font-size: 1.2rem;
}

/* 1-on-1 Video Session Styles */
.video-chamber {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

/* Video Section for 1-on-1 (Modal Overlay) */
#videoSection {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1000px;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.95);
    padding: 20px;
    border: 2px solid #ffd700;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    display: none; /* Hidden by default */
}

#videoSection.fullscreen-meeting {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 100%;
    max-width: none;
    border: none;
    border-radius: 0;
    padding: 0;
    background: #000;
}

#videoSection.fullscreen-meeting .video-container {
    height: 100%;
    border-radius: 0;
}

#videoSection.fullscreen-meeting .audience-info {
    display: none;
}

#videoSection.fullscreen-meeting .video-chamber {
    height: 100%;
    width: 100%;
}

#videoSection.fullscreen-meeting .audience-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2001;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 30px;
    border-radius: 30px;
    backdrop-filter: blur(5px);
    width: auto;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    min-height: 500px;
    width: 100%;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    min-height: 500px;
}

#localVideo {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    border-radius: 10px;
    object-fit: cover;
    z-index: 10;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.video-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    z-index: 11;
    backdrop-filter: blur(5px);
}

.audience-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Book collection sidebar */
.book-collection {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    padding-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    height: 100vh;
    max-height: 100vh;
}

.collection-section {
    margin-bottom: 30px;
    width: 100%;
    overflow: visible;
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.collection-header h3 {
    color: #ffffff;
    font-size: 1.2rem;
    margin: 0;
}

.section-nav {
    display: flex;
    gap: 8px;
}

.nav-arrow {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: #e0e6ed;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-arrow:hover {
    background: linear-gradient(135deg, #5a6578 0%, #3d4758 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.nav-arrow:active {
    transform: translateY(0);
}

.nav-arrow.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

.book-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 5px;
    scroll-behavior: smooth;
    position: relative;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    width: max-content;
    box-sizing: border-box;
    flex-wrap: nowrap;
}

.book-row::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Author grid */
.author-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.author-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease;
}

.author-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.15);
}

.author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, #4169e1, #87ceeb);
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.author-name {
    font-size: 0.9rem;
    color: #e6e6fa;
}

/* Book grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.book-card {
    flex: 0 0 100px;
    width: 100px;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.book-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.book-card .book-cover {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-sizing: border-box;
}

.book-card .author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.book-card .author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card .author-name {
    font-size: 0.75rem;
    color: #ffffff;
    text-align: center;
    margin-bottom: 4px;
    font-weight: 500;
    line-height: 1.2;
}

.book-card .author-specialty {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    line-height: 1.2;
}

.book-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    padding: 10px;
    position: relative;
    overflow: hidden;
}

.book-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 50%, 
        rgba(255, 255, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.book-card:hover .book-cover::before {
    opacity: 1;
}

#featured-authors {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 5px;
    scroll-behavior: smooth;
    position: relative;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    width: max-content;
    box-sizing: border-box;
    flex-wrap: nowrap;
}

#featured-authors::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}



.book-title {
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7);
    line-height: 1.2;
    z-index: 1;
    position: relative;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .book-collection {
        max-height: none;
        order: -1;
    }
    
    .fantasy-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .fantasy-container {
        padding: 15px;
    }
    
    .fantasy-title {
        font-size: 2rem;
    }
    
    .join-controls {
        flex-direction: column;
    }
    
    .fantasy-input {
        min-width: 100%;
    }
    
    .book-grid,
    .author-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .audience-controls {
        flex-direction: column;
    }
    
    .viewer-mirror {
        width: 120px;
        height: 80px;
        bottom: 10px;
        right: 10px;
    }
}

/* Custom scrollbar for book collection */
.book-collection::-webkit-scrollbar {
    width: 6px;
}

.book-collection::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.book-collection::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 3px;
}

.book-collection::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

/* Broadcast Section Styles */
.broadcast-section {
    margin-bottom: 30px;
    text-align: center;
}

.broadcast-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e9ecef;
}

.broadcast-container h3 {
    color: #dc3545;
    margin-bottom: 15px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
    max-width: 100%;
    margin: 0 auto;
}

#broadcastVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1.1em;
    pointer-events: none;
}

.join-section {
    text-align: center;
    margin-bottom: 30px;
}

.name-input {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

input[type="text"] {
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    min-width: 200px;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(187, 139, 52, 0.3), rgba(187, 139, 52, 0.5));
    border: 2px solid #bb8b34;
    color: #f3deb1;
    font-weight: bold;
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(187, 139, 52, 0.5), rgba(187, 139, 52, 0.7));
    box-shadow: 0 0 15px rgba(187, 139, 52, 0.4);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(240, 147, 251, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.status {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
    text-align: center;
}

.status.connected {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.disconnected {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status.connecting {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status.waiting {
    background: #cce5ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

.queue-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.queue-position {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
}

.video-section {
    display: none;
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

video {
    width: 100%;
    height: auto;
    display: block;
}

.video-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

.story-frame {
    position: relative;
}

.main-video-frame {
    position: relative;
}

.viewer-mirror {
    position: relative;
    width: 100%;
    height: auto;
    display: block;
}

.floating-preview {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    border: 3px solid #667eea;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 10;
    background: #000;
}

.floating-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.floating-preview .video-overlay {
    top: 5px;
    left: 5px;
    font-size: 0.8em;
    padding: 4px 8px;
}

.connection-info {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    color: #2e7d32;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.instructions {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.instructions h3 {
    color: #333;
    margin-bottom: 15px;
}

.instructions ul {
    color: #666;
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .name-input {
        flex-direction: column;
    }
    
    input[type="text"] {
        min-width: 100%;
    }
    
    button {
        width: 100%;
    }
}

/* Authors selection styles */


.authors-list {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 15px;
}

/* New grid layout for author buttons */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    padding: 10px 0;
}

.author-button {
    display: flex;
    align-items: center;
    padding: 20px;
    background: rgba(187, 139, 52, 0.25); /* unified gold tone */
    border: 2px solid rgba(255, 215, 0, 0.35);
    border-radius: 12px;
    backdrop-filter: blur(5px);
    cursor: pointer;
    transition: all 0.3s ease;
    color: inherit;
    text-align: left;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.author-button:hover {
    background: rgba(187, 139, 52, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(187, 139, 52, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
}

.author-button:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(139, 69, 19, 0.3);
}

.author-avatar {
    font-size: 3rem;
    margin-right: 20px;
    text-shadow: 0 0 10px rgba(243, 222, 177, 0.5);
    min-width: 60px;
    text-align: center;
}

.author-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.author-name {
    color: #f3deb1;
    font-size: 1.3rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(243, 222, 177, 0.3);
}

.author-specialty {
    color: #d4af37;
    font-size: 1rem;
    font-style: italic;
    opacity: 0.9;
}

.author-status {
    font-size: 0.9rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    width: fit-content;
}

.author-status.available {
    color: #90EE90;
    background: rgba(144, 238, 144, 0.2);
    border: 1px solid #90EE90;
}

.author-status.queue {
    color: #FFD700;
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid #FFD700;
}

.author-status.busy {
    color: #FF6B6B;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid #FF6B6B;
}

.no-authors {
    text-align: center;
    padding: 40px 20px;
    color: #ccc;
    font-style: italic;
}

/* Legacy styles - keeping for backward compatibility */
.author-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #8B4513;
    border-radius: 8px;
    backdrop-filter: blur(3px);
    transition: all 0.3s ease;
}

.author-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.author-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.author-info strong {
    color: #f3deb1;
    font-size: 1.1rem;
}

.queue-info {
    color: #ccc;
    font-size: 0.9rem;
    font-style: italic;
}

.join-author-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.join-author-btn:hover {
    background: linear-gradient(135deg, #A0522D, #CD853F);
    transform: scale(1.05);
}

.loading-authors {
    text-align: center;
    padding: 40px;
    color: #f3deb1;
}

.loading-authors p {
    margin-top: 15px;
    font-style: italic;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: #f5f1e8;
    border-radius: 20px;
    padding: 0;
    max-width: 85vw;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    border: 3px solid #8B4513;
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(139, 69, 19, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(160, 82, 45, 0.1) 0%, transparent 50%);
    pointer-events: none;
    border-radius: 17px;
}

.modal-header {
    background: transparent;
    padding: 25px 30px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #8B4513;
    position: relative;
    z-index: 1;
}

.modal-header h2 {
    color: #5d4037;
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
    text-align: center;
    flex: 1;
    font-family: 'Georgia', serif;
}

.close-button {
    background: none;
    border: 2px solid #8B4513;
    color: #8B4513;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    font-weight: bold;
}

.close-button:hover {
    background: #8B4513;
    color: #f5f1e8;
    transform: scale(1.1);
}

.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

/* Author Profiles Grid */
.author-profiles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.author-profile-tile {
    background: #f5f1e8;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 2px solid #8B4513;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.author-profile-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(139, 69, 19, 0.2);
    border-color: #A0522D;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    border-radius: 50%;
    overflow: hidden;
    background: #007BFF;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5em;
    font-weight: bold;
    border: none;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.emoji-avatar {
    font-size: 2em;
    line-height: 1;
}

.profile-info {
    margin-bottom: 15px;
    flex-grow: 1;
}

.profile-name {
    color: #5d4037;
    font-size: 1.1em;
    margin: 0 0 8px 0;
    font-weight: 600;
    font-family: 'Georgia', serif;
}

.profile-specialty {
    color: #8B4513;
    font-size: 0.85em;
    margin: 0;
    font-style: italic;
    line-height: 1.3;
}

.select-author-btn {
    background: #f1d221ff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    font-size: 0.9em;
}

.select-author-btn:hover {
    background: #b3a100ff;
    transform: scale(1.02);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .author-profiles-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    .viewer-mirror {
        width: 180px;
        height: 108px;
    }
    
    #localVideo {
        width: 180px;
        height: 135px;
    }
}

@media (max-width: 768px) {
    .author-profiles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .modal-content {
        max-width: 95vw;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .viewer-mirror {
        width: 160px;
        height: 96px;
        bottom: 15px;
        right: 15px;
    }
    
    #localVideo {
        width: 160px;
        height: 120px;
        bottom: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .author-profiles-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .viewer-mirror {
        width: 140px;
        height: 84px;
        bottom: 10px;
        right: 10px;
    }
    
    #localVideo {
        width: 140px;
        height: 105px;
        bottom: 10px;
        right: 10px;
    }
    
    .modal-header h2 {
        font-size: 1.2em;
    }
}

/* Success Message Styles */
.success-message {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid rgba(40, 167, 69, 0.5);
    color: #28a745;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    text-align: center;
    font-size: 14px;
}

/* Login Link Styles */
.login-link {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 215, 0, 0.3);
}

.login-link p {
    color: #f3deb1;
    margin: 0;
}

.login-link a {
    color: rgba(255, 215, 0, 0.8);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

.login-link a:hover {
    color: #f3deb1;
    text-decoration: underline;
}

/* Register Link Styles */
.register-link {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 215, 0, 0.2);
}

.register-link p {
    color: #f3deb1;
    margin: 0;
    font-size: 14px;
}

.register-btn {
    color: rgba(255, 215, 0, 0.9) !important;
    text-decoration: none;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: inline-block;
    margin-left: 5px;
}

.register-btn:hover {
    color: #f3deb1 !important;
    background: rgba(255, 215, 0, 0.1);
    text-decoration: none;
    transform: translateY(-1px);
}
.viewer-chat-interface {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-height: 500px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 15px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    padding: 20px;
}

.viewer-chat-interface .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 215, 0, 0.1);
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 13px 13px 0 0;
}

.viewer-chat-interface .chat-header h3 {
    color: #f3deb1;
    font-size: 16px;
    margin: 0;
}

.chat-header-buttons {
    display: flex;
    gap: 5px;
}

.minimize-chat-btn {
    background: none;
    border: none;
    color: #f3deb1;
    font-size: 14px;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    font-weight: bold;
}

.minimize-chat-btn:hover {
    background: rgba(255, 215, 0, 0.2);
}

.close-chat-btn {
    background: none;
    border: none;
    color: #f3deb1;
    font-size: 16px;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.close-chat-btn:hover {
    background: rgba(255, 215, 0, 0.2);
}

.viewer-chat-interface .chat-author-selector {
    padding: 0 0 15px 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    background: transparent;
}

.viewer-chat-interface .chat-author-selector label {
    display: block;
    color: #f3deb1;
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.viewer-chat-interface .author-select-dropdown {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #f3deb1;
    font-size: 0.9rem;
    cursor: pointer;
}

.viewer-chat-interface .author-select-dropdown:focus {
    outline: none;
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.viewer-chat-interface .chat-selected-author {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.viewer-chat-interface .selected-author-indicator {
    color: #f3deb1;
    font-size: 0.85rem;
}

.viewer-chat-interface .selected-author-indicator strong {
    color: rgba(255, 215, 0, 0.8);
}

.viewer-chat-interface .chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid rgba(187, 139, 52, 0.3);
    height: 200px;
}

.viewer-chat-interface .chat-placeholder {
    color: rgba(243, 222, 177, 0.6);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.viewer-chat-interface .chat-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    color: #f3deb1 !important;
}

.viewer-chat-interface .chat-message.sent {
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.3);
    margin-left: auto;
    text-align: right;
}

.viewer-chat-interface .chat-message.received {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-right: auto;
}

.viewer-chat-interface .chat-message .sender {
    font-size: 0.85em;
    font-weight: bold;
    margin-bottom: 4px;
    opacity: 0.8;
}

.viewer-chat-interface .chat-message.sent .sender {
    color: #f3deb1;
}

.viewer-chat-interface .chat-message.received .sender {
    color: #87ceeb;
}

.viewer-chat-interface .chat-message .content {
    color: #f3deb1 !important;
    line-height: 1.4;
    margin: 2px 0;
}

.viewer-chat-interface .chat-message .timestamp {
    font-size: 0.75em;
    opacity: 0.6;
    font-style: italic;
    margin-top: 4px;
}

.viewer-chat-interface .chat-input-container {
    padding: 0;
    background: transparent;
    border-top: none;
    border-radius: 0;
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: flex-end;
}

.viewer-chat-interface #viewerChatInput {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    color: #f3deb1;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 40px;
    flex: 1;
}

.viewer-chat-interface #viewerChatInput::placeholder {
    color: rgba(243, 222, 177, 0.5);
}

.viewer-chat-interface #viewerChatInput:focus {
    outline: none;
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.viewer-chat-interface .send-chat-btn {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(187, 139, 52, 0.3));
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 8px;
    padding: 10px 16px;
    color: #f3deb1;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    min-width: 60px;
}

.viewer-chat-interface .send-chat-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.4), rgba(187, 139, 52, 0.4));
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.viewer-chat-interface .send-chat-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Storyteller buttons spacing to prevent overlap */
.select-author-btn,
.connect-author-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 1px 2px;
    gap: 1px;
}

/* Unified book collection card and cover theme */
.book-row .book-cover {
  background: linear-gradient(135deg, rgba(187, 139, 52, 0.35), rgba(255, 215, 0, 0.25)) !important;
}

.book-row .book-card {
  background: rgba(250, 234, 199, 0.5);
  border: 1px solid rgba(187, 139, 52, 0.35);
}

.book-row .book-title {
  color: #ffffff;
}

/* Avatar images in featured authors and modal */
.author-avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  display: block;
  margin: 10px auto 8px;
  object-fit: cover;
}

.profile-avatar-img {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: block;
  margin: 8px auto 10px;
  object-fit: cover;
}