:root {
    --deep-purple: #2C005D; /* Darkest for background start, header */
    --main-purple: #4A00B7; /* Main background end, general elements */
    --medium-purple: #6F00D6; /* Section backgrounds, card base */
    --light-purple: #9B00F2; /* Accents, text highlights */
    --accent-purple: #B366FF; /* Buttons, interactive elements */
    --text-color: #E0E0E0; /* General text color */
    --white-transparent: rgba(255, 255, 255, 0.15); /* Frosted effect base */
    --white-transparent-strong: rgba(255, 255, 255, 0.25); /* List item background */
    --button-shadow: rgba(0, 0, 0, 0.2);
    --box-shadow-medium: rgba(0, 0, 0, 0.3);
    --box-shadow-light: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--background-gradient-start, var(--deep-purple)), var(--background-gradient-end, var(--main-purple)));
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.kahoot-header {
    background-color: var(--deep-purple);
    width: 100%;
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 4px 8px var(--button-shadow);
    margin-bottom: 30px;
    position: relative; /* Needed for absolute positioning of children */
}

.kahoot-logo-image {
    max-width: 100%;
    height: auto;
    max-height: 150px; /* Adjust as needed */
    display: block;
    margin: 0 auto;
}

/* Update Log Container and Button */
.update-log-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-project-version {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--accent-purple);
}

.update-log-button {
    background-color: var(--accent-purple);
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px var(--button-shadow);
}

.update-log-button:hover {
    background-color: var(--light-purple);
    transform: translateY(-1px);
}

/* Update Log Modal */
.update-log-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Dark overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Ensure it's on top */
    backdrop-filter: blur(5px);
}

.update-log-modal.hidden {
    display: none;
}

.update-log-content {
    background-color: var(--medium-purple);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    max-width: 700px;
    width: 90%;
    max-height: 80vh; /* Limit height for scrolling */
    overflow-y: auto; /* Enable scrolling for long lists */
    position: relative;
}

.update-log-close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

.update-log-close-button:hover {
    color: var(--accent-purple);
}

.update-log-list {
    text-align: left;
    margin-top: 20px;
}

.update-log-item {
    background-color: var(--deep-purple);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 4px 8px var(--button-shadow);
}

.update-log-item:last-child {
    margin-bottom: 0;
}

.update-log-version {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5em;
    font-weight: 700;
    color: var(--light-purple);
    margin-bottom: 5px;
}

.update-log-description {
    font-size: 1em;
    line-height: 1.5;
    color: var(--text-color);
}

.kahoot-container {
    background-color: var(--white-transparent);
    border-radius: 20px;
    padding: 30px 40px;
    box-shadow: 0 8px 16px var(--box-shadow-medium);
    text-align: center;
    max-width: 900px;
    width: 90%;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.section-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.2em;
    font-weight: 700;
    color: var(--light-purple); /* Changed from yellow to light purple */
    margin-bottom: 25px;
    text-shadow: 2px 2px var(--button-shadow);
}

.current-language-filter {
    font-size: 0.7em;
    font-weight: 400;
    color: var(--accent-purple);
}

/* Server List Section */
.server-list-section {
    background-color: var(--medium-purple); /* Previously pink room-code-section */
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: inset 0 0 15px var(--button-shadow);
}

.instructions-section {
    background-color: var(--deep-purple);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
    box-shadow: 0 4px 8px var(--button-shadow);
}

.instructions-section h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6em;
    color: var(--light-purple);
    margin-top: 0;
    margin-bottom: 10px;
}

.instructions-section p {
    font-size: 1.1em;
    line-height: 1.5;
    margin-bottom: 10px;
    color: var(--text-color);
}

.instructions-section p:last-child {
    margin-bottom: 0;
}

.instructions-section strong {
    color: var(--accent-purple);
}

.instructions-section a {
    color: var(--accent-purple);
    text-decoration: none;
    font-weight: 600;
}

.instructions-section a:hover {
    text-decoration: underline;
}

.server-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.server-item {
    background-color: var(--deep-purple); /* Previously red room-code background */
    padding: 15px 25px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 10px var(--box-shadow-medium);
    transition: transform 0.2s ease;
}

.server-item:hover {
    transform: translateY(-3px);
}

.server-item-left-content { /* New wrapper for hosted by and room info */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px; /* Space between hosted by and room name */
}

.hosted-by-info {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between "Hosted by:" and the link */
    font-size: 0.9em; /* Smaller font for this line */
}

.hosted-by-label {
    color: var(--text-color);
    font-weight: 400;
}

.room-creator-link {
    display: flex;
    align-items: center;
    gap: 5px; /* Space between avatar and username */
    text-decoration: none;
    color: var(--accent-purple);
    transition: color 0.2s ease;
}

.room-creator-link:hover {
    color: var(--light-purple);
    text-decoration: underline;
}

.room-creator-avatar {
    width: 30px; /* Smaller avatar for inline display */
    height: 30px;
    border-radius: 50%; /* Make it round */
    object-fit: cover;
    border: 1px solid var(--accent-purple); /* Small border */
}

.room-creator-username {
    font-family: 'Poppins', sans-serif;
    font-size: 1em; /* Adjust relative to hosted-by-info font size */
    font-weight: 600;
}

.room-info {
    display: flex;
    flex-direction: column;
    text-align: left;
    flex-grow: 1; /* Allows room info to take available space */
}

.room-name {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
}

.room-code-group {
    display: flex;
    align-items: baseline; /* Align text on the same baseline */
    gap: 5px; /* Space between label and PIN */
}

.room-code-label {
    font-family: 'Poppins', sans-serif;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--accent-purple);
}

.room-code-display {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.8em;
    font-weight: 700;
    color: var(--light-purple);
    letter-spacing: 3px;
    text-shadow: 2px 2px var(--button-shadow);
}

.room-language { /* Style for displaying language in room item */
    font-size: 0.9em;
    color: var(--text-color);
    margin-top: 5px;
    font-style: italic;
}

/* New: Styles for displaying tags in server item */
.room-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.room-tag {
    background-color: var(--accent-purple);
    color: white;
    font-size: 0.75em;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
}

.no-rooms-message {
    font-style: italic;
    color: var(--text-color); /* Changed to use general text color */
    font-size: 1.1em;
    padding: 20px;
    background-color: var(--deep-purple);
    border-radius: 10px;
}

.main-buttons {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    gap: 20px;
    justify-content: center;
    margin-top: 25px; /* Space above buttons if needed */
}

.kahoot-button {
    background-color: var(--accent-purple); /* Previously Kahoot blue */
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 8px var(--button-shadow);
}

.kahoot-button:hover {
    background-color: var(--light-purple); /* Darker purple on hover */
    transform: translateY(-2px);
}

.close-room-button {
    background-color: #E21B3C; /* A distinct red for "Close Room" */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px var(--button-shadow);
    flex-shrink: 0; /* Prevent button from shrinking */
}

.close-room-button:hover {
    background-color: #B0152F; /* Darker red */
    transform: translateY(-1px);
}

/* Share Room Form Section */
.share-room-form-section {
    background-color: var(--medium-purple); /* Similar to server list section */
    border-radius: 15px;
    padding: 30px;
    box-shadow: inset 0 0 15px var(--button-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.share-room-form-section.hidden,
.server-list-section.hidden,
.filter-hub-section.hidden,
.main-buttons.hidden,
.instructions-section.hidden { 
    display: none;
}

.create-room-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.create-room-form input[type="text"],
.create-room-form .language-select-dropdown {
    width: calc(100% - 40px); /* Adjusting for padding */
    max-width: 400px;
    padding: 15px 20px;
    border-radius: 10px;
    border: 2px solid var(--light-purple);
    background-color: var(--deep-purple);
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    font-size: 1.1em;
    outline: none;
    transition: border-color 0.3s ease;
    appearance: none; /* Remove default dropdown arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23E0E0E0" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
}

/* For multi-selects, remove the custom arrow */
.create-room-form select[multiple] {
    background-image: none;
    padding-right: 20px; /* Adjust padding for no arrow */
}

.create-room-form input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.create-room-form input[type="text"]:focus,
.create-room-form .language-select-dropdown:focus {
    border-color: var(--accent-purple);
}

.create-room-form .kahoot-button {
    width: auto;
    min-width: 180px;
    margin-top: 10px;
}

.create-room-form .cancel-button {
    background-color: #6C757D; /* Grey for cancel button */
}

.create-room-form .cancel-button:hover {
    background-color: #5A6268;
}

/* Filter Hub Section (previously Language Hub Section) */
.filter-hub-section {
    background-color: var(--medium-purple);
    border-radius: 15px;
    padding: 30px;
    box-shadow: inset 0 0 15px var(--button-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-category {
    margin-bottom: 15px;
}

.filter-category h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.8em;
    color: var(--light-purple);
    margin-bottom: 15px;
    text-align: left;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    justify-content: center;
    margin-bottom: 10px;
}

.filter-button {
    width: 100%; /* Ensure buttons fill their grid space */
    padding: 12px 15px;
    font-size: 1em;
    background-color: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px var(--button-shadow);
}

.filter-button:hover {
    background-color: var(--light-purple);
    transform: translateY(-1px);
}

.filter-button.selected {
    background-color: var(--light-purple); /* Highlight color for selected filters */
    border: 2px solid var(--text-color);
    box-shadow: 0 3px 6px var(--box-shadow-medium);
    transform: translateY(-2px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .kahoot-logo-image {
        max-height: 180px; /* Larger on mobile */
    }

    .kahoot-container {
        border: none; /* Remove white line on mobile */
    }

    .section-title {
        font-size: 1.8em;
    }

    .instructions-section h3 {
        font-size: 1.4em;
    }

    .instructions-section p {
        font-size: 1em;
    }

    .server-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px; /* Increase gap between stacked items */
    }

    .server-item-left-content {
        width: 100%; /* Ensure it takes full width when stacked */
        gap: 8px; /* Slightly reduce gap when stacked */
    }

    .hosted-by-info {
        font-size: 0.85em; /* Smaller on mobile */
    }
    .room-creator-avatar {
        width: 25px; /* Smaller avatar on mobile */
        height: 25px;
    }
    .room-creator-username {
        font-size: 0.9em;
    }

    .room-name {
        font-size: 1.2em;
    }

    .room-code-label {
        font-size: 1em;
    }

    .room-code-display {
        font-size: 1.5em;
    }

    .kahoot-button {
        padding: 12px 25px;
        font-size: 1em;
    }

    .close-room-button {
        padding: 8px 12px;
        font-size: 0.8em;
        margin-left: 0; /* Important: remove old margin-left */
        width: auto; /* Allow it to naturally size, not 100% */
        align-self: flex-end; /* Push to right when stacked */
    }

    .create-room-form input[type="text"],
    .create-room-form .language-select-dropdown {
        font-size: 1em;
        padding: 12px 15px;
    }

    .filter-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Smaller buttons on mobile */
    }

    .filter-button {
        font-size: 0.9em;
    }

    .update-log-container {
        top: 10px;
        right: 10px;
        gap: 5px;
    }

    .current-project-version,
    .update-log-button {
        font-size: 0.8em;
        padding: 6px 10px;
    }

    .update-log-modal .section-title {
        font-size: 1.8em;
    }
    .update-log-item {
        padding: 10px;
    }
    .update-log-version {
        font-size: 1.2em;
    }
    .update-log-description {
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .kahoot-logo-image {
        max-height: 150px; /* Even larger on very small screens */
    }

    .section-title {
        font-size: 1.5em;
    }

    .kahoot-container {
        padding: 20px 25px;
    }

    .server-list-section, .share-room-form-section, .filter-hub-section {
        padding: 20px;
    }

    .server-item-left-content {
        gap: 5px;
    }

    .hosted-by-info {
        font-size: 0.8em;
    }
    .room-creator-avatar {
        width: 20px;
        height: 20px;
    }
    .room-creator-username {
        font-size: 0.8em;
    }

    .main-buttons {
        flex-direction: column; /* Stack buttons vertically on very small screens */
        gap: 15px;
    }

    .update-log-container {
        flex-direction: column;
        align-items: flex-end;
        right: 5px;
        top: 5px;
    }
    .current-project-version,
    .update-log-button {
        font-size: 0.7em;
        padding: 5px 8px;
    }

    .update-log-modal .section-title {
        font-size: 1.5em;
    }
    .update-log-close-button {
        font-size: 1.8em;
        top: 10px;
        right: 15px;
    }
}