
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
        --indigo: #4338CA;
        --indigo-light: #EEF2FF;
        --bg: #F8F7FF;
        --white: #ffffff;
        --text: #1e1b4b;
        --radius: 20px;
        --toolbar-h: 64px;
        --header-h: 56px;
    }
    html, body {
        height: 100%; width: 100%;
        background: var(--bg);
        font-family: 'Nunito', sans-serif;
        color: var(--text);
        overflow: hidden;
    }
    body {
        -webkit-user-select: none;
        user-select: none;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    header {
        position: relative; z-index: 100;
        height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        background: var(--white); border-bottom: 1.5px solid #e0e7ff;
        display: flex; align-items: center; justify-content: space-between;
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }
    .logo { font-size: 22px; font-weight: 900; color: var(--indigo); letter-spacing: -0.5px; }
    .logo span { color: #f59e0b; }
    .header-actions { display: flex; gap: 8px; }
    .icon-btn {
        width: 40px; height: 40px; border-radius: 50%;
        border: 1.5px solid #e0e7ff; background: var(--white); color: var(--indigo);
        display: flex; align-items: center; justify-content: center;
        cursor: pointer; transition: background .15s, transform .12s;
        -webkit-tap-highlight-color: transparent;
    }
    .icon-btn:active { transform: scale(0.88); background: var(--indigo-light); }
    .icon-btn:disabled { opacity: .25; pointer-events: none; }
    .toolbar {
        position: relative; z-index: 90; background: var(--indigo);
        height: var(--toolbar-h); display: flex; align-items: center; gap: 12px;
        padding: 0 max(16px, env(safe-area-inset-left, 0px));
    }
    .tool-group { display: flex; align-items: center; gap: 8px; flex: 1; }
    .tool-icon {
        width: 28px; height: 28px; background: rgba(255,255,255,.15);
        border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    }
    .tool-icon svg { width: 15px; height: 15px; }
    input[type=range].toolbar-range {
        -webkit-appearance: none; appearance: none;
        flex: 1; height: 4px; border-radius: 99px;
        background: rgba(255,255,255,.25); outline: none; min-width: 0;
    }
    input[type=range].toolbar-range::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 18px; height: 18px; border-radius: 50%;
        background: #fff; border: 2px solid var(--indigo);
        cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.25);
    }
    .divider-v { width: 1px; height: 32px; background: rgba(255,255,255,.2); flex-shrink: 0; }
    .progress-wrap { position: relative; z-index: 89; height: 10px; background: #c7d2fe; }
    .progress-fill {
        height: 100%; width: 0%;
        background: linear-gradient(90deg, #22c55e, #4ade80);
        border-radius: 0 6px 6px 0;
        transition: width .35s cubic-bezier(.4,0,.2,1);
    }
    .canvas-wrap {
        position: absolute;
        top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + var(--toolbar-h) + 10px);
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        left: 12px;
        right: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .canvas-container {
        position: relative;
        width: 100%;
        aspect-ratio: 1 / 1;
        max-width: min(100%, calc(100vh - var(--header-h) - env(safe-area-inset-top, 0px) - var(--toolbar-h) - 10px - 24px));
        transform-origin: 0 0;  /* ← única mudança */
        will-change: transform;
    }

    .canvas-outer {
        position: absolute;
        inset: 0;
        touch-action: none;
        overflow: hidden;
        background: transparent;
        /* ← remove o display:flex, align/justify-content */
    }

    canvas {
        position: absolute; top: 0; left: 0;
        width: 100%; height: 100%;
        display: block; touch-action: none;
    }
    #lineart-canvas { z-index: 30; pointer-events: none; }
    #scratch-canvas { z-index: 20; }
    #target-canvas  { z-index: 10; }

    .canvas-placeholder {
        position: absolute; inset: 0; display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 8px;
        pointer-events: none; z-index: 5;
    }
    #menu-overlay {
        display: none; position: fixed; inset: 0; z-index: 200;
        background: var(--bg); flex-direction: column;
    }
    #menu-overlay.open { display: flex; }
    .menu-header {
        display: flex; align-items: center; justify-content: space-between;
        padding: 0 max(16px, env(safe-area-inset-right, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
        background: var(--white); border-bottom: 1.5px solid #e0e7ff; flex-shrink: 0;
    }
    .menu-title { font-size: 14px; font-weight: 900; color: var(--indigo); text-transform: uppercase; letter-spacing: .08em; }
    .gallery-grid {
        display: grid; grid-template-columns: repeat(2, 1fr);
        gap: 12px; padding: 16px; overflow-y: auto; flex: 1; align-content: start;
    }
    @media (min-width: 480px) { .gallery-grid { grid-template-columns: repeat(4, 1fr); } }
    .art-card {
        display: flex; flex-direction: column; align-items: center;
        padding: 8px 8px 6px; border: 2px solid #e0e7ff; border-radius: 16px;
        background: var(--white); cursor: pointer;
    }
    .art-card.active { border-color: var(--indigo); background: var(--indigo-light); }
    .art-card img { width: 100%; aspect-ratio: 1/1; object-fit: contain; border-radius: 10px; margin-bottom: 5px; }
    .art-card span { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #6366f1; }
    #confetti-canvas { position: fixed; inset: 0; z-index: 999; pointer-events: none; display: none; }

    /* ── reveal: canvas de brilho diagonal ── */
    #shine-canvas { position: absolute; inset: 0; z-index: 40; pointer-events: none; display: none; border-radius: var(--radius); }

    /* ── animação de zoom out→in do viewport ── */
    @keyframes reveal-pulse {
        0%   { transform: scale(1); }
        30%  { transform: scale(0.88); }
        65%  { transform: scale(1.06); }
        100% { transform: scale(1); }
    }
    .reveal-anim { animation: reveal-pulse 0.7s cubic-bezier(.4,0,.2,1) forwards; }
    
    @keyframes slideUp {
        0%   { transform: translateY(0); opacity: 1; }
        100% { transform: translateY(100%); opacity: 0; }
    }
