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

:root {
    --primary: #ff0000;
    --primary-dark: #cc0000;
    --bg-dark: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-input: #2a2a2a;
    --text: #ffffff;
    --text-muted: #aaaaaa;
    --border: #3a3a3a;
    --success: #00c853;
    --danger: #ff1744;
}

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

.app {
    min-height: 100vh;
}

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

.screen.active {
    display: flex;
}

/* Start Screen */
#start-screen {
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
}

.start-container {
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.logo {
    margin-bottom: 3rem;
}

.logo i {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.logo h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, var(--primary), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo p {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Start Options */
.start-options {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: center;
    margin-bottom: 3rem;
}

.option-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

.option-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(255, 0, 0, 0.1);
}

.option-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.option-icon i {
    font-size: 2.5rem;
}

.option-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.option-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.divider {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.divider span {
    background: var(--bg-dark);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

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

input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 8px 20px rgba(255, 0, 0, 0.3);
}

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

.btn-secondary:hover {
    background: #3a3a3a;
}

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

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

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1rem;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--text);
}

/* Features */
.features {
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
}

.feature i {
    color: var(--primary);
}

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

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

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo-small {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.logo-small i {
    color: var(--primary);
    font-size: 1.5rem;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.room-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.room-id {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.header-center {
    flex: 1;
    display: flex;
    padding: 0 1rem;
    min-width: 0;
}

.host-controls {
    width: 100%;
}

.video-url-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.header-url-input {
    flex: 1;
    padding: 0.5rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.header-url-input:focus {
    border-color: var(--primary);
}

.header-url-input::placeholder {
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: var(--text-muted);
}

.user-badge i {
    color: var(--primary);
}

/* Room Content */
.room-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    flex: 1;
    overflow: hidden;
}

.video-section {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.video-container {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

#player {
    width: 100%;
    height: 100%;
}

.player-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 1rem;
}

.player-placeholder i {
    font-size: 4rem;
    color: var(--primary);
}

.player-placeholder.hidden {
    display: none;
}

.video-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 10px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--success);
    font-size: 0.9rem;
}

.sync-status i {
    animation: spin 2s linear infinite;
}

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

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

/* Sidebar */
.sidebar {
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.users-panel {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.users-panel h3,
.chat-panel h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.users-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
}

.users-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.users-list li.host {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.2);
}

.users-list li.you {
    background: var(--bg-input);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.user-name {
    flex: 1;
}

.host-badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.you-badge {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-message.own {
    align-items: flex-end;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.chat-message.own .chat-message-header {
    flex-direction: row-reverse;
}

.chat-author {
    font-weight: 600;
    color: var(--primary);
}

.chat-timestamp {
    color: var(--text-muted);
}

.chat-bubble {
    background: var(--bg-input);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border-top-left-radius: 4px;
    max-width: 85%;
    word-break: break-word;
}

.chat-message.own .chat-bubble {
    background: var(--primary);
    border-top-left-radius: 12px;
    border-top-right-radius: 4px;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
}

.chat-input-area button {
    padding: 0.75rem 1rem;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
}

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

.modal-content input {
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
}

.modal-buttons button {
    flex: 1;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Responsive */
@media (max-width: 1024px) {
    .room-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 300px;
    }

    .sidebar {
        border-left: none;
        border-top: 1px solid var(--border);
        flex-direction: row;
    }

    .users-panel {
        border-bottom: none;
        border-right: 1px solid var(--border);
        width: 200px;
    }

    .chat-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .start-options {
        grid-template-columns: 1fr;
    }

    .divider {
        flex-direction: row;
    }

    .features {
        flex-direction: column;
        gap: 1rem;
    }

    .room-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .header-left,
    .header-center,
    .header-right {
        flex-wrap: wrap;
        justify-content: center;
    }

    .video-url-bar {
        max-width: 100%;
    }

    .room-content {
        grid-template-rows: auto 250px;
    }

    .sidebar {
        flex-direction: column;
    }

    .users-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .video-section {
        padding: 1rem;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

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