*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,body{
    width: 100%;
    min-height: 100vh;
}
html{
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-primary-color);
    color: var(--text-primary-color);
    font-size: 14px; /* Base font size for mobile */
}

main{
    width: 100%;
    min-height: 100vh;
    padding: var(--padding-sm);
}
main section{
    width: 100%;
    padding: var(--padding-md);
    display: flex;
    flex-direction: column; /* Stack on mobile */
    gap: var(--gutter-lg);
}

.btn{
    padding: var(--padding-sm) var(--padding-md);
    border: none;
    outline: none;
    border-radius: var(--border-radius-md);
    background-color: var(--bg-active-color);
    cursor: pointer;
    color: var(--text-active-color);
    font-size: var(--font-size-sm);
    white-space: nowrap;
}

main section .top{
    display: flex;
    align-items: center;
    gap: var(--gutter-sm);
    justify-content: center; /* Center buttons on mobile */
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
}

#reset-btn{
    background-color: red;
    color: wheat;
}
#download-btn{
    background-color: green;
    color: wheat;
}
main section .left{
    display: flex;
    flex-direction: column;
    gap: var(--gutter-md);
    width: 100%; /* Full width on mobile */
    align-items: center;
}
main section .right{
    width: 100%; /* Full width on mobile */
    background-color: rgb(44, 40, 40);
    padding: var(--padding-md);
    border-radius: var(--border-radius-lg);
    order: -1; /* Move filters above image on mobile */
}

main section .right .filters{
    display: flex;
    flex-direction: column;
    gap: var(--gutter-sm);
}

main section .bottom{
    background-color: rgb(44, 40, 40);
    width: 100%;
    padding: var(--padding-md);
    aspect-ratio: 4/3; /* Slightly different aspect ratio for mobile */
    border-radius: var(--border-radius-lg);
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 60vh; /* Limit height on mobile */
}


main section .bottom .placeholder{
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.6;
    gap: var(--gutter-sm);
    text-align: center;
}
main section .bottom .placeholder i{
    font-size: 4rem; /* Smaller icon on mobile */
}
main section .bottom .placeholder p{
    font-size: var(--font-size-md);
}
main section .right{
    display: flex;
    flex-direction: column;
    gap: var(--gutter-sm);
}

main section .right .filter{
    width: 100%;
}
main section .right .filter p{
    font-size: var(--font-size-sm);
    margin-bottom: 4px;
}
main section .right .filter input{
    width: 100%;
    outline: none;
    margin-top: 2px;
    appearance: none;
}
main section .right .filter input::-webkit-slider-runnable-track{
    background-color: var(--bg-active-color);
    height: 2px; /* Thinner track on mobile */
    border-radius: 1px;
}
main section .right .filter input::-webkit-slider-thumb{
    cursor: pointer;
    appearance: none;
    width: 16px; /* Smaller thumb on mobile */
    height: 16px;
    border-radius: 50%;
    background-color: red;
    margin-top: -7px;
}

canvas{
    max-width: 100%;
    max-height: 50vh;
    display: none;
    width: auto;
    height: auto;
}

.presets{
    display: flex;
    flex-wrap: wrap;
    gap: var(--gutter-sm);
    justify-content: center; /* Center preset buttons */
}

.presets .btn{
    padding: var(--padding-sm) var(--padding-sm);
    font-size: var(--font-size-sm);
    flex: 1 0 auto; /* Allow buttons to grow but not shrink too much */
    min-width: 80px; /* Minimum width for preset buttons */
}

h2{
    font-size: var(--font-size-lg);
    margin-bottom: var(--margin-sm);
    text-align: center;
}

/* Tablet styles (min-width: 768px) */
@media (min-width: 768px) {
    html{
        font-size: 16px;
    }
    
    main section{
        flex-direction: row; /* Side-by-side on tablet */
        padding: var(--padding-lg);
    }
    
    main section .left{
        width: 65%;
    }
    
    main section .right{
        width: 35%;
        order: 0; /* Reset order */
    }
    
    main section .top{
        justify-content: flex-start; /* Left align on tablet+ */
    }
    
    main section .bottom{
        padding: var(--padding-lg);
        aspect-ratio: 5/3;
    }
    
    main section .bottom .placeholder i{
        font-size: 6rem;
    }
    
    .btn{
        padding: var(--padding-sm) var(--padding-lg);
        font-size: var(--font-size-md);
    }
    
    .presets .btn{
        flex: 1 0 30%; /* 3 buttons per row on tablet */
    }
}

/* Desktop styles (min-width: 1024px) */
@media (min-width: 1024px) {
    main{
        padding: var(--padding-xl);
    }
    
    main section{
        padding: var(--padding-2xl);
    }
    
    main section .left{
        width: 70%;
    }
    
    main section .right{
        width: 30%;
        padding: var(--padding-lg);
    }
    
    main section .bottom{
        padding: var(--padding-2xl);
    }
    
    main section .bottom .placeholder i{
        font-size: 9rem;
    }
    
    .presets .btn{
        flex: 1 0 20%; /* 5 buttons per row on desktop */
    }
    
    h2{
        text-align: left; /* Left align headings on desktop */
    }
    
    main section .right .filter input::-webkit-slider-runnable-track{
        height: 3px;
    }
    
    main section .right .filter input::-webkit-slider-thumb{
        width: 20px;
        height: 20px;
        margin-top: -8.5px;
    }
}

/* Very small screens (max-width: 360px) */
@media (max-width: 360px) {
    main section{
        padding: var(--padding-sm);
        gap: var(--gutter-md);
    }
    
    main section .top{
        gap: 4px;
    }
    
    .btn{
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .presets .btn{
        min-width: 70px;
        padding: 6px 8px;
        font-size: 0.8rem;
    }
    
    main section .bottom{
        padding: var(--padding-sm);
        aspect-ratio: 1/1; /* Square on very small screens */
    }
}