        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            user-select: none;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            overflow-x: hidden;
            touch-action: manipulation;
        }

        .container {
            max-width: 100vw;
            margin: 0 auto;
            padding: 10px;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .header {
            margin-bottom: 7px; /* Mantém o espaçamento inferior */
            padding: 5px 10px; /* Ajustado para ter padding nas laterais também */
            
            display: flex; /* Transforma o header em um container flexível */
            align-items: center; /* Alinha verticalmente os itens (logo/título e user-info) ao centro */
        }

        .header h1 {
            color: white;
            font-size: clamp(1.5rem, 5vw, 2.5rem);
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
            margin-bottom: 5px;
        }

        .header p {
            color: rgba(255,255,255,0.9);
            font-size: clamp(0.8rem, 3vw, 1rem);
        }


        .game-area {
            display: flex;
            flex-direction: column;
            gap: 15px;
            flex: 1;
            background: rgba(255,255,255,0.95);
            border-radius: 20px;
            padding: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }


/* z-index define a ordem de sobreposição */
#coloringCanvas   { z-index: 1; }  /* tinta */
#outlineCanvas    { z-index: 2; pointer-events: none; width: 100% !important;  } /* contorno sempre visível */
#magnifierCanvas  { z-index: 3; }  /* lupa, se existir */



        /* Controles */
        .controls {
            display: flex;
            flex-direction: column;
            gap: 10px; 
            order: 2;
        }

        .control-section {
            background: white;
            border-radius: 15px;
            padding: 5px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        }


        /* Paleta de Cores */
        .color-palette {
            margin: 2px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
            gap: 8px;
            max-height: 120px;
            overflow-y: auto;
        }

        .color-item {
            aspect-ratio: 1;
            border: 3px solid #ddd;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.3s ease;
            min-height: 35px;
            position: relative;
        }

        .color-item:hover,
        .color-item.active {
            border-color: #333;
            transform: scale(1.1);
            box-shadow: 0 3px 10px rgba(0,0,0,0.3);
        }

        .color-item.active::after {
            content: '✓';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-weight: bold;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
        }

        /* Controle do Pincel */
        .brush-control {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .brush-control label {
            font-weight: bold;
            color: #333;
            white-space: nowrap;
        }

        .brush-slider {
            flex: 1;
            height: 6px;
            border-radius: 3px;
            background: #ddd;
            outline: none;
            -webkit-appearance: none;
        }

        .brush-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #4CAF50;
            cursor: pointer;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }

        .brush-preview {
            width: 30px;
            height: 30px;
            border: 2px solid #ddd;
            border-radius: 50%;
            background: white;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .brush-dot {
            background: #333;
            border-radius: 50%;
            transition: all 0.3s ease;
        }



        /* Status */
        .status {
            text-align: center;
            padding: 10px;
            background: rgba(255,255,255,0.9);
            border-radius: 10px;
            margin-top: 10px;
            font-weight: bold;
            color: #333;
            order: 4;
        }

 

        /* Melhorias para telas muito pequenas */
        @media (max-width: 480px) {
            .container {
                padding: 5px;
            }

            .game-area {
                padding: 5px;
                gap: 5px;
            }

            .control-section {
                padding: 10px;
            }

            .image-gallery {
                grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
                gap: 8px;
            }

            .color-palette {
                grid-template-columns: repeat(auto-fit, minmax(30px, 1fr));
                gap: 6px;
            }

            .color-item {
                min-height: 30px;
            }
        }

        /* Loading */
/* Seu CSS existente para .loading */
.loading {
    position: fixed; /* Fixado na tela */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9); /* Fundo branco semi-transparente */
    display: flex; /* Para centralizar o spinner */
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Garante que ele esteja ACIMA de tudo */
    flex-direction: column;
    
    /* Adicione estas transições para um efeito suave ao sumir */
    opacity: 1; /* Começa visível */
    visibility: visible; /* Começa visível */
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out; /* Transição para sumir */
}

/* A CLASSE CRÍTICA PARA ESCONDER */
.loading.hidden {
    opacity: 0; /* Torna-o totalmente transparente */
    visibility: hidden; /* Remove-o do fluxo de layout e do tab order, útil para acessibilidade */
    /* display: none; */ /* Opcional: Se você quer que ele suma imediatamente sem transição e libere o espaço */
    /* Se você usar 'display: none;', a transição de opacity não será aplicada. */
    /* Para transição suave, use opacity e visibility. */
}

        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 5px solid #f3f3f3;
            border-top: 5px solid #4CAF50;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .hidden {
            display: none;
        }


.tools-section h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
}

.tools-container {
    display: flex;
    gap: 10px;
    justify-content: center;
}





       .user-info {
   display: flex;
    align-items: center;
    gap: 15px;
    
    margin-left: auto; /* ESTE É O SEGREDO: Empurra este elemento para a direita, ocupando todo o espaço disponível */

    /* Remova estas propriedades se elas foram adicionadas na tentativa anterior e causaram problemas de fundo/padding */
    background: none;
    padding: 0;
    border-radius: 0;
    margin-bottom: 0;
}

.user-info p {
  margin: 0; /* Remove margem padrão do parágrafo */
    color: rgba(255,255,255,0.9); /* Altera para uma cor clara, consistente com o fundo degradê do body */
}

.header h1,
.header p:has(span[id="userName"]) ~ p /* Se tiver um p solto que não é o user-info */ {
    /* display: none; */ /* Descomente se quiser esconder elementos antigos no HTML */
}


/* ===== OTIMIZAÇÕES PARA DESKTOP (após remover o bloco de landscape conflitante) ===== */



    /* --- Paleta de Cores --- */
    .color-palette {
        grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); /* Mais colunas para as cores */
        max-height: none; /* Não limita a altura, mostrando todas as cores */
        overflow-y: visible; /* Sem scrollbar para as cores */
        padding: 5px; /* Um pouco de padding */
        justify-items: center; /* Centraliza os itens na grade */
    }

    .color-item {
        min-height: 40px; /* Cores maiores para melhor clique */
        min-width: 40px;
    }

    /* --- Controle do Pincel --- */
    .brush-control {
        justify-content: center; /* Centraliza o controle do pincel */
    }

    .brush-control label {
        font-size: 1rem; /* Labels do pincel maiores */
    }

    .brush-slider {
        height: 8px; /* Slider do pincel mais grosso */
    }

    .brush-slider::-webkit-slider-thumb {
        width: 24px; /* Polegar do slider maior */
        height: 24px;
    }

    .brush-preview {
        width: 35px; /* Pré-visualização do pincel maior */
        height: 35px;
    }


    /* --- Status --- */
    .status {
        padding: 15px; /* Mais padding */
        font-size: 1.1rem; /* Fonte maior */
    }






/* --- Interação de Mouse para Desktop (hover effects) --- */
/* Esta media query garante que os efeitos de hover e cursor: pointer só ocorram em dispositivos com mouse. */
/* Ela também ajusta o user-select para permitir seleção de texto em partes onde é útil. */
@media (hover: hover) and (pointer: fine) {
    /* Permite seleção de texto em todo o corpo, mas vamos sobrescrever em botões */
    body * {
        -webkit-user-select: text;
        user-select: text;
    }

    /* Mantém elementos interativos sem seleção de texto */
    .control-btn, .tool-btn, .color-item, .image-gallery img, .action-buttons .btn,
    #loginBtn, #registerBtn, #googleLoginBtn, #logoutBtn, #closePaletteModalBtn,
    .palette-option, .modal-close-btn, .brush-control label, .header h1, .header p {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Cursor de ponteiro para todos os elementos clicáveis */
    .control-btn, .tool-btn, .color-item, .action-buttons .btn,
    #loginBtn, #registerBtn, #googleLoginBtn, #logoutBtn, #closePaletteModalBtn,
    .palette-option, .modal-close-btn, .brush-slider::-webkit-slider-thumb {
        cursor: pointer;
    }

    /* Efeitos de hover */
    .color-item:hover {
        border-color: #333;
        transform: scale(1.1);
        box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    }
    .tool-btn:hover,
    .action-buttons .btn:hover,
    .modal-close-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
}

/* Ajustes para scrollbar em desktop (visualmente mais agradável) */
@media screen and (min-width: 992px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    ::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    ::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}



/* ===== ESTILOS BASE (MOBILE FIRST) para FERRAMENTAS E BOTÕES ===== */

.tools-section {
    margin-bottom: 5px;
}

.tools-section h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
    text-align: center; /* Centraliza o título no mobile também */
}

/* Container de botões - Mobile */
.tools-container {
    display: flex;
    flex-wrap: wrap; /* ESSENCIAL: Permite que os botões quebrem a linha */
    gap: 10px; /* Espaçamento entre os botões */
    justify-content: center; /* Centraliza os botões horizontalmente */
    padding: 0 5px; /* Adiciona um pequeno padding para não colar nas bordas em telas estreitas */
}


/* Ajusta o tamanho da fonte para o texto do botão para telas um pouco maiores, mas ainda mobile */
@media (min-width: 360px) {
    .tool-btn {
        font-size: 0.85rem;
        flex-basis: calc(25% - 10px); /* Tenta 4 colunas */
    }
    .tool-icon {
        font-size: 1.6rem;
    }
}


/* ===== MEDIA QUERIES PARA DESKTOP E TELAS MAIORES (revisado) ===== */

@media screen and (min-width: 768px) {
    
    .header {
        max-width: 800px; /* Define a mesma largura máxima do game-area */
        margin: 0 auto 15px auto; /* Centraliza e mantém o espaçamento inferior */
        padding: 15px 30px; /* Ajuste do padding do header */
    }
    
    .container {
        max-width: 960px; /* Mantém a largura máxima para o container principal */
    }

    .game-area {
        max-width: 800px; /* Largura máxima para a área do jogo */
        padding: 30px;
	/*#	lex-grow: 1; */
    }


    .controls {
        max-width: 700px; /* Largura máxima para os controles */
        gap: 10px;
    }

    .tools-section h3 {
        font-size: 1.2rem; /* Título maior para desktop */
    }

    .tools-container {
        display: grid; /* Usa grid para o layout em desktop */
        grid-template-columns: repeat(auto-fit, minmax(75px, 1fr)); /* 9 botões com min-width de 75px + gaps = 9*75 + 8*15 = 675 + 120 = 795px. Deve caber em 700px de largura se o grid encolher */
        gap: 15px; /* Mais espaço entre os botões */
        flex-wrap: initial; /* Reseta o flex-wrap */
        padding: 0; /* Remove padding extra */
    }

    .tool-btn {
        flex-direction: column; /* Continua ícone acima do texto */
        padding: 12px 10px; /* Padding maior */
        font-size: 0.95rem; /* Fonte maior para desktop */
        min-width: 75px; /* Nova largura mínima */
        flex-basis: auto; /* Deixa o grid controlar o tamanho */
    }

    .tool-icon {
        font-size: 1.8rem; /* Ícones maiores para desktop */
        margin-bottom: 5px;
    }

    /* Outros ajustes para desktop que você já tem podem permanecer */
    .color-palette {
        grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    }
    .color-item {
        min-height: 40px; min-width: 40px;
    }
    .brush-control label { font-size: 1rem; }
    .brush-slider { height: 8px; }
    .brush-slider::-webkit-slider-thumb { width: 24px; height: 24px; }
    .brush-preview { width: 35px; height: 35px; }
   /* .action-buttons .btn { padding: 15px 30px; font-size: 1.1rem; min-width: 150px; } */
    .status { padding: 15px; font-size: 1.1rem; }
}

/* Telas de desktop muito grandes (1200px+) - CORREÇÃO DE MAX-WIDTH do container*/
@media screen and (min-width: 1200px) {
    
    .header {
        max-width: 900px; /* Aumenta a largura máxima para telas maiores, igual ao game-area */
    }    
    .container {
        max-width: 900px; /* Permite que o container cresça mais */
    }

    .game-area {
        max-width: 900px; /* Aumenta a área do jogo */
    }

    .controls {
        max-width: 900px; /* Aumenta os controles */
    }

    .tools-container {
        grid-template-columns: repeat(auto-fit, minmax(85px, 1fr)); /* Permite botões ligeiramente maiores */
    }

    .color-palette {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    }
}

.price-table-wrap { overflow-x: auto; margin-top: 12px; }
.price-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.price-table th, .price-table td { padding: 12px; border-bottom: 1px solid #eee; vertical-align: top; text-align: left; }
.price-table thead th { background: #f6f6f6; color: #333; font-weight: 700; }
.price-table .price { font-weight: 700; margin-bottom: 8px; }
.price-table small { color: #666; }
.price-table .plan-cta { padding: 10px 12px; border: none; border-radius: 8px; cursor: pointer; font-weight: 700; background: #4CAF50; color: #fff; width: 100%; }
.price-table .plan-cta:hover { filter: brightness(0.95); }
.price-table tr.is-current td { background: #f0f8f0; }

.quota-line {
    margin-top: 8px;
    color: #cbd5e1;
    font-size: .9em;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

.quota-line strong {
    color: #fff
}

.quota-upgrade-btn {
    background: #f59e0b;
    color: #111;
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85em
}

.quota-upgrade-btn:hover {
    opacity: .9
}

     .menu-dropdown { transform: translateY(-10px); opacity: 0; transition: all 0.2s; }
     .menu-dropdown.active { transform: translateY(0); opacity: 1; }

#brushSizeControl,
#eraserSizeControl,
#zoomControl {
    font-size: .85em;
}


/* ===== ÁREA DO CANVAS - BLOCO ÚNICO ===== */

.canvas-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    order: 1;
    padding: 0;
}


/* canvases principais ocupam exatamente a mesma área */
#coloringCanvas,
#outlineCanvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

#coloringCanvas {
    z-index: 1;
    cursor: crosshair;
    touch-action: none;
}

#outlineCanvas {
    z-index: 2;
    pointer-events: none;
}

/* lupa separada, sem borda/sombra/círculo */
.magnifier-canvas,
#magnifierCanvas {
    position: absolute;
    width: 150px;
    height: 150px;
    display: none;
    pointer-events: none;
    z-index: 1000;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    inset: auto;
}


html.desktop-mobile-preview .container {
    align-items: center;
}

html.desktop-mobile-preview .game-area {
    width: min(430px, 100%);
    max-width: 430px;
    flex: 0 0 auto;
    margin: 0 auto;
}

html.desktop-mobile-preview .canvas-area {
    width: 100%;
}

.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
    border: 1px solid #d7d7d7;
    background: #fff;
}

html.desktop-mobile-preview .canvas-container {
    width: 100%;
    max-width: 390px;
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: none;
    margin: 0 auto;
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}

@media (max-width: 768px) {
    .canvas-container {
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto;
        min-height: 0;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }
}

/* ===== LARGURA UNIFICADA NO PREVIEW DESKTOP ===== */

html.desktop-mobile-preview .container {
    max-width: 430px;
    width: 100%;
    margin: 0 auto;
    padding: 10px;
    align-items: center;
}

html.desktop-mobile-preview .header,
html.desktop-mobile-preview .game-area,
html.desktop-mobile-preview .canvas-area,
html.desktop-mobile-preview .controls {
    width: 100%;
    max-width: 390px;
    margin-left: auto;
    margin-right: auto;
}

html.desktop-mobile-preview .game-area {
    flex: 0 0 auto;
    padding: 12px;
    gap: 12px;
}

html.desktop-mobile-preview .header {
    padding-left: 0;
    padding-right: 0;
}

/* ===== CANVAS QUADRADO ===== */

.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    background: #fff;
    border: 1px solid #d7d7d7;
}

#coloringCanvas,
#outlineCanvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ===== CONTROLES DESLIZANTES EMPILHADOS ===== */

#brushSizeControl,
#eraserSizeControl,
#zoomControl {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 0px;
    padding: 2px 12px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
}

#brushSizeControl .control-title,
#eraserSizeControl .control-title,
#zoomControl .control-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
}

#brushSize,
#eraserSize,
#zoomLevel {
    width: 100%;
}

#brushSizeValue,
#eraserSizeValue,
#zoomLevelValue {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    align-self: flex-end;
}

/* CONTROLES GERAIS MAIS ORGANIZADOS */
.controls {
    width: 100%;
}

.tools-section {
    width: 100%;
}

.tools-container {
    width: 100%;
}

/* Mobile real */
@media (max-width: 768px) {
    .header,
    .game-area,
    .canvas-area,
    .controls {
        width: 100%;
        max-width: 100%;
    }

    .game-area {
        gap: 10px;
        padding: 10px;
    }

    .canvas-container {
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto;
    }
}


/* ===== PREVIEW DESKTOP JÁ NO PRIMEIRO RENDER ===== */

html.desktop-mobile-preview .container {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    padding: 10px;
}

html.desktop-mobile-preview .header,
html.desktop-mobile-preview .game-area,
html.desktop-mobile-preview .canvas-area,
html.desktop-mobile-preview .controls {
    width: 100%;
    max-width: 390px;
    margin-left: auto;
    margin-right: auto;
}

html.desktop-mobile-preview .game-area {
    flex: 0 0 auto;
    gap: 12px;
    padding: 12px;
}

html.desktop-mobile-preview .canvas-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    min-height: 0;
    max-height: none;
    margin: 0 auto;
}

/* ===== FERRAMENTAS EM 2 LINHAS FIXAS ===== */

.tools-section {
    width: 100%;
}

.tools-section .tools-container {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    justify-content: stretch !important;
    align-items: stretch !important;
    padding: 0 !important;
    margin: 0 0 8px 0 !important;
}

.tools-section .tool-btn {
    min-width: 0 !important;
    width: 100% !important;
    padding: 8px 4px !important;
    border-width: 2px !important;
}

.tools-section .tool-icon {
    font-size: 20px !important;
    margin-bottom: 4px !important;
}

.tools-section .tool-btn span:last-child {
    font-size: 11px !important;
    text-align: center;
    line-height: 1.1;
}


.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

#coloringCanvas,
#paintLayerCanvas,
#outlineCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#paintLayerCanvas,
#outlineCanvas {
    pointer-events: none;
}