body {
    font-family: sans-serif;
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: #333;
}
#controls {
    margin-bottom: 20px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: grid; /* Use grid for better alignment */
    grid-template-columns: auto auto; /* Adjust columns as needed */
    gap: 15px 25px; /* Row and column gap */
    align-items: center;
}

/* Span controls across columns if needed */
#controls > div:nth-child(1) { /* Video file input */
    grid-column: 1 / -1; /* Span full width */
}
#controls > button { /* Fullscreen button */
    grid-column: 1 / -1; /* Span full width */
    justify-self: center; /* Center the button */
    padding: 8px 15px;
}


label {
    font-weight: bold;
    margin-right: 5px;
}
input[type="text"], input[type="color"], select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    vertical-align: middle; /* Align controls better */
}
input[type="color"] {
    padding: 0; /* Remove padding for color input */
    min-width: 40px; /* Ensure color picker is usable */
    height: 30px;
    border: none; /* Remove border for a cleaner look */
    vertical-align: middle;
}

#charsetInput {
    /* Make custom input slightly smaller if preset is chosen */
    margin-left: 5px;
}

/* Initially hide the fixed color input */
#fixedColorInput.hidden {
    display: none;
}


#asciiCanvas {
    display: block;
    background-color: #000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    margin-top: 10px;
    /* width/height set via JS */
}
#videoSource {
    max-width: 320px;
    margin-top: 10px;
    display: block; /* Make it block to prevent extra space */
    margin-left: auto; /* Center it */
    margin-right: auto;
}

/* Responsive adjustments (Example) */
@media (max-width: 768px) {
    #controls {
        grid-template-columns: 1fr; /* Stack controls on smaller screens */
        gap: 10px;
    }
    #controls > div {
        grid-column: auto; /* Reset span */
        display: flex;
        flex-direction: column; /* Stack label and input */
        align-items: flex-start;
    }
    #controls > button {
        grid-column: auto;
    }
}

/* ... (keep existing styles for body, #controls, labels, inputs, canvas, video) ... */

#controls {
    /* ... existing grid styles ... */
    /* Adjust grid layout if needed */
    grid-template-columns: 1fr; /* Example: Stack main preset and fieldset */
}

/* Style the fieldset */
#customControls {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 15px;
    margin-top: 10px; /* Add some space */
    display: grid; /* Use grid for layout inside */
    gap: 15px;
    grid-template-columns: auto 1fr; /* Labels and controls */
    align-items: center;
}
#customControls legend {
    font-weight: bold;
    padding: 0 5px; /* Space around legend text */
    color: #555;
}

/* Style for when controls are disabled */
#customControls:disabled {
    opacity: 0.6; /* Visually indicate disabled state */
    border-color: #e0e0e0;
}
#customControls:disabled legend {
    color: #999;
}


/* Ensure individual control divs stack correctly within fieldset grid */
#customControls > div {
    grid-column: 1 / -1; /* Make each control group span full width */
    display: flex;
    flex-wrap: wrap; /* Allow wrapping within a control group */
    align-items: center;
    gap: 5px 10px;
}


/* Initially hide the fixed color input */
#fixedColorInput.hidden {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #controls {
        /* Ensure it remains single column */
        grid-template-columns: 1fr;
        gap: 10px;
    }
    #customControls {
        grid-template-columns: 1fr; /* Stack labels above inputs */
        gap: 10px;
    }
    #customControls > div {
        flex-direction: column; /* Stack label and input */
        align-items: flex-start;
    }
    #controls > button { /* Center fullscreen button */
        grid-column: 1 / -1;
        justify-self: center;
    }
}
