@import url('https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=Ancizar+Sans:ital,wght@0,100..1000;1,100..1000&family=Oswald:wght@200..700&family=Permanent+Marker&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');

/* Fondo con gradiente suave */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(120deg, #e0e7ff 0%, #f4f4f4 100%);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: background 0.8s;
}

/* Animación de entrada para el header */
header {
    margin-top: .5rem;
    margin-bottom: 1rem;
    text-align: center;
    animation: fadeInDown 1s;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 5px;
    font-family: "Permanent Marker", "Poppins", sans-serif;
    color: #4f46e5;
    margin-bottom: 0.3rem;
    text-shadow: 0 2px 8px #d1d5db;
    animation: popIn 1.2s;
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    80% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

header p {
    color: #555;
    font-size: .95rem;
    margin-top: 0.5rem;
    animation: fadeIn 1.5s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Controles con sombra y animación */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px #d1d5db;
    padding: 1rem 1.5rem;
    animation: fadeInUp 1.2s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Paleta de colores con animación y efecto de selección */
.colors {
    display: grid;
    grid-template-columns: repeat(10, 32px);
    gap: 10px;
    margin-bottom: 1rem;
    justify-content: center;
    animation: fadeIn 1.5s;
}

.color {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px #b6b6b6;
    cursor: pointer;
    transition: border 0.2s, transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.color:hover {
    transform: scale(1.18) rotate(-5deg);
    border-color: #6366f1;
    box-shadow: 0 0 12px #a5b4fc;
    z-index: 2;
}

.color.selected {
    border: 3px solid #4f46e5;
    box-shadow: 0 0 16px #6366f1;
    animation: pulse 0.6s;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 #6366f1;
    }

    70% {
        box-shadow: 0 0 16px 8px #a5b4fc;
    }

    100% {
        box-shadow: 0 0 16px 0 #6366f1;
    }
}

/* Estilos para el selector de color personalizado */
#customColor {
    width: 40px;
    height: 40px;
    border: none;
    transition: border 0.2s, box-shadow 0.2s, transform 0.2s;
    vertical-align: middle;
    margin-right: 8px;
}

/* Canvas con animación y efecto de foco */
#canvasContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px #d1d5db;
    padding: 2rem;
    margin-bottom: 1rem;
    max-width: 100vw;
    overflow-x: auto;
    transition: box-shadow 0.2s;
    animation: fadeInUp 1.3s;
}

#canvasContainer:focus-within {
    box-shadow: 0 0 0 6px #6366f1;
}

canvas {
    image-rendering: pixelated;
    border: 2px solid #6366f1;
    background: #f3f4f6;
    cursor: crosshair;
    touch-action: none;
    border-radius: 10px;
    transition: border 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 12px #a5b4fc;
    outline: none;
}

canvas:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 4px #6366f1;
}

/* Botones con animación y colores amigables */
button,
select,
input[type="number"] {
    font-size: 1rem;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    border: 1px solid #bbb;
    background: #f3f4f6;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    box-shadow: 0 1px 4px #e5e7eb;
    margin: 0 0.2rem;
}

button:hover,
select:hover,
input[type="number"]:hover {
    background: #6366f1;
    color: #fff;
    box-shadow: 0 2px 12px #a5b4fc;
}

button:active {
    background: #4f46e5;
    color: #fff;
}

label {
    font-size: 1rem;
    margin-right: 0.5rem;
    color: #4f46e5;
    font-weight: 500;
}

/* Responsive para móviles */
@media (max-width: 600px) {
    body {
        padding: 0;
        min-width: 100vw;
        width: 100vw;
        overflow-x: hidden;
    }

    header {
        margin-top: 0.7rem;
        margin-bottom: 0.5rem;
        padding: 0 0.5rem;
    }

    #saveGalleryBtn.saved {
        background: #4f46e5;
        color: #fff;
        box-shadow: 0 0 8px #6366f1;
        transition: background 0.2s, color 0.2s;
    }

    .controls,
    .colors,
    .color-picker-container {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #fff;
        box-shadow: 0 2px 8px #d1d5db;
        border-radius: 10px;
        width: 100vw;
        max-width: 100vw;
        margin-left: -10px;
        margin-right: -10px;
    }

    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.7rem 0.5rem;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .colors {
        grid-template-columns: repeat(5, 32px);
        gap: 8px;
        margin-bottom: 0.5rem;
        justify-content: center;
        padding: 0.5rem 0;
    }

    .color-picker-container {
        justify-content: center;
        gap: 10px;
        padding: 0.5rem 0;
        margin-bottom: 0.5rem;
    }

    #canvasContainer {
        padding: 0.5rem;
        margin-bottom: 0.7rem;
        border-radius: 10px;
        box-shadow: 0 2px 8px #d1d5db;
        max-width: 98vw;
        width: 98vw;
        margin-left: auto;
        margin-right: auto;
        overflow-x: auto;
        overflow-y: auto;
        min-height: 60vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    canvas {
        width: 96vw !important;
        max-width: 96vw;
        height: auto !important;
        border-radius: 8px;
        display: block;
        margin: 0 auto;
        min-height: 300px;
        min-width: 300px;
    }

    button,
    select,
    input[type="number"] {
        width: auto;
        min-width: 80px;
        margin: 0.2rem 0.2rem;
        font-size: 1rem;
        padding: 0.5rem 0.7rem;
        box-sizing: border-box;
    }

    #customColor {
        width: 36px;
        height: 36px;
    }

    .color-picker-label {
        font-size: 0.95rem;
        padding: 0.2rem 0.5rem;
    }

    footer {
        font-size: 0.9rem;
        padding-bottom: 0.7rem;
        text-align: center;
        width: 100vw;
        background: transparent;
        margin-top: 1rem;
        position: relative;
        bottom: 0;
    }
}

/* Animación de entrada general */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}