body, html {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	background-color: #111;
	position: relative;
	font-family: Arial, sans-serif;
	-webkit-user-select: none;
	user-select: none;
}

#stream-video, #buffer-video {
	width: 100%;
	height: 100%;
	object-fit: contain;
	position: absolute;
	top: 0;
	left: 0;
}

#buffer-video {
	opacity: 0;
	pointer-events: none;
	z-index: 1;
}

#stream-video {
	z-index: 2;
}

/* --- SHARED HIDDEN STATE UTILITY --- */
#controls-container.hidden,
.viewer-counter-container.hidden,
#top-right-stop-btn.hidden,
#media-title-display.hidden,
body.hide-top-gradient::before,
body:not(.stream-active)::before {
	opacity: 0;
	pointer-events: none;
}

/* Large Transparent Pause Overlay Styles */
#pause-overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 90px;
	height: 90px;
	background: rgba(0, 0, 0, 0.6);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 15;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
	box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#pause-overlay.visible {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

#pause-overlay svg {
	fill: white;
	width: 48px;
	height: 48px;
}

#controls-container {
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 80px;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
	display: flex;
	align-items: flex-end;
	padding: 15px 20px;
	box-sizing: border-box;
	z-index: 20;
	opacity: 1;
	transition: opacity 0.4s ease;
}

.control-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
}

.control-left {
	display: flex;
	align-items: center;
	gap: 15px;
}

.btn {
	background: none;
	border: none;
	color: white;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px;
	margin: -12px;
	transition: opacity 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.btn:active {
	transform: scale(0.92);
}

.btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	transform: none;
}

.volume-group {
	display: flex;
	align-items: center;
	gap: 8px;
	color: white;
}

.volume-slider {
	appearance: none;
	width: 90px;
	height: 6px;
	background: rgba(255, 255, 255, 0.3);
	border-radius: 3px;
	outline: none;
	cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
	appearance: none;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: white;
}

/* Progress Bar Layout */
.progress-container {
	width: 100%;
	height: 5px;
	background: rgba(255, 255, 255, 0.3);
	padding-top: 10px;
	padding-bottom: 10px;
	background-clip: content-box;
	cursor: pointer;
	position: absolute;
	top: -15px;
	left: 0;
	transition: height 0.15s ease-in-out;
}

#controls-container:hover .progress-container {
	height: 8px;
}

.progress-bar-filled {
	height: 100%;
	background: #e50914;
	width: 0%;
	position: relative;
}

.progress-thumb {
	width: 14px;
	height: 14px;
	background: #ffffff;
	border-radius: 50%;
	position: absolute;
	right: -7px;
	top: 50%;
	transform: translateY(-50%) scale(0);
	transition: transform 0.1s ease-in-out;
	box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

#controls-container:hover .progress-thumb {
	transform: translateY(-50%) scale(1);
}

/* Hover Tracker & Tooltip Styles */
.progress-hover-tracker {
	position: absolute;
	top: 0;
	left: 0;
	width: 0%;
	height: 100%;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.15s ease-in-out;
	z-index: 5;
}

.progress-container:hover .progress-hover-tracker {
	opacity: 1;
}

.hover-transparent-dot {
	width: 14px;
	height: 14px;
	background: rgba(255, 255, 255, 0.5);
	border-radius: 50%;
	position: absolute;
	right: -7px;
	top: 50%;
	transform: translateY(-50%);
	box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.hover-time-tooltip {
	position: absolute;
	top: -26px;
	right: 0;
	transform: translateX(50%);
	background: rgba(0, 0, 0, 0.85);
	color: white;
	font-size: 11px;
	padding: 3px 6px;
	border-radius: 3px;
	white-space: nowrap;
}

/* Fixed-Height YouTube-Style Preview Frame */
.hover-preview-container {
	position: absolute;
	bottom: 125px;
	left: 0;
	transform: translateX(-50%);
	width: 160px;
	height: 90px;
	background: rgba(0, 0, 0, 0.9);
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	overflow: hidden;
	display: none;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
	pointer-events: none;
	z-index: 25;
}

.hover-preview-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.time-display {
	font-size: 12px;
	color: #ddd;
	margin-left: 10px;
	display: flex;
	align-items: center;
	white-space: nowrap;
}

/* Live Viewer Counter (Bottom Right) */
.viewer-counter-container {
	position: absolute;
	bottom: 90px;
	right: 20px;
	z-index: 25;
	font-family: Arial, sans-serif;
	opacity: 1;
	transition: opacity 0.4s ease;
}

.viewer-counter-btn {
	background: rgba(0, 0, 0, 0.7);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.2);
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 13px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 6px;
	transition: background 0.2s;
}

.viewer-counter-btn:hover {
	background: rgba(0, 0, 0, 0.85);
}

.viewer-dot {
	width: 8px;
	height: 8px;
	background-color: #2ecc71;
	border-radius: 50%;
	box-shadow: 0 0 6px #2ecc71;
}

.viewer-dropdown {
	position: absolute;
	bottom: 40px;
	right: 0;
	width: 200px;
	max-height: 180px;
	background: rgba(18, 18, 18, 0.95);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 8px;
	box-shadow: 0 8px 16px rgba(0,0,0,0.5);
	overflow-y: auto;
	display: none;
	z-index: 30;
	padding: 8px 0;
}

.viewer-dropdown.show {
	display: block;
}

.viewer-dropdown-title {
	padding: 4px 12px 8px 12px;
	font-size: 11px;
	color: #888;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.ip-item {
	padding: 6px 12px;
	font-size: 12px;
	color: #ddd;
	font-family: monospace;
}

.ip-item:hover {
	background: rgba(255, 255, 255, 0.05);
}

.subtitle-wrapper {
	position: relative;
	display: inline-block;
}

.sub-hover-controls {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 4px;
	margin-bottom: 6px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	z-index: 10;
}

.subtitle-wrapper:hover .sub-hover-controls {
	opacity: 1;
	visibility: visible;
}

.sub-hover-controls button {
	background: rgba(0, 0, 0, 0.8);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 4px 8px;
	cursor: pointer;
	font-size: 12px;
}

.sub-hover-controls button:hover {
	background: rgba(50, 50, 50, 0.9);
}

.sub-offset-badge {
	background: rgba(0, 0, 0, 0.8);
	color: #38bdf8;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 4px 6px;
	font-size: 11px;
	font-weight: bold;
	display: inline-flex;
	align-items: center;
	white-space: nowrap;
}

body.cursor-hidden {
	cursor: none;
}

@media (max-width: 600px) {
	#controls-container {
		height: 75px;
		padding: 12px 15px;
	}
	.control-left {
		gap: 12px;
	}
	.volume-slider {
		width: 70px;
	}
}

/* Top Right Stop Stream Button */
#top-right-stop-btn {
	position: absolute;
	top: 20px;
	right: 20px;
	z-index: 25;
	background: rgba(0, 0, 0, 0.6);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.2);
	padding: 8px 14px;
	border-radius: 4px;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.2s, opacity 0.4s ease;
}

#top-right-stop-btn:hover {
	background: rgba(229, 9, 20, 0.85);
	border-color: transparent;
}

/* Stop Confirmation Modal Overlay */
#stop-confirm-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.75);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

#stop-confirm-modal.show {
	opacity: 1;
	pointer-events: auto;
}

.stop-modal-content {
	background: #181818;
	border: 1px solid rgba(255, 255, 255, 0.15);
	padding: 25px 30px;
	border-radius: 8px;
	text-align: center;
	max-width: 320px;
	width: 90%;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.stop-modal-content h3 {
	margin: 0 0 10px 0;
	color: white;
	font-size: 1.2rem;
}

.stop-modal-content p {
	margin: 0 0 20px 0;
	color: #aaa;
	font-size: 0.9rem;
	line-height: 1.4;
}

.stop-modal-actions {
	display: flex;
	gap: 10px;
	justify-content: center;
}

.stop-modal-btn {
	padding: 8px 16px;
	border-radius: 4px;
	font-size: 0.9rem;
	cursor: pointer;
	border: none;
	font-weight: bold;
	transition: background 0.2s;
}

.btn-cancel-stop {
	background: #333;
	color: white;
}

.btn-cancel-stop:hover {
	background: #444;
}

.btn-confirm-stop {
	background: #e50914;
	color: white;
}

.btn-confirm-stop:hover {
	background: #f40612;
}

/* Disney+ / Hulu Style Media Title */
#media-title-display {
	position: absolute;
	top: 24px;
	left: 24px;
	z-index: 25;
	color: #ffffff;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: 0.3px;
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
	opacity: 1;
	pointer-events: none;
	transition: opacity 0.4s ease;
}

body::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100px;
	background: linear-gradient(rgba(0, 0, 0, 0.7), transparent);
	z-index: 10;
	pointer-events: none;
	transition: opacity 0.4s ease; /* Matches the fade transition */
}

/* Subtitle Button State Styling */
#subtitle-btn {
	color: #888888;
	transition: color 0.2s ease, transform 0.2s ease;
}

#subtitle-btn.active {
	color: #ffffff;
}

#custom-subtitle-display {
	position: absolute;
	left: 50%;
	bottom: 110px;
	transform: translateX(-50%);
	max-width: 80%;
	z-index: 12;
	display: none;
	text-align: center;
	white-space: pre-line;
	color: #fff;
	font-size: 26px;
	line-height: 1.3;
	padding: 4px 10px;
	background: rgba(0, 0, 0, 0.55);
	border-radius: 4px;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
	pointer-events: none;
	transition: bottom 0.3s ease;
}