/* ═══════════════════════════════════════════════════════════
   ASAF DAMAS — assets/jogo-extra.css
   Acrescentos ao tabuleiro: barra do jogo à distância,
   avisos flutuantes e ajustes para ecrãs de 4 polegadas.
   ═══════════════════════════════════════════════════════════ */

.barra-online {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-family: 'Lato', sans-serif;
  font-size: .8rem;
  background: rgba(46, 26, 8, .95);
  color: #f5e6c8;
  border-bottom: 1px solid #5c2a00;
}
body[data-theme="light"] .barra-online {
  background: rgba(255, 248, 240, .96);
  color: #2a1500;
  border-bottom-color: #b05800;
}
.barra-online[hidden] { display: none; }

.barra-online .voltar-painel {
  margin-left: auto;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  opacity: .85;
}

.ponto-ligacao {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b89060;
  flex: 0 0 auto;
}
.ponto-ligacao.ligado {
  background: #56c27e;
  animation: bater-ligacao 2s infinite;
}
.ponto-ligacao.ausente { background: #e8a030; }
.ponto-ligacao.parado  { background: #cc4433; }

@keyframes bater-ligacao {
  0%   { box-shadow: 0 0 0 0 rgba(86, 194, 126, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(86, 194, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(86, 194, 126, 0); }
}

/* Quando a barra existe, empurra o cabeçalho do jogo para baixo */
body:has(.barra-online:not([hidden])) header { top: 26px; }
body:has(.barra-online:not([hidden])) { padding-top: 26px; }

/* ── Aviso flutuante ────────────────────────────────────── */
.aviso-jogo {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  z-index: 90;
  max-width: 92vw;
  padding: 10px 16px;
  font-family: 'Lato', sans-serif;
  font-size: .88rem;
  background: rgba(46, 26, 8, .96);
  color: #f5e6c8;
  border-left: 4px solid #e8a030;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}
body[data-theme="light"] .aviso-jogo {
  background: #fff8f0;
  color: #2a1500;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .16);
}
.aviso-jogo[hidden] { display: none; }

/* ── Aviso de partida inacessível ───────────────────────── */
.aviso-partida {
  margin: 60px auto 0;
  max-width: 460px;
  padding: 16px 18px;
  font-family: 'Lato', sans-serif;
  border-left: 4px solid #cc4433;
  background: rgba(0, 0, 0, .2);
  color: #f5e6c8;
}
.aviso-partida a { color: #e8a030; }

/* ── Ecrãs muito pequenos ───────────────────────────────── */
@media (max-width: 400px) {
  .barra-online { font-size: .74rem; padding: 4px 8px; }
  .aviso-jogo   { font-size: .82rem; bottom: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .ponto-ligacao.ligado { animation: none; }
}

/* ── Retratos no placar (jogo à distância) ──────────────── */
.score-avatar.com-retrato {
  border-radius: 4px;
  width: 34px;
  height: 42px;
  padding: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .18);
}
.score-avatar.com-retrato img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
body[data-theme="light"] .score-avatar.com-retrato {
  background: rgba(0, 0, 0, .05);
  border-color: rgba(0, 0, 0, .14);
}
#score-p1.active-turn .score-avatar.com-retrato,
#score-p2.active-turn .score-avatar.com-retrato {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(232, 160, 48, .35);
}

@media (max-width: 400px) {
  .score-avatar.com-retrato { width: 28px; height: 35px; }
}

/* ═══════════════════════════════════════════════════════════
   CONVERSA ENTRE OS DOIS JOGADORES
   Vive no fluxo da página, logo acima do rodapé. Não flutua
   sobre o tabuleiro em nenhum tamanho de ecrã.
   ═══════════════════════════════════════════════════════════ */

.conversa {
  width: 100%;
  max-width: 620px;
  margin: 14px auto 0;
  font-family: 'Lato', sans-serif;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(184, 144, 96, .32);
  border-top: 3px solid var(--accent2);
  display: flex;
  flex-direction: column;
}
body[data-theme="light"] .conversa {
  background: #fffaf3;
  border-color: #e0cdb0;
  border-top-color: #b05800;
}

.conversa-puxador {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: .86rem;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.conversa-icone   { font-size: 1rem; }
.conversa-titulo  { flex: 1; letter-spacing: .3px; }
.conversa-seta    { font-size: .6rem; opacity: .7; transition: transform .2s; }
.conversa.recolhida .conversa-seta { transform: rotate(180deg); }

.conversa-nao-lidas {
  background: #cc4433;
  color: #fff;
  font-size: .68rem;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  text-align: center;
  border-radius: 9px;
  padding: 0 4px;
}
.conversa-nao-lidas[hidden] { display: none; }

.conversa.a-piscar { animation: chamar-conversa 1.2s ease-in-out 2; }
@keyframes chamar-conversa {
  0%, 100% { border-top-color: var(--accent2); }
  50%      { border-top-color: #cc4433; }
}

.conversa-corpo { display: flex; flex-direction: column; }
.conversa.recolhida .conversa-corpo { display: none; }

.conversa-nota {
  margin: 0;
  padding: 0 14px 8px;
  font-size: .74rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.conversa-mensagens {
  padding: 0 14px;
  max-height: 190px;
  min-height: 56px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.conversa-vazia { font-size: .78rem; color: var(--text-dim); margin: 8px 0; }

.conversa-msg {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: .84rem;
  line-height: 1.4;
  padding: 6px 9px;
  max-width: 88%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.conversa-msg.minha {
  align-self: flex-end;
  background: rgba(232, 160, 48, .16);
  border-right: 3px solid var(--accent);
}
.conversa-msg.dele {
  align-self: flex-start;
  background: rgba(255, 255, 255, .07);
  border-left: 3px solid #b89060;
}
body[data-theme="light"] .conversa-msg.dele { background: rgba(0, 0, 0, .05); }

.conversa-msg.sistema {
  align-self: center;
  max-width: 100%;
  text-align: center;
  font-size: .76rem;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-top: 1px dashed rgba(184, 144, 96, .5);
  border-bottom: 1px dashed rgba(184, 144, 96, .5);
  padding: 5px 0;
}

.conversa-autor { font-size: .68rem; color: var(--text-dim); letter-spacing: .3px; }
.conversa-autor em { font-style: normal; opacity: .8; }

.conversa-atalhos {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 9px 14px 0;
}
.conversa-atalho {
  font: inherit;
  font-size: .72rem;
  padding: 4px 8px;
  background: none;
  border: 1px solid rgba(184, 144, 96, .45);
  color: var(--text);
  cursor: pointer;
  opacity: .85;
}
.conversa-atalho:hover { border-color: var(--accent); opacity: 1; }

.conversa-escrita { padding: 8px 14px 12px; }
.conversa-escrita textarea {
  width: 100%;
  font: inherit;
  font-size: .86rem;
  padding: 7px 9px;
  resize: none;
  color: var(--text);
  background: rgba(0, 0, 0, .22);
  border: 1px solid rgba(184, 144, 96, .38);
  outline: none;
}
body[data-theme="light"] .conversa-escrita textarea { background: #fffdf9; border-color: #d8c3a5; }
.conversa-escrita textarea:focus { border-color: var(--accent); }

.conversa-linha-envio {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.conversa-contador {
  font-size: .72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.conversa-contador.quase { color: var(--accent); font-weight: 700; }

.conversa-enviar {
  margin-left: auto;
  font: inherit;
  font-size: .8rem;
  padding: 6px 15px;
  background: var(--accent2);
  border: 1px solid #5c2a00;
  color: #fff8ee;
  cursor: pointer;
}
.conversa-enviar:hover { background: var(--accent); color: #2e1a08; }
.conversa-enviar:disabled { opacity: .5; cursor: not-allowed; }

/* No telemóvel a conversa continua no fluxo, apenas mais compacta.
   Nunca cobre o tabuleiro nem a barra de acções. */
@media (max-width: 560px) {
  .conversa { margin: 12px 0 0; max-width: 100%; }
  .conversa-mensagens { max-height: 30vh; }
}

@media (max-width: 400px) {
  .conversa-puxador { font-size: .8rem; padding: 9px 11px; }
  .conversa-nota    { padding: 0 11px 7px; font-size: .7rem; }
  .conversa-mensagens { padding: 0 11px; max-height: 26vh; }
  .conversa-msg     { font-size: .8rem; max-width: 94%; }
  .conversa-atalhos { padding: 8px 11px 0; }
  .conversa-atalho  { font-size: .68rem; padding: 3px 6px; }
  .conversa-escrita { padding: 7px 11px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .conversa.a-piscar { animation: none; }
  .conversa-seta { transition: none; }
}

/* ═══════════════════════════════════════════════════════════
   PERGUNTA DO EMPATE
   ═══════════════════════════════════════════════════════════ */

#empate-modal .confirm-icon { font-size: 2.4rem; }

#empate-modal p { line-height: 1.55; }

.empate-quem {
  font-weight: 700;
  color: var(--accent);
  margin-top: 10px !important;
  padding-top: 10px;
  border-top: 1px solid rgba(184, 144, 96, .3);
}

.empate-espera {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px 0 4px;
  font-family: 'Lato', sans-serif;
  font-size: .86rem;
  color: var(--text-dim);
}
.empate-espera[hidden] { display: none; }

.empate-pontinhos { display: inline-flex; gap: 4px; }
.empate-pontinhos span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: empate-pulsar 1.2s infinite ease-in-out;
}
.empate-pontinhos span:nth-child(2) { animation-delay: .18s; }
.empate-pontinhos span:nth-child(3) { animation-delay: .36s; }

@keyframes empate-pulsar {
  0%, 80%, 100% { opacity: .25; transform: scale(.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

@media (max-width: 400px) {
  #empate-modal .confirm-icon { font-size: 2rem; }
  #empate-modal p { font-size: .88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .empate-pontinhos span { animation: none; opacity: .7; }
}

/* ═══════════════════════════════════════════════════════════
   ASSISTIR A PARTIDAS
   ═══════════════════════════════════════════════════════════ */

/* ── Contador na barra do jogo à distância ──────────────── */
.conta-espectadores {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding: 2px 8px;
  font: inherit;
  font-size: .74rem;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  color: inherit;
  cursor: pointer;
  border-radius: 10px;
}
.conta-espectadores[hidden] { display: none; }
.conta-espectadores:hover { background: rgba(255, 255, 255, .18); }
.conta-espectadores.com-gente {
  background: rgba(232, 160, 48, .22);
  border-color: var(--accent);
  color: var(--accent);
}
body[data-theme="light"] .conta-espectadores {
  background: rgba(0, 0, 0, .06);
  border-color: rgba(0, 0, 0, .14);
}

/* ── Janela flutuante de quem está a assistir ───────────── */
.espectadores-caixa {
  position: fixed;
  top: 60px;
  right: 14px;
  z-index: 78;
  width: 290px;
  max-width: calc(100vw - 28px);
  max-height: 70vh;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: 'Lato', sans-serif;
  background: #2e1a08;
  color: #f5e6c8;
  border: 1px solid #5c2a00;
  border-top: 3px solid var(--accent);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
}
body[data-theme="light"] .espectadores-caixa {
  background: #fff8f0;
  color: #2a1500;
  border-color: #d8c3a5;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .18);
}
.espectadores-caixa[hidden] { display: none; }

.espectadores-caixa h3 {
  margin: 0 0 10px;
  font-family: 'Cinzel', serif;
  font-size: .95rem;
}
.espectadores-caixa h4 {
  margin: 0 0 4px;
  font-family: 'Cinzel', serif;
  font-size: .85rem;
}
.espectadores-caixa p { font-size: .76rem; color: var(--text-dim); margin: 0 0 8px; }

.espectadores-fechar {
  float: right;
  background: none;
  border: 0;
  color: inherit;
  font-size: 1rem;
  cursor: pointer;
  opacity: .6;
  line-height: 1;
}
.espectadores-fechar:hover { opacity: 1; }

.espectadores-lista,
.espectadores-amigos {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.espectadores-lista li,
.espectadores-amigos li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(184, 144, 96, .22);
  font-size: .82rem;
}
.espectadores-lista li:last-child,
.espectadores-amigos li:last-child { border-bottom: 0; }

.espectadores-vazio {
  font-size: .78rem;
  color: var(--text-dim);
  border-bottom: 0 !important;
}

.esp-retrato {
  width: 26px; height: 32px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(184, 144, 96, .35);
  display: flex; align-items: center; justify-content: center;
  font-size: .64rem;
  font-family: 'Cinzel', serif;
  color: var(--text-dim);
}
.esp-retrato img { width: 100%; height: 100%; object-fit: cover; display: block; }

.esp-nome  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.esp-desde { font-size: .68rem; color: var(--text-dim); white-space: nowrap; }

.esp-ponto {
  width: 8px; height: 8px; border-radius: 50%;
  background: #8a7a66; flex: 0 0 auto;
}
.esp-ponto.em-linha { background: #56c27e; }

.esp-chamar {
  font: inherit;
  font-size: .7rem;
  padding: 3px 9px;
  background: var(--accent2);
  border: 1px solid #5c2a00;
  color: #fff8ee;
  cursor: pointer;
  white-space: nowrap;
}
.esp-chamar:hover:not(:disabled) { background: var(--accent); color: #2e1a08; }
.esp-chamar:disabled { opacity: .5; cursor: not-allowed; }
.esp-chamado { font-size: .7rem; color: var(--text-dim); white-space: nowrap; }

.espectadores-convidar {
  border-top: 1px dashed rgba(184, 144, 96, .4);
  padding-top: 10px;
  margin-top: 4px;
}
.espectadores-amigos { max-height: 170px; overflow-y: auto; }

.espectadores-permitir {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-top: 1px dashed rgba(184, 144, 96, .4);
  padding-top: 10px;
  font-size: .78rem;
  cursor: pointer;
}
.espectadores-permitir input { margin-top: 3px; flex: 0 0 auto; }
.espectadores-permitir small { color: var(--text-dim); font-size: .72rem; }

/* ── Sinal visível de que se está apenas a assistir ─────── */
body.modo-assistir #board { cursor: default; }
body.modo-assistir #board .cell { cursor: default !important; }

body.modo-assistir::before {
  content: '';
  position: fixed;
  inset: 0;
  border: 3px solid var(--accent);
  pointer-events: none;
  z-index: 55;
  opacity: .5;
}

@media (max-width: 560px) {
  .espectadores-caixa {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 62vh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
}

@media (max-width: 400px) {
  .conta-espectadores { font-size: .68rem; padding: 2px 6px; margin-left: 6px; }
  .espectadores-caixa { padding: 12px 12px; }
  .espectadores-caixa h3 { font-size: .88rem; }
}

/* ── Contacto no rodapé do tabuleiro ────────────────────── */
.rodape-contacto-jogo {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Em ecrãs estreitos o rodapé passa a três linhas centradas,
   para o contacto não espremer o cronómetro. */
@media (max-width: 620px) {
  footer {
    flex-direction: column;
    gap: 2px;
    text-align: center;
    padding: .45rem .8rem;
  }
  .rodape-contacto-jogo { white-space: normal; }
}

/* ═══════════════════════════════════════════════════════════
   TORCER POR UM JOGADOR
   ═══════════════════════════════════════════════════════════ */

.botao-gosto {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  padding: 2px 7px;
  font: inherit;
  font-size: .72rem;
  background: none;
  border: 1px solid rgba(184, 144, 96, .4);
  border-radius: 11px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1.4;
}
.botao-gosto[hidden] { display: none; }
.botao-gosto:hover { border-color: #d4705f; color: #d4705f; }
.botao-gosto:disabled { opacity: .6; cursor: wait; }

.gosto-icone { font-size: .85rem; line-height: 1; }
.gosto-conta { font-variant-numeric: tabular-nums; font-weight: 700; }

.botao-gosto.tem-gostos { color: #d4705f; border-color: rgba(212, 112, 95, .5); }
.botao-gosto.meu-favorito {
  background: rgba(212, 112, 95, .16);
  border-color: #d4705f;
  color: #d4705f;
  font-weight: 700;
}

.botao-gosto.a-bater .gosto-icone { animation: bater-coracao .6s ease-out; }
@keyframes bater-coracao {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.5); }
  45%  { transform: scale(.92); }
  70%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ── Nota da sessão no ecrã de fim de jogo ──────────────── */
.gameover-sessao {
  font-family: 'Lato', sans-serif;
  font-size: .86rem;
  color: var(--accent);
  margin: 0 0 12px;
  min-height: 1.2em;
}

#gameover-rematch.a-pedir {
  animation: chamar-revanche 1.3s ease-in-out infinite;
}
@keyframes chamar-revanche {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 160, 48, .5); }
  50%      { box-shadow: 0 0 0 8px rgba(232, 160, 48, 0); }
}

@media (max-width: 400px) {
  .botao-gosto { font-size: .68rem; padding: 2px 6px; }
  .gameover-sessao { font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .botao-gosto.a-bater .gosto-icone,
  #gameover-rematch.a-pedir { animation: none; }
}
