* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --bg-hover: #252547;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --border-color: #2a2a4a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* Welcome Screen */
#welcome-screen {
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a3e 100%);
    overflow-y: auto;
}

.welcome-container {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: var(--shadow);
    max-width: 800px;
    width: 100%;
    overflow: hidden;
}

.welcome-header {
    text-align: center;
    padding: 2rem 2rem 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
}

.welcome-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
}

.username-section {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="text"]::placeholder {
    color: #666;
}

.error {
    color: var(--danger-color);
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--primary-color);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
}

.tab-content {
    display: none;
    padding: 1.5rem;
}

.tab-content.active {
    display: block;
}

/* Rooms List */
.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.room-category {
    background: var(--bg-input);
    border-radius: 12px;
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(99, 102, 241, 0.1);
    cursor: pointer;
    transition: background 0.2s;
}

.category-header:hover {
    background: rgba(99, 102, 241, 0.15);
}

.category-icon {
    font-size: 1.5rem;
}

.category-name {
    font-weight: 600;
    flex: 1;
}

.category-toggle {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.room-category.collapsed .category-toggle {
    transform: rotate(-90deg);
}

.room-category.collapsed .category-rooms {
    display: none;
}

.category-rooms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
}

.room-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.room-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.room-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.room-card-icon {
    font-size: 1.25rem;
}

.room-card-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.room-card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.room-card-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.room-card-status .online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

.room-card-status.full .online-dot {
    background: var(--danger-color);
}

/* Private Section */
.private-section {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

/* Buttons */
.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    font-size: 1.25rem;
}

.btn-icon:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.separator {
    color: var(--text-secondary);
    margin: 1.25rem 0;
    position: relative;
}

.separator::before,
.separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.separator::before {
    left: 0;
}

.separator::after {
    right: 0;
}

.join-section {
    display: flex;
    gap: 0.75rem;
}

.join-section input {
    flex: 1;
    text-transform: uppercase;
    text-align: center;
    font-weight: 600;
    letter-spacing: 2px;
}

/* Room Screen */
#room-screen {
    flex-direction: column;
    height: 100vh;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
    flex-wrap: wrap;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.room-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.room-title h2 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.room-code-badge {
    font-family: monospace;
    font-size: 0.75rem;
    background: var(--bg-input);
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    color: var(--text-secondary);
}

.room-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.participants-badge {
    background: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.participants-badge.full {
    background: var(--danger-color);
}

#username-display {
    color: var(--text-secondary);
}

/* Videos Grid */
.room-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 400px));
    gap: 1rem;
    flex: 1;
    justify-content: center;
}

.video-container {
    position: relative;
    background: var(--bg-card);
    border-radius: 15px;
    overflow: hidden;
    aspect-ratio: 4/3;
    box-shadow: var(--shadow);
    max-width: 400px;
}

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

.video-container.local video {
    transform: scaleX(-1);
}

.video-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-label .name {
    font-weight: 600;
    font-size: 0.875rem;
}

.video-label .you {
    font-size: 0.75rem;
    background: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
}

.video-status {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.video-status .indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.video-status .indicator.off {
    background: var(--danger-color);
}

/* Report Button */
.video-actions {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
}

.btn-report {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
}

.video-container:hover .btn-report {
    opacity: 1;
}

.btn-report:hover {
    background: var(--danger-color);
    color: white;
}

/* Waiting Message */
.waiting-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.waiting-message p:first-child {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.share-hint strong {
    color: var(--primary-color);
    font-family: monospace;
    letter-spacing: 2px;
}

/* Room Controls */
.room-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.btn-control {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s;
}

.btn-control:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.btn-control.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-control:not(.active) {
    background: var(--danger-color);
    border-color: var(--danger-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 15px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.modal-content .hint {
    font-size: 0.875rem;
    background: var(--bg-input);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

.ban-info, .kick-info {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.ban-info {
    border-left: 4px solid var(--danger-color);
}

.kick-info {
    border-left: 4px solid var(--warning-color);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--success-color);
}

.toast.error {
    border-color: var(--danger-color);
}

.toast.warning {
    border-color: var(--warning-color);
}

/* Responsive */
@media (max-width: 768px) {
    .welcome-header {
        padding: 1.5rem 1.5rem 1rem;
    }

    .welcome-header h1 {
        font-size: 2rem;
    }

    .username-section, .tab-content {
        padding: 1rem;
    }

    .category-rooms {
        grid-template-columns: 1fr;
    }

    .room-header {
        flex-direction: column;
        align-items: stretch;
    }

    .room-info, .room-meta {
        justify-content: space-between;
    }

    .videos-grid {
        grid-template-columns: 1fr;
    }

    .video-container {
        aspect-ratio: 16/9;
    }

    .btn-report {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .room-title h2 {
        font-size: 0.875rem;
    }

    .btn-small {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }
}

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

/* Connecting state */
.connecting {
    position: relative;
}

.connecting::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}
