/* =========================================================
   BAÍA DOS NÚMEROS
   CSS específico das tarefas normais e difíceis da ilha.
   Arquivo extraído progressivamente de jogo-tarefas.css
   e paineis-visuais.css.
   Não incluir aqui regras gerais de palco, botões ou opções.
========================================================= */
/* =========================================================
   PAINÉIS VISUAIS DAS TAREFAS
   CSS específico de tarefas com fundo próprio:
   caranguejos, bolhas, coral e conchas.
   Arquivo extraído progressivamente de jogo-tarefas.css.
   Não incluir aqui regras gerais de palco, botões ou opções.
========================================================= */
/* =========================================================
   BASE DOS PAINÉIS COM FUNDO PRÓPRIO
========================================================= */

#palco-objetos.tarefa-caranguejos,
#palco-objetos.tarefa-bolhas {
    width: 100%;
    margin: 8px auto 12px;
    padding: 0;

    display: flex;
    justify-content: center;
    align-items: center;

    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.painel-fundo {
    position: relative;

    display: flex;
    justify-content: center;
    align-items: center;

    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
}

/* =========================================================
   TAREFA — CONTAGEM DE CARANGUEJOS
========================================================= */

.painel-caranguejos {
    width: min(320px, 100%);
    aspect-ratio: 320 / 160;

    background-image: url("../../../assets/tarefas/fundo_caranguejo.png");
}

.painel-caranguejos .painel-conteudo {
    width: 82%;
    height: 64%;
    max-height: 64%;
    padding: 4px;

    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    justify-items: center;
    align-content: start;
    gap: 10px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.painel-caranguejos .objeto-clicavel-contagem {
    position: relative;

    width: clamp(38px, 9vw, 42px);
    height: clamp(38px, 9vw, 42px);
    padding: 0;

    display: grid;
    place-items: center;

    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);

    box-shadow:
        0 3px 0 rgba(184, 107, 47, 0.22),
        0 6px 10px rgba(0, 0, 0, 0.08);
}

.painel-caranguejos .objeto-clicavel-contagem .objeto-img {
    width: clamp(24px, 6vw, 28px);
    height: clamp(24px, 6vw, 28px);
    object-fit: contain;
}

.painel-caranguejos .objeto-numero-contagem {
    top: -6px;
    right: -4px;

    min-width: 18px;
    height: 18px;

    font-size: 0.62rem;
}

.painel-caranguejos .objeto-clicavel-contagem.contado {
    background: #e9ffe9;
}

/* =========================================================
   TAREFA — CAMINHO DAS BOLHAS
========================================================= */

.painel-bolhas {
    width: min(320px, 100%);
    aspect-ratio: 320 / 128;

    background-image: url("../../../assets/tarefas/fundo_bolhas.png");
}

.painel-bolhas .painel-conteudo {
    width: 84%;
    height: 58%;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.painel-bolhas .bolha-numero {
    width: 50px;
    height: 50px;
    padding: 0;

    border-radius: 50%;

    background: radial-gradient(circle at 30% 25%, #ffffff, #8bdcff);
    color: var(--ocean-dark);

    font-size: 1.05rem;
    font-weight: 800;

    box-shadow: 0 4px 0 #3c8fc0;
}

/* =========================================================
   TAREFA 2 — COMPLETANDO O CORAL
   Baía dos Números · 6-7 · Rota Normal
========================================================= */

#palco-objetos.tarefa-completar-coral {
    width: 100%;
    min-height: auto;

    margin: 8px auto 14px;
    padding: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;

    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Área superior — Rede */

#palco-objetos.tarefa-completar-coral .area-rede-visual {
    position: relative;

    width: 100%;
    min-height: 205px;
    padding: 34px 12px 16px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    background-image: url("../../../assets/tarefas/fundo_rede_tarefa_1.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;

    border: none;
    box-shadow: none;

    overflow: hidden;
}

.placa-tarefa {
    position: absolute;
    left: 50%;
    top: 4px;

    transform: translateX(-50%);

    min-width: 120px;
    padding: 8px 18px;

    border-radius: 18px;

    background: linear-gradient(180deg, #348fe6, #1764b7);
    color: #ffffff;

    font-size: 1.12rem;
    font-weight: 900;
    line-height: 1;

    text-align: center;
    text-shadow: 1px 2px 0 rgba(0, 0, 0, 0.18);

    box-shadow:
        0 5px 0 #0d4e99,
        0 8px 14px rgba(0, 0, 0, 0.18);
}

.grade-peixes-rede {
    width: min(286px, calc(100% - 24px));
    margin: 10px auto 0;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px 8px;
}

.peixe-estoque-img {
    width: 46px;
    height: 46px;
    margin: 0;
    padding: 0;

    display: grid;
    place-items: center;

    border-radius: 14px;
    border: none;

    background: linear-gradient(180deg, #43a8ff, #2079d5);

    box-shadow:
        0 4px 0 #14599c,
        0 7px 12px rgba(0, 0, 0, 0.16);

    cursor: pointer;
}

.peixe-estoque-img img {
    width: 30px;
    height: 30px;

    display: block;
    object-fit: contain;
}

.peixe-estoque-img.movido {
    opacity: 0.28;
    transform: scale(0.92);
    filter: grayscale(0.25);
}

/* Instrução central */

.instrucao-arrastar-coral {
    margin: -2px auto 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;

    color: #6a4a2c;
    text-align: center;
}

.instrucao-arrastar-coral .seta-coral {
    font-size: 2rem;
    line-height: 0.8;
    color: #e9a83a;
    text-shadow:
        0 2px 0 #b46a1f,
        0 4px 8px rgba(0, 0, 0, 0.18);
}

.instrucao-arrastar-coral strong {
    font-size: 0.95rem;
    font-weight: 900;
}

/* Área inferior — Coral */

#palco-objetos.tarefa-completar-coral .area-coral-visual {
    position: relative;

    width: 100%;
    min-height: 190px;
    padding: 46px 14px 16px;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    background-image: url("../../../assets/tarefas/fundo_coral_tarefa_1.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;

    border: none;
    box-shadow: none;

    overflow: hidden;
}

.placa-coral {
    top: 0;

    min-width: 190px;

    background: linear-gradient(180deg, #ff9647, #e5661f);
    box-shadow:
        0 5px 0 #a94413,
        0 8px 14px rgba(0, 0, 0, 0.18);
}

.grade-slots-coral {
    width: min(286px, calc(100% - 24px));
    margin: 6px auto 0;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px 12px;
}

.slot-coral-vazio {
    width: 48px;
    height: 48px;

    display: grid;
    place-items: center;

    border: none;
    border-radius: 0;
    background: transparent;
}

.slot-coral-vazio.preenchido {
    background: transparent;
}

.peixe-coral-img {
    width: 40px;
    height: 40px;

    display: block;
    object-fit: contain;

    animation: peixeEntrandoCoral 0.22s ease both;
}

@keyframes peixeEntrandoCoral {
    from {
        opacity: 0;
        transform: scale(0.72) translateY(-6px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Botão confirmar específico */

.controles-coral .btn-controle-desafio {
    min-width: 220px;
    min-height: 52px;

    padding: 12px 26px;

    border-radius: 18px;

    font-size: 1rem;

    box-shadow:
        0 7px 0 #15549b,
        0 12px 18px rgba(0, 0, 0, 0.18);
}

.controles-coral .icone-btn-tarefa {
    width: 28px;
    height: 28px;
}

/* =========================================================
   TAREFA — ESTIMATIVA DE CONCHAS
========================================================= */

#palco-objetos.tarefa-estimativa-conchas {
    width: 100%;
    min-height: 155px;

    margin: 8px auto 12px;
    padding: 24px 18px 18px;

    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 12px;

    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 100% 100% !important;
    background-color: transparent !important;

    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;

    overflow: hidden;
}

#palco-objetos.tarefa-estimativa-conchas .objeto-estimativa-concha {
    width: 30px;
    height: 30px;
    padding: 0;

    display: grid;
    place-items: center;

    background: transparent;
    border: none;
    box-shadow: none;
}

#palco-objetos.tarefa-estimativa-conchas .objeto-estimativa-img {
    width: 28px;
    height: 28px;

    display: block;
    object-fit: contain;
}

#palco-objetos.tarefa-estimativa-conchas .objeto-estimativa {
    font-size: 0;
    line-height: 0;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"],
#palco-objetos.palco-padrao[data-exercicio-codigo="bussola_quebrada"],
#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"],
#palco-objetos.palco-padrao[data-exercicio-codigo="identidade_secreta"] {
    min-height: 180px;
    padding: 8px 6px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"] {
    background-image: url("../../../assets/tarefas/baia_numeros_dificil/trilha_pedras.png");
}

#palco-objetos.palco-padrao[data-exercicio-codigo="bussola_quebrada"] {
    background-image: url("../../../assets/tarefas/baia_numeros_dificil/bussola_quebrada.png");
}

#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] {
    background-image: url("../../../assets/tarefas/baia_numeros_dificil/farol.png");
}

#palco-objetos.palco-padrao[data-exercicio-codigo="identidade_secreta"] {
    background-image: url("../../../assets/tarefas/baia_numeros_dificil/identidade_secreta.png");
}

#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"] .reta-numerica,
#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] .reta-numerica {
    width: 100%;
    max-width: 320px;
    margin: 6px auto 10px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px 8px;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"] .ponto-reta,
#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] .ponto-reta {
    width: 52px;
    height: 52px;
    border-radius: 16px;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"] {
    padding: 12px 10px 14px;
    background-position: center 56%;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"] .reta-numerica {
    width: min(306px, 96%);
    transform: translateY(6px);
}

#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] {
    position: relative;
    min-height: 188px;
    padding: 8px 10px;
    background-position: center;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] .reta-numerica {
    position: absolute;
    left: 31%;
    right: 13%;
    top: 49%;
    transform: translateY(-50%);
    width: auto;
    max-width: none;
    margin: 0;
    padding-left: 0;

    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
}

#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] .ponto-reta {
    width: clamp(36px, 6.8vw, 48px);
    height: clamp(36px, 6.8vw, 48px);
    border-radius: 14px;
    font-size: clamp(0.82rem, 2.2vw, 0.96rem);
}

#tela-jogo:has(#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"]) #teclado-numerico,
#tela-jogo:has(#palco-objetos.palco-padrao[data-exercicio-codigo="trilha_pedras"]) .controles-desafio,
#tela-jogo:has(#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"]) #teclado-numerico,
#tela-jogo:has(#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"]) .controles-desafio {
    margin-top: 8px;
    gap: 12px;
}

/* =========================================================
   TAREFA — O SALTO DO GOLFINHO (RETA NUMÉRICA)
========================================================= */

#palco-objetos.palco-reta-numerica {
    width: min(360px, 100%);
    min-height: 204px;
    margin: 8px auto 12px;
    padding: 16px 10px 18px;
    border-radius: 26px;

    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
        url("../../../assets/tarefas/fundo_golfinho.png") no-repeat center / cover;

    border: 3px solid rgba(255, 255, 255, 0.72);
    box-shadow:
        inset 0 0 0 2px rgba(74, 144, 226, 0.24),
        0 10px 18px rgba(0, 0, 0, 0.12);
}

#palco-objetos.palco-reta-numerica .reta-numerica {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;

    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
    gap: 9px 7px;
    justify-items: center;
}

#palco-objetos.palco-reta-numerica .ponto-reta {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    border-width: 3px;

    background: linear-gradient(180deg, #ffffff, #e8f6ff);
    box-shadow:
        0 6px 0 #2c79c0,
        0 9px 14px rgba(0, 0, 0, 0.14);

    font-size: 1.08rem;
    font-weight: 900;
}

#palco-objetos.palco-reta-numerica .ponto-inicial {
    background: linear-gradient(180deg, #fff9df, #ffe8a6);
    border-color: #e49a2a;
    box-shadow:
        0 6px 0 #b56f13,
        0 9px 14px rgba(0, 0, 0, 0.14);
}

#palco-objetos.palco-reta-numerica .ponto-reta.selecionado {
    background: linear-gradient(180deg, #8dffc2, #3ccf79);
    border-color: #1f8f49;
    box-shadow:
        0 6px 0 #1b7a3f,
        0 9px 14px rgba(0, 0, 0, 0.14);
}

#tela-jogo:has(.palco-reta-numerica) .controles-desafio .btn-controle-desafio {
    min-height: 52px;
    min-width: min(280px, 92vw);
    padding: 12px 24px;
    font-size: 1rem;
}

/* ===============================
   BAÍA DOS NÚMEROS — FAROL DE PATRULHA
   Imagem chamada pelo JS
================================ */

#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] {
    position: relative;

    width: 100%;
    min-height: 188px;

    margin: 8px auto 12px;
    padding: 0;

    background-color: transparent !important;
    background-image: none !important;

    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;

    overflow: hidden;
}

/* A imagem já contém os números e interrogações.
   Então a reta gerada pelo JS não deve aparecer por cima. */
#palco-objetos.palco-padrao[data-exercicio-codigo="farol_patrulha"] .reta-numerica {
    display: none !important;
}