body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed from align-items: center so scrolling works better on mobile */
    min-height: 100vh;
    background-color: #282c34;
    color: #e0e0e0;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    background-color: var(--white);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 900px; /* Slightly wider to accommodate controls */
    box-sizing: border-box;
}

h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 30px;
    font-size: 2rem;
}

/* --- Control Layout --- */

/* The main container for the top controls */
.top-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center; /* Center items on desktop */
    align-items: flex-end; /* Align to bottom so buttons align with inputs */
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #555;
}

/* Individual groupings (Label + Input) */
.control-group {
    display: flex;
    flex-direction: column; /* Stack label above input by default for better responsiveness */
    gap: 5px;
}

/* Specific player controls group (Play/Stop) */
.player-controls {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

label {
    color: #a0a8b4;
    font-size: 0.9rem;
    font-weight: bold;
}

input[type="text"],
input[type="number"],
select {
    padding: 10px 12px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: var(--primary);
    color: #e0e0e0;
    font-size: 1rem;
    min-width: 120px; /* Reduced min-width to prevent overflow */
}

input[type="number"] {
    max-width: 80px;
}

button {
    background-color: #61dafb;
    color: #282c34;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.2s ease;
    white-space: nowrap; /* Prevent button text wrapping awkwardly */
    height: 42px; /* Fixed height to match inputs */
}

/*button:hover:not(:disabled) {
    background-color: #21a1f1;
}*/

button:disabled {
    background-color: #555;
    color: #bbb;
    cursor: not-allowed;
}

/* --- Modal Styles Updates --- */

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-group {
    width: 100%;
}

.modal-group input, 
.modal-group select {
    width: 100%;
    box-sizing: border-box; /* Ensure padding doesn't exceed 100% */
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-actions button {
    flex: 1;
}

.clear-button {
    background-color: #e22d3f;
    color: white;
}
.clear-button:hover {
    background-color: #c41c35;
}

#status {
    text-align: center;
    margin-top: 25px;
    font-style: italic;
    color: #a0a8b4;
}

/* --- Responsive Media Queries --- */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.75rem;
    }

    /* On tablets/mobiles, allow controls to grow */
    .control-group, 
    .player-controls {
        flex-grow: 1;
    }

    input[type="text"],
    select {
        width: 100%;
        box-sizing: border-box;
    }

    button {
        width: 100%; /* Buttons take full width of their container */
    }
}

@media (max-width: 600px) {
    .top-controls {
        flex-direction: column; /* Stack all controls vertically */
        align-items: stretch; /* Stretch to full width */
        gap: 20px;
    }

    .player-controls {
        flex-direction: row; /* Keep Play/Stop side by side */
        justify-content: space-between;
    }
    
    .control-group {
        width: 100%;
    }

    input[type="number"] {
        max-width: 100%; /* Allow tempo input to stretch */
        box-sizing: border-box;
    }

    /* Modal adjustments */
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
    }
}