
html, body { max-width: 100%; overflow-x: hidden; }
main.m { padding: 0.75rem; padding-bottom: 3rem; max-width: 100%; }
.bp, .bp * { box-sizing: border-box; }
.bp { max-width: 52rem; margin: 0 auto; }
.bp-lead { font-size: 1.05rem; line-height: 1.6; max-width: min(65ch, 100%); }

.bp h2 { color: #0f3a78; font-size: 1.2rem; margin: 1.6rem 0 0.4rem; }
.bp h3 { font-size: 1.05rem; margin: 1.2rem 0 0.4rem; }
/* Os títulos recebem foco ao mudar de ecrã ou de passo: o foco tem de ser
   visível e o título não pode ficar escondido debaixo de barras fixas. */
.bp h2, .bp h3 { scroll-margin-top: 6rem; }
.bp h2:focus-visible, .bp h3:focus-visible { outline: 3px solid #b45309; outline-offset: 4px; }

/* ---------- Listas de níveis ---------- */
.bp-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.bp-item { margin: 0; }
.bp-level {
    display: flex; align-items: center; gap: 0.6rem;
    width: 100%; text-align: left;
    font: inherit; font-weight: 700;
    min-height: 56px; padding: 0.7rem 0.9rem;
    border: 2px solid #0f3a78; border-radius: 0.6rem;
    background: #fff; color: #0f3a78; cursor: pointer;
}
.bp-level:hover { background: #0f3a78; color: #fff; }
.bp-level:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
.bp-level .bp-state { margin-left: auto; font-weight: 400; font-size: 0.95rem; }
.bp-level[aria-disabled="true"] { opacity: 0.65; cursor: default; }
.bp-level[aria-disabled="true"]:hover { background: #fff; color: #0f3a78; }

/* ---------- Botões ---------- */
.bp-btn {
    font: inherit; font-weight: 700;
    min-height: 48px; min-width: 48px;
    padding: 0.6rem 1rem; margin: 0.25rem 0.35rem 0.25rem 0;
    border: 2px solid #0f3a78; border-radius: 0.5rem;
    background: #0f3a78; color: #fff; cursor: pointer;
}
.bp-btn.is-secondary { background: #fff; color: #0f3a78; }
.bp-btn:hover { background: #0f3a78; color: #fff; border-color: #0f3a78; }
.bp-btn:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
.bp-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }

/* ---------- Cartões ---------- */
.bp-card {
    border: 2px solid #0f3a78; border-radius: 0.6rem;
    padding: 0.9rem; margin: 1rem 0; background: #fff;
    overflow-wrap: anywhere;
}
.bp-card h2, .bp-card h3 { margin-top: 0; }

/* ---------- Nota secundária dentro do cartão ---------- */
.bp-note {
    display: block; margin: 0.9rem 0 0; padding: 0.6rem 0.8rem;
    border-left: 6px solid #94a3b8; border-radius: 0 0.4rem 0.4rem 0;
    background: #f1f5f9; color: #334155;
}
.bp-note-label {
    display: block; font-size: 0.8rem; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase; color: #475569;
    margin-bottom: 0.2rem;
}
.bp-note-text { margin: 0; font-size: 0.95rem; line-height: 1.55; }


/* ---------- Célula Braille ---------- */
/* Linhas de células: nunca partem para a linha seguinte; quando não cabem no
   cartão, deslocam-se na horizontal (dedo, rato ou teclado). */
.bp-cells {
    display: flex; flex-wrap: nowrap; gap: 0.9rem; align-items: flex-start;
    max-width: 100%; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
    padding-bottom: 0.35rem;
}
.bp-cells > * { flex: 0 0 auto; }
.bp-cell {
    display: inline-grid; width: max-content; justify-self: start;
    grid-template-columns: repeat(2, 1.5rem);
    grid-auto-rows: 1.5rem; gap: 0.35rem;
    padding: 0.5rem; border: 2px solid #0f3a78; border-radius: 0.4rem;
    background: #fff;
}
.bp-cell.is-big { grid-template-columns: repeat(2, 2.2rem); grid-auto-rows: 2.2rem; }
.bp-dot {
    width: 100%; height: 100%; border-radius: 50%;
    border: 2px solid #0f3a78; background: #fff;
}
.bp-dot.is-on { background: #0f3a78; }
.bp-dot.is-numbered {
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; font-weight: 700; line-height: 1; color: #0f3a78;
}
.bp-dot.is-numbered.is-on { color: #fff; }
button.bp-dot { padding: 0; cursor: pointer; min-width: 1.5rem; min-height: 1.5rem; }
button.bp-dot:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
.bp-cellwrap { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.bp-cellwrap .bp-caption { font-size: 0.95rem; }

/* ---------- Opções de escolha ---------- */
.bp-options { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.8rem 0; padding: 0; list-style: none; }
.bp-option {
    font: inherit; display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    min-height: 56px; padding: 0.6rem 0.9rem;
    border: 2px solid #0f3a78; border-radius: 0.6rem;
    background: #fff; color: #0f3a78; cursor: pointer; font-weight: 700;
}
.bp-option:hover { background: #0f3a78; color: #fff; border-color: #0f3a78; }
.bp-option:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
.bp-option.is-right { border-color: #14532d; background: #dcfce7; color: #14532d; }
.bp-option.is-try { border-color: #b45309; background: #fef3c7; color: #7c2d12; }

/* ---------- Estado / feedback ---------- */
.bp-status { font-size: 1.05rem; font-weight: 700; margin: 0.8rem 0; }
/* ---------- Sinal de certo + botão de som ---------- */
.bp-status.is-right { color: #14532d; }
.bp-check {
    display: inline-flex; align-items: center; justify-content: center;
    width: 3.2rem; height: 3.2rem; margin: 0.6rem 0;
    border-radius: 50%; background: #dcfce7; border: 3px solid #14532d;
    color: #14532d; font-size: 1.8rem; line-height: 1; font-weight: 700;
    animation: bp-pop 0.35s ease-out;
}
@keyframes bp-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bp-check { animation: none; } }
/* Barra de ferramentas no fluxo da página: nada fica em posição fixa, para
   não tapar o elemento com foco (WCAG 2.2, critério 2.4.11). */
.bp-tools { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.5rem 0 0.25rem; }
.bp-soundtoggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    min-height: 48px; min-width: 48px; padding: 0.6rem 1rem; font: inherit; font-weight: 700;
    border: 2px solid #0f3a78; border-radius: 999px;
    background: #fff; color: #0f3a78; cursor: pointer;
}
.bp-soundtoggle:hover { background: #0f3a78; color: #fff; border-color: #0f3a78; }
.bp-soundtoggle:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
.bp-soundtoggle[aria-pressed="false"] { background: #f3f4f6; color: #444; border-color: #666; }

/* Botão "Ouvir" quando a leitura em voz alta está desativada */
.bp button.is-muted[data-bp-muted],
.bp .bp-btn.is-muted[data-bp-muted] {
    background: #f3f4f6 !important;
    color: #5b5b5b !important;
    border: 2px dashed #8a8a8a !important;
    box-shadow: none !important;
}
.bp button.is-muted[data-bp-muted]:hover,
.bp .bp-btn.is-muted[data-bp-muted]:hover {
    background: #e5e7eb !important;
    color: #3f3f3f !important;
    border-color: #6b7280 !important;
}
.bp button.is-muted[data-bp-muted]:hover * { color: #3f3f3f !important; }

.bp-status.is-try { color: #7c2d12; }
.bp-progressline { font-size: 0.95rem; color: #333; }
.bp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.bp [hidden] { display: none !important; }
.bp-braille { font-size: 1.6rem; line-height: 1.2; }

/* ---------- Caixa de texto Braille (Nível 13) ---------- */
.bp-textbox {
    display: flex; flex-wrap: wrap; align-content: flex-start;
    gap: 0.22rem 0.3rem; width: 100%; min-height: 8rem;
    margin: 0.8rem 0; padding: 0.85rem;
    border: 2px solid #0f3a78; border-radius: 0.45rem;
    background: #f8fafc;
}
.bp-textbox.is-editable { border-style: dashed; background: #fff; }
.bp-textcell {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.45rem; height: 2rem; flex: 0 0 1.45rem;
    border: 1px solid transparent;
    font-size: 1.75rem; line-height: 1; color: #0f3a78;
}
.bp-textcell.is-space { margin-right: 0.55rem; }
.bp-textcell.is-pending { color: #64748b; border-bottom-color: #94a3b8; }
.bp-textcell.is-current { border: 2px solid #b45309; border-radius: 0.2rem; background: #fef3c7; }

/* ---------- Prática livre ---------- */
.bp-free { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.bp-free li { margin: 0; }

/* =====================================================================
   ESTABILIDADE VISUAL  (WCAG 2.2 — 2.4.11, 3.2.5, 2.5.8; boas práticas
   de previsibilidade para pessoas autistas ou sensíveis à mudança)
   Princípio: as LARGURAS são fixas (cartão e célula Braille), para que
   nada salte na horizontal ao mudar de cartão. As ALTURAS acompanham o
   conteúdo — sem reservas forçadas que tornem os cartões altos.
   ===================================================================== */

/* A barra de deslocamento não muda a largura da página. */
html { scrollbar-gutter: stable; }

/* Palco do exercício: largura estável. A altura acompanha o conteúdo. */
.bp #bpStage { display: block; width: 100%; }

/* Cartão: largura fixa (100% dentro do limite do bloco .bp). A altura
   ajusta-se ao conteúdo — sem altura mínima forçada, sem flex. */
.bp-card { width: 100%; margin: 1rem 0; }

/* Célula Braille interativa (exercícios de marcar pontos): o contorno fica
   justo aos pontos, como nas células de exemplo — não estica para a largura
   do cartão. */
.bp-card .bp-cell,
.bp-cellwrap .bp-cell {
    display: inline-grid;
    width: max-content;
    max-width: 100%;
}

/* Célula Braille: largura fixa em todas as variantes — as colunas da
   grelha são fixas (ver regras base de .bp-cell / .bp-cell.is-big), por isso
   cada célula tem sempre a mesma largura. A altura acompanha o conteúdo. */

/* Botões de confirmação dos exercícios: largura ajustada ao conteúdo e
   alinhados à esquerda — não ocupam toda a largura do cartão. */
.bp-card .bp-btn {
    display: inline-block;
    width: auto;
    text-align: left;
}

/* Opções de resposta: grelha de células com a mesma largura (estabilidade
   horizontal); a altura acompanha o conteúdo de cada linha. */
.bp-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 0.6rem;
}
.bp-options > li { margin: 0; display: flex; }
.bp-option { width: 100%; justify-content: center; text-align: center; }
/* Certo/errado só mudam a cor — a caixa mantém as mesmas dimensões. */
.bp-option, .bp-option.is-right, .bp-option.is-try { border-width: 2px; }

/* =====================================================================
   DESLOCAMENTO HORIZONTAL
   Qualquer conteúdo mais largo do que o cartão pode ser deslocado na
   horizontal: com o dedo, arrastando com o rato ou com o teclado
   (Tab para o focar, setas esquerda/direita para deslocar).
   ===================================================================== */
.bp-scrollx {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}
.bp-cells,
.bp-scrollx { cursor: default; }
.bp-cells.is-scrollable,
.bp-scrollx.is-scrollable { cursor: grab; }
.bp-cells.is-dragging,
.bp-scrollx.is-dragging { cursor: grabbing; user-select: none; scroll-behavior: auto; }
.bp-cells:focus-visible,
.bp-scrollx:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }
/* Sombra discreta a indicar que há mais conteúdo para o lado. */
.bp-scrollwrap { position: relative; max-width: 100%; }
.bp-card { overflow-x: clip; }

/* Nenhum contentor do jogo pode crescer para além do espaço disponível:
   sem isto, o cartão fica mais largo do que o ecrã e a linha de sinais
   passa a ficar cortada (fora do ecrã) em vez de se deslocar. */
main.m, .bp, .bp #bpStage, .bp-card, .bp-card > *, .bp-cellwrap {
    min-width: 0;
}
.bp-cells, .bp-scrollx { width: 100%; }

/* Barra de deslocamento sempre visível quando há mais sinais para o lado. */
.bp-cells.is-scrollable::-webkit-scrollbar,
.bp-scrollx.is-scrollable::-webkit-scrollbar { height: 0.55rem; }
.bp-cells.is-scrollable::-webkit-scrollbar-thumb,
.bp-scrollx.is-scrollable::-webkit-scrollbar-thumb {
    background: #94a3b8; border-radius: 0.3rem;
}
.bp-cells.is-scrollable::-webkit-scrollbar-track,
.bp-scrollx.is-scrollable::-webkit-scrollbar-track {
    background: #e2e8f0; border-radius: 0.3rem;
}


/* =====================================================================
   POPUP DE NÍVEL — página inteira, como os jogos
   Conteúdo alinhado ao topo e centrado na horizontal; botão ✕ no
   canto superior direito fecha o popup (equivale a "Voltar aos níveis").
   ===================================================================== */
html.bp-level-open, html.bp-level-open body { overflow: hidden; }

/* =====================================================================
   BARRA SUPERIOR DO SITE (header) RECOLHIDA COM POPUP ABERTO
   Enquanto está aberto o popup de um nível (html.bp-level-open) ou um
   jogo (html.bpg-locked), o cabeçalho fixo do site é recolhido para fora
   do ecrã, para nunca se sobrepor ao popup nem ao jogo. O !important
   sobrepõe-se ao "style.top" aplicado pelo /js/page_script.js.
   ===================================================================== */
html.bp-level-open #menu_box,
html.bpg-locked #menu_box {
    top: -20rem !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 1 !important;
}
html.bp-level-open .cookie-banner,
html.bpg-locked .cookie-banner { display: none !important; }

/* z-index acima de qualquer barra fixa do site (header rebatível incluído)
   para que o popup cubra toda a página, inclusive o cabeçalho. */
.bp #bpLevel {
    position: fixed; inset: 0; z-index: 10000;
    background: #fff;
    overflow-y: auto;
    display: flex; flex-direction: column; align-items: center;
    /* Espaço mínimo em cima: o conteúdo do cartão começa logo no topo.
       O padding à direita do título deixa livre o botão de fechar (✕). */
    padding: 0.5rem 1rem 2.5rem;
}
/* Título do popup o mais acima possível — sem margem nem padding extra. */
.bp #bpLevel > #bpLevelTitle {
    margin: 0 0 0.15rem !important;
    padding: 0 3.4rem 0 0 !important;
    line-height: 1.25;
}
.bp #bpLevel > #bpLevelStep { margin: 0 0 0.4rem; }
.bp #bpLevel > #bpStage { margin-top: 0; }
.bp #bpLevel #bpStage > .bp-card:first-child { margin-top: 0.4rem; }
.bp #bpLevel[hidden] { display: none !important; }
.bp #bpLevel > * { width: 100%; max-width: 52rem; }
/* Botão de fechar: quadrado, largura = altura, mais pequeno. */
.bp-level-close {
    position: fixed; top: 0.6rem; right: 0.6rem; z-index: 10001;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.5rem; height: 2.5rem;
    aspect-ratio: 1 / 1;
    padding: 0; margin: 0; font: inherit; font-weight: 700; font-size: 1.1rem;
    line-height: 1; border: 2px solid #0f3a78; border-radius: 0.5rem;
    background: #fff; color: #0f3a78; cursor: pointer;
}
.bp-level-close:hover { background: #0f3a78; color: #fff; border-color: #0f3a78; }
.bp-level-close:focus-visible { outline: 3px solid #b45309; outline-offset: 3px; }


/* Ecrãs estreitos. */
@media (max-width: 30rem) {
    .bp-options { grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); }
}


/* =====================================================================
   "Vamos Jogar" — jogo de queda de blocos (/js/braille-play-game.js)
   Contrastes verificados: texto branco sobre blocos com luminância baixa
   (>= 4.5:1) e texto claro sobre o fundo escuro (>= 7:1).
   ===================================================================== */
.bpg-sr {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
html.bpg-locked, html.bpg-locked body { overflow: hidden; }
/* O popup do jogo tem de ficar ACIMA do popup dos niveis (#bpLevel = 10000)
   e do respetivo botao de fechar (10001); caso contrario, ao abrir o jogo a
   partir de um nivel, o jogo fica escondido por baixo do cartao. */
.bpg-overlay {
    position: fixed; inset: 0; z-index: 20000;
    background: #05101f;
    background-image:
        radial-gradient(120% 80% at 50% -10%, #123a63 0%, rgba(5,16,31,0) 60%),
        radial-gradient(80% 60% at 10% 110%, #10284a 0%, rgba(5,16,31,0) 70%);
    color: #f2f7ff;
    overflow: auto;
    padding: 0.6rem;
}
.bpg, .bpg * { box-sizing: border-box; }
/* Sem esta regra, o display:flex de .bpg-panel anula o atributo hidden
   e o painel escuro fica sempre por cima dos blocos. */
.bpg [hidden] { display: none !important; }
.bpg {
    display: flex; flex-direction: column; gap: 0.6rem;
    max-width: 52rem; margin: 0 auto; min-height: 100%;
}
.bpg-top { display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center; }
.bpg-top-mid { min-width: 0; text-align: center; }
.bpg-title {
    margin: 0; font-size: 1rem; color: #f2f7ff; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bpg-title { text-align: center; }
.bpg-title-main, .bpg-title-serie { display: block; overflow: hidden; text-overflow: ellipsis; }
.bpg-title-serie { font-size: 0.85em; color: #ffd166; }
.bpg-title:focus-visible { outline: 3px solid #ffd166; outline-offset: 3px; }
.bpg-stat {
    display: flex; flex-direction: column; align-items: center;
    min-width: 5.5rem; padding: 0.4rem 0.7rem;
    border: 2px solid #2f5f96; border-radius: 0.7rem; background: #0b1e37;
}
.bpg-stat-label { font-size: 0.7rem; letter-spacing: 0.08em; color: #cfe2ff; }
.bpg-stat-value { font-size: 1.4rem; line-height: 1.1; color: #ffffff; }

.bpg-boardwrap { position: relative; }
/* Campo de jogo focável (role="application"): foco bem visível. */
.bpg-boardwrap:focus { outline: none; }
.bpg-boardwrap:focus-visible {
    outline: 3px solid #ffd166;
    outline-offset: 4px;
    border-radius: 10px;
}
/* Largura ajustada as colunas: COLS x ROWS celulas quadradas (8 x 12),
   para o espaco entre colunas ser igual ao espaco entre os blocos
   empilhados. Centrado e nunca mais largo que o ecra. */
.bpg-board {
    position: relative;
    width: min(100%, calc(min(58vh, 30rem) * 8 / 12));
    aspect-ratio: 8 / 12;
    margin: 0 auto;
    border: 2px solid #3b6ea8; border-radius: calc(0.5rem + 2px); /* raio interior = raio dos blocos (0.5rem) */
    background: #071729; overflow: hidden;
}
.bpg-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); }
.bpg-gridline { border-right: 1px dashed rgba(207,226,255,0.28); }
.bpg-gridline:last-child { border-right: 0; }
.bpg-layer { position: absolute; inset: 0; }
/* Limite superior da pilha: quando os blocos chegam a esta linha o jogo
   acaba. Visivel em todos os jogos. */
.bpg-limit {
    position: absolute; left: 0; right: 0; height: 0;
    border-top: 3px dashed #ff9f5a; pointer-events: none; z-index: 2;
}
/* So aparece depois de o jogo iniciar. */
.bpg-limit { display: none; }
.bpg-started .bpg-limit { display: block; }
.bpg-limit-tag {
    position: absolute; right: 0.35rem; top: 0.15rem;
    font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase;
    color: #0b1e37; background: #ff9f5a;
    border-radius: 0.35rem; padding: 0.05rem 0.35rem; font-weight: 800;
}
/* Pop-up central (2 s) com os simbolos Braille do que foi tocado. */
.bpg-pop {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9);
    z-index: 5; pointer-events: none; text-align: center;
    padding: 0.8rem 1.2rem; border-radius: 1rem;
    background: rgba(4, 13, 26, 0.94); border: 2px solid #ffd166;
    box-shadow: 0 8px 28px rgba(0,0,0,0.5);
    opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 92%;
}
.bpg-pop.is-in { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.bpg-pop.is-out { opacity: 0; transform: translate(-50%, -50%) scale(1.04); }
.bpg-pop-braille {
    font-size: clamp(2.2rem, 9vw, 3.4rem); line-height: 1.1; color: #ffffff;
    letter-spacing: 0.06em; word-break: break-word;
}
.bpg-pop-text {
    margin-top: 0.3rem; font-size: 1rem; font-weight: 800; color: #ffd166;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.bpg-block { cursor: pointer; }
.bpg-block:focus-visible { outline: 3px solid #ffd166; outline-offset: 3px; }
.bpg-block {
    position: absolute; top: 0; left: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 0.5rem; color: #101317; font-weight: 800; line-height: 1;
    box-shadow: 0 3px 0 rgba(0,0,0,0.45), 0 0 18px rgba(255,255,255,0.16);
    will-change: transform;
}
.bpg-block.is-landed { box-shadow: 0 2px 0 rgba(0,0,0,0.45); }
.bpg-block-ch { text-shadow: none; }
/* Cores claras e vivas: contraste >= 7:1 com a letra #101317 (WCAG 2.2 AAA). */
.bpg-c-amarelo { background: #ffd166; }
.bpg-c-verde   { background: #7ff0a1; }
.bpg-c-azul    { background: #8ecbff; }
.bpg-c-rosa    { background: #ffb3c7; }
.bpg-c-roxo    { background: #c9b6ff; }
.bpg-c-coral   { background: #ffc09f; }
.bpg-c-ciano   { background: #9be7ff; }
.bpg-c-lima    { background: #e8ff9b; }
.bpg-btn-start { font-size: 1.25rem; padding: 0.9rem 1.8rem; }
/* Nível 9 — bloco da sílaba já acertado: fundo azul escuro, letra branca
   (contraste 12.8:1, acima do mínimo pedido de 7.1:1) e contorno branco. */
.bpg-block.is-solved {
    background: #0b2f6b; color: #ffffff;
    outline: 3px solid #ffffff; outline-offset: -3px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.6);
}
.bpg-block.is-burst { animation: bpg-burst 0.42s ease-out forwards; }
@keyframes bpg-burst {
    0%   { transform-origin: center; filter: brightness(1); opacity: 1; }
    35%  { filter: brightness(2.2); opacity: 1; }
    100% { filter: brightness(2.4); opacity: 0; }
}
.bpg-panel {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 0.6rem; text-align: center;
    background: rgba(4,13,26,0.92); border-radius: 1rem; padding: 1rem;
}
.bpg-panel-title { margin: 0; font-size: 1.4rem; color: #ffffff; }
.bpg-panel-score { margin: 0; font-size: 1.6rem; font-weight: 800; color: #ffd166; }
.bpg-panel-text { margin: 0; color: #dce9ff; }
.bpg-panel-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }

/* A célula interativa ocupa uma linha própria a toda a largura, logo por
   baixo da área de jogo, para ficar sempre centrada com ela (em todos os
   níveis, incluindo sílabas e palavras). Bónus e velocidade ficam abaixo. */
.bpg-bottom { display: grid; grid-template-columns: minmax(9.5rem, 1fr) minmax(9.5rem, 1fr); gap: 0.6rem; align-items: start; }
.bpg-bottom > .bpg-cellbox { grid-column: 1 / -1; grid-row: 1; width: 100%; }
.bpg-bottom > .bpg-side { grid-row: 2; }
/* Jogos das sílabas e das palavras: não há caixa de bónus (a bomba não se
   aplica a grupos), por isso a caixa da velocidade fica sozinha e é
   centrada por baixo da célula, alinhada com a área de jogo. */
.bpg-bottom.is-solo > .bpg-side-speed {
    grid-column: 1 / -1; grid-row: 2;
    justify-self: center; width: min(100%, 18rem);
}

/* ---------- Bloco a cair: o essencial em texto ---------- */
.bpg-side {
    border: 2px solid #2f5f96; border-radius: 0.8rem; background: #0b1e37; padding: 0.6rem;
}
.bpg-side-title { margin: 0 0 0.4rem; font-size: 0.78rem; letter-spacing: 0.08em; color: #cfe2ff; }
.bpg-hint { margin: 0.4rem 0 0; font-size: 0.8rem; color: #cfe2ff; }

.bpg-bomb, .bpg-speed, .bpg-btn {
    font: inherit; font-weight: 700; cursor: pointer;
    min-height: 48px; width: 100%;
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.5rem 0.7rem; margin-bottom: 0.35rem;
    border: 2px solid #4d82c2; border-radius: 0.6rem;
    background: #10294a; color: #f2f7ff;
}
.bpg-bomb[disabled] { opacity: 0.55; cursor: default; }
.bpg-bomb.is-armed, .bpg-speed.is-on { background: #1b64ad; border-color: #9cc6ff; }
.bpg-bomb:focus-visible, .bpg-speed:focus-visible, .bpg-btn:focus-visible, .bpg-dot:focus-visible {
    outline: 3px solid #ffd166; outline-offset: 3px;
}
.bpg-speeds { display: grid; }
.bpg-speed-icon, .bpg-bomb-icon { font-size: 1rem; }

.bpg-cellbox { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bpg-cellbox .bpg-hint { max-width: 26rem; text-align: center; }
.bpg-cell {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem;
    padding: 0.6rem; border-radius: 1rem; background: #f3f4f6; border: 2px solid #cbd5e1;
}
.bpg-cell.is-wrong { animation: bpg-shake 0.35s ease; }
@keyframes bpg-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
/* Célula interativa do jogo: 2/3 do tamanho original (64->43, 34->23).
   A célula fixa (prefixo do nível 8) é reduzida na mesma proporção para
   manter a coerência ao lado da célula interativa. */
.bpg-dot {
    display: flex; align-items: center; justify-content: center; gap: 0.35rem;
    min-width: 43px; min-height: 43px; padding: 0.3rem;
    border: 2px solid transparent; border-radius: 0.7rem;
    background: transparent; color: #1f2937; font: inherit; font-weight: 700; cursor: pointer; margin-bottom:0
}
.bpg-dot-disc {
    width: 23px; height: 23px; border-radius: 50%;
    background: #d1d5db; border: 2px solid #6b7280;
    transition: transform 0.12s ease, background-color 0.12s ease;
}
.bpg-dot.is-on .bpg-dot-disc { background: #111827; border-color: #111827; transform: scale(1.08); }
.bpg-dot.is-on { border-color: #1b64ad; }
.bpg-dot-num { font-size: 0.9rem; color: #374151; }

/* célula fixa (ex.: sinal de número no nível 8)
   A linha é uma grelha de 3 colunas simétricas para que a célula
   interativa fique sempre centrada com a área de jogo, mesmo quando
   existe uma célula fixa à esquerda. */
.bpg-cellrow {
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center; gap: 0.6rem; width: 100%;
}
.bpg-cellrow > .bpg-cell { grid-column: 2; justify-self: center; }
.bpg-cellfixed { grid-column: 1; justify-self: end; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }

.bpg-cell.is-fixed { background: #e6eef8; border-color: #1b64ad; border-style: dashed; }
.bpg-cell.is-fixed .bpg-dot { min-width: 32px; min-height: 32px; cursor: default; }
.bpg-cell.is-fixed .bpg-dot-disc { width: 17px; height: 17px; }
.bpg-cell.is-fixed .bpg-dot.is-on .bpg-dot-disc { background: #123a63; border-color: #123a63; }
.bpg-cellfixed-tag { margin: 0; font-size: 0.78rem; font-weight: 700; color: #123a63; text-align: center; }



.bpg-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; padding-bottom: 0.5rem; }
.bpg-bar .bpg-btn, .bpg-panel .bpg-btn { width: auto; margin: 0; }
.bpg-btn.is-ghost { background: #0b1e37; }

/* Área de jogo centrada na página: bónus à esquerda, velocidade à direita.
   Grelha de 3 colunas com laterais iguais para o centro ficar exato. */
.bpg-stage { display: flex; align-items: flex-start; justify-content: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.bpg-stage > .bpg-boardwrap { flex: 0 1 auto; min-width: 0; width: calc(min(58vh, 30rem) * 8 / 12); }
.bpg-stage > .bpg-boardwrap .bpg-board { width: 100%; }
.bpg-side-bonus .bpg-bomb-txt { white-space: nowrap; }
/* Evita saltos do ecrã ao ativar o bónus. */
.bpg-stage { overflow-anchor: none; }
.bpg-side-bonus .bpg-bomb { flex-wrap: nowrap; }
.bpg-stage { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.bpg-stage > .bpg-side-bonus, .bpg-stage > .bpg-side-col { grid-column: 1; grid-row: 1; justify-self: end; width: 100%; max-width: 11rem; }
.bpg-side-col { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.bpg-side-col > .bpg-side { width: 100%; }
.bpg-stage > .bpg-boardwrap { grid-column: 2; grid-row: 1; }
.bpg-stage > .bpg-side-speed { grid-column: 3; grid-row: 1; justify-self: start; width: 100%; max-width: 11rem; }
.bpg-bottom > .bpg-cellbox { grid-row: auto; }

@media (max-width: 40rem) {
    .bpg-stage > .bpg-side-bonus, .bpg-stage > .bpg-side-speed, .bpg-side-col > .bpg-side-bonus { padding: 0.4rem; }
    .bpg-side-col .bpg-hint { display: none; }
    .bpg-stage > .bpg-side .bpg-speed-icon + span { font-size: 0.8rem; }
    .bpg-stage > .bpg-boardwrap { width: calc(min(48vh, 24rem) * 8 / 12); }
    .bpg-stage > .bpg-side .bpg-hint { display: none; }
    .bpg-stage { gap: 0.4rem; }
    .bpg-bottom { grid-template-columns: 1fr; }
    .bpg-bottom > .bpg-cellbox { grid-column: 1; grid-row: 1; }
    .bpg-bottom > .bpg-side { grid-column: 1; grid-row: auto; }
    .bpg-board { width: min(100%, calc(min(48vh, 24rem) * 8 / 12)); }
    .bpg-stat { min-width: 4.5rem; padding: 0.3rem 0.5rem; }
    .bpg-stat-value { font-size: 1.15rem; }
    .bpg-title { font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) {
    .bpg-block.is-burst { animation: none; opacity: 0; }
    .bpg-pop { transition: none; }
    .bpg-cell.is-wrong { animation: none; outline: 3px solid #b45309; }
    .bpg-dot-disc { transition: none; }
}

/* Regra global: qualquer botão em hover fica com fundo #0f3a78 e letra branca. */
.bp button:hover,
.bp [role="button"]:hover,
.bp .bp-btn:hover,
.bp .bp-level:hover,
.bp .bp-option:hover,
.bp .bp-soundtoggle:hover,
.bp .bp-soundtoggle[aria-pressed="false"]:hover {
    background: #0f3a78 !important;
    color: #fff !important;
    border-color: #0f3a78 !important;
}
.bp button:hover *,
.bp .bp-option:hover *,
.bp .bp-level:hover * { color: #fff !important; }

/* Enquanto o jogo esta aberto, o popup do nivel e o seu botao de fechar
   ficam inertes por tras, para nao capturarem cliques nem teclado. */
html.bpg-locked .bp #bpLevel,
html.bpg-locked .bp-level-close {
    pointer-events: none !important;
}
html.bpg-locked .bpg-overlay,
html.bpg-locked .bpg-overlay * { pointer-events: auto; }

/* =====================================================================
   SINAIS COM PREFIXO (várias células, ex.: barra / = ponto 6 + ponto 2)
   As células do mesmo sinal ficam juntas, lado a lado.
   ===================================================================== */
.bp-signgroup { display: flex; flex-wrap: nowrap; gap: 0.35rem; align-items: flex-start; }
.bp-signwrap .bp-cellwrap { gap: 0; }
.bp-editrow { gap: 0.9rem; }
.bp-options.has-multi { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
@media (max-width: 30rem) {
    .bp-options.has-multi { grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
}

/* =====================================================================
   v28 — Acessibilidade e ajustes de apresentação
   ===================================================================== */
/* Em pausa (ou qualquer painel), a linha e a etiqueta "limite" ficam por
   baixo da transparência do painel. */
.bpg-panel { z-index: 10; }

/* Quando o texto dos botões de bónus e velocidade não cabe a 100%,
   ficam só os ícones. O texto continua disponível para leitores de ecrã. */
.bpg-side .bpg-bomb-txt, .bpg-side .bpg-speed-label { white-space: nowrap; }
.bpg-bomb.is-compact, .bpg-speed.is-compact { justify-content: center; gap: 0; }
.bpg-bomb.is-compact .bpg-bomb-txt, .bpg-speed.is-compact .bpg-speed-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.bpg-speed.is-compact .bpg-speed-icon, .bpg-bomb.is-compact .bpg-bomb-icon { font-size: 1.3rem; }
.bpg-side .bpg-bomb, .bpg-side .bpg-speed { position: relative; overflow: hidden; }

/* Créditos discretos por baixo do jogo */
.bpg-credits { margin: 0.2rem 0 0.4rem; text-align: center; font-size: 0.78rem; color: #b9cbe6; }
.bpg-credits a { color: #cfe2ff; text-decoration: underline; text-underline-offset: 2px; }
.bpg-credits a:hover { color: #ffffff; }
.bpg-credits a:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; border-radius: 2px; }
.bpg-bomb.is-compact, .bpg-speed.is-compact { padding-left: 0.2rem; padding-right: 0.2rem; }
/* Títulos das caixas laterais nunca cortados */
.bpg-side-title { overflow-wrap: anywhere; }
/* Ícone do bónus (emoji escuro): disco claro por trás para dar contraste
   sobre o fundo azul escuro; o botão desativado deixa de escurecer o ícone. */
.bpg-bomb-icon {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 1.9rem; height: 1.9rem; border-radius: 50%;
    background: #ffd166; border: 2px solid #ffffff; line-height: 1;
}
.bpg-bomb[disabled] { opacity: 1; color: #b9cbe6; border-style: dashed; }
.bpg-bomb[disabled] .bpg-bomb-icon { background: #cfe2ff; }

/* v31 — "Muito rápida" em duas linhas */
.bpg-speed-label.is-2lines { display: inline-block; text-align: center; line-height: 1.1; }
.bpg-speed-label.is-2lines > span { display: block; white-space: nowrap; }

/* =====================================================================
   v29 — Popup do jogo acima de tudo; botões do site escondidos com o
   jogo ativo; popup de escolha do nível do jogo.
   ===================================================================== */
.bpg-overlay { z-index: 2147483000 !important; }
/* Com o jogo aberto, tudo o resto da página (botões "voltar atrás",
   "voltar ao início", popup dos níveis, etc.) fica escondido. */
html.bpg-locked body > *:not(.bpg-overlay) { visibility: hidden !important; }
html.bpg-locked .bp-level-close,
html.bpg-locked #bpBack,
html.bpg-locked #bpLevelActions,
html.bpg-locked .bp-level-open-actions { visibility: hidden !important; pointer-events: none !important; }
html.bpg-locked .bpg-overlay, html.bpg-locked .bpg-overlay * { visibility: visible; }
html.bpg-locked .bpg-overlay [hidden] { visibility: hidden; }

.bpg-levelpick { margin-bottom: 0; justify-content: center; background: #1b3f6e; border-color: #7fb0ea; }
.bpg-levelpick:hover { background: #24528c; }
.bpg-levelpick:focus-visible, .bpg-lvl-opt:focus-visible { outline: 3px solid #ffb86b; outline-offset: 2px; }
.bpg-lvl-backdrop {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(2, 8, 18, 0.78);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.bpg-lvl-dialog {
    width: min(100%, 26rem); max-height: 90vh; overflow: auto;
    background: #0b1e37; border: 2px solid #4d82c2; border-radius: 0.9rem;
    padding: 1rem; color: #f2f7ff;
    display: flex; flex-direction: column; gap: 0.7rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.6);
}
.bpg-lvl-dialog .bpg-panel-title { margin: 0; }
.bpg-lvl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
.bpg-lvl-grid .bpg-lvl-opt { justify-content: center; margin: 0; padding: 0.4rem; }
.bpg-lvl-opt.is-on { background: #ff9f5a; border-color: #ffd0a8; color: #1a0d00; }
.bpg-lvl-dialog .bpg-panel-actions .bpg-btn { width: auto; margin: 0; }
.bpg-lvl-toast {
    position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); z-index: 60;
    background: #ff9f5a; color: #1a0d00; font-weight: 700;
    padding: 0.7rem 1.1rem; border-radius: 0.7rem; box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.5);
    max-width: calc(100% - 2rem); text-align: center;
}
