/* --- BASE --- */
* { box-sizing: border-box; }
body { 
    background: #000; 
    color: white; 
    font-family: sans-serif; 
    margin: 0; 
    display: flex; 
    justify-content: center; 
}

.app-container { 
    display: flex; 
    flex-direction: column; /* Móvil: Todo en una columna */
    gap: 20px; 
    padding: 15px; 
    align-items: center;
    width: 100%;
}

/* --- CANVAS (LADO IZQUIERDO EN PC) --- */
.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.canvas {
    position: relative;
    width: 312px; height: 312px; 
    background: #fff;
    image-rendering: pixelated;
    border: 5px solid #000;
    flex-shrink: 0;
    border-radius: 24px;
}

.layer {
    position: absolute; 
    width: 100%; height: 100%; 
    top: 0; left: 0;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-blend-mode: multiply;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
}

.no-tint { 
    background-blend-mode: normal !important; 
    -webkit-mask-image: none !important; 
    mask-image: none !important;
}

/* --- COLUMNA DE CONTROLES (LADO DERECHO EN PC) --- */
.controls-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 450px;
}

.selection-panel, .color-panel { 
    background: #1e1e1e; 
    padding: 20px; 
    border-radius: 24px; 
    width: 100%;
}

/* --- GRIDS Y SWATCHES --- */
.grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 10px; 
    margin-bottom: 20px; 
}

.item-card {
    background: #2a2a2a; border: 2px solid #444; 
    cursor: pointer; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 5px; border-radius: 8px;
}

.item-card img { width: 100%; image-rendering: pixelated; }

.picker-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); cursor: pointer; }

input[type="color"] { width: 40px; height: 40px; border: none; background: none; cursor: pointer; }

.download-btn {
    width: 100%; padding: 15px;
    background: #4CAF50; color: white;
    border: none; border-radius: 12px;
    font-weight: bold; cursor: pointer;
}

/* --- ADAPTACIÓN ESCRITORIO --- */
@media (min-width: 768px) {
    .app-container { 
        flex-direction: row; /* Gato izquierda, controles derecha */
        justify-content: center;
        align-items: flex-start;
        max-width: 1100px;
        padding: 40px;
    }

    .preview-section {
        position: sticky; /* El gato no se mueve al hacer scroll */
        top: 40px;
        width: 400px;
    }

    .canvas { width: 384px; height: 384px; }

    .controls-column {
        flex: 1; /* Ocupa el resto del espacio */
        max-width: 500px;
        height: 90vh;
        overflow-y: auto; /* Scroll solo en los controles */
        padding-right: 10px;
    }

    .grid { grid-template-columns: repeat(3, 1fr); }
}

.transform-details {
    width: 100%;
    background: #2a2a2a;
    border-radius: 12px;
    margin-top: 10px;
    padding: 10px;
    color: white;
}

.transform-details summary {
    cursor: pointer;
    list-style: none;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

.transform-controls {
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-row-range {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-row-range input {
    width: 65%;
}

.reset-btn {
    background: #666;
    color: white;
    border: none;
    padding: 5px;
    border-radius: 5px;
    cursor: pointer;
}

.canvas {
    position: relative;
    width: 312px; 
    height: 312px; 
    background: #fff;
    image-rendering: pixelated;
    border: 5px solid #000;
    overflow: hidden; /* Esto recorta al gato si se sale de los bordes */
}

#layer-background {
    transform: none !important; /* Garantiza que el fondo nunca se mueva por error */
}
