:root {
    --main-color: #00b050;
    --secondary-color: #ffd700;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    color: #333333;
    background: linear-gradient(135deg, #f5f7fa 0%, #e0e4e8 100%);
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

#topembed-livestream {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
    position: relative;
    background: #fff;
}

#events {
    list-style: none;
    padding: 0;
}

.event {
    margin: 0;
    padding: 12px;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.event:hover {
    background: #f0f0f0;
}

.event.live::after {
    content: 'LIVE';
    background: var(--secondary-color);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

.event-time {
    width: 60px;
    font-weight: bold;
    white-space: nowrap;
}

.event-flag {
    width: 30px;
    margin: 0 5px;
}

.event-details {
    flex: 1;
    margin-left: 5px;
}

.dropdown {
    display: none;
    position: relative;
    background: #fff;
    border: 1px solid var(--main-color);
    border-radius: 5px;
    padding: 5px;
    margin-top: 5px;
    z-index: 10;
}

.dropdown ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown li {
    margin: 2px 0;
}

.dropdown a {
    color: var(--main-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.dropdown a:hover {
    text-decoration: underline;
}

#stream-wrapper {
    position: relative;
    text-align: center;
    margin: 20px auto;
    width: 90%;
    max-width: 800px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 10px;
    display: block;
    transition: background 0.3s ease;
}

body.dark-mode #stream-wrapper {
    background: #2a2a2a;
}

#stream-wrapper .stream-title {
    color: var(--secondary-color);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: center;
}

#stream-wrapper iframe {
    width: 100%;
    min-height: 360px;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    background: #000;
    transition: height 0.5s ease, box-shadow 0.3s ease;
}

#stream-wrapper iframe:hover {
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.3);
}

#stream-wrapper .event-name {
    color: #333333;
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
    transition: color 0.3s ease;
}

body.dark-mode #stream-wrapper .event-name {
    color: #e0e0e0;
}

#stream-wrapper .additional-links {
    margin-top: 20px;
    padding: 10px;
    text-align: center;
    background: #fff;
    border-radius: 5px;
    border: 1px solid #ccc;
}

body.dark-mode #stream-wrapper .additional-links {
    background: #333;
    border: 1px solid #555;
}

#stream-wrapper .additional-links a {
    color: var(--main-color);
    margin: 0 10px;
    font-weight: 600;
    display: inline-block;
}

#stream-wrapper .additional-links a.active {
    font-weight: bold;
    color: #007b38;
    text-decoration: none;
}

body.dark-mode #stream-wrapper .additional-links a.active {
    color: #00cc66;
}

#stream-wrapper .additional-links a:hover {
    text-decoration: underline;
}

#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px;
    background: #00b050;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#backToTop.visible {
    display: block;
    opacity: 1;
}

body.dark-mode #backToTop {
    background: #004d20;
}

#search-container {
    margin: 20px 0;
    text-align: center;
    padding: 10px;
    background: linear-gradient(135deg, #ffffff, #e8f5e9);
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: background 0.3s ease;
}

body.dark-mode #search-container {
    background: linear-gradient(135deg, #2a2a2a, #3a4a3a);
}

#event-search {
    padding: 8px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 70%;
    max-width: 300px;
    outline: none;
    transition: border-color 0.3s ease;
}

#event-search:focus {
    border-color: var(--main-color);
}

#search-btn {
    padding: 8px 15px;
    font-size: 16px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--main-color), #008040);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease, transform 0.3s ease;
}

body.dark-mode #search-btn {
    background: linear-gradient(135deg, #004d20, #003020);
}

#search-btn:hover {
    background: linear-gradient(135deg, #008040, var(--main-color));
    transform: scale(1.05);
}

body.dark-mode #search-btn:hover {
    background: linear-gradient(135deg, #003020, #004d20);
}

@media (max-width: 768px) {
    .event {
        display: flex;
        align-items: center;
        padding: 8px;
        margin: 0;
        border-bottom: 1px solid #ccc;
    }

    .event-time {
        width: 60px;
        margin-right: 5px;
        font-size: 14px;
    }

    .event-flag {
        width: 25px;
        margin: 0 5px;
    }

    .event-details {
        font-size: 14px;
        margin-left: 5px;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .event.live::after {
        position: static;
        margin-left: 0;
        margin-top: 0;
    }

    .dropdown {
        padding: 3px;
    }

    .dropdown li {
        margin: 1px 0;
    }

    #stream-wrapper {
        width: 100%;
        /* Full width */
        padding: 5px;
        /* Internal padding */
        margin: 15px 0;
        /* No horizontal margin, only vertical */
        min-height: 250px;
        /* Stable height */
    }

    #stream-wrapper iframe {
        min-height: 200px;
        /* Adjusted for stability */
        width: 100%;
        /* Full width */
    }

    #search-container {
        padding: 8px;
    }

    #event-search {
        width: 60%;
        max-width: 200px;
        font-size: 14px;
        padding: 6px;
    }

    #search-btn {
        padding: 6px 12px;
        font-size: 14px;
        margin-left: 5px;
    }
}

@media (max-width: 480px) {
    .event {
        padding: 6px;
    }

    .event-time {
        width: 50px;
        font-size: 12px;
        margin-right: 3px;
    }

    .event-flag {
        width: 20px;
        margin: 0 3px;
    }

    .event-details {
        font-size: 12px;
        margin-left: 3px;
    }

    .dropdown a {
        font-size: 12px;
    }

    #stream-wrapper {
        width: 100%;
        /* Full width */
        padding: 3px;
        /* Internal padding */
        margin: 10px 0;
        /* No horizontal margin, only vertical */
        min-height: 180px;
        /* Scaled down */
    }

    #stream-wrapper iframe {
        min-height: 150px;
        /* Scaled down */
        width: 100%;
        /* Full width */
    }

    #search-container {
        padding: 6px;
    }

    #event-search {
        width: 50%;
        max-width: 150px;
        font-size: 12px;
        padding: 4px;
    }

    #search-btn {
        padding: 4px 10px;
        font-size: 12px;
        margin-left: 3px;
    }
}