
body {
    font-family: Arial, sans-serif;
    background: #110721;
    color: #110721;
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers the whole app on wide desktops */
    padding: 10px;       /* Slightly tighter padding for mobile edges */
    box-sizing: border-box;
}

/* --- THE TOP BAR (Logo + Controls Wrapper) --- */
.topbar {
    width: 100%;
    max-width: 1310px; /* 640px + 640px + 30px gap */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

/* Make your logo container scale down nicely */
.logo-container {
    width: 100%;
    max-width: 640px;
}
.logo-container img {
    width: 100%;
    height: auto;
    display: block;
}

.controls {
    box-sizing: border-box;
    min-height: 128px;   /* Allows height to grow if text wraps on tiny screens */
    width: 100%;
    max-width: 640px;
    background: #CCC;
    border-radius: 8px;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
}


/* --- THE WORKSPACE (Canvas + Saved Files Wrapper) --- */
.workspace {
    width: 100%;
    max-width: 1310px;
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: flex-start;
    box-sizing: border-box;
}

.canvas-container {
    width: 100%;
    max-width: 640px;
    aspect-ratio: 1 / 1; /* Automatically keeps it a perfect square on any device */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-sizing: border-box;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#savedfiles {
    width: 100%;
    max-width: 640px;
    height: 640px;
    background: #ccc;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 15px;
}

/* Maximum 20 lines of responsive stacking logic */
@media (max-width: 1330px) {
    .topbar, .workspace {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    /* Forces items to order exactly: Logo -> Controls -> Canvas -> Files */
    .logo-container { order: 1; }
    .controls       { order: 2; }
    .canvas-container{ order: 3; }
    #savedfiles     { order: 4; }

    /* Optional: Makes saved files slightly shorter on mobile so you don't scroll forever */
    #savedfiles {
        height: 450px; 
    }
}
