/* Batalha Naval: telas e cores das casas como no app (GameCell.tsx e gameConstants.ts) */
.bnaval {
  --bn-agua: #17324d;
  --bn-agua-borda: rgba(255, 255, 255, 0.14);
  --bn-moldura: var(--surface-2);
  --bn-azul: #2196f3;
  --bn-navio: #2e7d32;
  --bn-acerto: #ff5722;
  --bn-erro: #90a4ae;
  --bn-afundado: #c62828;
  --bn-verde-texto: #66bb6a;
  --bn-vermelho-texto: #ef5350;
  max-width: 980px;
  margin: 0 auto clamp(28px, 4vw, 44px);
}
:root[data-theme="light"] .bnaval {
  --bn-agua: #f0f8ff;
  --bn-agua-borda: #ccc;
  --bn-moldura: #f5f5f5;
  --bn-verde-texto: #2e7d32;
  --bn-vermelho-texto: #c62828;
}
.bnaval [hidden] {
  display: none !important;
}
.bnaval p {
  margin: 0;
}

/* ---------- Dificuldade (difficultyScreen) ---------- */
.bn-tela-dificuldade {
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
}
.bn-capa {
  width: min(100%, 240px);
  height: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.bn-titulo {
  margin: 0;
  font-size: clamp(20px, 3vw, 26px);
}
.bn-niveis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  width: min(100%, 720px);
}
.bn-nivel {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 18px 14px;
  border: 0;
  border-radius: var(--r);
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}
.bn-nivel:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}
.bn-nivel:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}
.bn-nivel-icone {
  font-size: 44px;
  line-height: 1.1;
}
.bn-nivel strong {
  font-size: 20px;
}
.bn-nivel span:last-child {
  font-size: 13px;
}
/* Verde, amarelo e vermelho do app, um pouco mais escuros para o texto branco ter contraste */
.bn-nivel-facil {
  background: #2e7d32;
}
.bn-nivel-medio {
  background: #ffc107;
  color: #333;
}
.bn-nivel-medio span:last-child {
  color: #5a4a00;
}
.bn-nivel-dificil {
  background: #d32f2f;
}

/* ---------- Jogo (gameScreen) ---------- */
.bn-topo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.bn-dificuldade {
  color: var(--text-2);
}
.bn-dificuldade strong {
  color: var(--blue-2);
}
:root[data-theme="light"] .bn-dificuldade strong {
  color: #1565c0;
}
.bn-topo-botoes {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bnaval .bn-pequeno {
  min-height: 42px;
  padding: 8px 16px;
}
.bn-icone {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 20px;
  cursor: pointer;
}
.bn-icone:hover {
  background: var(--surface-3);
}
.bn-icone:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
.bn-icone[aria-pressed="false"] {
  opacity: 0.7;
}
.bn-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.bn-vez {
  font-size: 16px;
  font-weight: 800;
}
.bn-vez.bn-vez-adversario {
  color: var(--bn-vermelho-texto);
}
.bn-tiros {
  color: var(--text-2);
  white-space: nowrap;
}

.bn-corpo {
  display: grid;
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
  gap: 18px;
}
@media (min-width: 880px) {
  .bn-corpo.bn-com-seletor {
    grid-template-columns: minmax(280px, 340px) minmax(0, 540px);
    align-items: start;
  }
}

/* Lista de navios (ShipSelector) */
.bn-seletor {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.bn-seletor-titulo {
  margin-bottom: 12px !important;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
}
.bn-frota {
  display: grid;
  gap: 8px;
}
.bn-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 2px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bn-item:hover {
  border-color: var(--blue-2);
}
.bn-item:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
.bn-item[aria-pressed="true"] {
  border-color: var(--bn-azul);
  background: rgba(33, 150, 243, 0.18);
}
.bn-item.bn-colocado {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.14);
  cursor: default;
}
.bn-previa {
  display: grid;
  flex: none;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  padding: 4px;
  background: var(--cor);
  border-radius: 6px;
}
.bn-previa-navio {
  display: block;
  width: calc(var(--n) * 24px);
  height: 24px;
  background-size: 100% 100%;
}
.bn-item-textos {
  min-width: 0;
}
.bn-item-nome {
  display: block;
  font-size: 14px;
  font-weight: 700;
}
.bn-item-info {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.bn-item-ok {
  display: block;
  margin-top: 4px;
  color: var(--bn-verde-texto);
  font-size: 12px;
  font-weight: 700;
}
.bn-orientacao {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-weight: 700;
}
.bnaval .bn-iniciar {
  width: 100%;
  margin-top: 14px;
  min-height: 52px;
  font-size: 17px;
}

/* Tabuleiro (GameBoard e GameCell) */
.bn-lado {
  min-width: 0;
}
.bn-rotulo {
  margin-bottom: 8px !important;
  font-weight: 800;
  text-align: center;
}
.bn-grade {
  container-type: inline-size;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  /* Linhas fixas: sem isso, a linha com 💧 ou com navio cresce e espreme as vazias */
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 540px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 5px;
  background: var(--bn-moldura);
  border: 2px solid var(--bn-azul);
  border-radius: 8px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.bn-casa {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bn-agua);
  border: 1px solid var(--bn-agua-borda);
  border-radius: 2px;
  color: inherit;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 5cqi;
  line-height: 1;
  cursor: default;
}
.bn-clicavel .bn-casa:not([aria-disabled="true"]) {
  cursor: pointer;
}
.bn-clicavel .bn-casa:not([aria-disabled="true"]):hover {
  filter: brightness(1.18);
}
.bn-casa:focus-visible {
  z-index: 1;
  outline: 3px solid var(--accent);
  outline-offset: -1px;
}
.bn-casa.bn-navio {
  background: var(--bn-navio);
}
.bn-casa.bn-acerto {
  background: var(--bn-acerto);
}
.bn-casa.bn-erro {
  background: var(--bn-erro);
}
.bn-casa.bn-afundado {
  background: var(--bn-afundado);
}
/* Último tiro, para dar para ver onde ele caiu */
.bn-casa.bn-ultimo {
  box-shadow: inset 0 0 0 3px #ffd54f;
}
/* Onde o navio escolhido vai ficar */
.bn-casa.bn-previa-ok {
  background: rgba(76, 175, 80, 0.55);
  box-shadow: inset 0 0 0 2px #a5d6a7;
}
.bn-casa.bn-previa-erro {
  background: rgba(239, 83, 80, 0.55);
  box-shadow: inset 0 0 0 2px #ef9a9a;
}

/* Fatia do desenho do navio: cada casa mostra o pedaço i da faixa com n pedaços */
.bn-fatia {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: calc(var(--n) * 100%) 100%;
  background-position: calc(var(--i) / (var(--n) - 1) * 100%) 0;
  pointer-events: none;
}
.bn-fatia.bn-vertical {
  transform: rotate(90deg);
}
.bn-img-carrier {
  --n: 5;
  background-image: url("/assets/jogos/batalha-naval/carrier.webp");
}
.bn-img-battleship {
  --n: 4;
  background-image: url("/assets/jogos/batalha-naval/battleship.webp");
}
.bn-img-submarine {
  --n: 3;
  background-image: url("/assets/jogos/batalha-naval/submarine.webp");
}
.bn-img-destroyer {
  --n: 3;
  background-image: url("/assets/jogos/batalha-naval/destroyer.webp");
}
.bn-img-patrol {
  --n: 2;
  background-image: url("/assets/jogos/batalha-naval/patrol.webp");
}

.bn-acoes {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}
.bn-instrucoes {
  max-width: 520px;
  margin: 12px auto 0 !important;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
.bn-instrucoes.bn-alerta {
  color: var(--bn-vermelho-texto);
  font-weight: 700;
}

/* ---------- Estatísticas ---------- */
.bn-estatisticas {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.bn-estatisticas-titulo {
  font-weight: 800;
}
.bn-numeros {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 720px;
  margin: 0;
}
@media (min-width: 720px) {
  .bn-numeros {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
.bn-numeros div {
  padding: 10px 6px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  text-align: center;
}
.bn-numeros dt {
  color: var(--muted);
  font-size: 12px;
}
.bn-numeros dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 800;
}

/* ---------- Diálogo (GameOverModal e confirmações) ---------- */
.bn-dialogo {
  width: min(calc(100% - 32px), 400px);
  padding: 24px 20px;
  color: var(--text);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.bn-dialogo::backdrop {
  background: rgba(10, 12, 16, 0.7);
}
:root[data-theme="light"] .bn-dialogo::backdrop {
  background: rgba(42, 29, 21, 0.45);
}
.bn-dialogo[open] {
  animation: bn-abrir 220ms ease-out;
}
@keyframes bn-abrir {
  from {
    opacity: 0;
    scale: 0.94;
  }
}
@media (prefers-reduced-motion: reduce) {
  .bn-dialogo[open] {
    animation: none;
  }
}
.bn-dialogo-titulo {
  margin-bottom: 8px !important;
  font-size: 24px;
  font-weight: 900;
}
.bn-dialogo-titulo.bn-venceu {
  color: var(--bn-verde-texto);
}
.bn-dialogo-titulo.bn-perdeu {
  color: var(--bn-vermelho-texto);
}
.bn-dialogo-texto {
  color: var(--text-2);
  line-height: 1.5;
}
.bn-dialogo-numero {
  display: grid;
  gap: 2px;
  margin-top: 16px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.bn-dialogo-numero span {
  color: var(--muted);
  font-size: 13px;
}
.bn-dialogo-numero strong {
  font-size: 28px;
}
.bn-dialogo-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}
.bnaval .bn-botao-vitoria {
  background: #2e7d32;
}
.bnaval .bn-botao-derrota {
  background: #d32f2f;
}
