* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #2b2a33; color: #f4efe6;
}

.jogo { display: flex; height: 100vh; min-height: 0; }
.area-tabuleiro {
  flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 6px;
}
/* overflow-y: auto, nao hidden: a 1000x600 nada sobra e nenhuma barra aparece, mas numa
   janela mais baixa o painel passa a ROLAR em vez de cortar o ultimo botao em silencio. */
.painel { flex: 0 0 300px; background: #35343f; overflow-y: auto; }

/* moldura: coordenadas + grade */
.moldura {
  --lado: 512px;
  display: grid;
  grid-template-columns: 20px var(--lado);
  grid-template-rows: var(--lado) 20px;
}
.numeros { display: grid; grid-template-rows: repeat(8, 1fr); }
.letras { display: grid; grid-template-columns: repeat(8, 1fr); }
.numeros span, .letras span {
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #c9c3b6;
}
.grade {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  width: var(--lado); height: var(--lado);
  box-shadow: 0 0 0 3px #1c1b22; touch-action: none; user-select: none;
}

.casa { position: relative; cursor: pointer; }
.casa.clara { background: #f0d9b5; }
.casa.escura { background: #b58863; }
.casa.ultimo { box-shadow: inset 0 0 0 100px rgba(255, 235, 59, .35); }
.casa.selecionada { box-shadow: inset 0 0 0 100px rgba(80, 160, 255, .45); }
.casa.xeque { box-shadow: inset 0 0 0 100px rgba(230, 40, 40, .5); }
.casa.arrastando .peca { opacity: .3; }

.peca { position: absolute; inset: 0; pointer-events: none; }
.peca svg, .fantasma svg { width: 100%; height: 100%; display: block; }
.fantasma { position: fixed; pointer-events: none; z-index: 10; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .45)); }

/* As três marcas de lance */
.marca { position: absolute; inset: 0; pointer-events: none; }
/* normal: bolinha verde no centro da casa vazia */
.marca-normal::after {
  content: ""; position: absolute; left: 35%; top: 35%; width: 30%; height: 30%;
  border-radius: 50%; background: rgba(30, 120, 60, .75);
}
/* captura: anel vermelho em volta da peça */
.marca-captura {
  border-radius: 50%; margin: 4%;
  box-shadow: inset 0 0 0 5px #c62828;
}
/* pulo: casa inteira laranja com moldura grossa que pulsa, mais o selo com a seta curva */
.marca-pulo {
  background: rgba(255, 152, 0, .45);
  box-shadow: inset 0 0 0 5px #ff6d00, inset 0 0 0 7px #fff;
  animation: pulsa 1.1s ease-in-out infinite;
}
.selo {
  position: absolute; right: 2px; top: 2px; width: 42%; height: 42%;
  background: #ff6d00; border-radius: 50%; box-shadow: 0 0 0 2px #fff; padding: 9%;
}
.selo svg, .amostra-pulo svg { width: 100%; height: 100%; display: block; }
@keyframes pulsa { 50% { background: rgba(255, 152, 0, .7); } }

.legenda {
  margin: 4px 0 0; font-size: 14px; line-height: 20px; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
  order: 3; /* a legenda fica sempre por ultimo: a placa do robo encosta no tabuleiro */
}
.amostra-pulo {
  flex: none; width: 20px; height: 20px; padding: 3px; background: #ff6d00;
  border-radius: 50%; box-shadow: 0 0 0 2px #fff; display: inline-block;
}

/* a placa do robô: carinha e nome, do lado do tabuleiro em que as peças dele estão */
.placa-robo { display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; }
.placa-robo[hidden] { display: none; }
.carinha-placa { flex: none; width: 34px; height: 34px; display: block; }
.carinha-placa svg { width: 100%; height: 100%; display: block; }
.nome-placa { font-size: 21px; font-weight: 700; letter-spacing: .3px; }

/* painel lateral: a coluna não rola; só a lista de lances rola, por dentro */
.painel { display: flex; flex-direction: column; gap: 8px; height: 100vh; min-height: 0; padding: 12px; }
.vez-linha { display: flex; align-items: center; gap: 10px; }
.chip-vez { flex: none; width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 2px #888; }
.chip-vez.b { background: #fdfcf9; }
.chip-vez.p { background: #2c2c2a; box-shadow: 0 0 0 2px #d3d1c7; }
.estado { margin: 0; font-size: 18px; min-height: 44px; font-weight: 600; display: flex; align-items: center; }
.estado.fim { font-size: 24px; color: #ffd166; background: #3b3a48; border-radius: 8px; padding: 6px 10px; box-shadow: 0 0 0 2px #ffd166; }
.b-novo.destaque { background: #ffd166; color: #2c2c2a; font-weight: 700; box-shadow: 0 0 0 3px #fff; animation: pisca 1s ease-in-out infinite; }
.estado.pensando { color: #ffd166; animation: pisca 1s ease-in-out infinite; }
@keyframes pisca { 50% { opacity: .55; } }
.capturadas { display: flex; flex-direction: column; gap: 6px; flex: none; }
.fileira { display: flex; flex-direction: column; gap: 2px; }
.rotulo { font-size: 12px; color: #c9c3b6; }
.pecas { display: flex; flex-wrap: wrap; min-height: 44px; align-content: flex-start; background: #2e2d38; border-radius: 6px; padding: 2px; }
.pecas .ico { width: 22px; height: 22px; background: #f0d9b5; border-radius: 4px; margin: 1px; }
/* quanto vale cada peça: uma fileira só, o Canhão com a borda laranja do pulo */
.valores { display: flex; flex-direction: column; gap: 2px; flex: none; }
.tabela-valores { display: flex; gap: 3px; background: #2e2d38; border-radius: 6px; padding: 3px; }
.valor { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 13px; line-height: 15px; }
.valor .ico { width: 26px; height: 26px; background: #f0d9b5; border-radius: 4px; }
.valor.canhao .ico { box-shadow: 0 0 0 2px #ff6d00; }
.valor.canhao b { color: #ffb36b; }
.painel h2 { margin: 2px 0 0; font-size: 14px; color: #c9c3b6; font-weight: 600; flex: none; }
.historico {
  flex: 1 1 0; min-height: 60px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: #2e2d38; border-radius: 6px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px 4px;
}
.historico li { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; height: 26px; }
.historico .numero { color: #9d98a8; margin-left: 4px; }
.historico .ico { width: 22px; height: 22px; background: #f0d9b5; border-radius: 4px; }
.historico .lance.pulo { background: #ff6d00; color: #fff; border-radius: 12px; padding: 0 4px 0 1px; box-shadow: 0 0 0 1px #fff; }
.ico-pulo { width: 16px; height: 16px; }
.botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: none; }
.botoes .b-ajuda { grid-column: 1 / -1; background: #ff6d00; border-color: #ffa04d; color: #fff; font-weight: 600; }
.botoes .b-ajuda:hover { background: #ff8a33; }
.botoes button, .caixa-inicial button.modo, .caixa-inicial button.lado, .caixa-inicial .comecar {
  font: inherit; color: inherit; background: #4a4958; border: 2px solid #6a6980;
  border-radius: 8px; padding: 7px 8px; cursor: pointer;
}
.botoes button:hover, .caixa-inicial button:hover { background: #5a5970; }

/* tela inicial */
.tela-inicial {
  position: fixed; inset: 0; z-index: 20; background: #2b2a33; display: flex;
  align-items: center; justify-content: center;
  /* auto, nao hidden: com a escolha dos dois jogos a tela ficou mais alta, e numa
     janela baixa cortar em silencio esconderia justamente o botao Comecar. */
  overflow: auto;
}
.tela-inicial[hidden] { display: none; }
.caixa-inicial { text-align: center; max-width: 900px; padding: 12px; margin: auto; }
.caixa-inicial h1 { margin: 0 0 14px; font-size: 34px; }
.modos { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.caixa-inicial .modo { font-size: 20px; padding: 10px 22px; }
.escolhido { border-color: #ffd166 !important; background: #5a5970 !important; }
.opcoes-robo[hidden] { display: none; }
.robos { display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }
.cartao-robo {
  width: 270px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; color: inherit; background: #3a3948; border: 3px solid transparent;
  border-top-color: var(--cor); border-radius: 12px; padding: 10px; cursor: pointer;
}
.cartao-robo.escolhido { border-color: #ffd166 !important; }
.carinha { width: 84px; height: 84px; display: block; }
.carinha svg { width: 100%; height: 100%; display: block; }
.nome-robo { font-size: 20px; font-weight: 700; }
.frase-robo { font-size: 14px; line-height: 18px; color: #ddd7c8; }
.lados { display: flex; gap: 10px; justify-content: center; align-items: center; margin-bottom: 12px; }
.caixa-inicial .comecar { font-size: 22px; font-weight: 700; padding: 10px 40px; background: #2e8b57; border-color: #3fae6e; }

/* caixa da promoção e cartão do Canhão: cobrem a tela */
.cobertura {
  position: fixed; inset: 0; z-index: 30; background: rgba(20, 19, 26, .8); display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
.cobertura[hidden] { display: none; }
.caixa-promocao, .caixa-cartao { background: #3a3948; border-radius: 14px; padding: 16px 20px; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.caixa-promocao h2, .caixa-cartao h2 { margin: 0 0 10px; font-size: 24px; }
.opcoes-promocao { display: flex; gap: 10px; margin-bottom: 12px; }
.escolha-promocao {
  display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; color: inherit;
  background: #4a4958; border: 3px solid #6a6980; border-radius: 10px; padding: 8px; cursor: pointer; width: 96px;
}
.escolha-promocao:hover { border-color: #ffd166; background: #5a5970; }
.ico-grande { width: 72px; height: 72px; background: #f0d9b5; border-radius: 8px; }
.cancelar-promocao, .fechar-cartao {
  font: inherit; color: inherit; background: #4a4958; border: 2px solid #6a6980; border-radius: 8px; padding: 7px 20px; cursor: pointer;
}
.fechar-cartao { background: #2e8b57; border-color: #3fae6e; font-weight: 700; padding: 8px 30px; }
.caixa-cartao { max-width: 940px; }
.caixa-cartao .sub { margin: 0 0 10px; color: #ddd7c8; }
.tres { display: flex; gap: 16px; justify-content: center; margin-bottom: 12px; }
.tres figure { margin: 0; width: 256px; }
.tres figcaption { font-size: 13px; line-height: 17px; margin-top: 6px; text-align: left; }
.tres figcaption em { color: #ffb36b; font-style: normal; font-weight: 700; }
.mini { --c: 30px; position: relative; display: grid; grid-template-columns: repeat(8, var(--c)); grid-template-rows: repeat(8, var(--c)); margin: 0 auto; width: calc(var(--c) * 8); box-shadow: 0 0 0 3px #1c1b22; }
.mc { position: relative; }
.mc.clara { background: #f0d9b5; }
.mc.escura { background: #b58863; }
.peca-mini { position: absolute; inset: 0; }
.peca-mini svg { width: 100%; height: 100%; display: block; }
.ponto { position: absolute; left: 30%; top: 30%; width: 40%; height: 40%; border-radius: 50%; background: rgba(30, 120, 60, .85); }
.ponto.pulo { left: 8%; top: 8%; width: 84%; height: 84%; border-radius: 4px; background: rgba(255, 152, 0, .6); box-shadow: inset 0 0 0 3px #ff6d00; }
.seta-mini { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }

/* ===== Celular e janelas estreitas =====
   O jogo nasceu para o computador: tabuleiro a esquerda, painel fixo de 300px a direita,
   tudo numa tela sem rolagem. Num celular isso nao cabe - sobra largura ZERO para o
   tabuleiro, e ele encolhe a quase nada. Aqui a linha vira pilha: tabuleiro em cima,
   painel inteiro embaixo, e a pagina passa a rolar.
   O --empilhado existe para o JS (tabuleiro-ui.js) saber em qual modo esta sem repetir
   o ponto de quebra: empilhado, ele mede o tabuleiro pela JANELA, porque a area passa a
   crescer com o proprio conteudo e a altura dela deixa de limitar qualquer coisa. */
:root { --empilhado: 0; }

@media (max-width: 760px) {
  :root { --empilhado: 1; }
  html, body { overflow: auto; height: auto; }
  .jogo { flex-direction: column; height: auto; min-height: 100%; }
  .area-tabuleiro { flex: none; width: 100%; padding: 4px 0 0; }
  .painel { flex: none; width: 100%; height: auto; overflow: visible; padding: 10px 12px 18px; }
  .historico { flex: none; height: 150px; }
  .legenda { white-space: normal; font-size: 13px; padding: 0 10px; }
  .estado { font-size: 17px; min-height: 0; }

  /* a tela inicial e as caixas que cobrem a tela podem passar da altura do celular */
  .tela-inicial, .cobertura { align-items: flex-start; overflow: auto; padding: 12px 0; }
  .caixa-inicial h1 { font-size: 26px; }
  .robos { flex-wrap: wrap; }
  .cartao-robo { width: 100%; max-width: 320px; }
  .caixa-promocao, .caixa-cartao { max-width: 100%; margin: 0 8px; padding: 12px; }
  .opcoes-promocao { flex-wrap: wrap; justify-content: center; }
  .escolha-promocao { width: 84px; }
  .ico-grande { width: 56px; height: 56px; }
  .tres { flex-wrap: wrap; }
  .tres figure { width: 100%; max-width: 288px; }
}

/* Os dois jogos na entrada: o do Canhao e o xadrez normal. Cartao DEITADO (desenho a
   esquerda, nome e frase a direita) de proposito: em pe ele comia a altura que a tela
   inicial precisa para os tres robos e o botao Comecar numa janela de 600px. */
.jogos { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.cartao-jogo {
  width: 340px; display: flex; align-items: center; gap: 10px;
  font: inherit; color: inherit; background: #3a3948; border: 3px solid #4a4958;
  border-radius: 12px; padding: 8px 10px; cursor: pointer;
}
.cartao-jogo:hover { background: #45445a; }
.cartao-jogo.escolhido { border-color: #ffd166 !important; }
.icone-jogo { flex: none; width: 52px; height: 52px; background: #f0d9b5; border-radius: 8px; padding: 2px; }
.icone-jogo svg { width: 100%; height: 100%; display: block; }
.texto-jogo { display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0; }
.nome-jogo { font-size: 19px; font-weight: 700; }
.frase-jogo { font-size: 12px; line-height: 16px; color: #ddd7c8; }

/* hidden precisa vencer o display das regras acima, que sao mais especificas */
.legenda[hidden], .valor[hidden], .botoes button[hidden], .placa-robo[hidden] { display: none !important; }

@media (max-width: 760px) {
  .jogos { flex-wrap: wrap; }
  .cartao-jogo { width: 100%; max-width: 340px; }
}
