body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #000000; /* Black background for dark mode */
    color: #ffffff; /* White text for contrast */
}

.stream-container {
    width: 100vw; /* Full viewport width */
    min-height: 100vh; /* Full height */
    display: grid;
    gap: 10px;
}

/* Single stream: 1x1 (full viewport) */
.stream-container.stream-count-1 {
    grid-template-columns: 100vw;
    grid-template-rows: 100vh;
}

.stream-container.stream-count-1 .stream {
    grid-column: 1;
    grid-row: 1;
}

/* Two streams: 1x2 (side by side, full width) */
.stream-container.stream-count-2 {
    grid-template-columns: repeat(2, calc(50vw - 5px)); /* 50% width each, minus half the gap */
    grid-template-rows: 100vh;
}

.stream-container.stream-count-2 .stream:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.stream-container.stream-count-2 .stream:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

/* 3-4 streams: 2x2 grid */
.stream-container.stream-count-3,
.stream-container.stream-count-4 {
    grid-template-columns: repeat(2, calc(50vw - 5px));
    grid-template-rows: repeat(2, calc(50vh - 5px));
}

/* 5-6 streams: 3x2 grid */
.stream-container.stream-count-5,
.stream-container.stream-count-6 {
    grid-template-columns: repeat(3, calc(33.33vw - 3.33px));
    grid-template-rows: repeat(2, calc(50vh - 5px));
}

/* 7-9 streams: 3x3 grid */
.stream-container.stream-count-7,
.stream-container.stream-count-8,
.stream-container.stream-count-9 {
    grid-template-columns: repeat(3, calc(33.33vw - 3.33px));
    grid-template-rows: repeat(3, calc(33.33vh - 3.33px));
}

/* 10-12 streams: 4x3 grid */
.stream-container.stream-count-10,
.stream-container.stream-count-11,
.stream-container.stream-count-12 {
    grid-template-columns: repeat(4, calc(25vw - 2.5px));
    grid-template-rows: repeat(3, calc(33.33vh - 3.33px));
}

/* 13-16 streams: 4x4 grid */
.stream-container.stream-count-13,
.stream-container.stream-count-14,
.stream-container.stream-count-15,
.stream-container.stream-count-16 {
    grid-template-columns: repeat(4, calc(25vw - 2.5px));
    grid-template-rows: repeat(4, calc(25vh - 2.5px));
}

.stream {
    background-color: #111111; /* Dark gray for stream containers */
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1);
}

.stream > div {
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9; /* Maintain 16:9 aspect ratio for players */
}

/* Overlay Styles */
.toggle-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #1e90ff; /* Bright blue */
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.toggle-overlay:hover {
    background-color: #1c86ee;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent black */
    z-index: 1000;
}

.overlay.active {
    display: block;
}

.overlay-content {
    position: fixed;
    background-color: #222222; /* Dark gray for overlay content */
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    opacity: 0.5; /* 50% transparent */
    z-index: 1001;
}

.close-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
}

.input-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

#stream-url {
    padding: 10px;
    flex: 1;
    border: 1px solid #444444;
    border-radius: 4px;
    font-size: 1em;
    background-color: #333333;
    color: #ffffff;
}

.input-container button {
    padding: 10px 20px;
    background-color: #1e90ff;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.input-container button:hover {
    background-color: #1c86ee;
}

.stream-list {
    max-height: 200px;
    overflow-y: auto;
}

.stream-list h3 {
    margin: 0 0 10px;
    font-size: 1.2em;
}

.stream-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stream-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #444444;
}

.stream-list li:last-child {
    border-bottom: none;
}

.stream-list button {
    background-color: #ff4444;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.9em;
}

.stream-list button:hover {
    background-color: #cc3333;
}