﻿        body {
            background-color: #333333; /* Fondo gris oscuro */
            font-family: 'Montserrat', sans-serif;
            margin: 0;
            padding: 0;
            overflow: hidden; /* Evitar scroll */
            -webkit-user-select: none;
            user-select: none;
        }
        #container {
            margin-top: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100vw;
            height: 100vh;
            overflow: hidden;
            position: relative;
        }
        #canvasContainer {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%; /* Asegurar que ocupe todo el ancho disponible */
            max-height: 100%;
            overflow: hidden;
            position: relative;
            background-color: #EEEEEE; /* Fondo gris muy claro */
            background-image: linear-gradient(45deg, #DDDDDD 25%, transparent 25%), 
                              linear-gradient(-45deg, #DDDDDD 25%, transparent 25%), 
                              linear-gradient(45deg, transparent 75%, #DDDDDD 75%), 
                              linear-gradient(-45deg, transparent 75%, #DDDDDD 75%);
            background-size: 20px 20px;
            background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
            cursor: crosshair; /* Cursor por defecto para pintar */
            touch-action: none; /* Desactivar acciones táctiles por defecto en móviles */
            -webkit-user-select: none;
            user-select: none;
        }
        #myCanvas {
            background-color: transparent;
            filter: drop-shadow(0px 4px 10px rgba(0, 0, 0, 0.3)); /* Sombra que se adapta al contenido */
            touch-action: none; /* Asegurar gestos táctiles (pinch/pan) en Android */
            -webkit-user-select: none;
            user-select: none;
        }
        #canvasContainer.edit-mode-active {
            outline: 4px solid #1e88e5;
            outline-offset: 4px;
        }
        #canvasContainer.edit-mode-active #myCanvas {
            filter: drop-shadow(0px 4px 12px rgba(30, 136, 229, 0.8));
        }
        #editOverlay {
            position: absolute;
            inset: 0;
            display: none;
            pointer-events: none;
        }
        #canvasContainer.edit-mode-active #editOverlay {
            display: block;
        }
        #editToolbar {
            position: absolute;
            top: 0;
            left: 0;
            display: flex;
            gap: 10px;
            pointer-events: auto;
            z-index: 110;
            transform: translate(0, 0);
        }
        #editToolbar .control-button {
            background-color: rgba(33, 150, 243, 0.9);
            color: #fff;
        }
        #editToolbar .control-button:hover {
            background-color: #1b75d1;
        }
        #editToolbar .control-button svg {
            width: 24px;
            height: 24px;
            stroke: currentColor;
            stroke-width: 2;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        #editToolbar .confirm-button {
            background-color: rgba(67, 160, 71, 0.9);
        }
        #editToolbar .confirm-button:hover {
            background-color: #2e7d32;
        }
        #editToolbar .cancel-button {
            background-color: rgba(229, 57, 53, 0.9);
        }
        #editToolbar .cancel-button:hover {
            background-color: #c62828;
        }
        #cropOverlay {
            position: absolute;
            border: 2px dashed #1e88e5;
            background-color: rgba(33, 150, 243, 0.12);
            display: none;
            pointer-events: none;
            z-index: 105;
        }
        #cropOverlay.crop-active {
            display: block;
            pointer-events: auto;
        }
        #cropOverlay .crop-area {
            position: absolute;
            inset: 0;
            cursor: move;
            pointer-events: auto;
        }
        .crop-handle {
            position: absolute;
            width: 26px;
            height: 26px;
            background-color: #1e88e5;
            border: 2px solid #ffffff;
            border-radius: 50%;
            pointer-events: auto;
            z-index: 120;
            touch-action: none;
            -webkit-tap-highlight-color: transparent;
        }
        .crop-handle::before {
            content: '';
            position: absolute;
            inset: -14px;
            border-radius: 50%;
            background-color: rgba(30, 136, 229, 0.001);
            pointer-events: auto;
        }
        .crop-handle.handle-top {
            top: 0;
            left: 50%;
            transform: translate(-50%, -50%);
            cursor: ns-resize;
        }
        .crop-handle.handle-right {
            top: 50%;
            right: 0;
            transform: translate(50%, -50%);
            cursor: ew-resize;
        }
        .crop-handle.handle-bottom {
            bottom: 0;
            left: 50%;
            transform: translate(-50%, 50%);
            cursor: ns-resize;
        }
        .crop-handle.handle-left {
            top: 50%;
            left: 0;
            transform: translate(-50%, -50%);
            cursor: ew-resize;
        }
        #cropOverlay.dragging .crop-area {
            cursor: grabbing;
        }
        .edit-toolbar-hidden {
            display: none !important;
        }
        #levelsPanel {
            position: absolute;
            top: 0;
            left: 0;
            transform: translate(0, 0);
            display: none;
            pointer-events: auto;
            z-index: 115;
            background-color: rgba(10, 10, 10, 0.85);
            color: #FFFFFF;
            padding: 16px 20px;
            border-radius: 12px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
            min-width: 260px;
            max-width: min(320px, calc(100vw - 32px));
            gap: 14px;
        }
        #levelsPanel.active {
            display: flex;
            flex-direction: column;
        }
        .levels-control {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        .levels-control label {
            font-size: 13px;
            min-width: 80px;
        }
        .levels-control input[type="range"] {
            flex: 1;
            accent-color: #1e88e5;
        }
        .levels-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 4px;
        }
        .levels-action-button {
            background-color: #1e88e5;
            border: none;
            color: #ffffff;
            border-radius: 10px;
            padding: 8px 14px;
            font-size: 13px;
            font-family: 'Montserrat', sans-serif;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            cursor: pointer;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
            transition: background-color 0.2s ease, transform 0.1s ease;
        }
        .levels-action-button:hover {
            background-color: #1669bb;
        }
        .levels-action-button:active {
            transform: translateY(1px);
        }
        .levels-action-button svg {
            width: 18px;
            height: 18px;
            stroke: currentColor;
            stroke-width: 2;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .levels-control .value {
            width: 42px;
            text-align: right;
            font-variant-numeric: tabular-nums;
        }
        #controls {
            position: fixed;
            top: 25px;
            right: 90px;
            left: auto;
            z-index: 100;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        #controls .control-button {
            margin: 0;
        }
        .control-button {
            padding: 10px;
            margin: 5px;
            font-size: 24px;
            cursor: pointer;
            border-radius: 50%;
            border: none;
            background-color: #ff4500;
            color: #fff;
            width: 50px;
            height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 3px 6px rgba(0,0,0,0.25); /* Sombra para botones */
            -webkit-user-select: none;
            user-select: none;
        }
        .control-button svg {
            width: 26px;
            height: 26px;
            stroke: currentColor;
            stroke-width: 2;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        /* Contenedor para los modos de pintura */
        #toolSelector {
            position: fixed;
            top: 90px;
            gap: 8px; /* Añadir espacio entre botones */
            left: 20px;
            z-index: 100;
            display: flex;
            flex-direction: column;
            max-height: calc(100vh - 120px);
            overflow-y: auto;
            padding-right: 16px;
            padding-bottom: 16px;
            overscroll-behavior: contain;
            touch-action: pan-y;
            -webkit-overflow-scrolling: touch;
        }
        #toolSelector > * {
            flex: 0 0 auto;
        }
        .tool-button {
            background-color: #666; /* Color base */
        }
        .active-tool {
            background-color: #cae8ff; /* Color de herramienta activa */
            border: 2px solid white;
            box-sizing: border-box;
        }
        .control-button:hover {
            background-color: #a7c1d5;
        }
        .color-circle {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            border: 2px solid white;
            box-shadow: 0 3px 6px rgba(0,0,0,0.25); /* Mantenemos la sombra */
        }
        .clr-texture-section {
            order: 5;
            margin-top: 16px;
            padding: 10px 0 18px;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            display: flex;
            flex-direction: column;
            gap: 10px;
            width: calc(100% - 32px);
            margin-left: 16px;
            margin-right: 16px;
        }
        .clr-texture-scroll-trigger {
            position: relative;
            margin: 0 auto;
            margin-top: -5px;
            width: 30px;
            height: 22px;
            padding: 0;
            border: none;
            background: transparent;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            order: 4;
        }
        .clr-texture-scroll-trigger::after {
            content: '';
            display: block;
            width: 0;
            height: 0;
            border-left: 10px solid transparent;
            border-right: 10px solid transparent;
            border-top: 12px solid rgba(255, 255, 255, 0.85);
            animation: pulseTriangle 1.8s ease-in-out infinite;
            --triangle-rotation: 0deg;
        }
        .clr-texture-scroll-trigger.scroll-triangle-up::after {
            --triangle-rotation: 180deg;
        }
        @keyframes pulseTriangle {
            0% {
                opacity: 0.8;
                transform: translateY(0) rotate(var(--triangle-rotation, 0deg));
            }
            50% {
                opacity: 1;
                transform: translateY(2px) rotate(var(--triangle-rotation, 0deg));
            }
            100% {
                opacity: 0.8;
                transform: translateY(0) rotate(var(--triangle-rotation, 0deg));
            }
        }
        .clr-picker {
            scrollbar-width: none;
            -ms-overflow-style: none;
        }
        .clr-picker::-webkit-scrollbar {
            width: 0;
            height: 0;
        }
        .clr-texture-section span {
            font-size: 0.7rem;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            color: rgba(255, 255, 255, 0.65);
        }
        .clr-texture-grid {
            display: grid;
            grid-template-columns: repeat(4, 52px);
            gap: 10px;
            justify-content: center;
        }
        .clr-texture-empty-message {
            font-size: 0.78rem;
            color: rgba(255, 255, 255, 0.75);
            text-align: center;
            margin: 0;
        }
        .texture-option {
            width: 52px;
            height: 52px;
            border-radius: 12px;
            border: 2px solid rgba(255, 255, 255, 0.6);
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            cursor: pointer;
            transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
            position: relative;
        }
        .texture-option::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: inherit;
            background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(0,0,0,0.25));
            pointer-events: none;
        }
        .texture-option.selected {
            border-color: #ffb300;
            box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0,0,0,0.4);
            transform: scale(1.04);
        }
        .texture-option:focus-visible {
            outline: 2px solid #ffffff;
            outline-offset: 3px;
        }
        #advancedColorPickerButton {
            background-color: #1e88e5;
            cursor: pointer;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            appearance: none;
            margin-left: 5px;
        }
        #advancedColorPickerButton:focus-visible {
            outline: 2px solid #ffffff;
            outline-offset: 3px;
        }
        #colorisInput {
            position: absolute;
            opacity: 0;
            width: 0;
            height: 0;
            pointer-events: none;
        }

        #opacitySliderContainer {
            position: fixed;
            display: none;
            align-items: center;
            gap: 6px;
            background-color: rgba(255, 255, 255, 0.95);
            padding: 8px 12px;
            border-radius: 10px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
            z-index: 120;
        }
        #opacitySliderContainer label {
            font-size: 12px;
            color: #333333;
        }
        #opacitySlider {
            width: 120px;
        }
        #opacityValue {
            font-size: 12px;
            color: #333333;
            min-width: 36px;
            text-align: right;
        }
        #toleranceSliderContainer {
            position: absolute;
            top: 0;
            left: 0;
            display: none;
            flex-direction: column;
            gap: 12px;
            background-color: rgba(10, 10, 10, 0.85);
            color: #ffffff;
            padding: 16px 20px;
            border-radius: 12px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
            min-width: 260px;
            max-width: min(320px, calc(100vw - 32px));
            pointer-events: auto;
            z-index: 118;
            transform: translate3d(0, 0, 0);
        }
        #toleranceSliderContainer label {
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: inherit;
        }
        #toleranceSliderContainer .tolerance-slider-row {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        #toleranceSlider {
            flex: 1;
            min-width: 160px;
            accent-color: #1e88e5;
        }
        #toleranceValue {
            font-size: 13px;
            font-weight: 600;
            min-width: 42px;
            text-align: right;
            color: inherit;
        }
        /* Botón de Reiniciar en la derecha */
        #resetButton {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 100;
            background-color: #ff4500;
            color: #fff;
            border: none;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            font-size: 24px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        #resetButton:hover {
            background-color: #e03e00;
        }
        #saveImageButton,
        #fullscreenButton {
            position: fixed;
            right: 20px;
            z-index: 100;
            color: #fff;
            border: none;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            font-size: 22px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 3px 6px rgba(0,0,0,0.25);
        }
        #saveImageButton {
            top: 80px;
            background-color: #1e88e5;
        }
        #saveImageButton:hover {
            background-color: #1669bb;
        }
        #fullscreenButton {
            top: 140px;
            background-color: #00acc1;
        }
        #fullscreenButton:hover {
            background-color: #0097a7;
        }
        #resetWarningModal {
            position: fixed;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.7);
            z-index: 999;
        }
        #resetWarningModal.active {
            display: flex;
        }
        #resetWarningContent {
            background: #1e1e1e;
            color: #ffffff;
            padding: 24px 28px;
            border-radius: 18px;
            max-width: 360px;
            width: calc(100% - 40px);
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
            font-family: 'Montserrat', sans-serif;
            text-align: center;
        }
        #resetWarningContent h2 {
            margin: 0 0 12px 0;
            font-size: 22px;
            letter-spacing: 0.5px;
        }
        #resetWarningContent p {
            margin: 0 0 24px 0;
            font-size: 15px;
            line-height: 1.4;
            color: #d3d7db;
        }
        .reset-modal-actions {
            display: flex;
            gap: 14px;
            justify-content: center;
            flex-wrap: wrap;
        }
        .reset-modal-actions button {
            min-width: 110px;
            padding: 10px 16px;
            border-radius: 30px;
            border: none;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
        }
        #cancelResetButton {
            background: rgba(255, 255, 255, 0.12);
            color: #ffffff;
        }
        #confirmResetButton {
            background: #ff4500;
            color: #ffffff;
        }
        #confirmResetButton:hover {
            background: #e03e00;
        }
        /* Estilos para la ventana modal */
        #modal {
            display: none; /* Oculto por defecto */
            position: fixed;
            z-index: 101;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.8); /* Fondo semitransparente oscuro */
            backdrop-filter: blur(5px); /* Desenfoque de fondo */
            /* Añadido para centrar el contenido */
            align-items: center;
            justify-content: center;
        }
        #modalContent {
            position: relative;
            background: linear-gradient(135deg, #a95bd8, #75d7e9, #16c3c6); /* Degradado personalizado */
            background-size: 220% 220%;
            animation: modalGradient 16s ease-in-out infinite;
            margin: 0; /* Quitar margen para que el centrado flex funcione */
            padding: 30px;
            border: none;
            width: 80%;
            max-width: 400px;
            text-align: center;
            border-radius: 20px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        }
        #modalLogo {
            max-width: 150px; /* Ajusta el tamaño del logo si es necesario */
            margin-bottom: 0; /* Reducir espacio con el título */
            border-radius: 15px; /* Bordes redondeados para el logo */
        }
        #modal h1 {
            font-family: 'Quicksand', sans-serif; /* Nueva fuente */
            font-size: 57px; /* Tamaño más grande */
            color: #fff; /* Cambiado a blanco para contraste */
            margin-top: 5px; /* Acercar al logo */
            margin-bottom: 20px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3); /* Sombra para legibilidad */
        }
        .modal-actions {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 14px;
            flex-wrap: wrap;
            margin-top: 50px;
        }
        .modal-actions.secondary-row {
            margin-top: 10px;
            flex-wrap: nowrap;
            justify-content: center;
        }
        #uploadButton {
            display: inline-block;
            padding: 15px 30px;
            font-size: 18px;
            cursor: pointer;
            border-radius: 30px;
            border: none;
            background: linear-gradient(135deg, #ff8a65, #ff7043);
            color: #fff;
            text-decoration: none;
            box-shadow: 0 3px 6px rgba(0,0,0,0.2);
            transition: background-color 0.2s ease, color 0.2s ease;
        }
        #uploadButton:hover {
            background: linear-gradient(135deg, #ff9e80, #ff7043);
        }
        #aboutButton {
            display: inline-block;
            padding: 15px 30px;
            font-size: 18px;
            border-radius: 30px;
            border: 2px solid rgba(255, 255, 255, 0.85);
            background: transparent;
            color: #fff;
            text-decoration: none;
            box-shadow: 0 3px 6px rgba(0,0,0,0.2);
            transition: background-color 0.2s ease, color 0.2s ease;
        }
        #aboutButton:hover {
            background-color: rgba(255, 255, 255, 0.15);
        }
        #openGalleryButton {
            display: inline-block;
            padding: 15px 30px;
            font-size: 18px;
            border-radius: 30px;
            border: none;
            background: linear-gradient(135deg, #26c6da, #1e88e5);
            color: #fff;
            text-decoration: none;
            box-shadow: 0 3px 6px rgba(0,0,0,0.2);
            transition: background-color 0.2s ease, color 0.2s ease;
        }
        #openGalleryButton:hover {
            background: linear-gradient(135deg, #4dd0e1, #1e88e5);
        }
        @keyframes modalGradient {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        #dropOverlay {
            position: fixed;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.65));
            backdrop-filter: blur(5px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
            z-index: 190;
        }
        #dropOverlay.visible {
            opacity: 1;
            pointer-events: auto;
        }
        #dropOverlay .drop-overlay-card {
            background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.88));
            border-radius: 20px;
            padding: 26px 30px 24px;
            box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
            border: 2px dashed rgba(30, 136, 229, 0.5);
            max-width: 380px;
            width: min(90vw, 420px);
            text-align: center;
            color: #1f1f1f;
            display: grid;
            gap: 8px;
        }
        #dropOverlay .drop-overlay-icon {
            width: 64px;
            height: 64px;
            margin: 0 auto 2px;
            border-radius: 50%;
            display: grid;
            place-items: center;
            font-size: 32px;
            color: #1e88e5;
            background: radial-gradient(circle at 30% 30%, rgba(30, 136, 229, 0.15), rgba(255, 255, 255, 0.9));
            border: 1px solid rgba(30, 136, 229, 0.35);
        }
        #dropOverlay .drop-overlay-title {
            margin: 0;
            font-size: 20px;
            font-weight: 700;
        }
        #dropOverlay .drop-overlay-subtitle {
            margin: 0;
            color: #4a5568;
            font-size: 15px;
        }
        #androidUploadMenu {
            position: fixed;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            background-color: rgba(0, 0, 0, 0.45);
            z-index: 999;
        }
        #androidUploadMenu.active {
            display: flex;
        }
        #androidUploadMenu .upload-menu-panel {
            background-color: #ffffff;
            border-radius: 18px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.35);
            padding: 20px;
            width: 260px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        #androidUploadMenu .upload-menu-panel button {
            font-size: 18px;
            padding: 12px 16px;
            border-radius: 12px;
            border: none;
            cursor: pointer;
            background-color: #ff4500;
            color: #fff;
            box-shadow: 0 3px 6px rgba(0,0,0,0.2);
        }
        #androidUploadMenu .upload-menu-panel button.secondary {
            background-color: #1e88e5;
        }
        #androidUploadMenu .upload-menu-panel button:active {
            transform: translateY(1px);
        }
        /* Botón flotante */
        #openModalButton {
            position: fixed;
            top: 25px; /* Mover hacia arriba */
            left: 25px; /* Mover hacia la izquierda */
            z-index: 102;
            background-color: #ff4500;
            color: #fff;
            border: none;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            font-size: 24px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 3px 6px rgba(0,0,0,0.25); /* Sombra para botones */
        }
        #openModalButton:hover {
            background-color: #e03e00;
        }
        /* Botón de cerrar modal */
        #closeModalButton {
            position: absolute;
            right: 20px;
            top: 20px;
            color: #fff; /* Cambiado a blanco para contraste */
            font-size: 30px;
            font-weight: bold;
            cursor: pointer;
            text-shadow: 0 2px 4px rgba(0,0,0,0.25); /* Sombra para el texto */
        }
        #closeModalButton:hover {
            color: #eee; /* Aclarar al pasar el ratón */
        }
        /* Efecto blur cuando el modal está abierto */
        .modal-open #container {
            filter: blur(5px); /* Aplicar desenfoque */
            margin-top: 0; /* Ocupar toda la altura */
            height: 100vh; /* Ocupar toda la altura */
            width: 100vw; /* Ocupar toda la anchura */
        }
    
