        html, body { margin: 0; height: 100%; overflow: hidden; }
        body { background: #eaf4fb; font-family: 'Baloo 2', system-ui, sans-serif; }

        /* Fade suave ao trocar de cena: mudar nível/forma recarrega a página, e o
           View Transitions cross-document faz um cross-fade automático. Só rola entre
           páginas que também têm esta regra (aqui, o próprio jogo); navegador sem
           suporte simplesmente troca sem fade (degradação limpa). */
        @view-transition { navigation: auto; }
        ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .7s; }

        #puzzleCanvas { display: block; touch-action: none; }

        /* Barra de controles — fica logo ABAIXO do menu principal (kids-menu).
           --menu-h é a altura real do menu, medida em JS (varia no mobile).
           Grid 1fr|auto|1fr: os níveis ficam SEMPRE centrados (em fluxo, então a
           barra tem altura real) e o título encosta à esquerda. */
        .pz-bar {
            position: fixed; top: var(--menu-h, 52px); left: 0; right: 0; z-index: 55;   /* acima do menu (z:50) pra as formas que saltam aparecerem na frente */
            display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
            padding: 14px 28px;
            background: rgba(255, 255, 255, .82); backdrop-filter: blur(6px);
            box-shadow: 0 4px 14px rgba(15, 39, 64, .10);
        }
        .pz-title {
            font-weight: 800; font-size: 24px; color: #0f2740;
            min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        /* Níveis + formas juntos, centralizados no meio da barra, com uma linha
           divisória entre os dois grupos e bastante espaço em volta dela. */
        .pz-center { grid-column: 2; display: flex; align-items: center; gap: 32px; }
        .pz-sep { align-self: stretch; width: 2px; background: rgba(15, 39, 64, .14); border-radius: 2px; }
        .pz-niveis { display: flex; gap: 10px; }
        .pz-nivel {
            text-decoration: none; font-weight: 700; font-size: 16px; color: #fff;
            min-width: 56px; text-align: center;
            border-radius: 14px; padding: 11px 30px; box-shadow: 0 4px 10px rgba(15, 39, 64, .12);
            transition: transform .12s ease, filter .12s ease; opacity: .55;
        }
        .pz-nivel:hover { transform: translateY(-2px); }
        .pz-nivel.is-active { opacity: 1; transform: translateY(-1px); }

        /* Seletor de forma do corte (Reto / Geométrico), à direita da barra. */
        .pz-formas { display: flex; gap: 16px; align-items: center; height: 44px; position: relative; top: 16px; }   /* altura fixa curta: os botões saltam pra fora (overflow) sem esticar a barra; top desce um pouco pra não bater no menu */
        .pz-forma {
            position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 84px;
            text-decoration: none; font-weight: 800; font-size: 18px; color: #0f2740;
            background: #fff; border: 3px solid #e2e8f0; border-radius: 18px;
            padding: 8px 16px; box-shadow: 0 6px 14px rgba(15, 39, 64, .12);
            transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), border-color .12s ease, color .12s ease, box-shadow .2s ease;
        }
        .pz-forma:hover { transform: translateY(-12px) scale(1.15) rotate(-3deg); box-shadow: 0 18px 30px rgba(15, 39, 64, .24); z-index: 2; }
        .pz-forma.is-active { border-color: #2aa9e0; color: #2aa9e0; transform: translateY(-6px) scale(1.08); box-shadow: 0 14px 26px rgba(42, 169, 224, .30); }
        .pz-forma.is-active:hover { transform: translateY(-14px) scale(1.2) rotate(-3deg); }
        .pz-forma-img { display: block; height: 64px; width: auto; max-width: 130px; object-fit: contain; }   /* imagem representa o tipo de corte */

        /* Gatilho das opções (só no modo compacto): aba com triângulo pendurada
           logo abaixo do menu; abre/fecha a barra por cima do jogo. Colorida no
           estilo dos botões do sistema (gradiente kids-fwd, azul → índigo). */
        .pz-abrir {
            display: none; position: fixed; z-index: 56;   /* acima da barra (55) */
            top: var(--menu-h, 52px); left: 50%; transform: translateX(-50%);
            width: 76px; height: 36px; border: 0; padding: 0; cursor: pointer;
            border-radius: 0 0 20px 20px;
            background: linear-gradient(135deg, var(--c-blue), var(--c-indigo));
            box-shadow: 0 10px 22px rgba(42, 169, 224, .45);
            color: #fff; font-size: 20px; line-height: 1;
            -webkit-tap-highlight-color: transparent;
            transition: transform .15s ease;
        }
        .pz-abrir:active { transform: translateX(-50%) scale(0.92); }
        .pz-abrir .seta { display: inline-block; transition: transform .2s ease; }
        .pz-abrir.aberta .seta { transform: rotate(180deg); }

        /* Modo compacto (celular em pé OU deitado — na paisagem quem aperta é a
           ALTURA): jogo em FULL SCREEN — só o triângulo fica na tela; ele traz
           de volta o cromo inteiro (menu, opções, Voltar). Com o menu escondido,
           --menu-h zera sozinho (syncLayout) e a aba sobe pro topo. */
        @media (max-width: 820px), (max-height: 520px) {
            body:not(.pz-aberto) .menu,
            body:not(.pz-aberto) .kids-nav,
            body:not(.pz-aberto) .pz-trocar,
            body:not(.pz-aberto) .pz-hint { display: none !important; }
            .pz-bar { display: none; grid-template-columns: 1fr; justify-items: center; gap: 8px; padding: 12px 16px; }
            .pz-bar.aberta { display: grid; padding-top: 40px; animation: pzDesce .35s cubic-bezier(.34, 1.56, .64, 1); }   /* folga pra aba não cobrir o título + entrada com molinha */
            body.pz-aberto .menu, body.pz-aberto .kids-nav { animation: pzSurge .3s ease both; }   /* menu e Voltar voltam num fade */
            .pz-abrir { display: block; }
            .pz-center { grid-column: auto; flex-direction: column; gap: 14px; }
            .pz-sep { align-self: stretch; width: auto; height: 2px; }
            .pz-niveis { flex-wrap: wrap; justify-content: center; }
            .pz-nivel { padding: 10px 22px; }
            .pz-formas { flex-wrap: wrap; justify-content: center; height: auto; }   /* mobile: volta a ocupar altura normal (empilha) */
        }

        @keyframes pzDesce { from { opacity: 0; transform: translateY(-18px); } }
        @keyframes pzSurge { from { opacity: 0; } }

        /* Celular em pé: a página carrega normal, mas o QUEBRA-CABEÇA fica
           deitado (canvas girado 90°) — a pessoa vê que precisa deitar o
           aparelho. O motor (kids-puzzle) troca medidas e coordenadas pela
           MESMA media query; ao girar o telefone de verdade, tudo volta ao normal. */
        @media (max-width: 820px) and (orientation: portrait) and (pointer: coarse) {
            #puzzleCanvas {
                position: fixed; top: 0; left: 0;
                transform-origin: 0 0;
                transform: rotate(90deg) translateY(-100%);
            }
        }

        .pz-hint {
            position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
            z-index: 15; font-weight: 600; font-size: 13px; color: #355;
            background: rgba(255, 255, 255, .8); border-radius: 999px; padding: 6px 14px;
        }

        /* Botão "Carregar nova imagem" — só no modo livre (?livre=1). Pílula violeta
           alinhada ao Voltar/Avançar (kids-nav, left:24px); o JS posiciona o top
           logo abaixo deles. */
        .pz-trocar {
            position: fixed; left: 24px; z-index: 61;
            display: inline-flex; align-items: center; gap: 10px;
            height: 48px; padding: 0 20px 0 8px; border: 0; border-radius: 999px;
            color: #fff; font-family: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
            background: linear-gradient(135deg, #a78bfa, #7c3aed);
            box-shadow: 0 12px 28px rgba(124, 58, 237, .38);
            transition: transform .15s ease;
        }
        .pz-trocar:hover  { transform: translateY(-2px) scale(1.05); }
        .pz-trocar:active { transform: translateY(0) scale(0.96); }
        .pz-trocar-ic {
            display: grid; place-items: center; width: 36px; height: 36px; flex: none;
            border-radius: 50%; background: rgba(255, 255, 255, .28); font-size: 18px;
        }
        @media (max-width: 820px) { .pz-trocar { height: 44px; font-size: .95rem; } }

        /* Tela de "Parabéns" */
        .pz-win {
            position: fixed; inset: 0; z-index: 80; display: none;   /* acima da barra de níveis (55) e do menu aberto (70) */
            align-items: center; justify-content: center;
            background: rgba(15, 39, 64, .55); backdrop-filter: blur(4px);
        }
        .pz-win.show { display: flex; }
        /* Modal de vitória: a IMAGEM montada é a estrela (grande e em destaque);
           título compacto em cima e ações embaixo. A caixa se ajusta à imagem. */
        .pz-win-box {
            position: relative;
            background: #fff; border-radius: 26px; padding: 16px 16px 18px; text-align: center;
            max-width: min(97vw, 1180px); box-shadow: 0 24px 60px rgba(15, 39, 64, .35);
            animation: pzpop .7s cubic-bezier(.2, 1.2, .4, 1);
            display: flex; flex-direction: column; align-items: center; gap: 12px;
        }
        .pz-win-fechar {
            position: absolute; top: -18px; right: -18px; z-index: 2;
            width: 58px; height: 58px; border: 4px solid #fff; border-radius: 50%;
            background: #ec5a5a; color: #fff;
            font-size: 34px; line-height: 1; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            box-shadow: 0 8px 20px rgba(236, 90, 90, .5);
            transition: transform .18s cubic-bezier(.2, 1.4, .4, 1), background .18s;
        }
        .pz-win-fechar:hover { background: #e04545; transform: scale(1.15) rotate(90deg); }
        .pz-win-fechar:active { transform: scale(.92); }
        @keyframes pzpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
        .pz-win-title { margin: 0; color: #0f2740; font-size: 28px; }
        .pz-win-img {
            display: block; width: auto; height: auto;
            max-width: min(95vw, 1120px); max-height: 80vh;
            object-fit: contain; border-radius: 16px;
            box-shadow: 0 14px 40px rgba(15, 39, 64, .30);
        }
        .pz-win-acoes { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; width: 100%; }
        .pz-win-acoes a {
            text-decoration: none; font-weight: 800; font-size: 15px; color: #fff;
            border-radius: 14px; padding: 12px 18px; cursor: pointer;
        }
        .pz-de-novo { background: var(--c-green, #22b07d); }
        .pz-voltar  { background: #2aa9e0; }
        .pz-baixar  { background: #f0922b; }
