*, ::after, ::before {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

html, body {
    height: 100dvh;
    width: 100dvw;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    background-color: #f0f2f5;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

div > div {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
    width: 100%;
    max-width: 900px;
}

div > div:last-of-type {
    border-bottom: none;
}

h1 {
    font-size: 1.8em;
    color: #6366f1;
    margin-bottom: 10px;
    padding-top: 10px;
    width: 100%;
    max-width: 900px;
    text-align: center;
}

/* Main Container */
body > div:first-of-type {
    background-color: #ffffff;
    padding: 20px;
    width: 100%;
    max-width: 950px;
}

/* Top Controls Section */
div > div:nth-child(2) {
    justify-content: space-between;
    align-items: flex-end;
}

div > div:nth-child(2) > div {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Label and Input Styling */
label {
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
}

input[type="file"],
input[type="text"],
input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    width: 100%;
    transition: border-color 0.2s;
}

input[type="file"] {
    padding: 6px 10px;
}

input[type="text"] {
    min-width: 200px;
}

input[type="file"]:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    border-color: #6366f1;
    outline: none;
}

div > div:nth-child(2) > div:last-child {
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.2s, box-shadow 0.2s;
    min-width: 100px;
    width: 100%;
}

#processBtn {
    background-color: #6366f1;
    color: white;
}

#processBtn:hover {
    background-color: #4f46e5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

#downloadBtn {
    background-color: #fff;
    color: #6366f1;
    border: 2px solid #6366f1;
}

#downloadBtn:hover {
    background-color: #eff1ff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Range Controls Section */
div > div:nth-child(3) {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    display: grid;
    gap: 20px 15px;
}

div > div:nth-child(3) > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

div > div:nth-child(3) input[type="number"] {
    width: 80px;
    text-align: right;
    margin-left: 10px;
}

div > div:nth-child(3) > div {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

div > div:nth-child(3) > div > label {
    flex-grow: 1;
}

div > div:nth-child(3) > div:not(:last-child) input[type="range"] {
    width: 100%;
    margin-top: 10px;
}

div > div:nth-child(3) > div:nth-child(7) input[type="range"],
div > div:nth-child(3) > div:nth-child(8) input[type="range"] {
    width: 100%;
    margin-top: 10px;
}

#canvas {
    display: block;
    width: 100%;
    margin-top: 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: #e9ecef;
}

@media (max-width: 600px) {
    body > div:first-of-type {
        padding: 15px;
    }

    div > div:nth-child(2) {
        flex-direction: column;
        align-items: stretch;
    }

    div > div:nth-child(2) > div {
        width: 100%;
    }

    div > div:nth-child(2) > div:last-child {
        flex-direction: row;
        justify-content: space-between;
        gap: 5px;
    }

    button {
        flex: 1;
        min-width: unset;
    }

    div > div:nth-child(3) {
        grid-template-columns: 1fr;
    }
}