body {
    font-family: Arial, sans-serif;
    background: #121212;
    color: #e6e9ee;
    margin: 0;
    padding: 20px;
    text-align: center;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 1.2rem;
    color: #8ab4ff;
}

#controls {
    margin: 20px auto;
    max-width: 800px;
}

#controls label {
    display: block;
    margin-bottom: 10px;
    text-align: left;
    color: #d6deea;
}

#controls input {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    margin-bottom: 12px;
    border: 1px solid #3a4a5a;
    border-radius: 6px;
    font-size: 1rem;
    background: #11161d;
    color: #e6e9ee;
}

button {
    display: block;
    width: 100%;
    margin: 10px auto;
    padding: 10px 15px;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

button:hover {
    background: #1d4ed8;
}

#status {
    margin-top: 15px;
    padding: 10px;
    background: #0c2033;
    color: #7dd3fc;
    border-radius: 6px;
    font-size: 0.95rem;
    display: inline-block;
}

.video-container {
    margin-top: 20px;
}

.app-grid {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: flex-start;
    margin-top: 20px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.video-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 560px;
    gap: 12px;
}

.video-wrapper {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    max-width: 560px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* video sizing */
.video-wrapper video {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
}

.chat-panel {
    width: 300px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
    background: #151b23;
    border: 1px solid #2a3442;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: linear-gradient(180deg,#141a23,#151b23);
    border-bottom: 1px solid #263241;
}

.chat-title {
    font-weight: 700;
    color: #dbe8ff;
}

.chat-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #9aa4b2;
}

.chat-messages {
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #0f141b;
    flex: 1 1 auto;
}

.chat-message {
    max-width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    background: #151b23;
    color: #e6e9ee;
    border: 1px solid #263241;
    font-size: 0.9rem;
    line-height: 1.2;
    word-break: break-word;
}

.chat-meta {
    font-size: 0.75rem;
    color: #9aa4b2;
    margin-bottom: 4px;
}

.chat-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #263241;
    background: #151b23;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px;
    border: 1px solid #3a4a5a;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    background: #11161d;
    color: #e6e9ee;
}

.chat-send {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
    max-width: 120px;
    box-sizing: border-box;
}

.chat-panel.collapsed .chat-messages,
.chat-panel.collapsed .chat-input-row {
    display: none;
}

.video-wrapper.hidden {
    display: none;
    background: transparent;
}

.exit-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 1500;
    opacity: 0.85;
    transition: opacity 0.2s ease, background 0.2s ease;
    width: auto;
    max-width: 120px;
    white-space: nowrap;
    display: inline-block;
    text-align: center;
}
.exit-btn:hover {
    opacity: 1;
    background: rgba(220, 38, 38, 1);
}
.exit-btn.hidden {
    display: none;
}

.switchcam-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(11, 151, 140, 0.9);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 1500;
    opacity: 0.85;
    transition: opacity 0.2s ease, background 0.2s ease;
    width: auto;
    max-width: 120px;
    white-space: nowrap;
    display: inline-block;
    text-align: center;
}
.switchcam-btn:hover {
    opacity: 1;
    background: rgb(39, 190, 178);
}

body.stream-active #controls,
body.stream-active h1 {
    display: none !important;
}

body.stream-active {
    background: #000;
    color: white;
}

#goBackBtn {
	padding: 10px 16px;
    max-width: 120px;
	font-size: 16px;
	background: #ff7f50;
	color: white;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	margin: 20px auto 40px;
	display: block;
	transition: background 0.2s ease, transform 0.1s ease;
}

#goBackBtn:hover {
	background: #ff6347;
	transform: scale(1.03);
}

@media (max-width: 768px) {
    .app-grid {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .video-container {
        margin-top: 8px;
        gap: 8px;
        width: 100%;
        flex: 0 0 auto;
    }

    .chat-panel {
        width: calc(100% - 24px);
        max-height: 360px;
        margin: 0;
    }

    .video-wrapper {
        width: calc(100% - 24px);
        height: auto;
        max-width: none;
        margin: 0;
    }

    .video-wrapper video {
        width: 100%;
        height: auto;
        max-height: 70vh;
        object-fit: contain;
    }
}

@media (orientation: portrait) {
    .app-grid {
        flex-direction: column;
        gap: 8px;
    }

    .chat-panel {
        width: calc(100% - 24px);
        max-height: 70vh;
        margin: 0;
    }

    .video-container {
        width: 100%;
        margin: 0;
        flex: 0 0 auto;
    }

    .video-wrapper {
        width: calc(100% - 24px);
        height: auto;
        max-width: none;
        margin: 0;
    }

    .video-wrapper video {
        width: 100%;
        height: auto;
        max-height: 75vh;
        object-fit: contain;
    }
}

.chat-panel.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1100;
    border-radius: 0;
    box-shadow: none;
    background: #0f1116;
}

body.chat-fullscreen-active .video-container,
body.chat-fullscreen-active #controls {
    display: none;
}

.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: #0f1116;
    box-shadow: none;
}
