* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d2b16;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  /* Evita zoom, seleção de texto e menu de "copiar" ao segurar o dedo */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#jogo {
  position: fixed;
  inset: 0;
}

#jogo canvas {
  display: block;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 18px);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

#topo {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

#titulo {
  font-weight: 900;
  letter-spacing: 0.08em;
  font-size: 14px;
  font-style: italic;
}

#titulo span {
  color: #f7d84a;
}

#topo-direita {
  display: flex;
  align-items: center;
  gap: 8px;
}

#versao {
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  font-size: 11px;
}

.botao-redondo {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 17px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

/* Linha de cima: cartão do cobrador à esquerda, falta e placar à direita */
#linha-info {
  width: 100%;
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  transition: opacity 0.25s;
}

#info-direita {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  text-align: right;
}

#info {
  font-size: 14px;
}

#placar {
  min-height: 16px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.9;
}

/* Pílulas pequenas da coluna da direita: falta fixa (treino) e ranking do dia (desafio) */
#botao-fixar,
#botao-ranking,
#botao-tienda {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 14px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
}

#botao-fixar.ativo {
  background: #f7d84a;
  color: #1b2a12;
  border-color: #f7d84a;
}

/* Cartão do cobrador (toque para trocar) */
#cartao-cobrador {
  pointer-events: auto;
  max-width: 56%; /* sobra espaço para "Falta 1 do dia · 24 m" e o placar do desafio na coluna da direita */
  min-width: 180px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 7px 10px 6px;
  background: linear-gradient(135deg, rgba(20, 12, 12, 0.82), rgba(70, 12, 18, 0.78));
  color: #fff;
  text-align: left;
  text-shadow: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.cartao-linha {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cartao-numero {
  min-width: 34px;
  font-size: 26px;
  font-weight: 900;
  font-style: italic;
  color: #f7d84a;
  line-height: 1;
}

.cartao-nome {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  overflow: hidden;
}

.cartao-nome b {
  font-size: 15px;
  line-height: 1.1;
}

.cartao-nome small,
.cartao-ovr small {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cartao-ovr {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.cartao-ovr b {
  font-size: 20px;
}

.cartao-nota {
  margin-top: 5px;
  font-size: 11px;
  opacity: 0.95;
}

.cartao-nota b {
  color: #4ade80;
}

.cartao-nota u {
  color: #f7d84a;
  text-decoration: none;
  font-weight: 800;
}

#mensagem {
  margin-top: 4px;
  min-height: 22px;
  font-size: 17px;
  font-weight: 700;
}

#controles {
  transition: opacity 0.25s;
  margin-top: auto;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#barra {
  width: 100%;
  height: 14px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

#barra {
  position: relative;
}

/* Marca do ponto ideal de força: passar dela aumenta o erro */
#barra-ideal {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  margin-left: -1px;
  background: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
}

#barra-preenchida {
  height: 100%;
  clip-path: inset(0 100% 0 0);
  background: linear-gradient(90deg, #f7d84a, #f39c12 70%, #e74c3c);
}

#botao-chute {
  pointer-events: auto;
  touch-action: none;
  flex: 1;
  height: 64px;
  border: none;
  border-radius: 32px;
  background: #f7d84a;
  color: #1b2a12;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: 0 4px 0 #b8971a, 0 6px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

#botao-chute.pressionado {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b8971a, 0 3px 8px rgba(0, 0, 0, 0.35);
  background: #ffe36b;
}

#dica {
  font-size: 13px;
  opacity: 0.9;
  text-align: center;
}

/* Bola grande para escolher o ponto de contato */
#linha-chute {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
}

#contato {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#contato-bola {
  pointer-events: auto;
  touch-action: none;
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffffff 0%, #ececec 45%, #b9b9b9 100%);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  cursor: crosshair;
}

/* Linhas finas em cruz para dar referência do centro */
#contato-bola::before,
#contato-bola::after {
  content: "";
  position: absolute;
  background: rgba(0, 0, 0, 0.15);
}

#contato-bola::before {
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 1px;
}

#contato-bola::after {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 1px;
}

#contato-ponto {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: #e63946;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

#contato-rotulo {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Painel de ajuste */
#painel {
  pointer-events: auto;
  touch-action: pan-y;
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 8px;
  right: 8px;
  max-width: 460px;
  margin: 0 auto;
  max-height: 62vh;
  overflow-y: auto;
  padding: 12px 14px 14px;
  border-radius: 14px;
  background: rgba(10, 20, 14, 0.92);
  text-shadow: none;
  font-size: 13px;
}

#painel[hidden] {
  display: none;
}

#painel-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}

#painel h3 {
  margin: 14px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #f7d84a;
}

#painel .campo {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  margin-bottom: 10px;
}

#painel .campo input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: #f7d84a;
}

#painel .campo.liga {
  grid-template-columns: 1fr auto auto;
  align-items: center;
}

#painel .campo.liga input {
  grid-column: auto;
  width: 22px;
  height: 22px;
}

#painel button {
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 700;
  background: #f7d84a;
  color: #1b2a12;
}

#painel-acoes {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

#painel-acoes button {
  flex: 1;
}

#painel-aviso {
  margin-top: 8px;
  color: #bfe8c3;
}

#painel-aviso textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-size: 11px;
  user-select: text;
  -webkit-user-select: text;
}

/* Durante o voo da bola, os controles ficam apagados para não tapar a jogada */
#hud.em-jogo #controles {
  opacity: 0.2;
}

/* Resultado da cobrança: GOL!, NA TRAVE!, POR CIMA... */
#resultado {
  position: fixed;
  left: 0;
  right: 0;
  top: 58%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

#resultado.mostrar {
  animation: aparecer 0.35s ease-out forwards;
}

#resultado-titulo {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 18px rgba(0, 0, 0, 0.45);
}

#resultado.gol #resultado-titulo {
  font-size: 76px;
  color: #f7d84a;
}

#resultado-sub {
  margin-top: 2px;
  font-size: 18px;
  font-weight: 800;
}

@keyframes aparecer {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  60% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Tela deitada (computador): controles no canto, para não tapar a bola */
@media (min-aspect-ratio: 1/1) {
  #controles {
    position: fixed;
    right: 16px;
    bottom: calc(env(safe-area-inset-bottom) + 16px);
    width: 380px;
  }
}

/* Durante o voo, o topo também some um pouco */
#hud.em-jogo #linha-info {
  opacity: 0.35;
}

/* Folhas que sobem de baixo: lista "Quem bate?" e ranking do dia */
#lista-cobradores,
#ranking {
  pointer-events: auto;
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  text-shadow: none;
}

#lista-cobradores[hidden],
#ranking[hidden] {
  display: none;
}

.folha {
  touch-action: pan-y;
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 14px 12px calc(env(safe-area-inset-bottom) + 14px);
  border-radius: 18px 18px 0 0;
  background: #101814;
}

.folha-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
}

.folha-cabecalho button {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  background: #f7d84a;
  color: #1b2a12;
}

.folha-explica {
  margin: 6px 2px 10px;
  font-size: 12px;
  opacity: 0.75;
}

.item-cobrador {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  text-align: left;
}

.item-cobrador.escolhido {
  border-color: #f7d84a;
  background: rgba(247, 216, 74, 0.12);
}

.item-numero {
  min-width: 34px;
  font-size: 22px;
  font-weight: 900;
  font-style: italic;
  color: #f7d84a;
  text-align: center;
}

.item-meio {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.item-meio b {
  font-size: 15px;
}

.item-meio small {
  font-size: 11px;
  opacity: 0.75;
}

.item-notas {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}

.item-notas b {
  font-size: 24px;
}

.item-notas small,
.item-notas em {
  font-size: 10px;
  font-style: normal;
  opacity: 0.75;
}

.item-selos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.selo {
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
}

.selo.especial {
  background: rgba(247, 216, 74, 0.25);
  color: #ffe58a;
}

.selo.sugerido {
  background: #4ade80;
  color: #0b2414;
}

.atributos {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.atributo {
  display: grid;
  grid-template-columns: auto;
  font-size: 9px;
  line-height: 1.2;
}

.atributo span {
  opacity: 0.7;
}

.atributo i {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.atributo i b {
  display: block;
  height: 100%;
}

.atributo em {
  font-style: normal;
  font-weight: 800;
  font-size: 11px;
}

/* Resultado de defesa e barreira em azul-claro */
#resultado.defesa #resultado-titulo {
  color: #7dd3fc;
}

/* Elementos que só aparecem quando o código novo os preenche */
#cartao-cobrador:empty,
#botao-fixar[hidden],
#botao-ranking[hidden],
#botao-tienda[hidden],
#botao-mudo[hidden] {
  display: none;
}

/* Ranking do dia: bloco "Entrar no ranking", mensagem, lista e rodapé */
#ranking-entrar {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(247, 216, 74, 0.45);
  border-radius: 12px;
  background: rgba(247, 216, 74, 0.08);
}

#ranking-melhor {
  font-size: 14px;
  font-weight: 700;
}

#ranking-formulario {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* O campo do nome: o resto da tela bloqueia seleção e toque (html, body); aqui libera */
#ranking-nome {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-family: inherit;
  font-size: 16px; /* no iPhone, menor que 16px dá zoom na tela ao focar */
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
  touch-action: manipulation;
}

#ranking-nome::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#ranking-nome:focus {
  outline: none;
  border-color: #f7d84a;
  box-shadow: 0 0 0 2px rgba(247, 216, 74, 0.3);
}

#ranking-enviar {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  background: #f7d84a;
  color: #1b2a12;
  touch-action: manipulation;
}

#ranking-enviar:disabled {
  opacity: 0.6;
}

#ranking-aviso {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #ffb4b4;
}

#ranking-aviso[hidden] {
  display: none;
}

#ranking-ja {
  margin: 4px 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: #4ade80;
}

#ranking-mensagem {
  margin: 0 0 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(247, 216, 74, 0.15);
  color: #ffe58a;
  font-size: 13px;
  font-weight: 700;
}

/* Cada linha do ranking: posição | nome (com reticências se for longo) | gols */
.ranking-linha {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
}

.ranking-linha.meu {
  border-color: #f7d84a;
  background: rgba(247, 216, 74, 0.12);
}

.ranking-posicao {
  font-size: 18px;
  font-weight: 900;
  font-style: italic;
  text-align: center;
  opacity: 0.8;
}

.ranking-posicao.ouro {
  color: #f7d84a;
  opacity: 1;
}

.ranking-posicao.prata {
  color: #dfe4ea;
  opacity: 1;
}

.ranking-posicao.bronze {
  color: #d99a5b;
  opacity: 1;
}

.ranking-nome {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ranking-linha.meu .ranking-nome {
  font-weight: 700;
}

.ranking-gols {
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.ranking-gols small {
  margin-left: 3px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
}

.ranking-vazio {
  padding: 18px 8px;
  text-align: center;
  font-size: 14px;
  opacity: 0.8;
}

.folha-rodape {
  margin: 10px 2px 0;
  text-align: center;
  font-size: 11px;
  opacity: 0.6;
}

/* Botões depois da cobrança: replay, gravar vídeo, salvar e entrar no ranking (ficam até o próximo chute) */
#acoes-jogada {
  position: fixed;
  left: 0;
  right: 0;
  top: 76.5%;
  transform: translateY(-100%); /* o bloco cresce para cima: a segunda linha não entra nos controles */
  display: flex;
  flex-wrap: wrap; /* com três botões (Replay, Gravar vídeo, Entrar no ranking), o terceiro sobe de linha */
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
#acoes-jogada button {
  pointer-events: auto;
  padding: 9px 14px;
  border: 2px solid #f7d84a;
  border-radius: 999px;
  background: rgba(10, 14, 24, 0.82);
  color: #f7d84a;
  font: 800 14px/1 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  animation: aparecer 0.35s ease-out forwards;
  touch-action: manipulation;
}
#acoes-jogada button:active {
  transform: scale(0.96);
}
#acoes-jogada button:disabled {
  opacity: 0.5;
}
#acoes-jogada button[hidden] {
  display: none;
}

/* Replay: só a cena, a etiqueta e o resultado no fim */
#replay-tag {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top) + 58px);
  right: 16px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(10, 14, 24, 0.7);
  color: #ff5a5a;
  font: 800 13px/1 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.08em;
  animation: piscar 1.2s ease-in-out infinite;
}
#hud.replay #replay-tag {
  display: block;
}
#hud.replay #controles,
#hud.replay #linha-info,
#hud.replay #mensagem,
#hud.replay #acoes-jogada {
  display: none;
}
@keyframes piscar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Modos de jogo: Treino, Desafio do Dia e Pênaltis (botões em pílula, logo abaixo do título) */
#modos {
  width: 100%;
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.25s;
}
#modos button {
  pointer-events: auto;
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
}
#modos button.ativo {
  background: #f7d84a;
  color: #1b2a12;
  border-color: #f7d84a;
}
#hud.em-jogo #modos {
  opacity: 0.35;
}
#hud.replay #modos {
  display: none;
}
