body {
    margin: 0;
    overflow: hidden; /* Prevent scrolling of the main page when modal is open */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background for the modal overlay */
    font-family: 'Open Sans', sans-serif;
}

.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Initial state for transition */
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    z-index: 1000; /* Ensure it's on top of everything */
}

.settings-modal.active {
    opacity: 1;
    transform: scale(1);
}

.settings-content {
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%); /* Gold to Dark Orange, matching main app */
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    width: 80%; /* Covers 80% of the screen */
    max-width: 600px; /* Max width for larger screens */
    min-height: 400px; /* Minimum height */
    text-align: center;
    border: 4px solid #FF4500; /* OrangeRed border */
    position: relative;
    color: #333;
    animation: fadeInScale 0.3s ease-out forwards;
    max-height: 90vh; /* Limit height for scrollable content */
    overflow-y: auto; /* Enable scrolling for long forms */
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2.5em;
    color: #D32F2F; /* Deep Red */
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease-in-out, color 0.2s ease-in-out;
}

.close-button:hover {
    transform: rotate(90deg);
    color: #B71C1C; /* Darker Red */
}

h2 {
    font-family: 'Fredoka One', cursive;
    color: #D32F2F; /* Deep Red */
    margin-bottom: 30px;
    font-size: 2.8em;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.setting-item {
    margin-bottom: 25px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.8); /* Slightly transparent white */
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.setting-item h3 {
    color: #FF4500; /* OrangeRed */
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5em;
    font-weight: 600;
}

.setting-item input[type="text"] {
    width: calc(100% - 20px);
    padding: 10px;
    border: 2px solid #FF8C00;
    border-radius: 8px;
    font-size: 1em;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease;
}

.setting-item input[type="text"]:focus {
    border-color: #FF4500;
    outline: none;
    box-shadow: 0 0 8px rgba(255, 69, 0, 0.3);
}

.setting-item input[type="file"] {
    width: calc(100% - 20px);
    padding: 10px;
    border: 2px solid #FF8C00;
    border-radius: 8px;
    font-size: 1em;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease;
    background-color: #fff;
    cursor: pointer;
}

.setting-item input[type="file"]::file-selector-button {
    background-color: #FF8C00;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 10px;
    transition: background-color 0.2s ease;
}

.setting-item input[type="file"]::file-selector-button:hover {
    background-color: #E65100;
}

.input-tip {
    font-size: 0.9em;
    color: #777;
    margin-top: 5px;
    text-align: left;
}

#volume-control {
    width: 80%;
    -webkit-appearance: none;
    appearance: none;
    height: 10px;
    background: #D32F2F; /* Deep red track */
    border-radius: 5px;
    outline: none;
    transition: opacity .2s;
}

#volume-control::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    background: #FFD700; /* Gold thumb */
    border: 2px solid #FF8C00; /* Darker orange border */
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, box-shadow 0.2s;
}

#volume-control::-webkit-slider-thumb:hover {
    background: #FFC107; /* Lighter gold on hover */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#volume-control::-moz-range-thumb {
    width: 25px;
    height: 25px;
    background: #FFD700;
    border: 2px solid #FF8C00;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s, box-shadow 0.2s;
}

#volume-control::-moz-range-thumb:hover {
    background: #FFC107;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.save-button {
    background: linear-gradient(to right, #4CAF50, #8BC34A); /* Green gradient */
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 30px;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.save-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    background: linear-gradient(to right, #4CAF50, #6D8E4A);
}

.settings-tip {
    margin-top: 40px;
    font-size: 1.1em;
    color: #555;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .settings-content {
        width: 90%;
        padding: 30px;
        /* For mobile, make it fill more of the screen height */
        height: auto;
        min-height: unset; /* Remove min-height constraint */
        max-height: 95vh; /* Allow it to be taller, with scroll if needed */
    }
    h2 {
        font-size: 2.2em;
    }
    .setting-item h3 {
        font-size: 1.3em;
    }
    #volume-control {
        width: 90%;
    }
    .setting-item input[type="text"],
    .setting-item input[type="file"] {
        width: calc(100% - 10px); /* Adjust for padding within input */
    }
    /* Ensure the iframe itself scales properly */
    body {
        /* On small screens, let the iframe take full viewport */
        padding: 0;
        margin: 0;
    }
    .settings-modal {
        /* When the modal is active, the entire viewport for the iframe */
        position: absolute; /* Changed to absolute to avoid fixed positioning issues inside iframe */
        top: 0;
        left: 0;
        width: 100vw; /* Use vw/vh for full screen in mobile iframe */
        height: 100vh;
        align-items: flex-start; /* Align to top to show 'X' more clearly */
        padding-top: 20px; /* Add some padding from top for the X button */
        box-sizing: border-box; /* Include padding in dimensions */
    }
    .settings-content {
        width: 95%; /* Adjust width to fit within mobile screen with padding */
        max-width: unset; /* Remove max-width constraint for mobile */
        max-height: calc(100% - 40px); /* Adjust max-height to fit within viewport, considering padding */
        padding: 20px;
        box-sizing: border-box;
        border-radius: 10px; /* Slightly smaller border-radius for mobile */
    }
    .close-button {
        font-size: 2em; /* Make 'X' slightly smaller on mobile */
        top: 10px; /* Adjust position for the 'X' button */
        right: 15px;
    }
}

@media (max-width: 480px) {
    .settings-content {
        padding: 20px;
        min-height: unset; /* Remove min-height constraint */
        max-height: 95vh; /* Allow it to be taller */
        width: 95%; /* Make it fill almost the entire width */
    }
    h2 {
        font-size: 1.8em;
    }
    .close-button {
        font-size: 2em;
        top: 10px;
        right: 15px;
    }
    .setting-item h3 {
        font-size: 1.1em;
    }
    .save-button {
        padding: 10px 20px;
        font-size: 1em;
    }
    /* Further adjust for very small screens */
    .settings-modal {
        padding-top: 10px; /* Reduce top padding for very small screens */
    }
    .settings-content {
        padding: 15px; /* Reduce content padding */
    }
}