/* QUEBRA-CABEÇAS - arquivo único, independente do portal.css */

body.qb {
    margin: 0;
    background: #FFFFFF;
    color: #26303B;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.55;
    --linha: #EBEDF2;
    --ink2: #4C5765;
    --raio: 14px;
    --alvo: 44px;
    --acento: #7DCFB8;
    --forte: #085C46;
    --claro: #F3FBF8;
}

body.qb * { box-sizing: border-box; }
body.qb img { max-width: 100%; }
body.qb .cont a,
body.qb .trilha a { color: #085C46; font-weight: 750; }
body.qb .cont a:hover,
body.qb .trilha a:hover { color: #05382A; }
body.qb .mega-abre,
body.qb .mega-abre:hover { color: #fff; }
body.qb .mega-painel a { color: #243044; font-weight: 520; }
body.qb .mega-painel a:hover { color: var(--tom-t); }
body.qb .mega-painel a.atual,
body.qb .mega-painel a.atual:hover { color: #fff; }
body.qb .arvore a.tr-nome,
body.qb .arvore .tr-nome { color: #3A2E28; font-weight: 500; }
body.qb .arvore .tr-linha:hover .tr-nome,
body.qb .arvore li.on:not([data-n="1"]) > .tr-linha .tr-nome,
body.qb .arvore li.on:not([data-n="1"]) > details > summary.tr-linha .tr-nome { color: #10241C; font-weight: 600; }
body.qb header a.marca { color: var(--pa); font-weight: 800; }

/* ---------- cabeçalho ---------- */

.qb-topo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 10px 16px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--linha);
    position: sticky;
    top: 0;
    z-index: 600;
}

.qb-topo-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--alvo);
    padding: 0 18px;
    border: 2px solid var(--acento);
    border-radius: 999px;
    background: var(--claro);
    color: var(--forte);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.qb-topo-home:hover { background: var(--acento); }

.qb-trilha {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    color: var(--ink2);
}

.qb-trilha a { color: var(--ink2); text-decoration: none; }
.qb-trilha a:hover { color: var(--forte); text-decoration: underline; }
.qb-trilha strong { color: #26303B; }
.qb-sep { color: var(--ink2); }

/* ---------- conteúdo ---------- */

.qb-pagina { max-width: 1100px; margin: 0 auto; padding: 16px; }

.qb-titulo {
    font-size: clamp(22px, 3.4vw, 32px);
    line-height: 1.25;
    margin: 22px 0 8px;
}

.qb-texto { margin: 0 0 18px; color: var(--ink2); max-width: 70ch; }

.qb-bloco {
    border: 2px solid var(--acento);
    border-radius: var(--raio);
    background: var(--claro);
    padding: 18px 20px;
    margin: 0 0 22px;
}

.qb-bloco[hidden] { display: none; }
.qb-bloco h2 { margin: 0 0 10px; font-size: 20px; color: var(--forte); }
.qb-bloco ul { margin: 0 0 14px; padding-left: 20px; }
.qb-bloco li { margin-bottom: 8px; }

/* ---------- grade e cards ---------- */

.qb-grade {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.qb-grade > li { margin: 0; padding: 0; }

.qb-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #FFFFFF;
    border: 2px solid var(--linha);
    border-radius: var(--raio);
    overflow: hidden;
    color: #26303B;
    text-decoration: none;
}

.qb-card:hover { border-color: var(--acento); }
.qb-card:hover .qb-card-t,
.qb-card:hover .qb-card-num { color: var(--forte); }

.qb-card img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--claro);
}

.qb-card-t {
    display: block;
    padding: 10px 12px 2px;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.3;
}

.qb-card-c {
    display: block;
    padding: 0 12px 12px;
    font-size: 14px;
    color: var(--ink2);
}

.qb-card-num {
    display: block;
    padding: 10px 12px 12px;
    font-weight: 700;
    font-size: 17px;
    color: var(--forte);
}

/* ---------- barra de controles ---------- */

.qb-barra {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    padding: 12px 16px;
    background: var(--claro);
    border-bottom: 1px solid var(--acento);
}

.qb-linha {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.qb-rotulo { font-weight: 700; color: var(--ink2); }

.qb-relogio {
    font-variant-numeric: tabular-nums;
    font-size: 22px;
    font-weight: 700;
    color: var(--forte);
    background: #FFFFFF;
    border: 2px solid var(--acento);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 96px;
    text-align: center;
}

/* ---------- botões ---------- */

.qb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--alvo);
    padding: 0 18px;
    border: 2px solid #085C46;
    border-radius: 999px;
    background: #FFFFFF;
    color: #085C46;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.qb-btn:hover { background: #E7F6F1; color: #05382A; }

.qb-btn-forte { background: #085C46; border-color: #085C46; color: #FFFFFF; }
.qb-btn-forte:hover { background: #05382A; color: #FFFFFF; }
.qb-btn-vazio { background: #FFFFFF; }

.qb-btn[aria-pressed="true"] {
    background: var(--forte);
    border-color: var(--forte);
    color: #FFFFFF;
}

.qb-campo {
    min-height: var(--alvo);
    padding: 0 14px;
    border: 2px solid var(--acento);
    border-radius: 10px;
    background: #FFFFFF;
    color: #26303B;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.qb-oculto { display: none !important; }

.qb-topo-home:focus-visible,
.qb-trilha a:focus-visible,
.qb-card:focus-visible,
.qb-btn:focus-visible,
.qb-campo:focus-visible,
.qb-link:focus-visible,
.qb-sobe:focus-visible {
    outline: 3px solid var(--forte);
    outline-offset: 2px;
}

/* ---------- palco: anúncio, jogo, anúncio ---------- */

body.qb .qb-jogando .wrap {
    max-width: none;
    padding-left: 12px;
    padding-right: 12px;
}

.qb-palco {
    display: grid;
    grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) 150px;
    gap: 12px;
    align-items: start;
    margin: 0 0 18px;
}

.qb-palco > .arvore {
    position: sticky;
    top: calc(var(--topo) + 16px);
    max-height: calc(100vh - var(--topo) - 28px);
    overflow: auto;
    margin: 0;
}

.qb-miolo { min-width: 0; }

.qb-icones { display: inline-flex; gap: 6px; align-items: center; }
.qb-ico { width: 44px; min-width: 44px; padding: 0; }
.qb-tam { padding: 0 14px; }
.qb-svg {
    width: 20px; height: 20px; display: block;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}

.anuncio-lado {
    min-height: 100%;
    margin: 0;
    padding: 12px;
    border-radius: 16px;
    border: 2px dashed #7DCFB8;
    background: #F3FBF8;
    color: #085C46;
    font-weight: 750;
    text-align: center;
}

/* ---------- tabuleiro ---------- */

.qb-tabuleiro {
    position: relative;
    width: 100%;
    height: clamp(480px, 78vh, 900px);
    background: var(--claro);
    border: 2px solid var(--acento);
    border-radius: var(--raio);
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#qb-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

#qb-canvas:active { cursor: grabbing; }

.qb-previa {
    position: absolute;
    opacity: 0.45;
    pointer-events: none;
    border-radius: 4px;
}

.qb-aviso {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    margin: 0;
    padding: 8px 16px;
    background: #FFFFFF;
    border: 2px solid var(--acento);
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink2);
    text-align: center;
    max-width: calc(100% - 24px);
}

.qb-aviso:empty { display: none; }

.qb-vitoria {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: max-content;
    max-width: calc(100% - 24px);
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid #085C46;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
    text-align: center;
    padding: 12px 18px 14px;
}

.qb-vitoria[hidden] { display: none; }

.qb-vitoria-t { margin: 0; font-size: 30px; font-weight: 800; color: var(--forte); }
.qb-vitoria-s { margin: 0; color: var(--ink2); }

.qb-vitoria-tempo {
    margin: 4px 0 14px;
    font-size: 40px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--forte);
}

/* ---------- rodapé ---------- */

.qb-rodape {
    border-top: 1px solid var(--linha);
    margin-top: 20px;
    padding: 22px 16px 48px;
}

.qb-rodape-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 1100px;
    margin: 0 auto;
}

.qb-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--alvo);
    padding: 0 20px;
    border: 2px solid var(--acento);
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--forte);
    font-weight: 700;
    text-decoration: none;
}

.qb-link:hover { background: var(--acento); }

/* ---------- voltar ao topo ---------- */

.qb-sobe {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--forte);
    color: #FFFFFF;
    font-size: 22px;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(38, 48, 59, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 900;
}

.qb-sobe.mostra { opacity: 1; pointer-events: auto; }

@media (max-width: 1199px) {
    .qb-palco { grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); }
    .anuncio-lado { display: none; }
}

@media (max-width: 999px) {
    .qb-palco { grid-template-columns: 1fr; }
    .qb-palco > .arvore { order: 2; position: static; max-height: none; }
}

/* ---------- telas pequenas ---------- */

@media (max-width: 620px) {
    body.qb { font-size: 16px; }
    .qb-topo { padding: 8px 12px; }
    .qb-trilha { font-size: 14px; }
    .qb-pagina { padding: 12px; }
    .qb-barra { padding: 10px 12px; }
    .qb-linha { width: 100%; }
    .qb-btn { flex: 1 1 auto; padding: 0 12px; }
    .qb-campo { flex: 1 1 auto; }
    .qb-relogio { min-width: 84px; font-size: 19px; }
    .qb-grade { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
    .qb-tabuleiro { height: clamp(300px, 58vh, 520px); border-radius: 12px; }
    .qb-palco { grid-template-columns: 1fr; }
    .anuncio-lado { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .qb-sobe { transition: none; }
}